Skip to content

Commit 6b72107

Browse files
committed
1 parent c9ad0c4 commit 6b72107

File tree

7 files changed

+44
-31
lines changed

7 files changed

+44
-31
lines changed

node_modules/semver/bin/semver.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const main = () => {
6161
switch (argv[0]) {
6262
case 'major': case 'minor': case 'patch': case 'prerelease':
6363
case 'premajor': case 'preminor': case 'prepatch':
64+
case 'release':
6465
inc = argv.shift()
6566
break
6667
default:
@@ -149,7 +150,7 @@ Options:
149150
-i --increment [<level>]
150151
Increment a version by the specified level. Level can
151152
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'.
153154
Only one version may be specified.
154155
155156
--preid <identifier>

node_modules/semver/classes/semver.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const debug = require('../internal/debug')
22
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')
44

55
const parseOptions = require('../internal/parse-options')
66
const { compareIdentifiers } = require('../internal/identifiers')
@@ -10,7 +10,7 @@ class SemVer {
1010

1111
if (version instanceof SemVer) {
1212
if (version.loose === !!options.loose &&
13-
version.includePrerelease === !!options.includePrerelease) {
13+
version.includePrerelease === !!options.includePrerelease) {
1414
return version
1515
} else {
1616
version = version.version
@@ -176,6 +176,20 @@ class SemVer {
176176
// preminor will bump the version up to the next minor release, and immediately
177177
// down to pre-release. premajor and prepatch work the same way.
178178
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+
179193
switch (release) {
180194
case 'premajor':
181195
this.prerelease.length = 0
@@ -206,6 +220,12 @@ class SemVer {
206220
}
207221
this.inc('pre', identifier, identifierBase)
208222
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
209229

210230
case 'major':
211231
// If this is a pre-major version, bump up to the same major version.
@@ -249,10 +269,6 @@ class SemVer {
249269
case 'pre': {
250270
const base = Number(identifierBase) ? 1 : 0
251271

252-
if (!identifier && identifierBase === false) {
253-
throw new Error('invalid increment argument: identifier is empty')
254-
}
255-
256272
if (this.prerelease.length === 0) {
257273
this.prerelease = [base]
258274
} else {

node_modules/semver/functions/diff.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,13 @@ const diff = (version1, version2) => {
2727
return 'major'
2828
}
2929

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+
}
3435
return 'patch'
3536
}
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'
4437
}
4538

4639
// add the `pre` prefix if we are going to a prerelease version

node_modules/semver/internal/re.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports = module.exports = {}
1010
const re = exports.re = []
1111
const safeRe = exports.safeRe = []
1212
const src = exports.src = []
13+
const safeSrc = exports.safeSrc = []
1314
const t = exports.t = {}
1415
let R = 0
1516

@@ -42,6 +43,7 @@ const createToken = (name, value, isGlobal) => {
4243
debug(name, index, value)
4344
t[name] = index
4445
src[index] = value
46+
safeSrc[index] = safe
4547
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
4648
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
4749
}

node_modules/semver/package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
{
22
"name": "semver",
3-
"version": "7.6.3",
3+
"version": "7.7.1",
44
"description": "The semantic version parser used by npm.",
55
"main": "index.js",
66
"scripts": {
77
"test": "tap",
88
"snap": "tap",
9-
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
9+
"lint": "npm run eslint",
1010
"postlint": "template-oss-check",
11-
"lintfix": "npm run lint -- --fix",
11+
"lintfix": "npm run eslint -- --fix",
1212
"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}\""
1415
},
1516
"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",
1819
"benchmark": "^2.1.4",
1920
"tap": "^16.0.0"
2021
},
@@ -51,7 +52,7 @@
5152
"author": "GitHub Inc.",
5253
"templateOSS": {
5354
"//@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",
5556
"engines": ">=10",
5657
"distPaths": [
5758
"classes/",

package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"proc-log": "^5.0.0",
141141
"qrcode-terminal": "^0.12.0",
142142
"read": "^4.0.0",
143-
"semver": "^7.6.3",
143+
"semver": "^7.7.1",
144144
"spdx-expression-parse": "^4.0.0",
145145
"ssri": "^12.0.0",
146146
"supports-color": "^9.4.0",
@@ -14396,9 +14396,9 @@
1439614396
}
1439714397
},
1439814398
"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==",
1440214402
"inBundle": true,
1440314403
"license": "ISC",
1440414404
"bin": {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"proc-log": "^5.0.0",
108108
"qrcode-terminal": "^0.12.0",
109109
"read": "^4.0.0",
110-
"semver": "^7.6.3",
110+
"semver": "^7.7.1",
111111
"spdx-expression-parse": "^4.0.0",
112112
"ssri": "^12.0.0",
113113
"supports-color": "^9.4.0",

0 commit comments

Comments
 (0)