+44
-31
lines changedFilter options
+44
-31
lines changed Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ const main = () => {
61
61
switch (argv[0]) {
62
62
case 'major': case 'minor': case 'patch': case 'prerelease':
63
63
case 'premajor': case 'preminor': case 'prepatch':
64
+
case 'release':
64
65
inc = argv.shift()
65
66
break
66
67
default:
@@ -149,7 +150,7 @@ Options:
149
150
-i --increment [<level>]
150
151
Increment a version by the specified level. Level can
151
152
be one of: major, minor, patch, premajor, preminor,
152
-
prepatch, or prerelease. Default level is 'patch'.
153
+
prepatch, prerelease, or release. Default level is 'patch'.
153
154
Only one version may be specified.
154
155
155
156
--preid <identifier>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1
1
const debug = require('../internal/debug')
2
2
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
3
-
const { safeRe: re, t } = require('../internal/re')
3
+
const { safeRe: re, safeSrc: src, t } = require('../internal/re')
4
4
5
5
const parseOptions = require('../internal/parse-options')
6
6
const { compareIdentifiers } = require('../internal/identifiers')
@@ -10,7 +10,7 @@ class SemVer {
10
10
11
11
if (version instanceof SemVer) {
12
12
if (version.loose === !!options.loose &&
13
-
version.includePrerelease === !!options.includePrerelease) {
13
+
version.includePrerelease === !!options.includePrerelease) {
14
14
return version
15
15
} else {
16
16
version = version.version
@@ -176,6 +176,20 @@ class SemVer {
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
178
inc (release, identifier, identifierBase) {
179
+
if (release.startsWith('pre')) {
180
+
if (!identifier && identifierBase === false) {
181
+
throw new Error('invalid increment argument: identifier is empty')
182
+
}
183
+
// Avoid an invalid semver results
184
+
if (identifier) {
185
+
const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`)
186
+
const match = `-${identifier}`.match(r)
187
+
if (!match || match[1] !== identifier) {
188
+
throw new Error(`invalid identifier: ${identifier}`)
189
+
}
190
+
}
191
+
}
192
+
179
193
switch (release) {
180
194
case 'premajor':
181
195
this.prerelease.length = 0
@@ -206,6 +220,12 @@ class SemVer {
206
220
}
207
221
this.inc('pre', identifier, identifierBase)
208
222
break
223
+
case 'release':
224
+
if (this.prerelease.length === 0) {
225
+
throw new Error(`version ${this.raw} is not a prerelease`)
226
+
}
227
+
this.prerelease.length = 0
228
+
break
209
229
210
230
case 'major':
211
231
// If this is a pre-major version, bump up to the same major version.
@@ -249,10 +269,6 @@ class SemVer {
249
269
case 'pre': {
250
270
const base = Number(identifierBase) ? 1 : 0
251
271
252
-
if (!identifier && identifierBase === false) {
253
-
throw new Error('invalid increment argument: identifier is empty')
254
-
}
255
-
256
272
if (this.prerelease.length === 0) {
257
273
this.prerelease = [base]
258
274
} else {
Original file line number Diff line number Diff line change
@@ -27,20 +27,13 @@ const diff = (version1, version2) => {
27
27
return 'major'
28
28
}
29
29
30
-
// Otherwise it can be determined by checking the high version
31
-
32
-
if (highVersion.patch) {
33
-
// anything higher than a patch bump would result in the wrong version
30
+
// If the main part has no difference
31
+
if (lowVersion.compareMain(highVersion) === 0) {
32
+
if (lowVersion.minor && !lowVersion.patch) {
33
+
return 'minor'
34
+
}
34
35
return 'patch'
35
36
}
36
-
37
-
if (highVersion.minor) {
38
-
// anything higher than a minor bump would result in the wrong version
39
-
return 'minor'
40
-
}
41
-
42
-
// bumping major/minor/patch all have same result
43
-
return 'major'
44
37
}
45
38
46
39
// add the `pre` prefix if we are going to a prerelease version
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ exports = module.exports = {}
10
10
const re = exports.re = []
11
11
const safeRe = exports.safeRe = []
12
12
const src = exports.src = []
13
+
const safeSrc = exports.safeSrc = []
13
14
const t = exports.t = {}
14
15
let R = 0
15
16
@@ -42,6 +43,7 @@ const createToken = (name, value, isGlobal) => {
42
43
debug(name, index, value)
43
44
t[name] = index
44
45
src[index] = value
46
+
safeSrc[index] = safe
45
47
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
46
48
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
47
49
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
1
1
{
2
2
"name": "semver",
3
-
"version": "7.6.3",
3
+
"version": "7.7.1",
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
-
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
9
+
"lint": "npm run eslint",
10
10
"postlint": "template-oss-check",
11
-
"lintfix": "npm run lint -- --fix",
11
+
"lintfix": "npm run eslint -- --fix",
12
12
"posttest": "npm run lint",
13
-
"template-oss-apply": "template-oss-apply --force"
13
+
"template-oss-apply": "template-oss-apply --force",
14
+
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
14
15
},
15
16
"devDependencies": {
16
-
"@npmcli/eslint-config": "^4.0.0",
17
-
"@npmcli/template-oss": "4.22.0",
17
+
"@npmcli/eslint-config": "^5.0.0",
18
+
"@npmcli/template-oss": "4.23.4",
18
19
"benchmark": "^2.1.4",
19
20
"tap": "^16.0.0"
20
21
},
@@ -51,7 +52,7 @@
51
52
"author": "GitHub Inc.",
52
53
"templateOSS": {
53
54
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
54
-
"version": "4.22.0",
55
+
"version": "4.23.4",
55
56
"engines": ">=10",
56
57
"distPaths": [
57
58
"classes/",
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@
140
140
"proc-log": "^5.0.0",
141
141
"qrcode-terminal": "^0.12.0",
142
142
"read": "^4.0.0",
143
-
"semver": "^7.6.3",
143
+
"semver": "^7.7.1",
144
144
"spdx-expression-parse": "^4.0.0",
145
145
"ssri": "^12.0.0",
146
146
"supports-color": "^9.4.0",
@@ -14396,9 +14396,9 @@
14396
14396
}
14397
14397
},
14398
14398
"node_modules/semver": {
14399
-
"version": "7.6.3",
14400
-
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
14401
-
"integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
14399
+
"version": "7.7.1",
14400
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
14401
+
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==",
14402
14402
"inBundle": true,
14403
14403
"license": "ISC",
14404
14404
"bin": {
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@
107
107
"proc-log": "^5.0.0",
108
108
"qrcode-terminal": "^0.12.0",
109
109
"read": "^4.0.0",
110
-
"semver": "^7.6.3",
110
+
"semver": "^7.7.1",
111
111
"spdx-expression-parse": "^4.0.0",
112
112
"ssri": "^12.0.0",
113
113
"supports-color": "^9.4.0",
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4