semver 5.7.0 → 6.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/CHANGELOG.md +8 -0
- package/README.md +21 -2
- package/package.json +3 -3
- package/semver.js +73 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# changes log
|
|
2
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
|
+
|
|
3
11
|
## 5.7
|
|
4
12
|
|
|
5
13
|
* Add `minVersion` method
|
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
|
|
7
|
+
npm install semver
|
|
8
8
|
````
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
@@ -231,7 +231,7 @@ comparator. Allows minor-level changes if not.
|
|
|
231
231
|
|
|
232
232
|
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
|
233
233
|
|
|
234
|
-
Allows changes that do not modify the left-most non-zero
|
|
234
|
+
Allows changes that do not modify the left-most non-zero element in the
|
|
235
235
|
`[major, minor, patch]` tuple. In other words, this allows patch and
|
|
236
236
|
minor updates for versions `1.0.0` and above, patch updates for
|
|
237
237
|
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
|
@@ -354,6 +354,9 @@ strings that they parse.
|
|
|
354
354
|
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
|
355
355
|
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
|
356
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()`.
|
|
357
360
|
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
|
358
361
|
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
|
359
362
|
or null if the versions are the same.
|
|
@@ -409,3 +412,19 @@ The maximum length for any semver component considered for coercion is 16 chara
|
|
|
409
412
|
longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`).
|
|
410
413
|
The maximum value for any semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`;
|
|
411
414
|
higher value components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
|
415
|
+
|
|
416
|
+
### Clean
|
|
417
|
+
|
|
418
|
+
* `clean(version)`: Clean a string to be a valid semver if possible
|
|
419
|
+
|
|
420
|
+
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
|
|
421
|
+
|
|
422
|
+
ex.
|
|
423
|
+
* `s.clean(' = v 2.1.5foo')`: `null`
|
|
424
|
+
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
|
425
|
+
* `s.clean(' = v 2.1.5-foo')`: `null`
|
|
426
|
+
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
|
427
|
+
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
|
428
|
+
* `s.clean(' =v2.1.5')`: `2.1.5`
|
|
429
|
+
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
|
430
|
+
* `s.clean('~1.0.0')`: `null`
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semver",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "The semantic version parser used by npm.",
|
|
5
5
|
"main": "semver.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "tap",
|
|
8
8
|
"preversion": "npm test",
|
|
9
9
|
"postversion": "npm publish",
|
|
10
|
-
"postpublish": "git push origin --
|
|
10
|
+
"postpublish": "git push origin --follow-tags"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"tap": "^
|
|
13
|
+
"tap": "^14.1.6"
|
|
14
14
|
},
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"repository": "https://github.com/npm/node-semver",
|
package/semver.js
CHANGED
|
@@ -425,6 +425,30 @@ SemVer.prototype.comparePre = function (other) {
|
|
|
425
425
|
} while (++i)
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
SemVer.prototype.compareBuild = function (other) {
|
|
429
|
+
if (!(other instanceof SemVer)) {
|
|
430
|
+
other = new SemVer(other, this.options)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
var i = 0
|
|
434
|
+
do {
|
|
435
|
+
var a = this.build[i]
|
|
436
|
+
var b = other.build[i]
|
|
437
|
+
debug('prerelease compare', i, a, b)
|
|
438
|
+
if (a === undefined && b === undefined) {
|
|
439
|
+
return 0
|
|
440
|
+
} else if (b === undefined) {
|
|
441
|
+
return 1
|
|
442
|
+
} else if (a === undefined) {
|
|
443
|
+
return -1
|
|
444
|
+
} else if (a === b) {
|
|
445
|
+
continue
|
|
446
|
+
} else {
|
|
447
|
+
return compareIdentifiers(a, b)
|
|
448
|
+
}
|
|
449
|
+
} while (++i)
|
|
450
|
+
}
|
|
451
|
+
|
|
428
452
|
// preminor will bump the version up to the next minor release, and immediately
|
|
429
453
|
// down to pre-release. premajor and prepatch work the same way.
|
|
430
454
|
SemVer.prototype.inc = function (release, identifier) {
|
|
@@ -619,6 +643,13 @@ function compareLoose (a, b) {
|
|
|
619
643
|
return compare(a, b, true)
|
|
620
644
|
}
|
|
621
645
|
|
|
646
|
+
exports.compareBuild = compareBuild
|
|
647
|
+
function compareBuild (a, b, loose) {
|
|
648
|
+
var versionA = new SemVer(a, loose)
|
|
649
|
+
var versionB = new SemVer(b, loose)
|
|
650
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
651
|
+
}
|
|
652
|
+
|
|
622
653
|
exports.rcompare = rcompare
|
|
623
654
|
function rcompare (a, b, loose) {
|
|
624
655
|
return compare(b, a, loose)
|
|
@@ -627,14 +658,14 @@ function rcompare (a, b, loose) {
|
|
|
627
658
|
exports.sort = sort
|
|
628
659
|
function sort (list, loose) {
|
|
629
660
|
return list.sort(function (a, b) {
|
|
630
|
-
return exports.
|
|
661
|
+
return exports.compareBuild(a, b, loose)
|
|
631
662
|
})
|
|
632
663
|
}
|
|
633
664
|
|
|
634
665
|
exports.rsort = rsort
|
|
635
666
|
function rsort (list, loose) {
|
|
636
667
|
return list.sort(function (a, b) {
|
|
637
|
-
return exports.
|
|
668
|
+
return exports.compareBuild(b, a, loose)
|
|
638
669
|
})
|
|
639
670
|
}
|
|
640
671
|
|
|
@@ -754,7 +785,7 @@ Comparator.prototype.parse = function (comp) {
|
|
|
754
785
|
throw new TypeError('Invalid comparator: ' + comp)
|
|
755
786
|
}
|
|
756
787
|
|
|
757
|
-
this.operator = m[1]
|
|
788
|
+
this.operator = m[1] !== undefined ? m[1] : ''
|
|
758
789
|
if (this.operator === '=') {
|
|
759
790
|
this.operator = ''
|
|
760
791
|
}
|
|
@@ -774,7 +805,7 @@ Comparator.prototype.toString = function () {
|
|
|
774
805
|
Comparator.prototype.test = function (version) {
|
|
775
806
|
debug('Comparator.test', version, this.options.loose)
|
|
776
807
|
|
|
777
|
-
if (this.semver === ANY) {
|
|
808
|
+
if (this.semver === ANY || version === ANY) {
|
|
778
809
|
return true
|
|
779
810
|
}
|
|
780
811
|
|
|
@@ -800,9 +831,15 @@ Comparator.prototype.intersects = function (comp, options) {
|
|
|
800
831
|
var rangeTmp
|
|
801
832
|
|
|
802
833
|
if (this.operator === '') {
|
|
834
|
+
if (this.value === '') {
|
|
835
|
+
return true
|
|
836
|
+
}
|
|
803
837
|
rangeTmp = new Range(comp.value, options)
|
|
804
838
|
return satisfies(this.value, rangeTmp, options)
|
|
805
839
|
} else if (comp.operator === '') {
|
|
840
|
+
if (comp.value === '') {
|
|
841
|
+
return true
|
|
842
|
+
}
|
|
806
843
|
rangeTmp = new Range(this.value, options)
|
|
807
844
|
return satisfies(comp.semver, rangeTmp, options)
|
|
808
845
|
}
|
|
@@ -934,16 +971,40 @@ Range.prototype.intersects = function (range, options) {
|
|
|
934
971
|
}
|
|
935
972
|
|
|
936
973
|
return this.set.some(function (thisComparators) {
|
|
937
|
-
return
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
974
|
+
return (
|
|
975
|
+
isSatisfiable(thisComparators, options) &&
|
|
976
|
+
range.set.some(function (rangeComparators) {
|
|
977
|
+
return (
|
|
978
|
+
isSatisfiable(rangeComparators, options) &&
|
|
979
|
+
thisComparators.every(function (thisComparator) {
|
|
980
|
+
return rangeComparators.every(function (rangeComparator) {
|
|
981
|
+
return thisComparator.intersects(rangeComparator, options)
|
|
982
|
+
})
|
|
983
|
+
})
|
|
984
|
+
)
|
|
942
985
|
})
|
|
943
|
-
|
|
986
|
+
)
|
|
944
987
|
})
|
|
945
988
|
}
|
|
946
989
|
|
|
990
|
+
// take a set of comparators and determine whether there
|
|
991
|
+
// exists a version which can satisfy it
|
|
992
|
+
function isSatisfiable (comparators, options) {
|
|
993
|
+
var result = true
|
|
994
|
+
var remainingComparators = comparators.slice()
|
|
995
|
+
var testComparator = remainingComparators.pop()
|
|
996
|
+
|
|
997
|
+
while (result && remainingComparators.length) {
|
|
998
|
+
result = remainingComparators.every(function (otherComparator) {
|
|
999
|
+
return testComparator.intersects(otherComparator, options)
|
|
1000
|
+
})
|
|
1001
|
+
|
|
1002
|
+
testComparator = remainingComparators.pop()
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
return result
|
|
1006
|
+
}
|
|
1007
|
+
|
|
947
1008
|
// Mostly just for testing and legacy API reasons
|
|
948
1009
|
exports.toComparators = toComparators
|
|
949
1010
|
function toComparators (range, options) {
|
|
@@ -1462,7 +1523,7 @@ function intersects (r1, r2, options) {
|
|
|
1462
1523
|
}
|
|
1463
1524
|
|
|
1464
1525
|
exports.coerce = coerce
|
|
1465
|
-
function coerce (version) {
|
|
1526
|
+
function coerce (version, options) {
|
|
1466
1527
|
if (version instanceof SemVer) {
|
|
1467
1528
|
return version
|
|
1468
1529
|
}
|
|
@@ -1479,5 +1540,5 @@ function coerce (version) {
|
|
|
1479
1540
|
|
|
1480
1541
|
return parse(match[1] +
|
|
1481
1542
|
'.' + (match[2] || '0') +
|
|
1482
|
-
'.' + (match[3] || '0'))
|
|
1543
|
+
'.' + (match[3] || '0'), options)
|
|
1483
1544
|
}
|