Skip to content

Commit 1530d62

Browse files
Bump semver from 7.5.1 to 7.5.2 (#87)
* Bump semver from 7.5.1 to 7.5.2 Bumps [semver](https://github.com/npm/node-semver) from 7.5.1 to 7.5.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md) - [Commits](npm/node-semver@v7.5.1...v7.5.2) --- updated-dependencies: - dependency-name: semver dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * generate dist * update licenses --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alessio Perugini <[email protected]>
1 parent 0fbeb49 commit 1530d62

File tree

4 files changed

+93
-58
lines changed

4 files changed

+93
-58
lines changed

.licenses/npm/semver-7.5.1.dep.yml .licenses/npm/semver-7.5.2.dep.yml

+1-1
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
type: npm
55
summary: The semantic version parser used by npm.
66
homepage:

dist/index.js

+87-52
Original file line numberDiff line numberDiff line change
@@ -8604,6 +8604,7 @@ class Comparator {
86048604
}
86058605
}
86068606

8607+
comp = comp.trim().split(/\s+/).join(' ')
86078608
debug('comparator', comp, options)
86088609
this.options = options
86098610
this.loose = !!options.loose
@@ -8721,7 +8722,7 @@ class Comparator {
87218722
module.exports = Comparator
87228723

87238724
const parseOptions = __nccwpck_require__(785)
8724-
const { re, t } = __nccwpck_require__(9523)
8725+
const { safeRe: re, t } = __nccwpck_require__(9523)
87258726
const cmp = __nccwpck_require__(5098)
87268727
const debug = __nccwpck_require__(427)
87278728
const SemVer = __nccwpck_require__(8088)
@@ -8761,19 +8762,26 @@ class Range {
87618762
this.loose = !!options.loose
87628763
this.includePrerelease = !!options.includePrerelease
87638764

8764-
// First, split based on boolean or ||
8765+
// First reduce all whitespace as much as possible so we do not have to rely
8766+
// on potentially slow regexes like \s*. This is then stored and used for
8767+
// future error messages as well.
87658768
this.raw = range
8766-
this.set = range
8769+
.trim()
8770+
.split(/\s+/)
8771+
.join(' ')
8772+
8773+
// First, split on ||
8774+
this.set = this.raw
87678775
.split('||')
87688776
// map the range to a 2d array of comparators
8769-
.map(r => this.parseRange(r.trim()))
8777+
.map(r => this.parseRange(r))
87708778
// throw out any comparator lists that are empty
87718779
// this generally means that it was not a valid range, which is allowed
87728780
// in loose mode, but will still throw if the WHOLE range is invalid.
87738781
.filter(c => c.length)
87748782

87758783
if (!this.set.length) {
8776-
throw new TypeError(`Invalid SemVer Range: ${range}`)
8784+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
87778785
}
87788786

87798787
// if we have any that are not the null set, throw out null sets.
@@ -8799,9 +8807,7 @@ class Range {
87998807

88008808
format () {
88018809
this.range = this.set
8802-
.map((comps) => {
8803-
return comps.join(' ').trim()
8804-
})
8810+
.map((comps) => comps.join(' ').trim())
88058811
.join('||')
88068812
.trim()
88078813
return this.range
@@ -8812,8 +8818,6 @@ class Range {
88128818
}
88138819

88148820
parseRange (range) {
8815-
range = range.trim()
8816-
88178821
// memoize range parsing for performance.
88188822
// this is a very hot path, and fully deterministic.
88198823
const memoOpts =
@@ -8840,9 +8844,6 @@ class Range {
88408844
// `^ 1.2.3` => `^1.2.3`
88418845
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
88428846

8843-
// normalize spaces
8844-
range = range.split(/\s+/).join(' ')
8845-
88468847
// At this point, the range is completely trimmed and
88478848
// ready to be split into comparators.
88488849

@@ -8938,7 +8939,7 @@ const Comparator = __nccwpck_require__(1532)
89388939
const debug = __nccwpck_require__(427)
89398940
const SemVer = __nccwpck_require__(8088)
89408941
const {
8941-
re,
8942+
safeRe: re,
89428943
t,
89438944
comparatorTrimReplace,
89448945
tildeTrimReplace,
@@ -8992,10 +8993,13 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
89928993
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
89938994
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
89948995
// ~0.0.1 --> >=0.0.1 <0.1.0-0
8995-
const replaceTildes = (comp, options) =>
8996-
comp.trim().split(/\s+/).map((c) => {
8997-
return replaceTilde(c, options)
8998-
}).join(' ')
8996+
const replaceTildes = (comp, options) => {
8997+
return comp
8998+
.trim()
8999+
.split(/\s+/)
9000+
.map((c) => replaceTilde(c, options))
9001+
.join(' ')
9002+
}
89999003

90009004
const replaceTilde = (comp, options) => {
90019005
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
@@ -9033,10 +9037,13 @@ const replaceTilde = (comp, options) => {
90339037
// ^1.2.0 --> >=1.2.0 <2.0.0-0
90349038
// ^0.0.1 --> >=0.0.1 <0.0.2-0
90359039
// ^0.1.0 --> >=0.1.0 <0.2.0-0
9036-
const replaceCarets = (comp, options) =>
9037-
comp.trim().split(/\s+/).map((c) => {
9038-
return replaceCaret(c, options)
9039-
}).join(' ')
9040+
const replaceCarets = (comp, options) => {
9041+
return comp
9042+
.trim()
9043+
.split(/\s+/)
9044+
.map((c) => replaceCaret(c, options))
9045+
.join(' ')
9046+
}
90409047

90419048
const replaceCaret = (comp, options) => {
90429049
debug('caret', comp, options)
@@ -9093,9 +9100,10 @@ const replaceCaret = (comp, options) => {
90939100

90949101
const replaceXRanges = (comp, options) => {
90959102
debug('replaceXRanges', comp, options)
9096-
return comp.split(/\s+/).map((c) => {
9097-
return replaceXRange(c, options)
9098-
}).join(' ')
9103+
return comp
9104+
.split(/\s+/)
9105+
.map((c) => replaceXRange(c, options))
9106+
.join(' ')
90999107
}
91009108

91019109
const replaceXRange = (comp, options) => {
@@ -9178,12 +9186,15 @@ const replaceXRange = (comp, options) => {
91789186
const replaceStars = (comp, options) => {
91799187
debug('replaceStars', comp, options)
91809188
// Looseness is ignored here. star is always as loose as it gets!
9181-
return comp.trim().replace(re[t.STAR], '')
9189+
return comp
9190+
.trim()
9191+
.replace(re[t.STAR], '')
91829192
}
91839193

91849194
const replaceGTE0 = (comp, options) => {
91859195
debug('replaceGTE0', comp, options)
9186-
return comp.trim()
9196+
return comp
9197+
.trim()
91879198
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
91889199
}
91899200

@@ -9221,7 +9232,7 @@ const hyphenReplace = incPr => ($0,
92219232
to = `<=${to}`
92229233
}
92239234

9224-
return (`${from} ${to}`).trim()
9235+
return `${from} ${to}`.trim()
92259236
}
92269237

92279238
const testSet = (set, version, options) => {
@@ -9268,7 +9279,7 @@ const testSet = (set, version, options) => {
92689279

92699280
const debug = __nccwpck_require__(427)
92709281
const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(2293)
9271-
const { re, t } = __nccwpck_require__(9523)
9282+
const { safeRe: re, t } = __nccwpck_require__(9523)
92729283

92739284
const parseOptions = __nccwpck_require__(785)
92749285
const { compareIdentifiers } = __nccwpck_require__(2463)
@@ -9559,8 +9570,10 @@ class SemVer {
95599570
default:
95609571
throw new Error(`invalid increment argument: ${release}`)
95619572
}
9562-
this.format()
9563-
this.raw = this.version
9573+
this.raw = this.format()
9574+
if (this.build.length) {
9575+
this.raw += `+${this.build.join('.')}`
9576+
}
95649577
return this
95659578
}
95669579
}
@@ -9647,7 +9660,7 @@ module.exports = cmp
96479660

96489661
const SemVer = __nccwpck_require__(8088)
96499662
const parse = __nccwpck_require__(5925)
9650-
const { re, t } = __nccwpck_require__(9523)
9663+
const { safeRe: re, t } = __nccwpck_require__(9523)
96519664

96529665
const coerce = (version, options) => {
96539666
if (version instanceof SemVer) {
@@ -9755,6 +9768,35 @@ const diff = (version1, version2) => {
97559768
const highVersion = v1Higher ? v1 : v2
97569769
const lowVersion = v1Higher ? v2 : v1
97579770
const highHasPre = !!highVersion.prerelease.length
9771+
const lowHasPre = !!lowVersion.prerelease.length
9772+
9773+
if (lowHasPre && !highHasPre) {
9774+
// Going from prerelease -> no prerelease requires some special casing
9775+
9776+
// If the low version has only a major, then it will always be a major
9777+
// Some examples:
9778+
// 1.0.0-1 -> 1.0.0
9779+
// 1.0.0-1 -> 1.1.1
9780+
// 1.0.0-1 -> 2.0.0
9781+
if (!lowVersion.patch && !lowVersion.minor) {
9782+
return 'major'
9783+
}
9784+
9785+
// Otherwise it can be determined by checking the high version
9786+
9787+
if (highVersion.patch) {
9788+
// anything higher than a patch bump would result in the wrong version
9789+
return 'patch'
9790+
}
9791+
9792+
if (highVersion.minor) {
9793+
// anything higher than a minor bump would result in the wrong version
9794+
return 'minor'
9795+
}
9796+
9797+
// bumping major/minor/patch all have same result
9798+
return 'major'
9799+
}
97589800

97599801
// add the `pre` prefix if we are going to a prerelease version
97609802
const prefix = highHasPre ? 'pre' : ''
@@ -9771,26 +9813,8 @@ const diff = (version1, version2) => {
97719813
return prefix + 'patch'
97729814
}
97739815

9774-
// at this point we know stable versions match but overall versions are not equal,
9775-
// so either they are both prereleases, or the lower version is a prerelease
9776-
9777-
if (highHasPre) {
9778-
// high and low are preleases
9779-
return 'prerelease'
9780-
}
9781-
9782-
if (lowVersion.patch) {
9783-
// anything higher than a patch bump would result in the wrong version
9784-
return 'patch'
9785-
}
9786-
9787-
if (lowVersion.minor) {
9788-
// anything higher than a minor bump would result in the wrong version
9789-
return 'minor'
9790-
}
9791-
9792-
// bumping major/minor/patch all have same result
9793-
return 'major'
9816+
// high and low are preleases
9817+
return 'prerelease'
97949818
}
97959819

97969820
module.exports = diff
@@ -10220,16 +10244,27 @@ exports = module.exports = {}
1022010244

1022110245
// The actual regexps go on exports.re
1022210246
const re = exports.re = []
10247+
const safeRe = exports.safeRe = []
1022310248
const src = exports.src = []
1022410249
const t = exports.t = {}
1022510250
let R = 0
1022610251

1022710252
const createToken = (name, value, isGlobal) => {
10253+
// Replace all greedy whitespace to prevent regex dos issues. These regex are
10254+
// used internally via the safeRe object since all inputs in this library get
10255+
// normalized first to trim and collapse all extra whitespace. The original
10256+
// regexes are exported for userland consumption and lower level usage. A
10257+
// future breaking change could export the safer regex only with a note that
10258+
// all input should have extra whitespace removed.
10259+
const safe = value
10260+
.split('\\s*').join('\\s{0,1}')
10261+
.split('\\s+').join('\\s')
1022810262
const index = R++
1022910263
debug(name, index, value)
1023010264
t[name] = index
1023110265
src[index] = value
1023210266
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
10267+
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
1023310268
}
1023410269

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

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@actions/exec": "^1.1.1",
2727
"@actions/tool-cache": "^1.7.2",
2828
"@actions/io": "^1.1.3",
29-
"semver": "^7.5.1",
29+
"semver": "^7.5.2",
3030
"typed-rest-client": "^1.8.9"
3131
},
3232
"devDependencies": {

0 commit comments

Comments
 (0)