semver 7.3.7 → 7.4.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/README.md +56 -0
- package/bin/semver.js +8 -2
- package/classes/comparator.js +37 -33
- package/classes/range.js +9 -2
- package/classes/semver.js +10 -9
- package/functions/diff.js +24 -8
- package/functions/inc.js +3 -2
- package/functions/parse.js +0 -10
- package/index.js +82 -41
- package/internal/constants.js +15 -2
- package/internal/parse-options.js +14 -10
- package/package.json +24 -12
- package/ranges/intersects.js +1 -1
- package/ranges/subset.js +6 -3
package/README.md
CHANGED
|
@@ -110,6 +110,9 @@ Options:
|
|
|
110
110
|
-l --loose
|
|
111
111
|
Interpret versions and ranges loosely
|
|
112
112
|
|
|
113
|
+
-n <0|1>
|
|
114
|
+
This is the base to be used for the prerelease identifier.
|
|
115
|
+
|
|
113
116
|
-p --include-prerelease
|
|
114
117
|
Always include prerelease versions in range matching
|
|
115
118
|
|
|
@@ -232,6 +235,24 @@ $ semver 1.2.4-beta.0 -i prerelease
|
|
|
232
235
|
1.2.4-beta.1
|
|
233
236
|
```
|
|
234
237
|
|
|
238
|
+
#### Prerelease Identifier Base
|
|
239
|
+
|
|
240
|
+
The method `.inc` takes an optional parameter 'identifierBase' string
|
|
241
|
+
that will let you let your prerelease number as zero-based or one-based.
|
|
242
|
+
If you do not specify this parameter, it will default to zero-based.
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
semver.inc('1.2.3', 'prerelease', 'beta', '1')
|
|
246
|
+
// '1.2.4-beta.1'
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
command-line example:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
$ semver 1.2.3 -i prerelease --preid beta -n 1
|
|
253
|
+
1.2.4-beta.1
|
|
254
|
+
```
|
|
255
|
+
|
|
235
256
|
### Advanced Range Syntax
|
|
236
257
|
|
|
237
258
|
Advanced range syntax desugars to primitive comparators in
|
|
@@ -513,6 +534,40 @@ ex.
|
|
|
513
534
|
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
|
514
535
|
* `s.clean('~1.0.0')`: `null`
|
|
515
536
|
|
|
537
|
+
## Constants
|
|
538
|
+
|
|
539
|
+
As a convenience, helper constants are exported to provide information about what `node-semver` supports:
|
|
540
|
+
|
|
541
|
+
### `RELEASE_TYPES`
|
|
542
|
+
|
|
543
|
+
- major
|
|
544
|
+
- premajor
|
|
545
|
+
- minor
|
|
546
|
+
- preminor
|
|
547
|
+
- patch
|
|
548
|
+
- prepatch
|
|
549
|
+
- prerelease
|
|
550
|
+
|
|
551
|
+
```
|
|
552
|
+
const semver = require('semver');
|
|
553
|
+
|
|
554
|
+
if (semver.RELEASE_TYPES.includes(arbitraryUserInput)) {
|
|
555
|
+
console.log('This is a valid release type!');
|
|
556
|
+
} else {
|
|
557
|
+
console.warn('This is NOT a valid release type!');
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### `SEMVER_SPEC_VERSION`
|
|
562
|
+
|
|
563
|
+
2.0.0
|
|
564
|
+
|
|
565
|
+
```
|
|
566
|
+
const semver = require('semver');
|
|
567
|
+
|
|
568
|
+
console.log('We are currently using the semver specification version:', semver.SEMVER_SPEC_VERSION);
|
|
569
|
+
```
|
|
570
|
+
|
|
516
571
|
## Exported Modules
|
|
517
572
|
|
|
518
573
|
<!--
|
|
@@ -566,3 +621,4 @@ The following modules are available:
|
|
|
566
621
|
* `require('semver/ranges/outside')`
|
|
567
622
|
* `require('semver/ranges/to-comparators')`
|
|
568
623
|
* `require('semver/ranges/valid')`
|
|
624
|
+
|
package/bin/semver.js
CHANGED
|
@@ -23,7 +23,10 @@ let rtl = false
|
|
|
23
23
|
|
|
24
24
|
let identifier
|
|
25
25
|
|
|
26
|
+
let identifierBase
|
|
27
|
+
|
|
26
28
|
const semver = require('../')
|
|
29
|
+
const parseOptions = require('../internal/parse-options')
|
|
27
30
|
|
|
28
31
|
let reverse = false
|
|
29
32
|
|
|
@@ -71,6 +74,9 @@ const main = () => {
|
|
|
71
74
|
case '-r': case '--range':
|
|
72
75
|
range.push(argv.shift())
|
|
73
76
|
break
|
|
77
|
+
case '-n':
|
|
78
|
+
identifierBase = argv.shift()
|
|
79
|
+
break
|
|
74
80
|
case '-c': case '--coerce':
|
|
75
81
|
coerce = true
|
|
76
82
|
break
|
|
@@ -88,7 +94,7 @@ const main = () => {
|
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
options = { loose
|
|
97
|
+
options = parseOptions({ loose, includePrerelease, rtl })
|
|
92
98
|
|
|
93
99
|
versions = versions.map((v) => {
|
|
94
100
|
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
|
@@ -127,7 +133,7 @@ const success = () => {
|
|
|
127
133
|
}).map((v) => {
|
|
128
134
|
return semver.clean(v, options)
|
|
129
135
|
}).map((v) => {
|
|
130
|
-
return inc ? semver.inc(v, inc, options, identifier) : v
|
|
136
|
+
return inc ? semver.inc(v, inc, options, identifier, identifierBase) : v
|
|
131
137
|
}).forEach((v, i, _) => {
|
|
132
138
|
console.log(v)
|
|
133
139
|
})
|
package/classes/comparator.js
CHANGED
|
@@ -78,13 +78,6 @@ class Comparator {
|
|
|
78
78
|
throw new TypeError('a Comparator is required')
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
if (!options || typeof options !== 'object') {
|
|
82
|
-
options = {
|
|
83
|
-
loose: !!options,
|
|
84
|
-
includePrerelease: false,
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
81
|
if (this.operator === '') {
|
|
89
82
|
if (this.value === '') {
|
|
90
83
|
return true
|
|
@@ -97,32 +90,43 @@ class Comparator {
|
|
|
97
90
|
return new Range(this.value, options).test(comp.semver)
|
|
98
91
|
}
|
|
99
92
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
(this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
(this.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
93
|
+
options = parseOptions(options)
|
|
94
|
+
|
|
95
|
+
// Special cases where nothing can possibly be lower
|
|
96
|
+
if (options.includePrerelease &&
|
|
97
|
+
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
if (!options.includePrerelease &&
|
|
101
|
+
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
|
102
|
+
return false
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Same direction increasing (> or >=)
|
|
106
|
+
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
|
107
|
+
return true
|
|
108
|
+
}
|
|
109
|
+
// Same direction decreasing (< or <=)
|
|
110
|
+
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
|
111
|
+
return true
|
|
112
|
+
}
|
|
113
|
+
// same SemVer and both sides are inclusive (<= or >=)
|
|
114
|
+
if (
|
|
115
|
+
(this.semver.version === comp.semver.version) &&
|
|
116
|
+
this.operator.includes('=') && comp.operator.includes('=')) {
|
|
117
|
+
return true
|
|
118
|
+
}
|
|
119
|
+
// opposite directions less than
|
|
120
|
+
if (cmp(this.semver, '<', comp.semver, options) &&
|
|
121
|
+
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
|
122
|
+
return true
|
|
123
|
+
}
|
|
124
|
+
// opposite directions greater than
|
|
125
|
+
if (cmp(this.semver, '>', comp.semver, options) &&
|
|
126
|
+
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
|
127
|
+
return true
|
|
128
|
+
}
|
|
129
|
+
return false
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
|
package/classes/range.js
CHANGED
|
@@ -81,8 +81,10 @@ class Range {
|
|
|
81
81
|
|
|
82
82
|
// memoize range parsing for performance.
|
|
83
83
|
// this is a very hot path, and fully deterministic.
|
|
84
|
-
const memoOpts =
|
|
85
|
-
|
|
84
|
+
const memoOpts =
|
|
85
|
+
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
|
|
86
|
+
(this.options.loose && FLAG_LOOSE)
|
|
87
|
+
const memoKey = memoOpts + ':' + range
|
|
86
88
|
const cached = cache.get(memoKey)
|
|
87
89
|
if (cached) {
|
|
88
90
|
return cached
|
|
@@ -190,6 +192,7 @@ class Range {
|
|
|
190
192
|
return false
|
|
191
193
|
}
|
|
192
194
|
}
|
|
195
|
+
|
|
193
196
|
module.exports = Range
|
|
194
197
|
|
|
195
198
|
const LRU = require('lru-cache')
|
|
@@ -206,6 +209,7 @@ const {
|
|
|
206
209
|
tildeTrimReplace,
|
|
207
210
|
caretTrimReplace,
|
|
208
211
|
} = require('../internal/re')
|
|
212
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
|
|
209
213
|
|
|
210
214
|
const isNullSet = c => c.value === '<0.0.0-0'
|
|
211
215
|
const isAny = c => c.value === ''
|
|
@@ -252,6 +256,7 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
|
|
252
256
|
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
|
253
257
|
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
254
258
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
259
|
+
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
|
255
260
|
const replaceTildes = (comp, options) =>
|
|
256
261
|
comp.trim().split(/\s+/).map((c) => {
|
|
257
262
|
return replaceTilde(c, options)
|
|
@@ -291,6 +296,8 @@ const replaceTilde = (comp, options) => {
|
|
|
291
296
|
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
|
292
297
|
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
|
293
298
|
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
299
|
+
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
|
300
|
+
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
|
294
301
|
const replaceCarets = (comp, options) =>
|
|
295
302
|
comp.trim().split(/\s+/).map((c) => {
|
|
296
303
|
return replaceCaret(c, options)
|
package/classes/semver.js
CHANGED
|
@@ -175,36 +175,36 @@ class SemVer {
|
|
|
175
175
|
|
|
176
176
|
// preminor will bump the version up to the next minor release, and immediately
|
|
177
177
|
// down to pre-release. premajor and prepatch work the same way.
|
|
178
|
-
inc (release, identifier) {
|
|
178
|
+
inc (release, identifier, identifierBase) {
|
|
179
179
|
switch (release) {
|
|
180
180
|
case 'premajor':
|
|
181
181
|
this.prerelease.length = 0
|
|
182
182
|
this.patch = 0
|
|
183
183
|
this.minor = 0
|
|
184
184
|
this.major++
|
|
185
|
-
this.inc('pre', identifier)
|
|
185
|
+
this.inc('pre', identifier, identifierBase)
|
|
186
186
|
break
|
|
187
187
|
case 'preminor':
|
|
188
188
|
this.prerelease.length = 0
|
|
189
189
|
this.patch = 0
|
|
190
190
|
this.minor++
|
|
191
|
-
this.inc('pre', identifier)
|
|
191
|
+
this.inc('pre', identifier, identifierBase)
|
|
192
192
|
break
|
|
193
193
|
case 'prepatch':
|
|
194
194
|
// If this is already a prerelease, it will bump to the next version
|
|
195
195
|
// drop any prereleases that might already exist, since they are not
|
|
196
196
|
// relevant at this point.
|
|
197
197
|
this.prerelease.length = 0
|
|
198
|
-
this.inc('patch', identifier)
|
|
199
|
-
this.inc('pre', identifier)
|
|
198
|
+
this.inc('patch', identifier, identifierBase)
|
|
199
|
+
this.inc('pre', identifier, identifierBase)
|
|
200
200
|
break
|
|
201
201
|
// If the input is a non-prerelease version, this acts the same as
|
|
202
202
|
// prepatch.
|
|
203
203
|
case 'prerelease':
|
|
204
204
|
if (this.prerelease.length === 0) {
|
|
205
|
-
this.inc('patch', identifier)
|
|
205
|
+
this.inc('patch', identifier, identifierBase)
|
|
206
206
|
}
|
|
207
|
-
this.inc('pre', identifier)
|
|
207
|
+
this.inc('pre', identifier, identifierBase)
|
|
208
208
|
break
|
|
209
209
|
|
|
210
210
|
case 'major':
|
|
@@ -263,14 +263,15 @@ class SemVer {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
if (identifier) {
|
|
266
|
+
const base = Number(identifierBase) ? 1 : 0
|
|
266
267
|
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
267
268
|
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
268
269
|
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
269
270
|
if (isNaN(this.prerelease[1])) {
|
|
270
|
-
this.prerelease = [identifier,
|
|
271
|
+
this.prerelease = [identifier, base]
|
|
271
272
|
}
|
|
272
273
|
} else {
|
|
273
|
-
this.prerelease = [identifier,
|
|
274
|
+
this.prerelease = [identifier, base]
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
277
|
break
|
package/functions/diff.js
CHANGED
|
@@ -2,19 +2,35 @@ const parse = require('./parse')
|
|
|
2
2
|
const eq = require('./eq')
|
|
3
3
|
|
|
4
4
|
const diff = (version1, version2) => {
|
|
5
|
-
|
|
5
|
+
const v1 = parse(version1)
|
|
6
|
+
const v2 = parse(version2)
|
|
7
|
+
if (eq(v1, v2)) {
|
|
6
8
|
return null
|
|
7
9
|
} else {
|
|
8
|
-
const v1 = parse(version1)
|
|
9
|
-
const v2 = parse(version2)
|
|
10
10
|
const hasPre = v1.prerelease.length || v2.prerelease.length
|
|
11
11
|
const prefix = hasPre ? 'pre' : ''
|
|
12
12
|
const defaultResult = hasPre ? 'prerelease' : ''
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
|
|
14
|
+
if (v1.major !== v2.major) {
|
|
15
|
+
return prefix + 'major'
|
|
16
|
+
}
|
|
17
|
+
if (v1.minor !== v2.minor) {
|
|
18
|
+
return prefix + 'minor'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (v1.patch !== v2.patch) {
|
|
22
|
+
return prefix + 'patch'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!v1.prerelease.length || !v2.prerelease.length) {
|
|
26
|
+
if (v1.patch) {
|
|
27
|
+
return 'patch'
|
|
28
|
+
}
|
|
29
|
+
if (v1.minor) {
|
|
30
|
+
return 'minor'
|
|
31
|
+
}
|
|
32
|
+
if (v1.major) {
|
|
33
|
+
return 'major'
|
|
18
34
|
}
|
|
19
35
|
}
|
|
20
36
|
return defaultResult // may be undefined
|
package/functions/inc.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const SemVer = require('../classes/semver')
|
|
2
2
|
|
|
3
|
-
const inc = (version, release, options, identifier) => {
|
|
3
|
+
const inc = (version, release, options, identifier, identifierBase) => {
|
|
4
4
|
if (typeof (options) === 'string') {
|
|
5
|
+
identifierBase = identifier
|
|
5
6
|
identifier = options
|
|
6
7
|
options = undefined
|
|
7
8
|
}
|
|
@@ -10,7 +11,7 @@ const inc = (version, release, options, identifier) => {
|
|
|
10
11
|
return new SemVer(
|
|
11
12
|
version instanceof SemVer ? version.version : version,
|
|
12
13
|
options
|
|
13
|
-
).inc(release, identifier).version
|
|
14
|
+
).inc(release, identifier, identifierBase).version
|
|
14
15
|
} catch (er) {
|
|
15
16
|
return null
|
|
16
17
|
}
|
package/functions/parse.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const { MAX_LENGTH } = require('../internal/constants')
|
|
2
|
-
const { re, t } = require('../internal/re')
|
|
3
2
|
const SemVer = require('../classes/semver')
|
|
4
|
-
|
|
5
|
-
const parseOptions = require('../internal/parse-options')
|
|
6
3
|
const parse = (version, options) => {
|
|
7
|
-
options = parseOptions(options)
|
|
8
|
-
|
|
9
4
|
if (version instanceof SemVer) {
|
|
10
5
|
return version
|
|
11
6
|
}
|
|
@@ -18,11 +13,6 @@ const parse = (version, options) => {
|
|
|
18
13
|
return null
|
|
19
14
|
}
|
|
20
15
|
|
|
21
|
-
const r = options.loose ? re[t.LOOSE] : re[t.FULL]
|
|
22
|
-
if (!r.test(version)) {
|
|
23
|
-
return null
|
|
24
|
-
}
|
|
25
|
-
|
|
26
16
|
try {
|
|
27
17
|
return new SemVer(version, options)
|
|
28
18
|
} catch (er) {
|
package/index.js
CHANGED
|
@@ -1,48 +1,89 @@
|
|
|
1
1
|
// just pre-load all the stuff that index.js lazily exports
|
|
2
2
|
const internalRe = require('./internal/re')
|
|
3
|
+
const constants = require('./internal/constants')
|
|
4
|
+
const SemVer = require('./classes/semver')
|
|
5
|
+
const identifiers = require('./internal/identifiers')
|
|
6
|
+
const parse = require('./functions/parse')
|
|
7
|
+
const valid = require('./functions/valid')
|
|
8
|
+
const clean = require('./functions/clean')
|
|
9
|
+
const inc = require('./functions/inc')
|
|
10
|
+
const diff = require('./functions/diff')
|
|
11
|
+
const major = require('./functions/major')
|
|
12
|
+
const minor = require('./functions/minor')
|
|
13
|
+
const patch = require('./functions/patch')
|
|
14
|
+
const prerelease = require('./functions/prerelease')
|
|
15
|
+
const compare = require('./functions/compare')
|
|
16
|
+
const rcompare = require('./functions/rcompare')
|
|
17
|
+
const compareLoose = require('./functions/compare-loose')
|
|
18
|
+
const compareBuild = require('./functions/compare-build')
|
|
19
|
+
const sort = require('./functions/sort')
|
|
20
|
+
const rsort = require('./functions/rsort')
|
|
21
|
+
const gt = require('./functions/gt')
|
|
22
|
+
const lt = require('./functions/lt')
|
|
23
|
+
const eq = require('./functions/eq')
|
|
24
|
+
const neq = require('./functions/neq')
|
|
25
|
+
const gte = require('./functions/gte')
|
|
26
|
+
const lte = require('./functions/lte')
|
|
27
|
+
const cmp = require('./functions/cmp')
|
|
28
|
+
const coerce = require('./functions/coerce')
|
|
29
|
+
const Comparator = require('./classes/comparator')
|
|
30
|
+
const Range = require('./classes/range')
|
|
31
|
+
const satisfies = require('./functions/satisfies')
|
|
32
|
+
const toComparators = require('./ranges/to-comparators')
|
|
33
|
+
const maxSatisfying = require('./ranges/max-satisfying')
|
|
34
|
+
const minSatisfying = require('./ranges/min-satisfying')
|
|
35
|
+
const minVersion = require('./ranges/min-version')
|
|
36
|
+
const validRange = require('./ranges/valid')
|
|
37
|
+
const outside = require('./ranges/outside')
|
|
38
|
+
const gtr = require('./ranges/gtr')
|
|
39
|
+
const ltr = require('./ranges/ltr')
|
|
40
|
+
const intersects = require('./ranges/intersects')
|
|
41
|
+
const simplifyRange = require('./ranges/simplify')
|
|
42
|
+
const subset = require('./ranges/subset')
|
|
3
43
|
module.exports = {
|
|
44
|
+
parse,
|
|
45
|
+
valid,
|
|
46
|
+
clean,
|
|
47
|
+
inc,
|
|
48
|
+
diff,
|
|
49
|
+
major,
|
|
50
|
+
minor,
|
|
51
|
+
patch,
|
|
52
|
+
prerelease,
|
|
53
|
+
compare,
|
|
54
|
+
rcompare,
|
|
55
|
+
compareLoose,
|
|
56
|
+
compareBuild,
|
|
57
|
+
sort,
|
|
58
|
+
rsort,
|
|
59
|
+
gt,
|
|
60
|
+
lt,
|
|
61
|
+
eq,
|
|
62
|
+
neq,
|
|
63
|
+
gte,
|
|
64
|
+
lte,
|
|
65
|
+
cmp,
|
|
66
|
+
coerce,
|
|
67
|
+
Comparator,
|
|
68
|
+
Range,
|
|
69
|
+
satisfies,
|
|
70
|
+
toComparators,
|
|
71
|
+
maxSatisfying,
|
|
72
|
+
minSatisfying,
|
|
73
|
+
minVersion,
|
|
74
|
+
validRange,
|
|
75
|
+
outside,
|
|
76
|
+
gtr,
|
|
77
|
+
ltr,
|
|
78
|
+
intersects,
|
|
79
|
+
simplifyRange,
|
|
80
|
+
subset,
|
|
81
|
+
SemVer,
|
|
4
82
|
re: internalRe.re,
|
|
5
83
|
src: internalRe.src,
|
|
6
84
|
tokens: internalRe.t,
|
|
7
|
-
SEMVER_SPEC_VERSION:
|
|
8
|
-
|
|
9
|
-
compareIdentifiers:
|
|
10
|
-
rcompareIdentifiers:
|
|
11
|
-
parse: require('./functions/parse'),
|
|
12
|
-
valid: require('./functions/valid'),
|
|
13
|
-
clean: require('./functions/clean'),
|
|
14
|
-
inc: require('./functions/inc'),
|
|
15
|
-
diff: require('./functions/diff'),
|
|
16
|
-
major: require('./functions/major'),
|
|
17
|
-
minor: require('./functions/minor'),
|
|
18
|
-
patch: require('./functions/patch'),
|
|
19
|
-
prerelease: require('./functions/prerelease'),
|
|
20
|
-
compare: require('./functions/compare'),
|
|
21
|
-
rcompare: require('./functions/rcompare'),
|
|
22
|
-
compareLoose: require('./functions/compare-loose'),
|
|
23
|
-
compareBuild: require('./functions/compare-build'),
|
|
24
|
-
sort: require('./functions/sort'),
|
|
25
|
-
rsort: require('./functions/rsort'),
|
|
26
|
-
gt: require('./functions/gt'),
|
|
27
|
-
lt: require('./functions/lt'),
|
|
28
|
-
eq: require('./functions/eq'),
|
|
29
|
-
neq: require('./functions/neq'),
|
|
30
|
-
gte: require('./functions/gte'),
|
|
31
|
-
lte: require('./functions/lte'),
|
|
32
|
-
cmp: require('./functions/cmp'),
|
|
33
|
-
coerce: require('./functions/coerce'),
|
|
34
|
-
Comparator: require('./classes/comparator'),
|
|
35
|
-
Range: require('./classes/range'),
|
|
36
|
-
satisfies: require('./functions/satisfies'),
|
|
37
|
-
toComparators: require('./ranges/to-comparators'),
|
|
38
|
-
maxSatisfying: require('./ranges/max-satisfying'),
|
|
39
|
-
minSatisfying: require('./ranges/min-satisfying'),
|
|
40
|
-
minVersion: require('./ranges/min-version'),
|
|
41
|
-
validRange: require('./ranges/valid'),
|
|
42
|
-
outside: require('./ranges/outside'),
|
|
43
|
-
gtr: require('./ranges/gtr'),
|
|
44
|
-
ltr: require('./ranges/ltr'),
|
|
45
|
-
intersects: require('./ranges/intersects'),
|
|
46
|
-
simplifyRange: require('./ranges/simplify'),
|
|
47
|
-
subset: require('./ranges/subset'),
|
|
85
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
86
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
87
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
88
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers,
|
|
48
89
|
}
|
package/internal/constants.js
CHANGED
|
@@ -9,9 +9,22 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
|
9
9
|
// Max safe segment length for coercion.
|
|
10
10
|
const MAX_SAFE_COMPONENT_LENGTH = 16
|
|
11
11
|
|
|
12
|
+
const RELEASE_TYPES = [
|
|
13
|
+
'major',
|
|
14
|
+
'premajor',
|
|
15
|
+
'minor',
|
|
16
|
+
'preminor',
|
|
17
|
+
'patch',
|
|
18
|
+
'prepatch',
|
|
19
|
+
'prerelease',
|
|
20
|
+
]
|
|
21
|
+
|
|
12
22
|
module.exports = {
|
|
13
|
-
SEMVER_SPEC_VERSION,
|
|
14
23
|
MAX_LENGTH,
|
|
15
|
-
MAX_SAFE_INTEGER,
|
|
16
24
|
MAX_SAFE_COMPONENT_LENGTH,
|
|
25
|
+
MAX_SAFE_INTEGER,
|
|
26
|
+
RELEASE_TYPES,
|
|
27
|
+
SEMVER_SPEC_VERSION,
|
|
28
|
+
FLAG_INCLUDE_PRERELEASE: 0b001,
|
|
29
|
+
FLAG_LOOSE: 0b010,
|
|
17
30
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
// parse out just the options we care about
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const parseOptions = options =>
|
|
5
|
-
!options
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
// parse out just the options we care about
|
|
2
|
+
const looseOption = Object.freeze({ loose: true })
|
|
3
|
+
const emptyOpts = Object.freeze({ })
|
|
4
|
+
const parseOptions = options => {
|
|
5
|
+
if (!options) {
|
|
6
|
+
return emptyOpts
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (typeof options !== 'object') {
|
|
10
|
+
return looseOption
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return options
|
|
14
|
+
}
|
|
11
15
|
module.exports = parseOptions
|
package/package.json
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semver",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "The semantic version parser used by npm.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "tap",
|
|
8
8
|
"snap": "tap",
|
|
9
|
-
"preversion": "npm test",
|
|
10
|
-
"postversion": "npm publish",
|
|
11
|
-
"postpublish": "git push origin --follow-tags",
|
|
12
9
|
"lint": "eslint \"**/*.js\"",
|
|
13
10
|
"postlint": "template-oss-check",
|
|
14
11
|
"lintfix": "npm run lint -- --fix",
|
|
15
|
-
"prepublishOnly": "git push origin --follow-tags",
|
|
16
12
|
"posttest": "npm run lint",
|
|
17
13
|
"template-oss-apply": "template-oss-apply --force"
|
|
18
14
|
},
|
|
19
15
|
"devDependencies": {
|
|
20
|
-
"@npmcli/eslint-config": "^
|
|
21
|
-
"@npmcli/template-oss": "
|
|
16
|
+
"@npmcli/eslint-config": "^4.0.0",
|
|
17
|
+
"@npmcli/template-oss": "4.13.0",
|
|
22
18
|
"tap": "^16.0.0"
|
|
23
19
|
},
|
|
24
20
|
"license": "ISC",
|
|
@@ -31,6 +27,7 @@
|
|
|
31
27
|
},
|
|
32
28
|
"files": [
|
|
33
29
|
"bin/",
|
|
30
|
+
"lib/",
|
|
34
31
|
"classes/",
|
|
35
32
|
"functions/",
|
|
36
33
|
"internal/",
|
|
@@ -41,7 +38,11 @@
|
|
|
41
38
|
],
|
|
42
39
|
"tap": {
|
|
43
40
|
"check-coverage": true,
|
|
44
|
-
"coverage-map": "map.js"
|
|
41
|
+
"coverage-map": "map.js",
|
|
42
|
+
"nyc-arg": [
|
|
43
|
+
"--exclude",
|
|
44
|
+
"tap-snapshots/**"
|
|
45
|
+
]
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
48
|
"node": ">=10"
|
|
@@ -52,17 +53,18 @@
|
|
|
52
53
|
"author": "GitHub Inc.",
|
|
53
54
|
"templateOSS": {
|
|
54
55
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
55
|
-
"version": "
|
|
56
|
+
"version": "4.13.0",
|
|
56
57
|
"engines": ">=10",
|
|
57
58
|
"ciVersions": [
|
|
58
59
|
"10.0.0",
|
|
59
60
|
"10.x",
|
|
60
61
|
"12.x",
|
|
61
62
|
"14.x",
|
|
62
|
-
"16.x"
|
|
63
|
+
"16.x",
|
|
64
|
+
"18.x"
|
|
63
65
|
],
|
|
66
|
+
"npmSpec": "8",
|
|
64
67
|
"distPaths": [
|
|
65
|
-
"bin/",
|
|
66
68
|
"classes/",
|
|
67
69
|
"functions/",
|
|
68
70
|
"internal/",
|
|
@@ -70,6 +72,16 @@
|
|
|
70
72
|
"index.js",
|
|
71
73
|
"preload.js",
|
|
72
74
|
"range.bnf"
|
|
73
|
-
]
|
|
75
|
+
],
|
|
76
|
+
"allowPaths": [
|
|
77
|
+
"/classes/",
|
|
78
|
+
"/functions/",
|
|
79
|
+
"/internal/",
|
|
80
|
+
"/ranges/",
|
|
81
|
+
"/index.js",
|
|
82
|
+
"/preload.js",
|
|
83
|
+
"/range.bnf"
|
|
84
|
+
],
|
|
85
|
+
"publish": "true"
|
|
74
86
|
}
|
|
75
87
|
}
|
package/ranges/intersects.js
CHANGED
package/ranges/subset.js
CHANGED
|
@@ -68,6 +68,9 @@ const subset = (sub, dom, options = {}) => {
|
|
|
68
68
|
return true
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
|
|
72
|
+
const minimumVersion = [new Comparator('>=0.0.0')]
|
|
73
|
+
|
|
71
74
|
const simpleSubset = (sub, dom, options) => {
|
|
72
75
|
if (sub === dom) {
|
|
73
76
|
return true
|
|
@@ -77,9 +80,9 @@ const simpleSubset = (sub, dom, options) => {
|
|
|
77
80
|
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
78
81
|
return true
|
|
79
82
|
} else if (options.includePrerelease) {
|
|
80
|
-
sub =
|
|
83
|
+
sub = minimumVersionWithPreRelease
|
|
81
84
|
} else {
|
|
82
|
-
sub =
|
|
85
|
+
sub = minimumVersion
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
|
|
@@ -87,7 +90,7 @@ const simpleSubset = (sub, dom, options) => {
|
|
|
87
90
|
if (options.includePrerelease) {
|
|
88
91
|
return true
|
|
89
92
|
} else {
|
|
90
|
-
dom =
|
|
93
|
+
dom = minimumVersion
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
|