Skip to content

Commit 72d6a79

Browse files
committedJun 19, 2023
deps: semver@7.5.2
1 parent 98f1f5f commit 72d6a79

File tree

9 files changed

+96
-61
lines changed

9 files changed

+96
-61
lines changed
 

‎node_modules/semver/classes/comparator.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Comparator {
1616
}
1717
}
1818

19+
comp = comp.trim().split(/\s+/).join(' ')
1920
debug('comparator', comp, options)
2021
this.options = options
2122
this.loose = !!options.loose
@@ -133,7 +134,7 @@ class Comparator {
133134
module.exports = Comparator
134135

135136
const parseOptions = require('../internal/parse-options')
136-
const { re, t } = require('../internal/re')
137+
const { safeRe: re, t } = require('../internal/re')
137138
const cmp = require('../functions/cmp')
138139
const debug = require('../internal/debug')
139140
const SemVer = require('./semver')

‎node_modules/semver/classes/range.js

+37-27
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,26 @@ class Range {
2626
this.loose = !!options.loose
2727
this.includePrerelease = !!options.includePrerelease
2828

29-
// First, split based on boolean or ||
29+
// First reduce all whitespace as much as possible so we do not have to rely
30+
// on potentially slow regexes like \s*. This is then stored and used for
31+
// future error messages as well.
3032
this.raw = range
31-
this.set = range
33+
.trim()
34+
.split(/\s+/)
35+
.join(' ')
36+
37+
// First, split on ||
38+
this.set = this.raw
3239
.split('||')
3340
// map the range to a 2d array of comparators
34-
.map(r => this.parseRange(r.trim()))
41+
.map(r => this.parseRange(r))
3542
// throw out any comparator lists that are empty
3643
// this generally means that it was not a valid range, which is allowed
3744
// in loose mode, but will still throw if the WHOLE range is invalid.
3845
.filter(c => c.length)
3946

4047
if (!this.set.length) {
41-
throw new TypeError(`Invalid SemVer Range: ${range}`)
48+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
4249
}
4350

4451
// if we have any that are not the null set, throw out null sets.
@@ -64,9 +71,7 @@ class Range {
6471

6572
format () {
6673
this.range = this.set
67-
.map((comps) => {
68-
return comps.join(' ').trim()
69-
})
74+
.map((comps) => comps.join(' ').trim())
7075
.join('||')
7176
.trim()
7277
return this.range
@@ -77,8 +82,6 @@ class Range {
7782
}
7883

7984
parseRange (range) {
80-
range = range.trim()
81-
8285
// memoize range parsing for performance.
8386
// this is a very hot path, and fully deterministic.
8487
const memoOpts =
@@ -105,9 +108,6 @@ class Range {
105108
// `^ 1.2.3` => `^1.2.3`
106109
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
107110

108-
// normalize spaces
109-
range = range.split(/\s+/).join(' ')
110-
111111
// At this point, the range is completely trimmed and
112112
// ready to be split into comparators.
113113

@@ -203,7 +203,7 @@ const Comparator = require('./comparator')
203203
const debug = require('../internal/debug')
204204
const SemVer = require('./semver')
205205
const {
206-
re,
206+
safeRe: re,
207207
t,
208208
comparatorTrimReplace,
209209
tildeTrimReplace,
@@ -257,10 +257,13 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
257257
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
258258
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
259259
// ~0.0.1 --> >=0.0.1 <0.1.0-0
260-
const replaceTildes = (comp, options) =>
261-
comp.trim().split(/\s+/).map((c) => {
262-
return replaceTilde(c, options)
263-
}).join(' ')
260+
const replaceTildes = (comp, options) => {
261+
return comp
262+
.trim()
263+
.split(/\s+/)
264+
.map((c) => replaceTilde(c, options))
265+
.join(' ')
266+
}
264267

265268
const replaceTilde = (comp, options) => {
266269
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
@@ -298,10 +301,13 @@ const replaceTilde = (comp, options) => {
298301
// ^1.2.0 --> >=1.2.0 <2.0.0-0
299302
// ^0.0.1 --> >=0.0.1 <0.0.2-0
300303
// ^0.1.0 --> >=0.1.0 <0.2.0-0
301-
const replaceCarets = (comp, options) =>
302-
comp.trim().split(/\s+/).map((c) => {
303-
return replaceCaret(c, options)
304-
}).join(' ')
304+
const replaceCarets = (comp, options) => {
305+
return comp
306+
.trim()
307+
.split(/\s+/)
308+
.map((c) => replaceCaret(c, options))
309+
.join(' ')
310+
}
305311

306312
const replaceCaret = (comp, options) => {
307313
debug('caret', comp, options)
@@ -358,9 +364,10 @@ const replaceCaret = (comp, options) => {
358364

359365
const replaceXRanges = (comp, options) => {
360366
debug('replaceXRanges', comp, options)
361-
return comp.split(/\s+/).map((c) => {
362-
return replaceXRange(c, options)
363-
}).join(' ')
367+
return comp
368+
.split(/\s+/)
369+
.map((c) => replaceXRange(c, options))
370+
.join(' ')
364371
}
365372

366373
const replaceXRange = (comp, options) => {
@@ -443,12 +450,15 @@ const replaceXRange = (comp, options) => {
443450
const replaceStars = (comp, options) => {
444451
debug('replaceStars', comp, options)
445452
// Looseness is ignored here. star is always as loose as it gets!
446-
return comp.trim().replace(re[t.STAR], '')
453+
return comp
454+
.trim()
455+
.replace(re[t.STAR], '')
447456
}
448457

449458
const replaceGTE0 = (comp, options) => {
450459
debug('replaceGTE0', comp, options)
451-
return comp.trim()
460+
return comp
461+
.trim()
452462
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
453463
}
454464

@@ -486,7 +496,7 @@ const hyphenReplace = incPr => ($0,
486496
to = `<=${to}`
487497
}
488498

489-
return (`${from} ${to}`).trim()
499+
return `${from} ${to}`.trim()
490500
}
491501

492502
const testSet = (set, version, options) => {

‎node_modules/semver/classes/semver.js

+5-3
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 { re, t } = require('../internal/re')
3+
const { safeRe: re, t } = require('../internal/re')
44

55
const parseOptions = require('../internal/parse-options')
66
const { compareIdentifiers } = require('../internal/identifiers')
@@ -291,8 +291,10 @@ class SemVer {
291291
default:
292292
throw new Error(`invalid increment argument: ${release}`)
293293
}
294-
this.format()
295-
this.raw = this.version
294+
this.raw = this.format()
295+
if (this.build.length) {
296+
this.raw += `+${this.build.join('.')}`
297+
}
296298
return this
297299
}
298300
}

‎node_modules/semver/functions/coerce.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const SemVer = require('../classes/semver')
22
const parse = require('./parse')
3-
const { re, t } = require('../internal/re')
3+
const { safeRe: re, t } = require('../internal/re')
44

55
const coerce = (version, options) => {
66
if (version instanceof SemVer) {

‎node_modules/semver/functions/diff.js

+31-20
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ const diff = (version1, version2) => {
1313
const highVersion = v1Higher ? v1 : v2
1414
const lowVersion = v1Higher ? v2 : v1
1515
const highHasPre = !!highVersion.prerelease.length
16+
const lowHasPre = !!lowVersion.prerelease.length
17+
18+
if (lowHasPre && !highHasPre) {
19+
// Going from prerelease -> no prerelease requires some special casing
20+
21+
// If the low version has only a major, then it will always be a major
22+
// Some examples:
23+
// 1.0.0-1 -> 1.0.0
24+
// 1.0.0-1 -> 1.1.1
25+
// 1.0.0-1 -> 2.0.0
26+
if (!lowVersion.patch && !lowVersion.minor) {
27+
return 'major'
28+
}
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
34+
return 'patch'
35+
}
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+
}
1645

1746
// add the `pre` prefix if we are going to a prerelease version
1847
const prefix = highHasPre ? 'pre' : ''
@@ -29,26 +58,8 @@ const diff = (version1, version2) => {
2958
return prefix + 'patch'
3059
}
3160

32-
// at this point we know stable versions match but overall versions are not equal,
33-
// so either they are both prereleases, or the lower version is a prerelease
34-
35-
if (highHasPre) {
36-
// high and low are preleases
37-
return 'prerelease'
38-
}
39-
40-
if (lowVersion.patch) {
41-
// anything higher than a patch bump would result in the wrong version
42-
return 'patch'
43-
}
44-
45-
if (lowVersion.minor) {
46-
// anything higher than a minor bump would result in the wrong version
47-
return 'minor'
48-
}
49-
50-
// bumping major/minor/patch all have same result
51-
return 'major'
61+
// high and low are preleases
62+
return 'prerelease'
5263
}
5364

5465
module.exports = diff

‎node_modules/semver/internal/re.js

+11
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,27 @@ exports = module.exports = {}
44

55
// The actual regexps go on exports.re
66
const re = exports.re = []
7+
const safeRe = exports.safeRe = []
78
const src = exports.src = []
89
const t = exports.t = {}
910
let R = 0
1011

1112
const createToken = (name, value, isGlobal) => {
13+
// Replace all greedy whitespace to prevent regex dos issues. These regex are
14+
// used internally via the safeRe object since all inputs in this library get
15+
// normalized first to trim and collapse all extra whitespace. The original
16+
// regexes are exported for userland consumption and lower level usage. A
17+
// future breaking change could export the safer regex only with a note that
18+
// all input should have extra whitespace removed.
19+
const safe = value
20+
.split('\\s*').join('\\s{0,1}')
21+
.split('\\s+').join('\\s')
1222
const index = R++
1323
debug(name, index, value)
1424
t[name] = index
1525
src[index] = value
1626
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
27+
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
1728
}
1829

1930
// The following Regular Expressions can be used for tokenizing,

‎node_modules/semver/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "semver",
3-
"version": "7.5.1",
3+
"version": "7.5.2",
44
"description": "The semantic version parser used by npm.",
55
"main": "index.js",
66
"scripts": {
@@ -14,7 +14,7 @@
1414
},
1515
"devDependencies": {
1616
"@npmcli/eslint-config": "^4.0.0",
17-
"@npmcli/template-oss": "4.14.1",
17+
"@npmcli/template-oss": "4.15.1",
1818
"tap": "^16.0.0"
1919
},
2020
"license": "ISC",
@@ -37,7 +37,7 @@
3737
"range.bnf"
3838
],
3939
"tap": {
40-
"check-coverage": true,
40+
"timeout": 30,
4141
"coverage-map": "map.js",
4242
"nyc-arg": [
4343
"--exclude",
@@ -53,7 +53,7 @@
5353
"author": "GitHub Inc.",
5454
"templateOSS": {
5555
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
56-
"version": "4.14.1",
56+
"version": "4.15.1",
5757
"engines": ">=10",
5858
"ciVersions": [
5959
"10.0.0",

‎package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
"proc-log": "^3.0.0",
140140
"qrcode-terminal": "^0.12.0",
141141
"read": "^2.1.0",
142-
"semver": "^7.5.1",
142+
"semver": "^7.5.2",
143143
"sigstore": "^1.5.0",
144144
"ssri": "^10.0.4",
145145
"supports-color": "^9.3.1",
@@ -11366,9 +11366,9 @@
1136611366
}
1136711367
},
1136811368
"node_modules/semver": {
11369-
"version": "7.5.1",
11370-
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz",
11371-
"integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==",
11369+
"version": "7.5.2",
11370+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz",
11371+
"integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==",
1137211372
"inBundle": true,
1137311373
"dependencies": {
1137411374
"lru-cache": "^6.0.0"

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"proc-log": "^3.0.0",
107107
"qrcode-terminal": "^0.12.0",
108108
"read": "^2.1.0",
109-
"semver": "^7.5.1",
109+
"semver": "^7.5.2",
110110
"sigstore": "^1.5.0",
111111
"ssri": "^10.0.4",
112112
"supports-color": "^9.3.1",

0 commit comments

Comments
 (0)
Please sign in to comment.