semver 5.6.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,47 @@
1
+ # changes log
2
+
3
+ ## 6.0
4
+
5
+ * Fix `intersects` logic.
6
+
7
+ This is technically a bug fix, but since it is also a change to behavior
8
+ that may require users updating their code, it is marked as a major
9
+ version increment.
10
+
11
+ ## 5.7
12
+
13
+ * Add `minVersion` method
14
+
15
+ ## 5.6
16
+
17
+ * Move boolean `loose` param to an options object, with
18
+ backwards-compatibility protection.
19
+ * Add ability to opt out of special prerelease version handling with
20
+ the `includePrerelease` option flag.
21
+
22
+ ## 5.5
23
+
24
+ * Add version coercion capabilities
25
+
26
+ ## 5.4
27
+
28
+ * Add intersection checking
29
+
30
+ ## 5.3
31
+
32
+ * Add `minSatisfying` method
33
+
34
+ ## 5.2
35
+
36
+ * Add `prerelease(v)` that returns prerelease components
37
+
38
+ ## 5.1
39
+
40
+ * Add Backus-Naur for ranges
41
+ * Remove excessively cute inspection methods
42
+
43
+ ## 5.0
44
+
45
+ * Remove AMD/Browserified build artifacts
46
+ * Fix ltr and gtr when using the `*` range
47
+ * Fix for range `*` with a prerelease identifier
package/README.md CHANGED
@@ -4,7 +4,7 @@ semver(1) -- The semantic versioner for npm
4
4
  ## Install
5
5
 
6
6
  ```bash
7
- npm install --save semver
7
+ npm install semver
8
8
  ````
9
9
 
10
10
  ## Usage
@@ -20,6 +20,7 @@ semver.clean(' =v1.2.3 ') // '1.2.3'
20
20
  semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
21
21
  semver.gt('1.2.3', '9.8.7') // false
22
22
  semver.lt('1.2.3', '9.8.7') // true
23
+ semver.minVersion('>=1.0.0') // '1.0.0'
23
24
  semver.valid(semver.coerce('v2')) // '2.0.0'
24
25
  semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
25
26
  ```
@@ -29,7 +30,7 @@ As a command-line utility:
29
30
  ```
30
31
  $ semver -h
31
32
 
32
- A JavaScript implementation of the http://semver.org/ specification
33
+ A JavaScript implementation of the https://semver.org/ specification
33
34
  Copyright Isaac Z. Schlueter
34
35
 
35
36
  Usage: semver [options] <version> [<version> [...]]
@@ -71,7 +72,7 @@ multiple versions to the utility will just sort them.
71
72
  ## Versions
72
73
 
73
74
  A "version" is described by the `v2.0.0` specification found at
74
- <http://semver.org/>.
75
+ <https://semver.org/>.
75
76
 
76
77
  A leading `"="` or `"v"` character is stripped off and ignored.
77
78
 
@@ -137,6 +138,13 @@ the user is indicating that they are aware of the risk. However, it
137
138
  is still not appropriate to assume that they have opted into taking a
138
139
  similar risk on the *next* set of prerelease versions.
139
140
 
141
+ Note that this behavior can be suppressed (treating all prerelease
142
+ versions as if they were normal versions, for the purpose of range
143
+ matching) by setting the `includePrerelease` flag on the options
144
+ object to any
145
+ [functions](https://github.com/npm/node-semver#functions) that do
146
+ range matching.
147
+
140
148
  #### Prerelease Identifiers
141
149
 
142
150
  The method `.inc` takes an additional `identifier` string argument that
@@ -223,7 +231,7 @@ comparator. Allows minor-level changes if not.
223
231
 
224
232
  #### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
225
233
 
226
- Allows changes that do not modify the left-most non-zero digit in the
234
+ Allows changes that do not modify the left-most non-zero element in the
227
235
  `[major, minor, patch]` tuple. In other words, this allows patch and
228
236
  minor updates for versions `1.0.0` and above, patch updates for
229
237
  versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
@@ -325,6 +333,8 @@ strings that they parse.
325
333
  * `patch(v)`: Return the patch version number.
326
334
  * `intersects(r1, r2, loose)`: Return true if the two supplied ranges
327
335
  or comparators intersect.
336
+ * `parse(v)`: Attempt to parse a string as a semantic version, returning either
337
+ a `SemVer` object or `null`.
328
338
 
329
339
  ### Comparison
330
340
 
@@ -344,6 +354,9 @@ strings that they parse.
344
354
  `v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
345
355
  * `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
346
356
  in descending order when passed to `Array.sort()`.
357
+ * `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
358
+ are equal. Sorts in ascending order if passed to `Array.sort()`.
359
+ `v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
347
360
  * `diff(v1, v2)`: Returns difference between two versions by the release type
348
361
  (`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
349
362
  or null if the versions are the same.
@@ -361,6 +374,8 @@ strings that they parse.
361
374
  that satisfies the range, or `null` if none of them do.
362
375
  * `minSatisfying(versions, range)`: Return the lowest version in the list
363
376
  that satisfies the range, or `null` if none of them do.
377
+ * `minVersion(range)`: Return the lowest version that can possibly match
378
+ the given range.
364
379
  * `gtr(version, range)`: Return `true` if version is greater than all the
365
380
  versions possible in the range.
366
381
  * `ltr(version, range)`: Return `true` if version is less than all the
package/bin/semver CHANGED
@@ -4,20 +4,28 @@
4
4
  // any supplied version is valid and passes all tests.
5
5
 
6
6
  var argv = process.argv.slice(2)
7
- , versions = []
8
- , range = []
9
- , gt = []
10
- , lt = []
11
- , eq = []
12
- , inc = null
13
- , version = require("../package.json").version
14
- , loose = false
15
- , includePrerelease = false
16
- , coerce = false
17
- , identifier = undefined
18
- , semver = require("../semver")
19
- , reverse = false
20
- , options = {}
7
+
8
+ var versions = []
9
+
10
+ var range = []
11
+
12
+ var inc = null
13
+
14
+ var version = require('../package.json').version
15
+
16
+ var loose = false
17
+
18
+ var includePrerelease = false
19
+
20
+ var coerce = false
21
+
22
+ var identifier
23
+
24
+ var semver = require('../semver')
25
+
26
+ var reverse = false
27
+
28
+ var options = {}
21
29
 
22
30
  main()
23
31
 
@@ -25,45 +33,45 @@ function main () {
25
33
  if (!argv.length) return help()
26
34
  while (argv.length) {
27
35
  var a = argv.shift()
28
- var i = a.indexOf('=')
29
- if (i !== -1) {
30
- a = a.slice(0, i)
31
- argv.unshift(a.slice(i + 1))
36
+ var indexOfEqualSign = a.indexOf('=')
37
+ if (indexOfEqualSign !== -1) {
38
+ a = a.slice(0, indexOfEqualSign)
39
+ argv.unshift(a.slice(indexOfEqualSign + 1))
32
40
  }
33
41
  switch (a) {
34
- case "-rv": case "-rev": case "--rev": case "--reverse":
42
+ case '-rv': case '-rev': case '--rev': case '--reverse':
35
43
  reverse = true
36
44
  break
37
- case "-l": case "--loose":
45
+ case '-l': case '--loose':
38
46
  loose = true
39
47
  break
40
- case "-p": case "--include-prerelease":
48
+ case '-p': case '--include-prerelease':
41
49
  includePrerelease = true
42
50
  break
43
- case "-v": case "--version":
51
+ case '-v': case '--version':
44
52
  versions.push(argv.shift())
45
53
  break
46
- case "-i": case "--inc": case "--increment":
54
+ case '-i': case '--inc': case '--increment':
47
55
  switch (argv[0]) {
48
- case "major": case "minor": case "patch": case "prerelease":
49
- case "premajor": case "preminor": case "prepatch":
56
+ case 'major': case 'minor': case 'patch': case 'prerelease':
57
+ case 'premajor': case 'preminor': case 'prepatch':
50
58
  inc = argv.shift()
51
59
  break
52
60
  default:
53
- inc = "patch"
61
+ inc = 'patch'
54
62
  break
55
63
  }
56
64
  break
57
- case "--preid":
65
+ case '--preid':
58
66
  identifier = argv.shift()
59
67
  break
60
- case "-r": case "--range":
68
+ case '-r': case '--range':
61
69
  range.push(argv.shift())
62
70
  break
63
- case "-c": case "--coerce":
71
+ case '-c': case '--coerce':
64
72
  coerce = true
65
73
  break
66
- case "-h": case "--help": case "-?":
74
+ case '-h': case '--help': case '-?':
67
75
  return help()
68
76
  default:
69
77
  versions.push(a)
@@ -74,15 +82,14 @@ function main () {
74
82
  var options = { loose: loose, includePrerelease: includePrerelease }
75
83
 
76
84
  versions = versions.map(function (v) {
77
- return coerce ? (semver.coerce(v) || {version: v}).version : v
85
+ return coerce ? (semver.coerce(v) || { version: v }).version : v
78
86
  }).filter(function (v) {
79
87
  return semver.valid(v)
80
88
  })
81
89
  if (!versions.length) return fail()
82
- if (inc && (versions.length !== 1 || range.length))
83
- return failInc()
90
+ if (inc && (versions.length !== 1 || range.length)) { return failInc() }
84
91
 
85
- for (var i = 0, l = range.length; i < l ; i ++) {
92
+ for (var i = 0, l = range.length; i < l; i++) {
86
93
  versions = versions.filter(function (v) {
87
94
  return semver.satisfies(v, range[i], options)
88
95
  })
@@ -92,62 +99,62 @@ function main () {
92
99
  }
93
100
 
94
101
  function failInc () {
95
- console.error("--inc can only be used on a single version with no range")
102
+ console.error('--inc can only be used on a single version with no range')
96
103
  fail()
97
104
  }
98
105
 
99
106
  function fail () { process.exit(1) }
100
107
 
101
108
  function success () {
102
- var compare = reverse ? "rcompare" : "compare"
109
+ var compare = reverse ? 'rcompare' : 'compare'
103
110
  versions.sort(function (a, b) {
104
111
  return semver[compare](a, b, options)
105
112
  }).map(function (v) {
106
113
  return semver.clean(v, options)
107
114
  }).map(function (v) {
108
115
  return inc ? semver.inc(v, inc, options, identifier) : v
109
- }).forEach(function (v,i,_) { console.log(v) })
116
+ }).forEach(function (v, i, _) { console.log(v) })
110
117
  }
111
118
 
112
119
  function help () {
113
- console.log(["SemVer " + version
114
- ,""
115
- ,"A JavaScript implementation of the http://semver.org/ specification"
116
- ,"Copyright Isaac Z. Schlueter"
117
- ,""
118
- ,"Usage: semver [options] <version> [<version> [...]]"
119
- ,"Prints valid versions sorted by SemVer precedence"
120
- ,""
121
- ,"Options:"
122
- ,"-r --range <range>"
123
- ," Print versions that match the specified range."
124
- ,""
125
- ,"-i --increment [<level>]"
126
- ," Increment a version by the specified level. Level can"
127
- ," be one of: major, minor, patch, premajor, preminor,"
128
- ," prepatch, or prerelease. Default level is 'patch'."
129
- ," Only one version may be specified."
130
- ,""
131
- ,"--preid <identifier>"
132
- ," Identifier to be used to prefix premajor, preminor,"
133
- ," prepatch or prerelease version increments."
134
- ,""
135
- ,"-l --loose"
136
- ," Interpret versions and ranges loosely"
137
- ,""
138
- ,"-p --include-prerelease"
139
- ," Always include prerelease versions in range matching"
140
- ,""
141
- ,"-c --coerce"
142
- ," Coerce a string into SemVer if possible"
143
- ," (does not imply --loose)"
144
- ,""
145
- ,"Program exits successfully if any valid version satisfies"
146
- ,"all supplied ranges, and prints all satisfying versions."
147
- ,""
148
- ,"If no satisfying versions are found, then exits failure."
149
- ,""
150
- ,"Versions are printed in ascending order, so supplying"
151
- ,"multiple versions to the utility will just sort them."
152
- ].join("\n"))
120
+ console.log(['SemVer ' + version,
121
+ '',
122
+ 'A JavaScript implementation of the https://semver.org/ specification',
123
+ 'Copyright Isaac Z. Schlueter',
124
+ '',
125
+ 'Usage: semver [options] <version> [<version> [...]]',
126
+ 'Prints valid versions sorted by SemVer precedence',
127
+ '',
128
+ 'Options:',
129
+ '-r --range <range>',
130
+ ' Print versions that match the specified range.',
131
+ '',
132
+ '-i --increment [<level>]',
133
+ ' Increment a version by the specified level. Level can',
134
+ ' be one of: major, minor, patch, premajor, preminor,',
135
+ " prepatch, or prerelease. Default level is 'patch'.",
136
+ ' Only one version may be specified.',
137
+ '',
138
+ '--preid <identifier>',
139
+ ' Identifier to be used to prefix premajor, preminor,',
140
+ ' prepatch or prerelease version increments.',
141
+ '',
142
+ '-l --loose',
143
+ ' Interpret versions and ranges loosely',
144
+ '',
145
+ '-p --include-prerelease',
146
+ ' Always include prerelease versions in range matching',
147
+ '',
148
+ '-c --coerce',
149
+ ' Coerce a string into SemVer if possible',
150
+ ' (does not imply --loose)',
151
+ '',
152
+ 'Program exits successfully if any valid version satisfies',
153
+ 'all supplied ranges, and prints all satisfying versions.',
154
+ '',
155
+ 'If no satisfying versions are found, then exits failure.',
156
+ '',
157
+ 'Versions are printed in ascending order, so supplying',
158
+ 'multiple versions to the utility will just sort them.'
159
+ ].join('\n'))
153
160
  }
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "5.6.0",
3
+ "version": "6.1.0",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "semver.js",
6
6
  "scripts": {
7
- "test": "tap test/*.js --cov -J"
7
+ "test": "tap",
8
+ "preversion": "npm test",
9
+ "postversion": "npm publish",
10
+ "postpublish": "git push origin --follow-tags"
8
11
  },
9
12
  "devDependencies": {
10
- "tap": "^12.0.1"
13
+ "tap": "^14.1.6"
11
14
  },
12
15
  "license": "ISC",
13
16
  "repository": "https://github.com/npm/node-semver",
@@ -18,5 +21,8 @@
18
21
  "bin",
19
22
  "range.bnf",
20
23
  "semver.js"
21
- ]
24
+ ],
25
+ "tap": {
26
+ "check-coverage": true
27
+ }
22
28
  }