semver 5.0.1 → 5.1.1

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/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
+ sudo: false
1
2
  language: node_js
2
3
  node_js:
3
4
  - '0.10'
4
5
  - '0.12'
5
- - 'iojs'
6
+ - '4'
7
+ - '5'
package/README.md CHANGED
@@ -16,18 +16,35 @@ As a command-line utility:
16
16
 
17
17
  $ semver -h
18
18
 
19
- Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | --preid <identifier> | -l | -rv]
20
- Test if version(s) satisfy the supplied range(s), and sort them.
19
+ SemVer 5.1.0
21
20
 
22
- Multiple versions or ranges may be supplied, unless increment
23
- option is specified. In that case, only a single version may
24
- be used, and it is incremented by the specified level
21
+ A JavaScript implementation of the http://semver.org/ specification
22
+ Copyright Isaac Z. Schlueter
23
+
24
+ Usage: semver [options] <version> [<version> [...]]
25
+ Prints valid versions sorted by SemVer precedence
26
+
27
+ Options:
28
+ -r --range <range>
29
+ Print versions that match the specified range.
30
+
31
+ -i --increment [<level>]
32
+ Increment a version by the specified level. Level can
33
+ be one of: major, minor, patch, premajor, preminor,
34
+ prepatch, or prerelease. Default level is 'patch'.
35
+ Only one version may be specified.
36
+
37
+ --preid <identifier>
38
+ Identifier to be used to prefix premajor, preminor,
39
+ prepatch or prerelease version increments.
40
+
41
+ -l --loose
42
+ Interpret versions and ranges loosely
25
43
 
26
44
  Program exits successfully if any valid version satisfies
27
45
  all supplied ranges, and prints all satisfying versions.
28
46
 
29
- If no versions are valid, or ranges are not satisfied,
30
- then exits failure.
47
+ If no satisfying versions are found, then exits failure.
31
48
 
32
49
  Versions are printed in ascending order, so supplying
33
50
  multiple versions to the utility will just sort them.
@@ -107,7 +124,7 @@ The method `.inc` takes an additional `identifier` string argument that
107
124
  will append the value of the string as a prerelease identifier:
108
125
 
109
126
  ```javascript
110
- > semver.inc('1.2.3', 'pre', 'beta')
127
+ > semver.inc('1.2.3', 'prerelease', 'beta')
111
128
  '1.2.4-beta.0'
112
129
  ```
113
130
 
@@ -228,6 +245,30 @@ zero.
228
245
  * `^1.x` := `>=1.0.0 <2.0.0`
229
246
  * `^0.x` := `>=0.0.0 <1.0.0`
230
247
 
248
+ ### Range Grammar
249
+
250
+ Putting all this together, here is a Backus-Naur grammar for ranges,
251
+ for the benefit of parser authors:
252
+
253
+ ```bnf
254
+ range-set ::= range ( logical-or range ) *
255
+ logical-or ::= ( ' ' ) * '||' ( ' ' ) *
256
+ range ::= hyphen | simple ( ' ' simple ) * | ''
257
+ hyphen ::= partial ' - ' partial
258
+ simple ::= primitive | partial | tilde | caret
259
+ primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial
260
+ partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
261
+ xr ::= 'x' | 'X' | '*' | nr
262
+ nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
263
+ tilde ::= '~' partial
264
+ caret ::= '^' partial
265
+ qualifier ::= ( '-' pre )? ( '+' build )?
266
+ pre ::= parts
267
+ build ::= parts
268
+ parts ::= part ( '.' part ) *
269
+ part ::= nr | [-0-9A-Za-z]+
270
+ ```
271
+
231
272
  ## Functions
232
273
 
233
274
  All methods and classes take a final `loose` boolean argument that, if
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "semver",
3
- "version": "5.0.1",
3
+ "version": "5.1.1",
4
4
  "description": "The semantic version parser used by npm.",
5
5
  "main": "semver.js",
6
6
  "scripts": {
7
7
  "test": "tap test/*.js"
8
8
  },
9
9
  "devDependencies": {
10
- "tap": "^1.2.0",
11
- "uglify-js": "~2.3.6"
10
+ "tap": "^2.0.0"
12
11
  },
13
12
  "license": "ISC",
14
13
  "repository": "https://github.com/npm/node-semver",
package/range.bnf ADDED
@@ -0,0 +1,16 @@
1
+ range-set ::= range ( logical-or range ) *
2
+ logical-or ::= ( ' ' ) * '||' ( ' ' ) *
3
+ range ::= hyphen | simple ( ' ' simple ) * | ''
4
+ hyphen ::= partial ' - ' partial
5
+ simple ::= primitive | partial | tilde | caret
6
+ primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial
7
+ partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
8
+ xr ::= 'x' | 'X' | '*' | nr
9
+ nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
10
+ tilde ::= '~' partial
11
+ caret ::= '^' partial
12
+ qualifier ::= ( '-' pre )? ( '+' build )?
13
+ pre ::= parts
14
+ build ::= parts
15
+ parts ::= part ( '.' part ) *
16
+ part ::= nr | [-0-9A-Za-z]+
package/semver.js CHANGED
@@ -332,10 +332,6 @@ SemVer.prototype.format = function() {
332
332
  return this.version;
333
333
  };
334
334
 
335
- SemVer.prototype.inspect = function() {
336
- return '<SemVer "' + this + '">';
337
- };
338
-
339
335
  SemVer.prototype.toString = function() {
340
336
  return this.version;
341
337
  };
@@ -481,6 +477,7 @@ SemVer.prototype.inc = function(release, identifier) {
481
477
  throw new Error('invalid increment argument: ' + release);
482
478
  }
483
479
  this.format();
480
+ this.raw = this.version;
484
481
  return this;
485
482
  };
486
483
 
@@ -691,10 +688,6 @@ Comparator.prototype.parse = function(comp) {
691
688
  this.semver = new SemVer(m[2], this.loose);
692
689
  };
693
690
 
694
- Comparator.prototype.inspect = function() {
695
- return '<SemVer Comparator "' + this + '">';
696
- };
697
-
698
691
  Comparator.prototype.toString = function() {
699
692
  return this.value;
700
693
  };
@@ -738,10 +731,6 @@ function Range(range, loose) {
738
731
  this.format();
739
732
  }
740
733
 
741
- Range.prototype.inspect = function() {
742
- return '<SemVer Range "' + this.range + '">';
743
- };
744
-
745
734
  Range.prototype.format = function() {
746
735
  this.range = this.set.map(function(comps) {
747
736
  return comps.join(' ').trim();
@@ -847,7 +836,7 @@ function replaceTilde(comp, loose) {
847
836
  else if (isX(m))
848
837
  ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
849
838
  else if (isX(p))
850
- // ~1.2 == >=1.2.0- <1.3.0-
839
+ // ~1.2 == >=1.2.0 <1.3.0
851
840
  ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
852
841
  else if (pr) {
853
842
  debug('replaceTilde pr', pr);
package/test/index.js CHANGED
@@ -391,14 +391,14 @@ test('\nincrement versions test', function(t) {
391
391
  ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'],
392
392
  ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'],
393
393
  ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'],
394
- ['1.2.0', 'prepatch', '1.2.1-dev.0', 'dev'],
395
- ['1.2.0-1', 'prepatch', '1.2.1-dev.0', 'dev'],
396
- ['1.2.0', 'preminor', '1.3.0-dev.0', 'dev'],
397
- ['1.2.3-1', 'preminor', '1.3.0-dev.0', 'dev'],
398
- ['1.2.0', 'premajor', '2.0.0-dev.0', 'dev'],
399
- ['1.2.3-1', 'premajor', '2.0.0-dev.0', 'dev'],
400
- ['1.2.0-1', 'minor', '1.2.0', 'dev'],
401
- ['1.0.0-1', 'major', '1.0.0', 'dev'],
394
+ ['1.2.0', 'prepatch', '1.2.1-dev.0', false, 'dev'],
395
+ ['1.2.0-1', 'prepatch', '1.2.1-dev.0', false, 'dev'],
396
+ ['1.2.0', 'preminor', '1.3.0-dev.0', false, 'dev'],
397
+ ['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'],
398
+ ['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev'],
399
+ ['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev'],
400
+ ['1.2.0-1', 'minor', '1.2.0', false, 'dev'],
401
+ ['1.0.0-1', 'major', '1.0.0', false, 'dev'],
402
402
  ['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev']
403
403
 
404
404
  ].forEach(function(v) {
@@ -410,6 +410,19 @@ test('\nincrement versions test', function(t) {
410
410
  var found = inc(pre, what, loose, id);
411
411
  var cmd = 'inc(' + pre + ', ' + what + ', ' + id + ')';
412
412
  t.equal(found, wanted, cmd + ' === ' + wanted);
413
+
414
+ var parsed = semver.parse(pre, loose);
415
+ if (wanted) {
416
+ parsed.inc(what, id);
417
+ t.equal(parsed.version, wanted, cmd + ' object version updated');
418
+ t.equal(parsed.raw, wanted, cmd + ' object raw field updated');
419
+ } else if (parsed) {
420
+ t.throws(function () {
421
+ parsed.inc(what, id)
422
+ })
423
+ } else {
424
+ t.equal(parsed, null)
425
+ }
413
426
  });
414
427
 
415
428
  t.end();