Compare commits

...

3 Commits

Author SHA1 Message Date
Angela P Wen
004c5de30b Merge pull request #1746 from github/update-v2.20.2-7dfbc0e0d
Merge main into releases/v2
2023-07-03 03:58:33 -07:00
github-actions[bot]
cb0b0a398e Update changelog for v2.20.2 2023-07-03 10:12:32 +00:00
dependabot[bot]
7dfbc0e0db Bump semver from 7.3.8 to 7.5.2 (#1745)
* Bump semver from 7.3.8 to 7.5.2

Bumps [semver](https://github.com/npm/node-semver) from 7.3.8 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](https://github.com/npm/node-semver/compare/v7.3.8...v7.5.2)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update checked-in dependencies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-03 07:45:09 +00:00
20 changed files with 329 additions and 155 deletions

View File

@@ -1,6 +1,6 @@
# CodeQL Action Changelog # CodeQL Action Changelog
## [UNRELEASED] ## 2.20.2 - 03 Jul 2023
No user facing changes. No user facing changes.

6
node_modules/.package-lock.json generated vendored
View File

@@ -5221,9 +5221,9 @@
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.3.8", "version": "7.5.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==",
"dependencies": { "dependencies": {
"lru-cache": "^6.0.0" "lru-cache": "^6.0.0"
}, },

67
node_modules/semver/README.md generated vendored
View File

@@ -110,6 +110,9 @@ Options:
-l --loose -l --loose
Interpret versions and ranges loosely Interpret versions and ranges loosely
-n <0|1>
This is the base to be used for the prerelease identifier.
-p --include-prerelease -p --include-prerelease
Always include prerelease versions in range matching Always include prerelease versions in range matching
@@ -232,6 +235,35 @@ $ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1 1.2.4-beta.1
``` ```
#### Prerelease Identifier Base
The method `.inc` takes an optional parameter 'identifierBase' string
that will let you let your prerelease number as zero-based or one-based.
Set to `false` to omit the prerelease number altogether.
If you do not specify this parameter, it will default to zero-based.
```javascript
semver.inc('1.2.3', 'prerelease', 'beta', '1')
// '1.2.4-beta.1'
```
```javascript
semver.inc('1.2.3', 'prerelease', 'beta', false)
// '1.2.4-beta'
```
command-line example:
```bash
$ semver 1.2.3 -i prerelease --preid beta -n 1
1.2.4-beta.1
```
```bash
$ semver 1.2.3 -i prerelease --preid beta -n false
1.2.4-beta
```
### Advanced Range Syntax ### Advanced Range Syntax
Advanced range syntax desugars to primitive comparators in Advanced range syntax desugars to primitive comparators in
@@ -513,6 +545,40 @@ ex.
* `s.clean(' 2.1.5 ')`: `'2.1.5'` * `s.clean(' 2.1.5 ')`: `'2.1.5'`
* `s.clean('~1.0.0')`: `null` * `s.clean('~1.0.0')`: `null`
## Constants
As a convenience, helper constants are exported to provide information about what `node-semver` supports:
### `RELEASE_TYPES`
- major
- premajor
- minor
- preminor
- patch
- prepatch
- prerelease
```
const semver = require('semver');
if (semver.RELEASE_TYPES.includes(arbitraryUserInput)) {
console.log('This is a valid release type!');
} else {
console.warn('This is NOT a valid release type!');
}
```
### `SEMVER_SPEC_VERSION`
2.0.0
```
const semver = require('semver');
console.log('We are currently using the semver specification version:', semver.SEMVER_SPEC_VERSION);
```
## Exported Modules ## Exported Modules
<!-- <!--
@@ -566,3 +632,4 @@ The following modules are available:
* `require('semver/ranges/outside')` * `require('semver/ranges/outside')`
* `require('semver/ranges/to-comparators')` * `require('semver/ranges/to-comparators')`
* `require('semver/ranges/valid')` * `require('semver/ranges/valid')`

18
node_modules/semver/bin/semver.js generated vendored
View File

@@ -23,7 +23,10 @@ let rtl = false
let identifier let identifier
let identifierBase
const semver = require('../') const semver = require('../')
const parseOptions = require('../internal/parse-options')
let reverse = false let reverse = false
@@ -71,6 +74,12 @@ const main = () => {
case '-r': case '--range': case '-r': case '--range':
range.push(argv.shift()) range.push(argv.shift())
break break
case '-n':
identifierBase = argv.shift()
if (identifierBase === 'false') {
identifierBase = false
}
break
case '-c': case '--coerce': case '-c': case '--coerce':
coerce = true coerce = true
break break
@@ -88,7 +97,7 @@ const main = () => {
} }
} }
options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl } options = parseOptions({ loose, includePrerelease, rtl })
versions = versions.map((v) => { versions = versions.map((v) => {
return coerce ? (semver.coerce(v, options) || { version: v }).version : v return coerce ? (semver.coerce(v, options) || { version: v }).version : v
@@ -127,7 +136,7 @@ const success = () => {
}).map((v) => { }).map((v) => {
return semver.clean(v, options) return semver.clean(v, options)
}).map((v) => { }).map((v) => {
return inc ? semver.inc(v, inc, options, identifier) : v return inc ? semver.inc(v, inc, options, identifier, identifierBase) : v
}).forEach((v, i, _) => { }).forEach((v, i, _) => {
console.log(v) console.log(v)
}) })
@@ -172,6 +181,11 @@ Options:
--ltr --ltr
Coerce version strings left to right (default) Coerce version strings left to right (default)
-n <base>
Base number to be used for the prerelease identifier.
Can be either 0 or 1, or false to omit the number altogether.
Defaults to 0.
Program exits successfully if any valid version satisfies Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions. all supplied ranges, and prints all satisfying versions.

View File

@@ -16,6 +16,7 @@ class Comparator {
} }
} }
comp = comp.trim().split(/\s+/).join(' ')
debug('comparator', comp, options) debug('comparator', comp, options)
this.options = options this.options = options
this.loose = !!options.loose this.loose = !!options.loose
@@ -78,13 +79,6 @@ class Comparator {
throw new TypeError('a Comparator is required') throw new TypeError('a Comparator is required')
} }
if (!options || typeof options !== 'object') {
options = {
loose: !!options,
includePrerelease: false,
}
}
if (this.operator === '') { if (this.operator === '') {
if (this.value === '') { if (this.value === '') {
return true return true
@@ -97,39 +91,50 @@ class Comparator {
return new Range(this.value, options).test(comp.semver) return new Range(this.value, options).test(comp.semver)
} }
const sameDirectionIncreasing = options = parseOptions(options)
(this.operator === '>=' || this.operator === '>') &&
(comp.operator === '>=' || comp.operator === '>')
const sameDirectionDecreasing =
(this.operator === '<=' || this.operator === '<') &&
(comp.operator === '<=' || comp.operator === '<')
const sameSemVer = this.semver.version === comp.semver.version
const differentDirectionsInclusive =
(this.operator === '>=' || this.operator === '<=') &&
(comp.operator === '>=' || comp.operator === '<=')
const oppositeDirectionsLessThan =
cmp(this.semver, '<', comp.semver, options) &&
(this.operator === '>=' || this.operator === '>') &&
(comp.operator === '<=' || comp.operator === '<')
const oppositeDirectionsGreaterThan =
cmp(this.semver, '>', comp.semver, options) &&
(this.operator === '<=' || this.operator === '<') &&
(comp.operator === '>=' || comp.operator === '>')
return ( // Special cases where nothing can possibly be lower
sameDirectionIncreasing || if (options.includePrerelease &&
sameDirectionDecreasing || (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
(sameSemVer && differentDirectionsInclusive) || return false
oppositeDirectionsLessThan || }
oppositeDirectionsGreaterThan if (!options.includePrerelease &&
) (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
return false
}
// Same direction increasing (> or >=)
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
return true
}
// Same direction decreasing (< or <=)
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
return true
}
// same SemVer and both sides are inclusive (<= or >=)
if (
(this.semver.version === comp.semver.version) &&
this.operator.includes('=') && comp.operator.includes('=')) {
return true
}
// opposite directions less than
if (cmp(this.semver, '<', comp.semver, options) &&
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
return true
}
// opposite directions greater than
if (cmp(this.semver, '>', comp.semver, options) &&
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
return true
}
return false
} }
} }
module.exports = Comparator module.exports = Comparator
const parseOptions = require('../internal/parse-options') const parseOptions = require('../internal/parse-options')
const { re, t } = require('../internal/re') const { safeRe: re, t } = require('../internal/re')
const cmp = require('../functions/cmp') const cmp = require('../functions/cmp')
const debug = require('../internal/debug') const debug = require('../internal/debug')
const SemVer = require('./semver') const SemVer = require('./semver')

72
node_modules/semver/classes/range.js generated vendored
View File

@@ -26,19 +26,26 @@ class Range {
this.loose = !!options.loose this.loose = !!options.loose
this.includePrerelease = !!options.includePrerelease this.includePrerelease = !!options.includePrerelease
// First, split based on boolean or || // First reduce all whitespace as much as possible so we do not have to rely
// on potentially slow regexes like \s*. This is then stored and used for
// future error messages as well.
this.raw = range this.raw = range
this.set = range .trim()
.split(/\s+/)
.join(' ')
// First, split on ||
this.set = this.raw
.split('||') .split('||')
// map the range to a 2d array of comparators // map the range to a 2d array of comparators
.map(r => this.parseRange(r.trim())) .map(r => this.parseRange(r))
// throw out any comparator lists that are empty // throw out any comparator lists that are empty
// this generally means that it was not a valid range, which is allowed // this generally means that it was not a valid range, which is allowed
// in loose mode, but will still throw if the WHOLE range is invalid. // in loose mode, but will still throw if the WHOLE range is invalid.
.filter(c => c.length) .filter(c => c.length)
if (!this.set.length) { if (!this.set.length) {
throw new TypeError(`Invalid SemVer Range: ${range}`) throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
} }
// if we have any that are not the null set, throw out null sets. // if we have any that are not the null set, throw out null sets.
@@ -64,9 +71,7 @@ class Range {
format () { format () {
this.range = this.set this.range = this.set
.map((comps) => { .map((comps) => comps.join(' ').trim())
return comps.join(' ').trim()
})
.join('||') .join('||')
.trim() .trim()
return this.range return this.range
@@ -77,12 +82,12 @@ class Range {
} }
parseRange (range) { parseRange (range) {
range = range.trim()
// memoize range parsing for performance. // memoize range parsing for performance.
// this is a very hot path, and fully deterministic. // this is a very hot path, and fully deterministic.
const memoOpts = Object.keys(this.options).join(',') const memoOpts =
const memoKey = `parseRange:${memoOpts}:${range}` (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
(this.options.loose && FLAG_LOOSE)
const memoKey = memoOpts + ':' + range
const cached = cache.get(memoKey) const cached = cache.get(memoKey)
if (cached) { if (cached) {
return cached return cached
@@ -103,9 +108,6 @@ class Range {
// `^ 1.2.3` => `^1.2.3` // `^ 1.2.3` => `^1.2.3`
range = range.replace(re[t.CARETTRIM], caretTrimReplace) range = range.replace(re[t.CARETTRIM], caretTrimReplace)
// normalize spaces
range = range.split(/\s+/).join(' ')
// At this point, the range is completely trimmed and // At this point, the range is completely trimmed and
// ready to be split into comparators. // ready to be split into comparators.
@@ -190,6 +192,7 @@ class Range {
return false return false
} }
} }
module.exports = Range module.exports = Range
const LRU = require('lru-cache') const LRU = require('lru-cache')
@@ -200,12 +203,13 @@ const Comparator = require('./comparator')
const debug = require('../internal/debug') const debug = require('../internal/debug')
const SemVer = require('./semver') const SemVer = require('./semver')
const { const {
re, safeRe: re,
t, t,
comparatorTrimReplace, comparatorTrimReplace,
tildeTrimReplace, tildeTrimReplace,
caretTrimReplace, caretTrimReplace,
} = require('../internal/re') } = require('../internal/re')
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
const isNullSet = c => c.value === '<0.0.0-0' const isNullSet = c => c.value === '<0.0.0-0'
const isAny = c => c.value === '' const isAny = c => c.value === ''
@@ -253,10 +257,13 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
// ~0.0.1 --> >=0.0.1 <0.1.0-0 // ~0.0.1 --> >=0.0.1 <0.1.0-0
const replaceTildes = (comp, options) => const replaceTildes = (comp, options) => {
comp.trim().split(/\s+/).map((c) => { return comp
return replaceTilde(c, options) .trim()
}).join(' ') .split(/\s+/)
.map((c) => replaceTilde(c, options))
.join(' ')
}
const replaceTilde = (comp, options) => { const replaceTilde = (comp, options) => {
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
@@ -294,10 +301,13 @@ const replaceTilde = (comp, options) => {
// ^1.2.0 --> >=1.2.0 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0
// ^0.0.1 --> >=0.0.1 <0.0.2-0 // ^0.0.1 --> >=0.0.1 <0.0.2-0
// ^0.1.0 --> >=0.1.0 <0.2.0-0 // ^0.1.0 --> >=0.1.0 <0.2.0-0
const replaceCarets = (comp, options) => const replaceCarets = (comp, options) => {
comp.trim().split(/\s+/).map((c) => { return comp
return replaceCaret(c, options) .trim()
}).join(' ') .split(/\s+/)
.map((c) => replaceCaret(c, options))
.join(' ')
}
const replaceCaret = (comp, options) => { const replaceCaret = (comp, options) => {
debug('caret', comp, options) debug('caret', comp, options)
@@ -354,9 +364,10 @@ const replaceCaret = (comp, options) => {
const replaceXRanges = (comp, options) => { const replaceXRanges = (comp, options) => {
debug('replaceXRanges', comp, options) debug('replaceXRanges', comp, options)
return comp.split(/\s+/).map((c) => { return comp
return replaceXRange(c, options) .split(/\s+/)
}).join(' ') .map((c) => replaceXRange(c, options))
.join(' ')
} }
const replaceXRange = (comp, options) => { const replaceXRange = (comp, options) => {
@@ -439,12 +450,15 @@ const replaceXRange = (comp, options) => {
const replaceStars = (comp, options) => { const replaceStars = (comp, options) => {
debug('replaceStars', comp, options) debug('replaceStars', comp, options)
// Looseness is ignored here. star is always as loose as it gets! // Looseness is ignored here. star is always as loose as it gets!
return comp.trim().replace(re[t.STAR], '') return comp
.trim()
.replace(re[t.STAR], '')
} }
const replaceGTE0 = (comp, options) => { const replaceGTE0 = (comp, options) => {
debug('replaceGTE0', comp, options) debug('replaceGTE0', comp, options)
return comp.trim() return comp
.trim()
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
} }
@@ -482,7 +496,7 @@ const hyphenReplace = incPr => ($0,
to = `<=${to}` to = `<=${to}`
} }
return (`${from} ${to}`).trim() return `${from} ${to}`.trim()
} }
const testSet = (set, version, options) => { const testSet = (set, version, options) => {

View File

@@ -1,6 +1,6 @@
const debug = require('../internal/debug') const debug = require('../internal/debug')
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants') const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
const { re, t } = require('../internal/re') const { safeRe: re, t } = require('../internal/re')
const parseOptions = require('../internal/parse-options') const parseOptions = require('../internal/parse-options')
const { compareIdentifiers } = require('../internal/identifiers') const { compareIdentifiers } = require('../internal/identifiers')
@@ -16,7 +16,7 @@ class SemVer {
version = version.version version = version.version
} }
} else if (typeof version !== 'string') { } else if (typeof version !== 'string') {
throw new TypeError(`Invalid Version: ${version}`) throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
} }
if (version.length > MAX_LENGTH) { if (version.length > MAX_LENGTH) {
@@ -175,36 +175,36 @@ class SemVer {
// preminor will bump the version up to the next minor release, and immediately // preminor will bump the version up to the next minor release, and immediately
// down to pre-release. premajor and prepatch work the same way. // down to pre-release. premajor and prepatch work the same way.
inc (release, identifier) { inc (release, identifier, identifierBase) {
switch (release) { switch (release) {
case 'premajor': case 'premajor':
this.prerelease.length = 0 this.prerelease.length = 0
this.patch = 0 this.patch = 0
this.minor = 0 this.minor = 0
this.major++ this.major++
this.inc('pre', identifier) this.inc('pre', identifier, identifierBase)
break break
case 'preminor': case 'preminor':
this.prerelease.length = 0 this.prerelease.length = 0
this.patch = 0 this.patch = 0
this.minor++ this.minor++
this.inc('pre', identifier) this.inc('pre', identifier, identifierBase)
break break
case 'prepatch': case 'prepatch':
// If this is already a prerelease, it will bump to the next version // If this is already a prerelease, it will bump to the next version
// drop any prereleases that might already exist, since they are not // drop any prereleases that might already exist, since they are not
// relevant at this point. // relevant at this point.
this.prerelease.length = 0 this.prerelease.length = 0
this.inc('patch', identifier) this.inc('patch', identifier, identifierBase)
this.inc('pre', identifier) this.inc('pre', identifier, identifierBase)
break break
// If the input is a non-prerelease version, this acts the same as // If the input is a non-prerelease version, this acts the same as
// prepatch. // prepatch.
case 'prerelease': case 'prerelease':
if (this.prerelease.length === 0) { if (this.prerelease.length === 0) {
this.inc('patch', identifier) this.inc('patch', identifier, identifierBase)
} }
this.inc('pre', identifier) this.inc('pre', identifier, identifierBase)
break break
case 'major': case 'major':
@@ -246,9 +246,15 @@ class SemVer {
break break
// This probably shouldn't be used publicly. // This probably shouldn't be used publicly.
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
case 'pre': case 'pre': {
const base = Number(identifierBase) ? 1 : 0
if (!identifier && identifierBase === false) {
throw new Error('invalid increment argument: identifier is empty')
}
if (this.prerelease.length === 0) { if (this.prerelease.length === 0) {
this.prerelease = [0] this.prerelease = [base]
} else { } else {
let i = this.prerelease.length let i = this.prerelease.length
while (--i >= 0) { while (--i >= 0) {
@@ -259,27 +265,36 @@ class SemVer {
} }
if (i === -1) { if (i === -1) {
// didn't increment anything // didn't increment anything
this.prerelease.push(0) if (identifier === this.prerelease.join('.') && identifierBase === false) {
throw new Error('invalid increment argument: identifier already exists')
}
this.prerelease.push(base)
} }
} }
if (identifier) { if (identifier) {
// 1.2.0-beta.1 bumps to 1.2.0-beta.2, // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
let prerelease = [identifier, base]
if (identifierBase === false) {
prerelease = [identifier]
}
if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
if (isNaN(this.prerelease[1])) { if (isNaN(this.prerelease[1])) {
this.prerelease = [identifier, 0] this.prerelease = prerelease
} }
} else { } else {
this.prerelease = [identifier, 0] this.prerelease = prerelease
} }
} }
break break
}
default: default:
throw new Error(`invalid increment argument: ${release}`) throw new Error(`invalid increment argument: ${release}`)
} }
this.format() this.raw = this.format()
this.raw = this.version if (this.build.length) {
this.raw += `+${this.build.join('.')}`
}
return this return this
} }
} }

View File

@@ -1,6 +1,6 @@
const SemVer = require('../classes/semver') const SemVer = require('../classes/semver')
const parse = require('./parse') const parse = require('./parse')
const { re, t } = require('../internal/re') const { safeRe: re, t } = require('../internal/re')
const coerce = (version, options) => { const coerce = (version, options) => {
if (version instanceof SemVer) { if (version instanceof SemVer) {

View File

@@ -1,23 +1,65 @@
const parse = require('./parse') const parse = require('./parse.js')
const eq = require('./eq')
const diff = (version1, version2) => { const diff = (version1, version2) => {
if (eq(version1, version2)) { const v1 = parse(version1, null, true)
const v2 = parse(version2, null, true)
const comparison = v1.compare(v2)
if (comparison === 0) {
return null return null
} else {
const v1 = parse(version1)
const v2 = parse(version2)
const hasPre = v1.prerelease.length || v2.prerelease.length
const prefix = hasPre ? 'pre' : ''
const defaultResult = hasPre ? 'prerelease' : ''
for (const key in v1) {
if (key === 'major' || key === 'minor' || key === 'patch') {
if (v1[key] !== v2[key]) {
return prefix + key
} }
const v1Higher = comparison > 0
const highVersion = v1Higher ? v1 : v2
const lowVersion = v1Higher ? v2 : v1
const highHasPre = !!highVersion.prerelease.length
const lowHasPre = !!lowVersion.prerelease.length
if (lowHasPre && !highHasPre) {
// Going from prerelease -> no prerelease requires some special casing
// If the low version has only a major, then it will always be a major
// Some examples:
// 1.0.0-1 -> 1.0.0
// 1.0.0-1 -> 1.1.1
// 1.0.0-1 -> 2.0.0
if (!lowVersion.patch && !lowVersion.minor) {
return 'major'
} }
// Otherwise it can be determined by checking the high version
if (highVersion.patch) {
// anything higher than a patch bump would result in the wrong version
return 'patch'
} }
return defaultResult // may be undefined
if (highVersion.minor) {
// anything higher than a minor bump would result in the wrong version
return 'minor'
} }
// bumping major/minor/patch all have same result
return 'major'
}
// add the `pre` prefix if we are going to a prerelease version
const prefix = highHasPre ? 'pre' : ''
if (v1.major !== v2.major) {
return prefix + 'major'
}
if (v1.minor !== v2.minor) {
return prefix + 'minor'
}
if (v1.patch !== v2.patch) {
return prefix + 'patch'
}
// high and low are preleases
return 'prerelease'
} }
module.exports = diff module.exports = diff

View File

@@ -1,7 +1,8 @@
const SemVer = require('../classes/semver') const SemVer = require('../classes/semver')
const inc = (version, release, options, identifier) => { const inc = (version, release, options, identifier, identifierBase) => {
if (typeof (options) === 'string') { if (typeof (options) === 'string') {
identifierBase = identifier
identifier = options identifier = options
options = undefined options = undefined
} }
@@ -10,7 +11,7 @@ const inc = (version, release, options, identifier) => {
return new SemVer( return new SemVer(
version instanceof SemVer ? version.version : version, version instanceof SemVer ? version.version : version,
options options
).inc(release, identifier).version ).inc(release, identifier, identifierBase).version
} catch (er) { } catch (er) {
return null return null
} }

View File

@@ -1,33 +1,16 @@
const { MAX_LENGTH } = require('../internal/constants')
const { re, t } = require('../internal/re')
const SemVer = require('../classes/semver') const SemVer = require('../classes/semver')
const parse = (version, options, throwErrors = false) => {
const parseOptions = require('../internal/parse-options')
const parse = (version, options) => {
options = parseOptions(options)
if (version instanceof SemVer) { if (version instanceof SemVer) {
return version return version
} }
if (typeof version !== 'string') {
return null
}
if (version.length > MAX_LENGTH) {
return null
}
const r = options.loose ? re[t.LOOSE] : re[t.FULL]
if (!r.test(version)) {
return null
}
try { try {
return new SemVer(version, options) return new SemVer(version, options)
} catch (er) { } catch (er) {
if (!throwErrors) {
return null return null
} }
throw er
}
} }
module.exports = parse module.exports = parse

1
node_modules/semver/index.js generated vendored
View File

@@ -83,6 +83,7 @@ module.exports = {
src: internalRe.src, src: internalRe.src,
tokens: internalRe.t, tokens: internalRe.t,
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
RELEASE_TYPES: constants.RELEASE_TYPES,
compareIdentifiers: identifiers.compareIdentifiers, compareIdentifiers: identifiers.compareIdentifiers,
rcompareIdentifiers: identifiers.rcompareIdentifiers, rcompareIdentifiers: identifiers.rcompareIdentifiers,
} }

View File

@@ -9,9 +9,22 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
// Max safe segment length for coercion. // Max safe segment length for coercion.
const MAX_SAFE_COMPONENT_LENGTH = 16 const MAX_SAFE_COMPONENT_LENGTH = 16
const RELEASE_TYPES = [
'major',
'premajor',
'minor',
'preminor',
'patch',
'prepatch',
'prerelease',
]
module.exports = { module.exports = {
SEMVER_SPEC_VERSION,
MAX_LENGTH, MAX_LENGTH,
MAX_SAFE_INTEGER,
MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_COMPONENT_LENGTH,
MAX_SAFE_INTEGER,
RELEASE_TYPES,
SEMVER_SPEC_VERSION,
FLAG_INCLUDE_PRERELEASE: 0b001,
FLAG_LOOSE: 0b010,
} }

View File

@@ -1,11 +1,15 @@
// parse out just the options we care about so we always get a consistent // parse out just the options we care about
// obj with keys in a consistent order. const looseOption = Object.freeze({ loose: true })
const opts = ['includePrerelease', 'loose', 'rtl'] const emptyOpts = Object.freeze({ })
const parseOptions = options => const parseOptions = options => {
!options ? {} if (!options) {
: typeof options !== 'object' ? { loose: true } return emptyOpts
: opts.filter(k => options[k]).reduce((o, k) => { }
o[k] = true
return o if (typeof options !== 'object') {
}, {}) return looseOption
}
return options
}
module.exports = parseOptions module.exports = parseOptions

11
node_modules/semver/internal/re.js generated vendored
View File

@@ -4,16 +4,27 @@ exports = module.exports = {}
// The actual regexps go on exports.re // The actual regexps go on exports.re
const re = exports.re = [] const re = exports.re = []
const safeRe = exports.safeRe = []
const src = exports.src = [] const src = exports.src = []
const t = exports.t = {} const t = exports.t = {}
let R = 0 let R = 0
const createToken = (name, value, isGlobal) => { const createToken = (name, value, isGlobal) => {
// Replace all greedy whitespace to prevent regex dos issues. These regex are
// used internally via the safeRe object since all inputs in this library get
// normalized first to trim and collapse all extra whitespace. The original
// regexes are exported for userland consumption and lower level usage. A
// future breaking change could export the safer regex only with a note that
// all input should have extra whitespace removed.
const safe = value
.split('\\s*').join('\\s{0,1}')
.split('\\s+').join('\\s')
const index = R++ const index = R++
debug(name, index, value) debug(name, index, value)
t[name] = index t[name] = index
src[index] = value src[index] = value
re[index] = new RegExp(value, isGlobal ? 'g' : undefined) re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
} }
// The following Regular Expressions can be used for tokenizing, // The following Regular Expressions can be used for tokenizing,

15
node_modules/semver/package.json generated vendored
View File

@@ -1,6 +1,6 @@
{ {
"name": "semver", "name": "semver",
"version": "7.3.8", "version": "7.5.2",
"description": "The semantic version parser used by npm.", "description": "The semantic version parser used by npm.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@@ -13,8 +13,8 @@
"template-oss-apply": "template-oss-apply --force" "template-oss-apply": "template-oss-apply --force"
}, },
"devDependencies": { "devDependencies": {
"@npmcli/eslint-config": "^3.0.1", "@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.4.4", "@npmcli/template-oss": "4.15.1",
"tap": "^16.0.0" "tap": "^16.0.0"
}, },
"license": "ISC", "license": "ISC",
@@ -37,7 +37,7 @@
"range.bnf" "range.bnf"
], ],
"tap": { "tap": {
"check-coverage": true, "timeout": 30,
"coverage-map": "map.js", "coverage-map": "map.js",
"nyc-arg": [ "nyc-arg": [
"--exclude", "--exclude",
@@ -53,9 +53,8 @@
"author": "GitHub Inc.", "author": "GitHub Inc.",
"templateOSS": { "templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.4.4", "version": "4.15.1",
"engines": ">=10", "engines": ">=10",
"content": "./scripts",
"ciVersions": [ "ciVersions": [
"10.0.0", "10.0.0",
"10.x", "10.x",
@@ -64,6 +63,7 @@
"16.x", "16.x",
"18.x" "18.x"
], ],
"npmSpec": "8",
"distPaths": [ "distPaths": [
"classes/", "classes/",
"functions/", "functions/",
@@ -81,6 +81,7 @@
"/index.js", "/index.js",
"/preload.js", "/preload.js",
"/range.bnf" "/range.bnf"
] ],
"publish": "true"
} }
} }

View File

@@ -2,6 +2,6 @@ const Range = require('../classes/range')
const intersects = (r1, r2, options) => { const intersects = (r1, r2, options) => {
r1 = new Range(r1, options) r1 = new Range(r1, options)
r2 = new Range(r2, options) r2 = new Range(r2, options)
return r1.intersects(r2) return r1.intersects(r2, options)
} }
module.exports = intersects module.exports = intersects

View File

@@ -68,6 +68,9 @@ const subset = (sub, dom, options = {}) => {
return true return true
} }
const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
const minimumVersion = [new Comparator('>=0.0.0')]
const simpleSubset = (sub, dom, options) => { const simpleSubset = (sub, dom, options) => {
if (sub === dom) { if (sub === dom) {
return true return true
@@ -77,9 +80,9 @@ const simpleSubset = (sub, dom, options) => {
if (dom.length === 1 && dom[0].semver === ANY) { if (dom.length === 1 && dom[0].semver === ANY) {
return true return true
} else if (options.includePrerelease) { } else if (options.includePrerelease) {
sub = [new Comparator('>=0.0.0-0')] sub = minimumVersionWithPreRelease
} else { } else {
sub = [new Comparator('>=0.0.0')] sub = minimumVersion
} }
} }
@@ -87,7 +90,7 @@ const simpleSubset = (sub, dom, options) => {
if (options.includePrerelease) { if (options.includePrerelease) {
return true return true
} else { } else {
dom = [new Comparator('>=0.0.0')] dom = minimumVersion
} }
} }

8
package-lock.json generated
View File

@@ -32,7 +32,7 @@
"jsonschema": "1.4.1", "jsonschema": "1.4.1",
"long": "^5.2.0", "long": "^5.2.0",
"path": "^0.12.7", "path": "^0.12.7",
"semver": "^7.3.2", "semver": "^7.5.2",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"zlib": "^1.0.5" "zlib": "^1.0.5"
}, },
@@ -5277,9 +5277,9 @@
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.3.8", "version": "7.5.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.2.tgz",
"integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "integrity": "sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ==",
"dependencies": { "dependencies": {
"lru-cache": "^6.0.0" "lru-cache": "^6.0.0"
}, },

View File

@@ -44,7 +44,7 @@
"jsonschema": "1.4.1", "jsonschema": "1.4.1",
"long": "^5.2.0", "long": "^5.2.0",
"path": "^0.12.7", "path": "^0.12.7",
"semver": "^7.3.2", "semver": "^7.5.2",
"uuid": "^9.0.0", "uuid": "^9.0.0",
"zlib": "^1.0.5" "zlib": "^1.0.5"
}, },