]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/validate-npm-package-name/README.md
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / validate-npm-package-name / README.md
1 # validate-npm-package-name
2
3 Give me a string and I'll tell you if it's a valid `npm` package name.
4
5 This package exports a single synchronous function that takes a `string` as
6 input and returns an object with two properties:
7
8 - `validForNewPackages` :: `Boolean`
9 - `validForOldPackages` :: `Boolean`
10
11 ## Contents
12
13 - [Naming rules](#naming-rules)
14 - [Examples](#examples)
15     + [Valid Names](#valid-names)
16     + [Invalid Names](#invalid-names)
17 - [Legacy Names](#legacy-names)
18 - [Tests](#tests)
19 - [License](#license)
20
21 ## Naming Rules
22
23 Below is a list of rules that valid `npm` package name should conform to.
24
25 - package name length should be greater than zero
26 - all the characters in the package name must be lowercase i.e., no uppercase or mixed case names are allowed
27 - package name *can* consist of hyphens
28 - package name must *not* contain any non-url-safe characters (since name ends up being part of a URL)
29 - package name should not start with `.` or `_`
30 - package name should *not* contain any leading or trailing spaces
31 - package name *cannot* be the same as a node.js/io.js core module nor a reserved/blacklisted name. For example, the following names are invalid:
32     + http
33     + stream
34     + node_modules
35     + favicon.ico
36 - package name length cannot exceed 214
37
38
39 ## Examples
40
41 ### Valid Names
42
43 ```js
44 var validate = require("validate-npm-package-name")
45
46 validate("some-package")
47 validate("example.com")
48 validate("under_score")
49 validate("123numeric")
50 validate("crazy!")
51 validate("@npm/thingy")
52 validate("@jane/foo.js")
53 ```
54
55 All of the above names are valid, so you'll get this object back:
56
57 ```js
58 {
59   validForNewPackages: true,
60   validForOldPackages: true
61 }
62 ```
63
64 ### Invalid Names
65
66 ```js
67 validate(" leading-space:and:weirdchars")
68 ```
69
70 That was never a valid package name, so you get this:
71
72 ```js
73 {
74   validForNewPackages: false,
75   validForOldPackages: false,
76   errors: [
77     'name cannot contain leading or trailing spaces',
78     'name can only contain URL-friendly characters'
79   ]
80 }
81 ```
82
83 ## Legacy Names
84
85 In the old days of npm, package names were wild. They could have capital
86 letters in them. They could be really long. They could be the name of an
87 existing module in node core.
88
89 If you give this function a package name that **used to be valid**, you'll see
90 a change in the value of `validForNewPackages` property, and a warnings array
91 will be present:
92
93 ```js
94 validate("cRaZY-paCkAgE-with-mixed-case-and-more-than-214-characters-----------------------------------------------------------------------------------------------------------------------------------------------------------")
95 ```
96
97 returns:
98
99 ```js
100 {
101   validForNewPackages: false,
102   validForOldPackages: true,
103   warnings: [
104     "name can no longer contain capital letters",
105     "name can no longer contain more than 214 characters"
106   ]
107 }
108 ```
109
110 ## Tests
111
112 ```sh
113 npm install
114 npm test
115 ```
116
117 ## License
118
119 ISC