From 41f4b687016c5cc65d83a8a1cc2c049b6471f5cf Mon Sep 17 00:00:00 2001 From: Aleksei Igrychev Date: Wed, 24 Apr 2024 14:03:13 +0100 Subject: [PATCH] feat: working within 2 major version Signed-off-by: Aleksei Igrychev --- .github/workflows/test.yaml | 2 +- README.md | 20 +- build/README.md | 2 +- build/index.js | 695 ++++++++++++++++++++++-------------- cleanup/README.md | 2 +- cleanup/index.js | 695 ++++++++++++++++++++++-------------- converge/README.md | 2 +- converge/index.js | 695 ++++++++++++++++++++++-------------- dismiss/README.md | 2 +- dismiss/index.js | 695 ++++++++++++++++++++++-------------- install/README.md | 8 +- install/index.js | 695 ++++++++++++++++++++++-------------- run/README.md | 2 +- run/index.js | 695 ++++++++++++++++++++++-------------- src/common.ts | 22 +- src/manager.ts | 2 +- src/werf.ts | 5 +- 17 files changed, 2639 insertions(+), 1600 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8f40209..0b81e23 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -38,6 +38,6 @@ jobs: - name: Install uses: ./install with: - version: v1.2.35 + version: v2.1.0 - run: werf version \ No newline at end of file diff --git a/README.md b/README.md index b4d9a8e..170f147 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ converge: fetch-depth: 0 - name: Install werf - uses: werf/actions/install@v1.2 + uses: werf/actions/install@v2 - name: Run script run: | @@ -34,15 +34,7 @@ converge: ## Versioning -When using action, select the version corresponding to the required `MAJOR.MINOR` version of werf: - -```yaml -# Setup actual werf version within 1.1 alpha channel. -- uses: werf/actions/install@v1.1 - -# Setup actual werf version within 1.2 alpha channel. -- uses: werf/actions/install@v1.2 -``` +When using action, select the version corresponding to the required `MAJOR` version of werf. By default, the action installs actual werf version within alpha channel (more details about channels, werf release cycle and compatibility promise [here](https://werf.io/installation.html#all-changes-in-werf-go-through-all-stability-channels)). Using the `channel` input the user can switch the release channel. @@ -50,7 +42,7 @@ Using the `channel` input the user can switch the release channel. > This is recommended approach to be up-to-date and to use actual werf version without changing configurations. ```yaml -- uses: werf/actions/install@v1.2 +- uses: werf/actions/install@v2 with: channel: alpha ``` @@ -58,9 +50,9 @@ Using the `channel` input the user can switch the release channel. Withal, it is not necessary to work within release channels, and the user might specify certain werf version with `version` input. ```yaml -- uses: werf/actions/install@v1.2 +- uses: werf/actions/install@v2 with: - version: v1.2.9 + version: v2.1.0 ``` ## FAQ @@ -78,7 +70,7 @@ Make sure to use `fetch-depth: 0` setting in the checkout action, like follows: By default, fetch-depth set to `1` which disables git history when checking out code. werf cache selection algorithm uses git history to determine whether some image bound to some commit could be used as a cache when building current commit (current commit should be descendant to the cache commit). -Setting `fetch-depth` to `0` enables full fetch of git history and it is a **recommended** approach. It is also possible to limit fetch history with some decent number of commits, which would enable images caching limited to that number of commits, but this would have a negative impact on cache reproducibility. +Setting `fetch-depth` to `0` enables full fetch of git history, and it is a **recommended** approach. It is also possible to limit fetch history with some decent number of commits, which would enable images caching limited to that number of commits, but this would have a negative impact on cache reproducibility. ## License diff --git a/build/README.md b/build/README.md index 089b5ae..d60e463 100644 --- a/build/README.md +++ b/build/README.md @@ -38,7 +38,7 @@ build: fetch-depth: 0 - name: Build - uses: werf/actions/build@v1.2 + uses: werf/actions/build@v2 with: kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} ``` diff --git a/build/index.js b/build/index.js index 757a140..366e96a 100644 --- a/build/index.js +++ b/build/index.js @@ -12265,6 +12265,11 @@ var isArray = Array.isArray || function (xs) { var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; Cookie.prototype.parse = function parse(str, request_domain, request_path) { if (this instanceof Cookie) { + if ( str.length > 32768 ) { + console.warn("Cookie too long for parsing (>32768 characters)"); + return; + } + var parts = str.split(";").filter(function (value) { return !!value; }); @@ -21763,6 +21768,7 @@ class Comparator { static get ANY () { return ANY } + constructor (comp, options) { options = parseOptions(options) @@ -21774,6 +21780,7 @@ class Comparator { } } + comp = comp.trim().split(/\s+/).join(' ') debug('comparator', comp, options) this.options = options this.loose = !!options.loose @@ -21836,13 +21843,6 @@ class Comparator { throw new TypeError('a Comparator is required') } - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (this.operator === '') { if (this.value === '') { return true @@ -21855,39 +21855,50 @@ class Comparator { return new Range(this.value, options).test(comp.semver) } - const sameDirectionIncreasing = - (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 === '>') + options = parseOptions(options) - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) + // Special cases where nothing can possibly be lower + if (options.includePrerelease && + (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { + return false + } + 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 const parseOptions = __nccwpck_require__(3379) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const cmp = __nccwpck_require__(486) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) @@ -21927,19 +21938,26 @@ class Range { this.loose = !!options.loose 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.set = range - .split(/\s*\|\|\s*/) + .trim() + .split(/\s+/) + .join(' ') + + // First, split on || + this.set = this.raw + .split('||') // map the range to a 2d array of comparators - .map(range => this.parseRange(range.trim())) + .map(r => this.parseRange(r)) // throw out any comparator lists that are empty // 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. .filter(c => c.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. @@ -21947,9 +21965,9 @@ class Range { // keep the first one, in case they're all null sets const first = this.set[0] this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) + if (this.set.length === 0) { this.set = [first] - else if (this.set.length > 1) { + } else if (this.set.length > 1) { // if we have any that are *, then the range is just * for (const c of this.set) { if (c.length === 1 && isAny(c[0])) { @@ -21965,9 +21983,7 @@ class Range { format () { this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) + .map((comps) => comps.join(' ').trim()) .join('||') .trim() return this.range @@ -21978,15 +21994,16 @@ class Range { } parseRange (range) { - range = range.trim() - // memoize range parsing for performance. // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range const cached = cache.get(memoKey) - if (cached) + if (cached) { return cached + } const loose = this.options.loose // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` @@ -21995,7 +22012,7 @@ class Range { debug('hyphen replace', range) // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) + debug('comparator trim', range) // `~ 1.2.3` => `~1.2.3` range = range.replace(re[t.TILDETRIM], tildeTrimReplace) @@ -22003,36 +22020,40 @@ class Range { // `^ 1.2.3` => `^1.2.3` range = range.replace(re[t.CARETTRIM], caretTrimReplace) - // normalize spaces - range = range.split(/\s+/).join(' ') - // At this point, the range is completely trimmed and // ready to be split into comparators. - const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const rangeList = range + let rangeList = range .split(' ') .map(comp => parseComparator(comp, this.options)) .join(' ') .split(/\s+/) // >=0.0.0 is equivalent to * .map(comp => replaceGTE0(comp, this.options)) + + if (loose) { // in loose mode, throw out any that are not valid comparators - .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) - .map(comp => new Comparator(comp, this.options)) + rangeList = rangeList.filter(comp => { + debug('loose invalid filter', comp, this.options) + return !!comp.match(re[t.COMPARATORLOOSE]) + }) + } + debug('range list', rangeList) // if any comparators are the null set, then replace with JUST null set // if more than one comparator, remove any * comparators // also, don't include the same comparator more than once - const l = rangeList.length const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) + const comparators = rangeList.map(comp => new Comparator(comp, this.options)) + for (const comp of comparators) { + if (isNullSet(comp)) { return [comp] + } rangeMap.set(comp.value, comp) } - if (rangeMap.size > 1 && rangeMap.has('')) + if (rangeMap.size > 1 && rangeMap.has('')) { rangeMap.delete('') + } const result = [...rangeMap.values()] cache.set(memoKey, result) @@ -22083,6 +22104,7 @@ class Range { return false } } + module.exports = Range const LRU = __nccwpck_require__(9505) @@ -22093,12 +22115,13 @@ const Comparator = __nccwpck_require__(1044) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) const { - re, + safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, - caretTrimReplace + caretTrimReplace, } = __nccwpck_require__(3640) +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __nccwpck_require__(5455) const isNullSet = c => c.value === '<0.0.0-0' const isAny = c => c.value === '' @@ -22145,10 +22168,14 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <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 -const replaceTildes = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceTilde(comp, options) - }).join(' ') +// ~0.0.1 --> >=0.0.1 <0.1.0-0 +const replaceTildes = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceTilde(c, options)) + .join(' ') +} const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] @@ -22184,10 +22211,15 @@ const replaceTilde = (comp, options) => { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 // ^1.2.3 --> >=1.2.3 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0 -const replaceCarets = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceCaret(comp, options) - }).join(' ') +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 +const replaceCarets = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceCaret(c, options)) + .join(' ') +} const replaceCaret = (comp, options) => { debug('caret', comp, options) @@ -22244,9 +22276,10 @@ const replaceCaret = (comp, options) => { const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') + return comp + .split(/\s+/) + .map((c) => replaceXRange(c, options)) + .join(' ') } const replaceXRange = (comp, options) => { @@ -22306,8 +22339,9 @@ const replaceXRange = (comp, options) => { } } - if (gtlt === '<') + if (gtlt === '<') { pr = '-0' + } ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { @@ -22328,12 +22362,15 @@ const replaceXRange = (comp, options) => { const replaceStars = (comp, options) => { debug('replaceStars', comp, options) // 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) => { debug('replaceGTE0', comp, options) - return comp.trim() + return comp + .trim() .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') } @@ -22371,7 +22408,7 @@ const hyphenReplace = incPr => ($0, to = `<=${to}` } - return (`${from} ${to}`).trim() + return `${from} ${to}`.trim() } const testSet = (set, version, options) => { @@ -22418,7 +22455,7 @@ const testSet = (set, version, options) => { const debug = __nccwpck_require__(9408) const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const parseOptions = __nccwpck_require__(3379) const { compareIdentifiers } = __nccwpck_require__(3226) @@ -22434,7 +22471,7 @@ class SemVer { version = version.version } } 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) { @@ -22593,36 +22630,36 @@ class SemVer { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { + inc (release, identifier, identifierBase) { switch (release) { case 'premajor': this.prerelease.length = 0 this.patch = 0 this.minor = 0 this.major++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'preminor': this.prerelease.length = 0 this.patch = 0 this.minor++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) break // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { - this.inc('patch', identifier) + this.inc('patch', identifier, identifierBase) } - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'major': @@ -22664,9 +22701,15 @@ class SemVer { break // This probably shouldn't be used publicly. // 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) { - this.prerelease = [0] + this.prerelease = [base] } else { let i = this.prerelease.length while (--i >= 0) { @@ -22677,27 +22720,36 @@ class SemVer { } if (i === -1) { // 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) { // 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 - if (this.prerelease[0] === identifier) { + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } else { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } break - + } default: throw new Error(`invalid increment argument: ${release}`) } - this.format() - this.raw = this.version + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } return this } } @@ -22733,17 +22785,21 @@ const lte = __nccwpck_require__(2712) const cmp = (a, op, b, loose) => { switch (op) { case '===': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a === b case '!==': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a !== b case '': @@ -22780,7 +22836,7 @@ module.exports = cmp const SemVer = __nccwpck_require__(5501) const parse = __nccwpck_require__(6020) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const coerce = (version, options) => { if (version instanceof SemVer) { @@ -22823,8 +22879,9 @@ const coerce = (version, options) => { re[t.COERCERTL].lastIndex = -1 } - if (match === null) + if (match === null) { return null + } return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) } @@ -22873,27 +22930,69 @@ module.exports = compare /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const parse = __nccwpck_require__(6020) -const eq = __nccwpck_require__(6650) 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 - } 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 - } - } - } - return defaultResult // may be undefined } + + 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' + } + + 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 @@ -22934,14 +23033,18 @@ module.exports = gte const SemVer = __nccwpck_require__(5501) -const inc = (version, release, options, identifier) => { +const inc = (version, release, options, identifier, identifierBase) => { if (typeof (options) === 'string') { + identifierBase = identifier identifier = options options = undefined } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier, identifierBase).version } catch (er) { return null } @@ -23004,35 +23107,18 @@ module.exports = neq /***/ 6020: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) const SemVer = __nccwpck_require__(5501) - -const parseOptions = __nccwpck_require__(3379) -const parse = (version, options) => { - options = parseOptions(options) - +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { 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 { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } @@ -23129,51 +23215,92 @@ module.exports = valid // just pre-load all the stuff that index.js lazily exports const internalRe = __nccwpck_require__(3640) +const constants = __nccwpck_require__(5455) +const SemVer = __nccwpck_require__(5501) +const identifiers = __nccwpck_require__(3226) +const parse = __nccwpck_require__(6020) +const valid = __nccwpck_require__(8573) +const clean = __nccwpck_require__(9154) +const inc = __nccwpck_require__(2100) +const diff = __nccwpck_require__(7693) +const major = __nccwpck_require__(625) +const minor = __nccwpck_require__(2019) +const patch = __nccwpck_require__(1215) +const prerelease = __nccwpck_require__(8761) +const compare = __nccwpck_require__(1366) +const rcompare = __nccwpck_require__(8316) +const compareLoose = __nccwpck_require__(554) +const compareBuild = __nccwpck_require__(4450) +const sort = __nccwpck_require__(3211) +const rsort = __nccwpck_require__(5090) +const gt = __nccwpck_require__(3788) +const lt = __nccwpck_require__(1125) +const eq = __nccwpck_require__(6650) +const neq = __nccwpck_require__(2098) +const gte = __nccwpck_require__(5280) +const lte = __nccwpck_require__(2712) +const cmp = __nccwpck_require__(486) +const coerce = __nccwpck_require__(3669) +const Comparator = __nccwpck_require__(1044) +const Range = __nccwpck_require__(1838) +const satisfies = __nccwpck_require__(8840) +const toComparators = __nccwpck_require__(4017) +const maxSatisfying = __nccwpck_require__(7093) +const minSatisfying = __nccwpck_require__(3916) +const minVersion = __nccwpck_require__(6344) +const validRange = __nccwpck_require__(1757) +const outside = __nccwpck_require__(8437) +const gtr = __nccwpck_require__(1555) +const ltr = __nccwpck_require__(6732) +const intersects = __nccwpck_require__(184) +const simplifyRange = __nccwpck_require__(530) +const subset = __nccwpck_require__(1132) module.exports = { + parse, + valid, + clean, + inc, + diff, + major, + minor, + patch, + prerelease, + compare, + rcompare, + compareLoose, + compareBuild, + sort, + rsort, + gt, + lt, + eq, + neq, + gte, + lte, + cmp, + coerce, + Comparator, + Range, + satisfies, + toComparators, + maxSatisfying, + minSatisfying, + minVersion, + validRange, + outside, + gtr, + ltr, + intersects, + simplifyRange, + subset, + SemVer, re: internalRe.re, src: internalRe.src, tokens: internalRe.t, - SEMVER_SPEC_VERSION: (__nccwpck_require__(5455).SEMVER_SPEC_VERSION), - SemVer: __nccwpck_require__(5501), - compareIdentifiers: (__nccwpck_require__(3226).compareIdentifiers), - rcompareIdentifiers: (__nccwpck_require__(3226).rcompareIdentifiers), - parse: __nccwpck_require__(6020), - valid: __nccwpck_require__(8573), - clean: __nccwpck_require__(9154), - inc: __nccwpck_require__(2100), - diff: __nccwpck_require__(7693), - major: __nccwpck_require__(625), - minor: __nccwpck_require__(2019), - patch: __nccwpck_require__(1215), - prerelease: __nccwpck_require__(8761), - compare: __nccwpck_require__(1366), - rcompare: __nccwpck_require__(8316), - compareLoose: __nccwpck_require__(554), - compareBuild: __nccwpck_require__(4450), - sort: __nccwpck_require__(3211), - rsort: __nccwpck_require__(5090), - gt: __nccwpck_require__(3788), - lt: __nccwpck_require__(1125), - eq: __nccwpck_require__(6650), - neq: __nccwpck_require__(2098), - gte: __nccwpck_require__(5280), - lte: __nccwpck_require__(2712), - cmp: __nccwpck_require__(486), - coerce: __nccwpck_require__(3669), - Comparator: __nccwpck_require__(1044), - Range: __nccwpck_require__(1838), - satisfies: __nccwpck_require__(8840), - toComparators: __nccwpck_require__(4017), - maxSatisfying: __nccwpck_require__(7093), - minSatisfying: __nccwpck_require__(3916), - minVersion: __nccwpck_require__(6344), - validRange: __nccwpck_require__(1757), - outside: __nccwpck_require__(8437), - gtr: __nccwpck_require__(1555), - ltr: __nccwpck_require__(6732), - intersects: __nccwpck_require__(184), - simplifyRange: __nccwpck_require__(530), - subset: __nccwpck_require__(1132), + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, } @@ -23188,16 +23315,29 @@ const SEMVER_SPEC_VERSION = '2.0.0' const MAX_LENGTH = 256 const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/* istanbul ignore next */ 9007199254740991 // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, } @@ -23243,7 +23383,7 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, - rcompareIdentifiers + rcompareIdentifiers, } @@ -23252,16 +23392,20 @@ module.exports = { /***/ 3379: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} module.exports = parseOptions @@ -23276,16 +23420,27 @@ exports = module.exports = {} // The actual regexps go on exports.re const re = exports.re = [] +const safeRe = exports.safeRe = [] const src = exports.src = [] const t = exports.t = {} let R = 0 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++ - debug(index, value) + debug(name, index, value) t[name] = index src[index] = value 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, @@ -23450,8 +23605,8 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + // Star ranges basically just allow anything at all. createToken('STAR', '(<|>)?=?\\s*\\*') // >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), @@ -23474,7 +23629,7 @@ const Range = __nccwpck_require__(1838) const intersects = (r1, r2, options) => { r1 = new Range(r1, options) r2 = new Range(r2, options) - return r1.intersects(r2) + return r1.intersects(r2, options) } module.exports = intersects @@ -23607,8 +23762,9 @@ const minVersion = (range, loose) => { throw new Error(`Unexpected operation: ${comparator.operator}`) } }) - if (setMin && (!minver || gt(minver, setMin))) + if (setMin && (!minver || gt(minver, setMin))) { minver = setMin + } } if (minver && range.test(minver)) { @@ -23627,7 +23783,7 @@ module.exports = minVersion const SemVer = __nccwpck_require__(5501) const Comparator = __nccwpck_require__(1044) -const {ANY} = Comparator +const { ANY } = Comparator const Range = __nccwpck_require__(1838) const satisfies = __nccwpck_require__(8840) const gt = __nccwpck_require__(3788) @@ -23719,38 +23875,41 @@ const satisfies = __nccwpck_require__(8840) const compare = __nccwpck_require__(1366) module.exports = (versions, range, options) => { const set = [] - let min = null + let first = null let prev = null const v = versions.sort((a, b) => compare(a, b, options)) for (const version of v) { const included = satisfies(version, range, options) if (included) { prev = version - if (!min) - min = version + if (!first) { + first = version + } } else { if (prev) { - set.push([min, prev]) + set.push([first, prev]) } prev = null - min = null + first = null } } - if (min) - set.push([min, null]) + if (first) { + set.push([first, null]) + } const ranges = [] for (const [min, max] of set) { - if (min === max) + if (min === max) { ranges.push(min) - else if (!max && min === v[0]) + } else if (!max && min === v[0]) { ranges.push('*') - else if (!max) + } else if (!max) { ranges.push(`>=${min}`) - else if (min === v[0]) + } else if (min === v[0]) { ranges.push(`<=${max}`) - else + } else { ranges.push(`${min} - ${max}`) + } } const simplified = ranges.join(' || ') const original = typeof range.raw === 'string' ? range.raw : String(range) @@ -23806,8 +23965,9 @@ const compare = __nccwpck_require__(1366) // - Else return true const subset = (sub, dom, options = {}) => { - if (sub === dom) + if (sub === dom) { return true + } sub = new Range(sub, options) dom = new Range(dom, options) @@ -23817,73 +23977,87 @@ const subset = (sub, dom, options = {}) => { for (const simpleDom of dom.set) { const isSub = simpleSubset(simpleSub, simpleDom, options) sawNonNull = sawNonNull || isSub !== null - if (isSub) + if (isSub) { continue OUTER + } } // the null set is a subset of everything, but null simple ranges in // a complex range should be ignored. so if we saw a non-null range, // then we know this isn't a subset, but if EVERY simple range was null, // then it is a subset. - if (sawNonNull) + if (sawNonNull) { return false + } } return true } +const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] +const minimumVersion = [new Comparator('>=0.0.0')] + const simpleSubset = (sub, dom, options) => { - if (sub === dom) + if (sub === dom) { return true + } if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) + if (dom.length === 1 && dom[0].semver === ANY) { return true - else if (options.includePrerelease) - sub = [ new Comparator('>=0.0.0-0') ] - else - sub = [ new Comparator('>=0.0.0') ] + } else if (options.includePrerelease) { + sub = minimumVersionWithPreRelease + } else { + sub = minimumVersion + } } if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) + if (options.includePrerelease) { return true - else - dom = [ new Comparator('>=0.0.0') ] + } else { + dom = minimumVersion + } } const eqSet = new Set() let gt, lt for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') + if (c.operator === '>' || c.operator === '>=') { gt = higherGT(gt, c, options) - else if (c.operator === '<' || c.operator === '<=') + } else if (c.operator === '<' || c.operator === '<=') { lt = lowerLT(lt, c, options) - else + } else { eqSet.add(c.semver) + } } - if (eqSet.size > 1) + if (eqSet.size > 1) { return null + } let gtltComp if (gt && lt) { gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) + if (gtltComp > 0) { return null - else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { return null + } } // will iterate one or zero times for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) + if (gt && !satisfies(eq, String(gt), options)) { return null + } - if (lt && !satisfies(eq, String(lt), options)) + if (lt && !satisfies(eq, String(lt), options)) { return null + } for (const c of dom) { - if (!satisfies(eq, String(c), options)) + if (!satisfies(eq, String(c), options)) { return false + } } return true @@ -23919,10 +24093,12 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '>' || c.operator === '>=') { higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) + if (higher === c && higher !== gt) { return false - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + } + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { return false + } } if (lt) { if (needDomLTPre) { @@ -23935,37 +24111,44 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '<' || c.operator === '<=') { lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) + if (lower === c && lower !== lt) { return false - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + } + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { return false + } } - if (!c.operator && (lt || gt) && gtltComp !== 0) + if (!c.operator && (lt || gt) && gtltComp !== 0) { return false + } } // if there was a < or >, and nothing in the dom, then must be false // UNLESS it was limited by another range in the other direction. // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) + if (gt && hasDomLT && !lt && gtltComp !== 0) { return false + } - if (lt && hasDomGT && !gt && gtltComp !== 0) + if (lt && hasDomGT && !gt && gtltComp !== 0) { return false + } // we needed a prerelease range in a specific tuple, but didn't get one // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) + if (needDomGTPre || needDomLTPre) { return false + } return true } // >=1.2.3 is lower than >1.2.3 const higherGT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp > 0 ? a : comp < 0 ? b @@ -23975,8 +24158,9 @@ const higherGT = (a, b, options) => { // <=1.2.3 is higher than <1.2.3 const lowerLT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp < 0 ? a : comp > 0 ? b @@ -31688,7 +31872,6 @@ const github_1 = __nccwpck_require__(2726); const typescript_string_operations_1 = __nccwpck_require__(9363); const manager_1 = __nccwpck_require__(1856); const werf = __importStar(__nccwpck_require__(8525)); -const minimalWerfVersion = 'v1.1.17'; function PrepareEnvironAndRunWerfCommand(args) { return __awaiter(this, void 0, void 0, function* () { try { @@ -31741,15 +31924,10 @@ function ProcessGitHubContext() { exports.ProcessGitHubContext = ProcessGitHubContext; function ValidateWerfVersion(version) { const ver = semver.coerce(version); - if (ver) { - if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) { - throw new Error(typescript_string_operations_1.String.Format('The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})', version.trim(), werf.MAJOR_MINOR_GROUP)); - } - if (semver.gte(ver, minimalWerfVersion)) { - return; - } + if (ver && ver.major === werf.MAJOR) { + return; } - throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported (expected version must be equal or greater than {1})', version.trim(), minimalWerfVersion)); + throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', version.trim(), werf.GROUP)); } exports.ValidateWerfVersion = ValidateWerfVersion; @@ -31898,7 +32076,7 @@ class Manager { const version = this.version.slice('v'.length); return this._constructReleaseUrl(version); } - const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`; + const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}`; try { const resp = yield request .get(url) @@ -31965,10 +32143,9 @@ exports.Manager = Manager; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MINOR = exports.MAJOR = exports.MAJOR_MINOR_GROUP = void 0; -exports.MAJOR_MINOR_GROUP = '1.2'; -exports.MAJOR = 1; -exports.MINOR = 2; +exports.MAJOR = exports.GROUP = void 0; +exports.GROUP = '2'; +exports.MAJOR = 2; /***/ }), diff --git a/cleanup/README.md b/cleanup/README.md index cc1cbd5..de4445c 100644 --- a/cleanup/README.md +++ b/cleanup/README.md @@ -39,7 +39,7 @@ cleanup: run: git fetch --prune --unshallow - name: Cleanup - uses: werf/actions/cleanup@v1.2 + uses: werf/actions/cleanup@v2 with: kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} env: diff --git a/cleanup/index.js b/cleanup/index.js index 53a2fe7..e052d42 100644 --- a/cleanup/index.js +++ b/cleanup/index.js @@ -12265,6 +12265,11 @@ var isArray = Array.isArray || function (xs) { var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; Cookie.prototype.parse = function parse(str, request_domain, request_path) { if (this instanceof Cookie) { + if ( str.length > 32768 ) { + console.warn("Cookie too long for parsing (>32768 characters)"); + return; + } + var parts = str.split(";").filter(function (value) { return !!value; }); @@ -21763,6 +21768,7 @@ class Comparator { static get ANY () { return ANY } + constructor (comp, options) { options = parseOptions(options) @@ -21774,6 +21780,7 @@ class Comparator { } } + comp = comp.trim().split(/\s+/).join(' ') debug('comparator', comp, options) this.options = options this.loose = !!options.loose @@ -21836,13 +21843,6 @@ class Comparator { throw new TypeError('a Comparator is required') } - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (this.operator === '') { if (this.value === '') { return true @@ -21855,39 +21855,50 @@ class Comparator { return new Range(this.value, options).test(comp.semver) } - const sameDirectionIncreasing = - (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 === '>') + options = parseOptions(options) - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) + // Special cases where nothing can possibly be lower + if (options.includePrerelease && + (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { + return false + } + 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 const parseOptions = __nccwpck_require__(3379) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const cmp = __nccwpck_require__(486) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) @@ -21927,19 +21938,26 @@ class Range { this.loose = !!options.loose 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.set = range - .split(/\s*\|\|\s*/) + .trim() + .split(/\s+/) + .join(' ') + + // First, split on || + this.set = this.raw + .split('||') // map the range to a 2d array of comparators - .map(range => this.parseRange(range.trim())) + .map(r => this.parseRange(r)) // throw out any comparator lists that are empty // 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. .filter(c => c.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. @@ -21947,9 +21965,9 @@ class Range { // keep the first one, in case they're all null sets const first = this.set[0] this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) + if (this.set.length === 0) { this.set = [first] - else if (this.set.length > 1) { + } else if (this.set.length > 1) { // if we have any that are *, then the range is just * for (const c of this.set) { if (c.length === 1 && isAny(c[0])) { @@ -21965,9 +21983,7 @@ class Range { format () { this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) + .map((comps) => comps.join(' ').trim()) .join('||') .trim() return this.range @@ -21978,15 +21994,16 @@ class Range { } parseRange (range) { - range = range.trim() - // memoize range parsing for performance. // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range const cached = cache.get(memoKey) - if (cached) + if (cached) { return cached + } const loose = this.options.loose // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` @@ -21995,7 +22012,7 @@ class Range { debug('hyphen replace', range) // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) + debug('comparator trim', range) // `~ 1.2.3` => `~1.2.3` range = range.replace(re[t.TILDETRIM], tildeTrimReplace) @@ -22003,36 +22020,40 @@ class Range { // `^ 1.2.3` => `^1.2.3` range = range.replace(re[t.CARETTRIM], caretTrimReplace) - // normalize spaces - range = range.split(/\s+/).join(' ') - // At this point, the range is completely trimmed and // ready to be split into comparators. - const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const rangeList = range + let rangeList = range .split(' ') .map(comp => parseComparator(comp, this.options)) .join(' ') .split(/\s+/) // >=0.0.0 is equivalent to * .map(comp => replaceGTE0(comp, this.options)) + + if (loose) { // in loose mode, throw out any that are not valid comparators - .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) - .map(comp => new Comparator(comp, this.options)) + rangeList = rangeList.filter(comp => { + debug('loose invalid filter', comp, this.options) + return !!comp.match(re[t.COMPARATORLOOSE]) + }) + } + debug('range list', rangeList) // if any comparators are the null set, then replace with JUST null set // if more than one comparator, remove any * comparators // also, don't include the same comparator more than once - const l = rangeList.length const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) + const comparators = rangeList.map(comp => new Comparator(comp, this.options)) + for (const comp of comparators) { + if (isNullSet(comp)) { return [comp] + } rangeMap.set(comp.value, comp) } - if (rangeMap.size > 1 && rangeMap.has('')) + if (rangeMap.size > 1 && rangeMap.has('')) { rangeMap.delete('') + } const result = [...rangeMap.values()] cache.set(memoKey, result) @@ -22083,6 +22104,7 @@ class Range { return false } } + module.exports = Range const LRU = __nccwpck_require__(9505) @@ -22093,12 +22115,13 @@ const Comparator = __nccwpck_require__(1044) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) const { - re, + safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, - caretTrimReplace + caretTrimReplace, } = __nccwpck_require__(3640) +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __nccwpck_require__(5455) const isNullSet = c => c.value === '<0.0.0-0' const isAny = c => c.value === '' @@ -22145,10 +22168,14 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <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 -const replaceTildes = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceTilde(comp, options) - }).join(' ') +// ~0.0.1 --> >=0.0.1 <0.1.0-0 +const replaceTildes = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceTilde(c, options)) + .join(' ') +} const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] @@ -22184,10 +22211,15 @@ const replaceTilde = (comp, options) => { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 // ^1.2.3 --> >=1.2.3 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0 -const replaceCarets = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceCaret(comp, options) - }).join(' ') +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 +const replaceCarets = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceCaret(c, options)) + .join(' ') +} const replaceCaret = (comp, options) => { debug('caret', comp, options) @@ -22244,9 +22276,10 @@ const replaceCaret = (comp, options) => { const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') + return comp + .split(/\s+/) + .map((c) => replaceXRange(c, options)) + .join(' ') } const replaceXRange = (comp, options) => { @@ -22306,8 +22339,9 @@ const replaceXRange = (comp, options) => { } } - if (gtlt === '<') + if (gtlt === '<') { pr = '-0' + } ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { @@ -22328,12 +22362,15 @@ const replaceXRange = (comp, options) => { const replaceStars = (comp, options) => { debug('replaceStars', comp, options) // 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) => { debug('replaceGTE0', comp, options) - return comp.trim() + return comp + .trim() .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') } @@ -22371,7 +22408,7 @@ const hyphenReplace = incPr => ($0, to = `<=${to}` } - return (`${from} ${to}`).trim() + return `${from} ${to}`.trim() } const testSet = (set, version, options) => { @@ -22418,7 +22455,7 @@ const testSet = (set, version, options) => { const debug = __nccwpck_require__(9408) const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const parseOptions = __nccwpck_require__(3379) const { compareIdentifiers } = __nccwpck_require__(3226) @@ -22434,7 +22471,7 @@ class SemVer { version = version.version } } 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) { @@ -22593,36 +22630,36 @@ class SemVer { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { + inc (release, identifier, identifierBase) { switch (release) { case 'premajor': this.prerelease.length = 0 this.patch = 0 this.minor = 0 this.major++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'preminor': this.prerelease.length = 0 this.patch = 0 this.minor++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) break // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { - this.inc('patch', identifier) + this.inc('patch', identifier, identifierBase) } - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'major': @@ -22664,9 +22701,15 @@ class SemVer { break // This probably shouldn't be used publicly. // 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) { - this.prerelease = [0] + this.prerelease = [base] } else { let i = this.prerelease.length while (--i >= 0) { @@ -22677,27 +22720,36 @@ class SemVer { } if (i === -1) { // 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) { // 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 - if (this.prerelease[0] === identifier) { + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } else { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } break - + } default: throw new Error(`invalid increment argument: ${release}`) } - this.format() - this.raw = this.version + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } return this } } @@ -22733,17 +22785,21 @@ const lte = __nccwpck_require__(2712) const cmp = (a, op, b, loose) => { switch (op) { case '===': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a === b case '!==': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a !== b case '': @@ -22780,7 +22836,7 @@ module.exports = cmp const SemVer = __nccwpck_require__(5501) const parse = __nccwpck_require__(6020) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const coerce = (version, options) => { if (version instanceof SemVer) { @@ -22823,8 +22879,9 @@ const coerce = (version, options) => { re[t.COERCERTL].lastIndex = -1 } - if (match === null) + if (match === null) { return null + } return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) } @@ -22873,27 +22930,69 @@ module.exports = compare /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const parse = __nccwpck_require__(6020) -const eq = __nccwpck_require__(6650) 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 - } 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 - } - } - } - return defaultResult // may be undefined } + + 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' + } + + 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 @@ -22934,14 +23033,18 @@ module.exports = gte const SemVer = __nccwpck_require__(5501) -const inc = (version, release, options, identifier) => { +const inc = (version, release, options, identifier, identifierBase) => { if (typeof (options) === 'string') { + identifierBase = identifier identifier = options options = undefined } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier, identifierBase).version } catch (er) { return null } @@ -23004,35 +23107,18 @@ module.exports = neq /***/ 6020: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) const SemVer = __nccwpck_require__(5501) - -const parseOptions = __nccwpck_require__(3379) -const parse = (version, options) => { - options = parseOptions(options) - +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { 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 { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } @@ -23129,51 +23215,92 @@ module.exports = valid // just pre-load all the stuff that index.js lazily exports const internalRe = __nccwpck_require__(3640) +const constants = __nccwpck_require__(5455) +const SemVer = __nccwpck_require__(5501) +const identifiers = __nccwpck_require__(3226) +const parse = __nccwpck_require__(6020) +const valid = __nccwpck_require__(8573) +const clean = __nccwpck_require__(9154) +const inc = __nccwpck_require__(2100) +const diff = __nccwpck_require__(7693) +const major = __nccwpck_require__(625) +const minor = __nccwpck_require__(2019) +const patch = __nccwpck_require__(1215) +const prerelease = __nccwpck_require__(8761) +const compare = __nccwpck_require__(1366) +const rcompare = __nccwpck_require__(8316) +const compareLoose = __nccwpck_require__(554) +const compareBuild = __nccwpck_require__(4450) +const sort = __nccwpck_require__(3211) +const rsort = __nccwpck_require__(5090) +const gt = __nccwpck_require__(3788) +const lt = __nccwpck_require__(1125) +const eq = __nccwpck_require__(6650) +const neq = __nccwpck_require__(2098) +const gte = __nccwpck_require__(5280) +const lte = __nccwpck_require__(2712) +const cmp = __nccwpck_require__(486) +const coerce = __nccwpck_require__(3669) +const Comparator = __nccwpck_require__(1044) +const Range = __nccwpck_require__(1838) +const satisfies = __nccwpck_require__(8840) +const toComparators = __nccwpck_require__(4017) +const maxSatisfying = __nccwpck_require__(7093) +const minSatisfying = __nccwpck_require__(3916) +const minVersion = __nccwpck_require__(6344) +const validRange = __nccwpck_require__(1757) +const outside = __nccwpck_require__(8437) +const gtr = __nccwpck_require__(1555) +const ltr = __nccwpck_require__(6732) +const intersects = __nccwpck_require__(184) +const simplifyRange = __nccwpck_require__(530) +const subset = __nccwpck_require__(1132) module.exports = { + parse, + valid, + clean, + inc, + diff, + major, + minor, + patch, + prerelease, + compare, + rcompare, + compareLoose, + compareBuild, + sort, + rsort, + gt, + lt, + eq, + neq, + gte, + lte, + cmp, + coerce, + Comparator, + Range, + satisfies, + toComparators, + maxSatisfying, + minSatisfying, + minVersion, + validRange, + outside, + gtr, + ltr, + intersects, + simplifyRange, + subset, + SemVer, re: internalRe.re, src: internalRe.src, tokens: internalRe.t, - SEMVER_SPEC_VERSION: (__nccwpck_require__(5455).SEMVER_SPEC_VERSION), - SemVer: __nccwpck_require__(5501), - compareIdentifiers: (__nccwpck_require__(3226).compareIdentifiers), - rcompareIdentifiers: (__nccwpck_require__(3226).rcompareIdentifiers), - parse: __nccwpck_require__(6020), - valid: __nccwpck_require__(8573), - clean: __nccwpck_require__(9154), - inc: __nccwpck_require__(2100), - diff: __nccwpck_require__(7693), - major: __nccwpck_require__(625), - minor: __nccwpck_require__(2019), - patch: __nccwpck_require__(1215), - prerelease: __nccwpck_require__(8761), - compare: __nccwpck_require__(1366), - rcompare: __nccwpck_require__(8316), - compareLoose: __nccwpck_require__(554), - compareBuild: __nccwpck_require__(4450), - sort: __nccwpck_require__(3211), - rsort: __nccwpck_require__(5090), - gt: __nccwpck_require__(3788), - lt: __nccwpck_require__(1125), - eq: __nccwpck_require__(6650), - neq: __nccwpck_require__(2098), - gte: __nccwpck_require__(5280), - lte: __nccwpck_require__(2712), - cmp: __nccwpck_require__(486), - coerce: __nccwpck_require__(3669), - Comparator: __nccwpck_require__(1044), - Range: __nccwpck_require__(1838), - satisfies: __nccwpck_require__(8840), - toComparators: __nccwpck_require__(4017), - maxSatisfying: __nccwpck_require__(7093), - minSatisfying: __nccwpck_require__(3916), - minVersion: __nccwpck_require__(6344), - validRange: __nccwpck_require__(1757), - outside: __nccwpck_require__(8437), - gtr: __nccwpck_require__(1555), - ltr: __nccwpck_require__(6732), - intersects: __nccwpck_require__(184), - simplifyRange: __nccwpck_require__(530), - subset: __nccwpck_require__(1132), + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, } @@ -23188,16 +23315,29 @@ const SEMVER_SPEC_VERSION = '2.0.0' const MAX_LENGTH = 256 const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/* istanbul ignore next */ 9007199254740991 // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, } @@ -23243,7 +23383,7 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, - rcompareIdentifiers + rcompareIdentifiers, } @@ -23252,16 +23392,20 @@ module.exports = { /***/ 3379: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} module.exports = parseOptions @@ -23276,16 +23420,27 @@ exports = module.exports = {} // The actual regexps go on exports.re const re = exports.re = [] +const safeRe = exports.safeRe = [] const src = exports.src = [] const t = exports.t = {} let R = 0 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++ - debug(index, value) + debug(name, index, value) t[name] = index src[index] = value 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, @@ -23450,8 +23605,8 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + // Star ranges basically just allow anything at all. createToken('STAR', '(<|>)?=?\\s*\\*') // >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), @@ -23474,7 +23629,7 @@ const Range = __nccwpck_require__(1838) const intersects = (r1, r2, options) => { r1 = new Range(r1, options) r2 = new Range(r2, options) - return r1.intersects(r2) + return r1.intersects(r2, options) } module.exports = intersects @@ -23607,8 +23762,9 @@ const minVersion = (range, loose) => { throw new Error(`Unexpected operation: ${comparator.operator}`) } }) - if (setMin && (!minver || gt(minver, setMin))) + if (setMin && (!minver || gt(minver, setMin))) { minver = setMin + } } if (minver && range.test(minver)) { @@ -23627,7 +23783,7 @@ module.exports = minVersion const SemVer = __nccwpck_require__(5501) const Comparator = __nccwpck_require__(1044) -const {ANY} = Comparator +const { ANY } = Comparator const Range = __nccwpck_require__(1838) const satisfies = __nccwpck_require__(8840) const gt = __nccwpck_require__(3788) @@ -23719,38 +23875,41 @@ const satisfies = __nccwpck_require__(8840) const compare = __nccwpck_require__(1366) module.exports = (versions, range, options) => { const set = [] - let min = null + let first = null let prev = null const v = versions.sort((a, b) => compare(a, b, options)) for (const version of v) { const included = satisfies(version, range, options) if (included) { prev = version - if (!min) - min = version + if (!first) { + first = version + } } else { if (prev) { - set.push([min, prev]) + set.push([first, prev]) } prev = null - min = null + first = null } } - if (min) - set.push([min, null]) + if (first) { + set.push([first, null]) + } const ranges = [] for (const [min, max] of set) { - if (min === max) + if (min === max) { ranges.push(min) - else if (!max && min === v[0]) + } else if (!max && min === v[0]) { ranges.push('*') - else if (!max) + } else if (!max) { ranges.push(`>=${min}`) - else if (min === v[0]) + } else if (min === v[0]) { ranges.push(`<=${max}`) - else + } else { ranges.push(`${min} - ${max}`) + } } const simplified = ranges.join(' || ') const original = typeof range.raw === 'string' ? range.raw : String(range) @@ -23806,8 +23965,9 @@ const compare = __nccwpck_require__(1366) // - Else return true const subset = (sub, dom, options = {}) => { - if (sub === dom) + if (sub === dom) { return true + } sub = new Range(sub, options) dom = new Range(dom, options) @@ -23817,73 +23977,87 @@ const subset = (sub, dom, options = {}) => { for (const simpleDom of dom.set) { const isSub = simpleSubset(simpleSub, simpleDom, options) sawNonNull = sawNonNull || isSub !== null - if (isSub) + if (isSub) { continue OUTER + } } // the null set is a subset of everything, but null simple ranges in // a complex range should be ignored. so if we saw a non-null range, // then we know this isn't a subset, but if EVERY simple range was null, // then it is a subset. - if (sawNonNull) + if (sawNonNull) { return false + } } return true } +const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] +const minimumVersion = [new Comparator('>=0.0.0')] + const simpleSubset = (sub, dom, options) => { - if (sub === dom) + if (sub === dom) { return true + } if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) + if (dom.length === 1 && dom[0].semver === ANY) { return true - else if (options.includePrerelease) - sub = [ new Comparator('>=0.0.0-0') ] - else - sub = [ new Comparator('>=0.0.0') ] + } else if (options.includePrerelease) { + sub = minimumVersionWithPreRelease + } else { + sub = minimumVersion + } } if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) + if (options.includePrerelease) { return true - else - dom = [ new Comparator('>=0.0.0') ] + } else { + dom = minimumVersion + } } const eqSet = new Set() let gt, lt for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') + if (c.operator === '>' || c.operator === '>=') { gt = higherGT(gt, c, options) - else if (c.operator === '<' || c.operator === '<=') + } else if (c.operator === '<' || c.operator === '<=') { lt = lowerLT(lt, c, options) - else + } else { eqSet.add(c.semver) + } } - if (eqSet.size > 1) + if (eqSet.size > 1) { return null + } let gtltComp if (gt && lt) { gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) + if (gtltComp > 0) { return null - else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { return null + } } // will iterate one or zero times for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) + if (gt && !satisfies(eq, String(gt), options)) { return null + } - if (lt && !satisfies(eq, String(lt), options)) + if (lt && !satisfies(eq, String(lt), options)) { return null + } for (const c of dom) { - if (!satisfies(eq, String(c), options)) + if (!satisfies(eq, String(c), options)) { return false + } } return true @@ -23919,10 +24093,12 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '>' || c.operator === '>=') { higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) + if (higher === c && higher !== gt) { return false - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + } + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { return false + } } if (lt) { if (needDomLTPre) { @@ -23935,37 +24111,44 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '<' || c.operator === '<=') { lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) + if (lower === c && lower !== lt) { return false - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + } + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { return false + } } - if (!c.operator && (lt || gt) && gtltComp !== 0) + if (!c.operator && (lt || gt) && gtltComp !== 0) { return false + } } // if there was a < or >, and nothing in the dom, then must be false // UNLESS it was limited by another range in the other direction. // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) + if (gt && hasDomLT && !lt && gtltComp !== 0) { return false + } - if (lt && hasDomGT && !gt && gtltComp !== 0) + if (lt && hasDomGT && !gt && gtltComp !== 0) { return false + } // we needed a prerelease range in a specific tuple, but didn't get one // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) + if (needDomGTPre || needDomLTPre) { return false + } return true } // >=1.2.3 is lower than >1.2.3 const higherGT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp > 0 ? a : comp < 0 ? b @@ -23975,8 +24158,9 @@ const higherGT = (a, b, options) => { // <=1.2.3 is higher than <1.2.3 const lowerLT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp < 0 ? a : comp > 0 ? b @@ -31688,7 +31872,6 @@ const github_1 = __nccwpck_require__(2726); const typescript_string_operations_1 = __nccwpck_require__(9363); const manager_1 = __nccwpck_require__(1856); const werf = __importStar(__nccwpck_require__(8525)); -const minimalWerfVersion = 'v1.1.17'; function PrepareEnvironAndRunWerfCommand(args) { return __awaiter(this, void 0, void 0, function* () { try { @@ -31741,15 +31924,10 @@ function ProcessGitHubContext() { exports.ProcessGitHubContext = ProcessGitHubContext; function ValidateWerfVersion(version) { const ver = semver.coerce(version); - if (ver) { - if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) { - throw new Error(typescript_string_operations_1.String.Format('The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})', version.trim(), werf.MAJOR_MINOR_GROUP)); - } - if (semver.gte(ver, minimalWerfVersion)) { - return; - } + if (ver && ver.major === werf.MAJOR) { + return; } - throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported (expected version must be equal or greater than {1})', version.trim(), minimalWerfVersion)); + throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', version.trim(), werf.GROUP)); } exports.ValidateWerfVersion = ValidateWerfVersion; @@ -31898,7 +32076,7 @@ class Manager { const version = this.version.slice('v'.length); return this._constructReleaseUrl(version); } - const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`; + const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}`; try { const resp = yield request .get(url) @@ -31965,10 +32143,9 @@ exports.Manager = Manager; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MINOR = exports.MAJOR = exports.MAJOR_MINOR_GROUP = void 0; -exports.MAJOR_MINOR_GROUP = '1.2'; -exports.MAJOR = 1; -exports.MINOR = 2; +exports.MAJOR = exports.GROUP = void 0; +exports.GROUP = '2'; +exports.MAJOR = 2; /***/ }), diff --git a/converge/README.md b/converge/README.md index 9e32335..5072333 100644 --- a/converge/README.md +++ b/converge/README.md @@ -41,7 +41,7 @@ converge: fetch-depth: 0 - name: Converge - uses: werf/actions/converge@v1.2 + uses: werf/actions/converge@v2 with: kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} env: production diff --git a/converge/index.js b/converge/index.js index f5e5828..0ea0b23 100644 --- a/converge/index.js +++ b/converge/index.js @@ -12265,6 +12265,11 @@ var isArray = Array.isArray || function (xs) { var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; Cookie.prototype.parse = function parse(str, request_domain, request_path) { if (this instanceof Cookie) { + if ( str.length > 32768 ) { + console.warn("Cookie too long for parsing (>32768 characters)"); + return; + } + var parts = str.split(";").filter(function (value) { return !!value; }); @@ -21763,6 +21768,7 @@ class Comparator { static get ANY () { return ANY } + constructor (comp, options) { options = parseOptions(options) @@ -21774,6 +21780,7 @@ class Comparator { } } + comp = comp.trim().split(/\s+/).join(' ') debug('comparator', comp, options) this.options = options this.loose = !!options.loose @@ -21836,13 +21843,6 @@ class Comparator { throw new TypeError('a Comparator is required') } - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (this.operator === '') { if (this.value === '') { return true @@ -21855,39 +21855,50 @@ class Comparator { return new Range(this.value, options).test(comp.semver) } - const sameDirectionIncreasing = - (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 === '>') + options = parseOptions(options) - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) + // Special cases where nothing can possibly be lower + if (options.includePrerelease && + (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { + return false + } + 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 const parseOptions = __nccwpck_require__(3379) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const cmp = __nccwpck_require__(486) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) @@ -21927,19 +21938,26 @@ class Range { this.loose = !!options.loose 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.set = range - .split(/\s*\|\|\s*/) + .trim() + .split(/\s+/) + .join(' ') + + // First, split on || + this.set = this.raw + .split('||') // map the range to a 2d array of comparators - .map(range => this.parseRange(range.trim())) + .map(r => this.parseRange(r)) // throw out any comparator lists that are empty // 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. .filter(c => c.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. @@ -21947,9 +21965,9 @@ class Range { // keep the first one, in case they're all null sets const first = this.set[0] this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) + if (this.set.length === 0) { this.set = [first] - else if (this.set.length > 1) { + } else if (this.set.length > 1) { // if we have any that are *, then the range is just * for (const c of this.set) { if (c.length === 1 && isAny(c[0])) { @@ -21965,9 +21983,7 @@ class Range { format () { this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) + .map((comps) => comps.join(' ').trim()) .join('||') .trim() return this.range @@ -21978,15 +21994,16 @@ class Range { } parseRange (range) { - range = range.trim() - // memoize range parsing for performance. // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range const cached = cache.get(memoKey) - if (cached) + if (cached) { return cached + } const loose = this.options.loose // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` @@ -21995,7 +22012,7 @@ class Range { debug('hyphen replace', range) // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) + debug('comparator trim', range) // `~ 1.2.3` => `~1.2.3` range = range.replace(re[t.TILDETRIM], tildeTrimReplace) @@ -22003,36 +22020,40 @@ class Range { // `^ 1.2.3` => `^1.2.3` range = range.replace(re[t.CARETTRIM], caretTrimReplace) - // normalize spaces - range = range.split(/\s+/).join(' ') - // At this point, the range is completely trimmed and // ready to be split into comparators. - const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const rangeList = range + let rangeList = range .split(' ') .map(comp => parseComparator(comp, this.options)) .join(' ') .split(/\s+/) // >=0.0.0 is equivalent to * .map(comp => replaceGTE0(comp, this.options)) + + if (loose) { // in loose mode, throw out any that are not valid comparators - .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) - .map(comp => new Comparator(comp, this.options)) + rangeList = rangeList.filter(comp => { + debug('loose invalid filter', comp, this.options) + return !!comp.match(re[t.COMPARATORLOOSE]) + }) + } + debug('range list', rangeList) // if any comparators are the null set, then replace with JUST null set // if more than one comparator, remove any * comparators // also, don't include the same comparator more than once - const l = rangeList.length const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) + const comparators = rangeList.map(comp => new Comparator(comp, this.options)) + for (const comp of comparators) { + if (isNullSet(comp)) { return [comp] + } rangeMap.set(comp.value, comp) } - if (rangeMap.size > 1 && rangeMap.has('')) + if (rangeMap.size > 1 && rangeMap.has('')) { rangeMap.delete('') + } const result = [...rangeMap.values()] cache.set(memoKey, result) @@ -22083,6 +22104,7 @@ class Range { return false } } + module.exports = Range const LRU = __nccwpck_require__(9505) @@ -22093,12 +22115,13 @@ const Comparator = __nccwpck_require__(1044) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) const { - re, + safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, - caretTrimReplace + caretTrimReplace, } = __nccwpck_require__(3640) +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __nccwpck_require__(5455) const isNullSet = c => c.value === '<0.0.0-0' const isAny = c => c.value === '' @@ -22145,10 +22168,14 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <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 -const replaceTildes = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceTilde(comp, options) - }).join(' ') +// ~0.0.1 --> >=0.0.1 <0.1.0-0 +const replaceTildes = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceTilde(c, options)) + .join(' ') +} const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] @@ -22184,10 +22211,15 @@ const replaceTilde = (comp, options) => { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 // ^1.2.3 --> >=1.2.3 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0 -const replaceCarets = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceCaret(comp, options) - }).join(' ') +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 +const replaceCarets = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceCaret(c, options)) + .join(' ') +} const replaceCaret = (comp, options) => { debug('caret', comp, options) @@ -22244,9 +22276,10 @@ const replaceCaret = (comp, options) => { const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') + return comp + .split(/\s+/) + .map((c) => replaceXRange(c, options)) + .join(' ') } const replaceXRange = (comp, options) => { @@ -22306,8 +22339,9 @@ const replaceXRange = (comp, options) => { } } - if (gtlt === '<') + if (gtlt === '<') { pr = '-0' + } ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { @@ -22328,12 +22362,15 @@ const replaceXRange = (comp, options) => { const replaceStars = (comp, options) => { debug('replaceStars', comp, options) // 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) => { debug('replaceGTE0', comp, options) - return comp.trim() + return comp + .trim() .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') } @@ -22371,7 +22408,7 @@ const hyphenReplace = incPr => ($0, to = `<=${to}` } - return (`${from} ${to}`).trim() + return `${from} ${to}`.trim() } const testSet = (set, version, options) => { @@ -22418,7 +22455,7 @@ const testSet = (set, version, options) => { const debug = __nccwpck_require__(9408) const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const parseOptions = __nccwpck_require__(3379) const { compareIdentifiers } = __nccwpck_require__(3226) @@ -22434,7 +22471,7 @@ class SemVer { version = version.version } } 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) { @@ -22593,36 +22630,36 @@ class SemVer { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { + inc (release, identifier, identifierBase) { switch (release) { case 'premajor': this.prerelease.length = 0 this.patch = 0 this.minor = 0 this.major++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'preminor': this.prerelease.length = 0 this.patch = 0 this.minor++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) break // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { - this.inc('patch', identifier) + this.inc('patch', identifier, identifierBase) } - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'major': @@ -22664,9 +22701,15 @@ class SemVer { break // This probably shouldn't be used publicly. // 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) { - this.prerelease = [0] + this.prerelease = [base] } else { let i = this.prerelease.length while (--i >= 0) { @@ -22677,27 +22720,36 @@ class SemVer { } if (i === -1) { // 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) { // 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 - if (this.prerelease[0] === identifier) { + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } else { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } break - + } default: throw new Error(`invalid increment argument: ${release}`) } - this.format() - this.raw = this.version + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } return this } } @@ -22733,17 +22785,21 @@ const lte = __nccwpck_require__(2712) const cmp = (a, op, b, loose) => { switch (op) { case '===': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a === b case '!==': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a !== b case '': @@ -22780,7 +22836,7 @@ module.exports = cmp const SemVer = __nccwpck_require__(5501) const parse = __nccwpck_require__(6020) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const coerce = (version, options) => { if (version instanceof SemVer) { @@ -22823,8 +22879,9 @@ const coerce = (version, options) => { re[t.COERCERTL].lastIndex = -1 } - if (match === null) + if (match === null) { return null + } return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) } @@ -22873,27 +22930,69 @@ module.exports = compare /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const parse = __nccwpck_require__(6020) -const eq = __nccwpck_require__(6650) 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 - } 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 - } - } - } - return defaultResult // may be undefined } + + 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' + } + + 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 @@ -22934,14 +23033,18 @@ module.exports = gte const SemVer = __nccwpck_require__(5501) -const inc = (version, release, options, identifier) => { +const inc = (version, release, options, identifier, identifierBase) => { if (typeof (options) === 'string') { + identifierBase = identifier identifier = options options = undefined } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier, identifierBase).version } catch (er) { return null } @@ -23004,35 +23107,18 @@ module.exports = neq /***/ 6020: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) const SemVer = __nccwpck_require__(5501) - -const parseOptions = __nccwpck_require__(3379) -const parse = (version, options) => { - options = parseOptions(options) - +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { 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 { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } @@ -23129,51 +23215,92 @@ module.exports = valid // just pre-load all the stuff that index.js lazily exports const internalRe = __nccwpck_require__(3640) +const constants = __nccwpck_require__(5455) +const SemVer = __nccwpck_require__(5501) +const identifiers = __nccwpck_require__(3226) +const parse = __nccwpck_require__(6020) +const valid = __nccwpck_require__(8573) +const clean = __nccwpck_require__(9154) +const inc = __nccwpck_require__(2100) +const diff = __nccwpck_require__(7693) +const major = __nccwpck_require__(625) +const minor = __nccwpck_require__(2019) +const patch = __nccwpck_require__(1215) +const prerelease = __nccwpck_require__(8761) +const compare = __nccwpck_require__(1366) +const rcompare = __nccwpck_require__(8316) +const compareLoose = __nccwpck_require__(554) +const compareBuild = __nccwpck_require__(4450) +const sort = __nccwpck_require__(3211) +const rsort = __nccwpck_require__(5090) +const gt = __nccwpck_require__(3788) +const lt = __nccwpck_require__(1125) +const eq = __nccwpck_require__(6650) +const neq = __nccwpck_require__(2098) +const gte = __nccwpck_require__(5280) +const lte = __nccwpck_require__(2712) +const cmp = __nccwpck_require__(486) +const coerce = __nccwpck_require__(3669) +const Comparator = __nccwpck_require__(1044) +const Range = __nccwpck_require__(1838) +const satisfies = __nccwpck_require__(8840) +const toComparators = __nccwpck_require__(4017) +const maxSatisfying = __nccwpck_require__(7093) +const minSatisfying = __nccwpck_require__(3916) +const minVersion = __nccwpck_require__(6344) +const validRange = __nccwpck_require__(1757) +const outside = __nccwpck_require__(8437) +const gtr = __nccwpck_require__(1555) +const ltr = __nccwpck_require__(6732) +const intersects = __nccwpck_require__(184) +const simplifyRange = __nccwpck_require__(530) +const subset = __nccwpck_require__(1132) module.exports = { + parse, + valid, + clean, + inc, + diff, + major, + minor, + patch, + prerelease, + compare, + rcompare, + compareLoose, + compareBuild, + sort, + rsort, + gt, + lt, + eq, + neq, + gte, + lte, + cmp, + coerce, + Comparator, + Range, + satisfies, + toComparators, + maxSatisfying, + minSatisfying, + minVersion, + validRange, + outside, + gtr, + ltr, + intersects, + simplifyRange, + subset, + SemVer, re: internalRe.re, src: internalRe.src, tokens: internalRe.t, - SEMVER_SPEC_VERSION: (__nccwpck_require__(5455).SEMVER_SPEC_VERSION), - SemVer: __nccwpck_require__(5501), - compareIdentifiers: (__nccwpck_require__(3226).compareIdentifiers), - rcompareIdentifiers: (__nccwpck_require__(3226).rcompareIdentifiers), - parse: __nccwpck_require__(6020), - valid: __nccwpck_require__(8573), - clean: __nccwpck_require__(9154), - inc: __nccwpck_require__(2100), - diff: __nccwpck_require__(7693), - major: __nccwpck_require__(625), - minor: __nccwpck_require__(2019), - patch: __nccwpck_require__(1215), - prerelease: __nccwpck_require__(8761), - compare: __nccwpck_require__(1366), - rcompare: __nccwpck_require__(8316), - compareLoose: __nccwpck_require__(554), - compareBuild: __nccwpck_require__(4450), - sort: __nccwpck_require__(3211), - rsort: __nccwpck_require__(5090), - gt: __nccwpck_require__(3788), - lt: __nccwpck_require__(1125), - eq: __nccwpck_require__(6650), - neq: __nccwpck_require__(2098), - gte: __nccwpck_require__(5280), - lte: __nccwpck_require__(2712), - cmp: __nccwpck_require__(486), - coerce: __nccwpck_require__(3669), - Comparator: __nccwpck_require__(1044), - Range: __nccwpck_require__(1838), - satisfies: __nccwpck_require__(8840), - toComparators: __nccwpck_require__(4017), - maxSatisfying: __nccwpck_require__(7093), - minSatisfying: __nccwpck_require__(3916), - minVersion: __nccwpck_require__(6344), - validRange: __nccwpck_require__(1757), - outside: __nccwpck_require__(8437), - gtr: __nccwpck_require__(1555), - ltr: __nccwpck_require__(6732), - intersects: __nccwpck_require__(184), - simplifyRange: __nccwpck_require__(530), - subset: __nccwpck_require__(1132), + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, } @@ -23188,16 +23315,29 @@ const SEMVER_SPEC_VERSION = '2.0.0' const MAX_LENGTH = 256 const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/* istanbul ignore next */ 9007199254740991 // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, } @@ -23243,7 +23383,7 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, - rcompareIdentifiers + rcompareIdentifiers, } @@ -23252,16 +23392,20 @@ module.exports = { /***/ 3379: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} module.exports = parseOptions @@ -23276,16 +23420,27 @@ exports = module.exports = {} // The actual regexps go on exports.re const re = exports.re = [] +const safeRe = exports.safeRe = [] const src = exports.src = [] const t = exports.t = {} let R = 0 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++ - debug(index, value) + debug(name, index, value) t[name] = index src[index] = value 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, @@ -23450,8 +23605,8 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + // Star ranges basically just allow anything at all. createToken('STAR', '(<|>)?=?\\s*\\*') // >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), @@ -23474,7 +23629,7 @@ const Range = __nccwpck_require__(1838) const intersects = (r1, r2, options) => { r1 = new Range(r1, options) r2 = new Range(r2, options) - return r1.intersects(r2) + return r1.intersects(r2, options) } module.exports = intersects @@ -23607,8 +23762,9 @@ const minVersion = (range, loose) => { throw new Error(`Unexpected operation: ${comparator.operator}`) } }) - if (setMin && (!minver || gt(minver, setMin))) + if (setMin && (!minver || gt(minver, setMin))) { minver = setMin + } } if (minver && range.test(minver)) { @@ -23627,7 +23783,7 @@ module.exports = minVersion const SemVer = __nccwpck_require__(5501) const Comparator = __nccwpck_require__(1044) -const {ANY} = Comparator +const { ANY } = Comparator const Range = __nccwpck_require__(1838) const satisfies = __nccwpck_require__(8840) const gt = __nccwpck_require__(3788) @@ -23719,38 +23875,41 @@ const satisfies = __nccwpck_require__(8840) const compare = __nccwpck_require__(1366) module.exports = (versions, range, options) => { const set = [] - let min = null + let first = null let prev = null const v = versions.sort((a, b) => compare(a, b, options)) for (const version of v) { const included = satisfies(version, range, options) if (included) { prev = version - if (!min) - min = version + if (!first) { + first = version + } } else { if (prev) { - set.push([min, prev]) + set.push([first, prev]) } prev = null - min = null + first = null } } - if (min) - set.push([min, null]) + if (first) { + set.push([first, null]) + } const ranges = [] for (const [min, max] of set) { - if (min === max) + if (min === max) { ranges.push(min) - else if (!max && min === v[0]) + } else if (!max && min === v[0]) { ranges.push('*') - else if (!max) + } else if (!max) { ranges.push(`>=${min}`) - else if (min === v[0]) + } else if (min === v[0]) { ranges.push(`<=${max}`) - else + } else { ranges.push(`${min} - ${max}`) + } } const simplified = ranges.join(' || ') const original = typeof range.raw === 'string' ? range.raw : String(range) @@ -23806,8 +23965,9 @@ const compare = __nccwpck_require__(1366) // - Else return true const subset = (sub, dom, options = {}) => { - if (sub === dom) + if (sub === dom) { return true + } sub = new Range(sub, options) dom = new Range(dom, options) @@ -23817,73 +23977,87 @@ const subset = (sub, dom, options = {}) => { for (const simpleDom of dom.set) { const isSub = simpleSubset(simpleSub, simpleDom, options) sawNonNull = sawNonNull || isSub !== null - if (isSub) + if (isSub) { continue OUTER + } } // the null set is a subset of everything, but null simple ranges in // a complex range should be ignored. so if we saw a non-null range, // then we know this isn't a subset, but if EVERY simple range was null, // then it is a subset. - if (sawNonNull) + if (sawNonNull) { return false + } } return true } +const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] +const minimumVersion = [new Comparator('>=0.0.0')] + const simpleSubset = (sub, dom, options) => { - if (sub === dom) + if (sub === dom) { return true + } if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) + if (dom.length === 1 && dom[0].semver === ANY) { return true - else if (options.includePrerelease) - sub = [ new Comparator('>=0.0.0-0') ] - else - sub = [ new Comparator('>=0.0.0') ] + } else if (options.includePrerelease) { + sub = minimumVersionWithPreRelease + } else { + sub = minimumVersion + } } if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) + if (options.includePrerelease) { return true - else - dom = [ new Comparator('>=0.0.0') ] + } else { + dom = minimumVersion + } } const eqSet = new Set() let gt, lt for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') + if (c.operator === '>' || c.operator === '>=') { gt = higherGT(gt, c, options) - else if (c.operator === '<' || c.operator === '<=') + } else if (c.operator === '<' || c.operator === '<=') { lt = lowerLT(lt, c, options) - else + } else { eqSet.add(c.semver) + } } - if (eqSet.size > 1) + if (eqSet.size > 1) { return null + } let gtltComp if (gt && lt) { gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) + if (gtltComp > 0) { return null - else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { return null + } } // will iterate one or zero times for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) + if (gt && !satisfies(eq, String(gt), options)) { return null + } - if (lt && !satisfies(eq, String(lt), options)) + if (lt && !satisfies(eq, String(lt), options)) { return null + } for (const c of dom) { - if (!satisfies(eq, String(c), options)) + if (!satisfies(eq, String(c), options)) { return false + } } return true @@ -23919,10 +24093,12 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '>' || c.operator === '>=') { higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) + if (higher === c && higher !== gt) { return false - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + } + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { return false + } } if (lt) { if (needDomLTPre) { @@ -23935,37 +24111,44 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '<' || c.operator === '<=') { lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) + if (lower === c && lower !== lt) { return false - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + } + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { return false + } } - if (!c.operator && (lt || gt) && gtltComp !== 0) + if (!c.operator && (lt || gt) && gtltComp !== 0) { return false + } } // if there was a < or >, and nothing in the dom, then must be false // UNLESS it was limited by another range in the other direction. // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) + if (gt && hasDomLT && !lt && gtltComp !== 0) { return false + } - if (lt && hasDomGT && !gt && gtltComp !== 0) + if (lt && hasDomGT && !gt && gtltComp !== 0) { return false + } // we needed a prerelease range in a specific tuple, but didn't get one // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) + if (needDomGTPre || needDomLTPre) { return false + } return true } // >=1.2.3 is lower than >1.2.3 const higherGT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp > 0 ? a : comp < 0 ? b @@ -23975,8 +24158,9 @@ const higherGT = (a, b, options) => { // <=1.2.3 is higher than <1.2.3 const lowerLT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp < 0 ? a : comp > 0 ? b @@ -31637,7 +31821,6 @@ const github_1 = __nccwpck_require__(2726); const typescript_string_operations_1 = __nccwpck_require__(9363); const manager_1 = __nccwpck_require__(1856); const werf = __importStar(__nccwpck_require__(8525)); -const minimalWerfVersion = 'v1.1.17'; function PrepareEnvironAndRunWerfCommand(args) { return __awaiter(this, void 0, void 0, function* () { try { @@ -31690,15 +31873,10 @@ function ProcessGitHubContext() { exports.ProcessGitHubContext = ProcessGitHubContext; function ValidateWerfVersion(version) { const ver = semver.coerce(version); - if (ver) { - if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) { - throw new Error(typescript_string_operations_1.String.Format('The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})', version.trim(), werf.MAJOR_MINOR_GROUP)); - } - if (semver.gte(ver, minimalWerfVersion)) { - return; - } + if (ver && ver.major === werf.MAJOR) { + return; } - throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported (expected version must be equal or greater than {1})', version.trim(), minimalWerfVersion)); + throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', version.trim(), werf.GROUP)); } exports.ValidateWerfVersion = ValidateWerfVersion; @@ -31899,7 +32077,7 @@ class Manager { const version = this.version.slice('v'.length); return this._constructReleaseUrl(version); } - const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`; + const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}`; try { const resp = yield request .get(url) @@ -31966,10 +32144,9 @@ exports.Manager = Manager; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MINOR = exports.MAJOR = exports.MAJOR_MINOR_GROUP = void 0; -exports.MAJOR_MINOR_GROUP = '1.2'; -exports.MAJOR = 1; -exports.MINOR = 2; +exports.MAJOR = exports.GROUP = void 0; +exports.GROUP = '2'; +exports.MAJOR = 2; /***/ }), diff --git a/dismiss/README.md b/dismiss/README.md index 8c5a1e7..d94cc23 100644 --- a/dismiss/README.md +++ b/dismiss/README.md @@ -39,7 +39,7 @@ dismiss: uses: actions/checkout@v4 - name: Dismiss - uses: werf/actions/dismiss@v1.2 + uses: werf/actions/dismiss@v2 with: kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} env: production diff --git a/dismiss/index.js b/dismiss/index.js index 486d0e3..a4d2a0c 100644 --- a/dismiss/index.js +++ b/dismiss/index.js @@ -12265,6 +12265,11 @@ var isArray = Array.isArray || function (xs) { var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; Cookie.prototype.parse = function parse(str, request_domain, request_path) { if (this instanceof Cookie) { + if ( str.length > 32768 ) { + console.warn("Cookie too long for parsing (>32768 characters)"); + return; + } + var parts = str.split(";").filter(function (value) { return !!value; }); @@ -21763,6 +21768,7 @@ class Comparator { static get ANY () { return ANY } + constructor (comp, options) { options = parseOptions(options) @@ -21774,6 +21780,7 @@ class Comparator { } } + comp = comp.trim().split(/\s+/).join(' ') debug('comparator', comp, options) this.options = options this.loose = !!options.loose @@ -21836,13 +21843,6 @@ class Comparator { throw new TypeError('a Comparator is required') } - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (this.operator === '') { if (this.value === '') { return true @@ -21855,39 +21855,50 @@ class Comparator { return new Range(this.value, options).test(comp.semver) } - const sameDirectionIncreasing = - (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 === '>') + options = parseOptions(options) - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) + // Special cases where nothing can possibly be lower + if (options.includePrerelease && + (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { + return false + } + 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 const parseOptions = __nccwpck_require__(3379) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const cmp = __nccwpck_require__(486) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) @@ -21927,19 +21938,26 @@ class Range { this.loose = !!options.loose 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.set = range - .split(/\s*\|\|\s*/) + .trim() + .split(/\s+/) + .join(' ') + + // First, split on || + this.set = this.raw + .split('||') // map the range to a 2d array of comparators - .map(range => this.parseRange(range.trim())) + .map(r => this.parseRange(r)) // throw out any comparator lists that are empty // 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. .filter(c => c.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. @@ -21947,9 +21965,9 @@ class Range { // keep the first one, in case they're all null sets const first = this.set[0] this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) + if (this.set.length === 0) { this.set = [first] - else if (this.set.length > 1) { + } else if (this.set.length > 1) { // if we have any that are *, then the range is just * for (const c of this.set) { if (c.length === 1 && isAny(c[0])) { @@ -21965,9 +21983,7 @@ class Range { format () { this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) + .map((comps) => comps.join(' ').trim()) .join('||') .trim() return this.range @@ -21978,15 +21994,16 @@ class Range { } parseRange (range) { - range = range.trim() - // memoize range parsing for performance. // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range const cached = cache.get(memoKey) - if (cached) + if (cached) { return cached + } const loose = this.options.loose // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` @@ -21995,7 +22012,7 @@ class Range { debug('hyphen replace', range) // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) + debug('comparator trim', range) // `~ 1.2.3` => `~1.2.3` range = range.replace(re[t.TILDETRIM], tildeTrimReplace) @@ -22003,36 +22020,40 @@ class Range { // `^ 1.2.3` => `^1.2.3` range = range.replace(re[t.CARETTRIM], caretTrimReplace) - // normalize spaces - range = range.split(/\s+/).join(' ') - // At this point, the range is completely trimmed and // ready to be split into comparators. - const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const rangeList = range + let rangeList = range .split(' ') .map(comp => parseComparator(comp, this.options)) .join(' ') .split(/\s+/) // >=0.0.0 is equivalent to * .map(comp => replaceGTE0(comp, this.options)) + + if (loose) { // in loose mode, throw out any that are not valid comparators - .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) - .map(comp => new Comparator(comp, this.options)) + rangeList = rangeList.filter(comp => { + debug('loose invalid filter', comp, this.options) + return !!comp.match(re[t.COMPARATORLOOSE]) + }) + } + debug('range list', rangeList) // if any comparators are the null set, then replace with JUST null set // if more than one comparator, remove any * comparators // also, don't include the same comparator more than once - const l = rangeList.length const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) + const comparators = rangeList.map(comp => new Comparator(comp, this.options)) + for (const comp of comparators) { + if (isNullSet(comp)) { return [comp] + } rangeMap.set(comp.value, comp) } - if (rangeMap.size > 1 && rangeMap.has('')) + if (rangeMap.size > 1 && rangeMap.has('')) { rangeMap.delete('') + } const result = [...rangeMap.values()] cache.set(memoKey, result) @@ -22083,6 +22104,7 @@ class Range { return false } } + module.exports = Range const LRU = __nccwpck_require__(9505) @@ -22093,12 +22115,13 @@ const Comparator = __nccwpck_require__(1044) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) const { - re, + safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, - caretTrimReplace + caretTrimReplace, } = __nccwpck_require__(3640) +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __nccwpck_require__(5455) const isNullSet = c => c.value === '<0.0.0-0' const isAny = c => c.value === '' @@ -22145,10 +22168,14 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <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 -const replaceTildes = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceTilde(comp, options) - }).join(' ') +// ~0.0.1 --> >=0.0.1 <0.1.0-0 +const replaceTildes = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceTilde(c, options)) + .join(' ') +} const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] @@ -22184,10 +22211,15 @@ const replaceTilde = (comp, options) => { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 // ^1.2.3 --> >=1.2.3 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0 -const replaceCarets = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceCaret(comp, options) - }).join(' ') +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 +const replaceCarets = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceCaret(c, options)) + .join(' ') +} const replaceCaret = (comp, options) => { debug('caret', comp, options) @@ -22244,9 +22276,10 @@ const replaceCaret = (comp, options) => { const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') + return comp + .split(/\s+/) + .map((c) => replaceXRange(c, options)) + .join(' ') } const replaceXRange = (comp, options) => { @@ -22306,8 +22339,9 @@ const replaceXRange = (comp, options) => { } } - if (gtlt === '<') + if (gtlt === '<') { pr = '-0' + } ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { @@ -22328,12 +22362,15 @@ const replaceXRange = (comp, options) => { const replaceStars = (comp, options) => { debug('replaceStars', comp, options) // 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) => { debug('replaceGTE0', comp, options) - return comp.trim() + return comp + .trim() .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') } @@ -22371,7 +22408,7 @@ const hyphenReplace = incPr => ($0, to = `<=${to}` } - return (`${from} ${to}`).trim() + return `${from} ${to}`.trim() } const testSet = (set, version, options) => { @@ -22418,7 +22455,7 @@ const testSet = (set, version, options) => { const debug = __nccwpck_require__(9408) const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const parseOptions = __nccwpck_require__(3379) const { compareIdentifiers } = __nccwpck_require__(3226) @@ -22434,7 +22471,7 @@ class SemVer { version = version.version } } 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) { @@ -22593,36 +22630,36 @@ class SemVer { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { + inc (release, identifier, identifierBase) { switch (release) { case 'premajor': this.prerelease.length = 0 this.patch = 0 this.minor = 0 this.major++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'preminor': this.prerelease.length = 0 this.patch = 0 this.minor++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) break // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { - this.inc('patch', identifier) + this.inc('patch', identifier, identifierBase) } - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'major': @@ -22664,9 +22701,15 @@ class SemVer { break // This probably shouldn't be used publicly. // 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) { - this.prerelease = [0] + this.prerelease = [base] } else { let i = this.prerelease.length while (--i >= 0) { @@ -22677,27 +22720,36 @@ class SemVer { } if (i === -1) { // 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) { // 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 - if (this.prerelease[0] === identifier) { + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } else { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } break - + } default: throw new Error(`invalid increment argument: ${release}`) } - this.format() - this.raw = this.version + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } return this } } @@ -22733,17 +22785,21 @@ const lte = __nccwpck_require__(2712) const cmp = (a, op, b, loose) => { switch (op) { case '===': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a === b case '!==': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a !== b case '': @@ -22780,7 +22836,7 @@ module.exports = cmp const SemVer = __nccwpck_require__(5501) const parse = __nccwpck_require__(6020) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const coerce = (version, options) => { if (version instanceof SemVer) { @@ -22823,8 +22879,9 @@ const coerce = (version, options) => { re[t.COERCERTL].lastIndex = -1 } - if (match === null) + if (match === null) { return null + } return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) } @@ -22873,27 +22930,69 @@ module.exports = compare /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const parse = __nccwpck_require__(6020) -const eq = __nccwpck_require__(6650) 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 - } 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 - } - } - } - return defaultResult // may be undefined } + + 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' + } + + 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 @@ -22934,14 +23033,18 @@ module.exports = gte const SemVer = __nccwpck_require__(5501) -const inc = (version, release, options, identifier) => { +const inc = (version, release, options, identifier, identifierBase) => { if (typeof (options) === 'string') { + identifierBase = identifier identifier = options options = undefined } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier, identifierBase).version } catch (er) { return null } @@ -23004,35 +23107,18 @@ module.exports = neq /***/ 6020: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) const SemVer = __nccwpck_require__(5501) - -const parseOptions = __nccwpck_require__(3379) -const parse = (version, options) => { - options = parseOptions(options) - +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { 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 { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } @@ -23129,51 +23215,92 @@ module.exports = valid // just pre-load all the stuff that index.js lazily exports const internalRe = __nccwpck_require__(3640) +const constants = __nccwpck_require__(5455) +const SemVer = __nccwpck_require__(5501) +const identifiers = __nccwpck_require__(3226) +const parse = __nccwpck_require__(6020) +const valid = __nccwpck_require__(8573) +const clean = __nccwpck_require__(9154) +const inc = __nccwpck_require__(2100) +const diff = __nccwpck_require__(7693) +const major = __nccwpck_require__(625) +const minor = __nccwpck_require__(2019) +const patch = __nccwpck_require__(1215) +const prerelease = __nccwpck_require__(8761) +const compare = __nccwpck_require__(1366) +const rcompare = __nccwpck_require__(8316) +const compareLoose = __nccwpck_require__(554) +const compareBuild = __nccwpck_require__(4450) +const sort = __nccwpck_require__(3211) +const rsort = __nccwpck_require__(5090) +const gt = __nccwpck_require__(3788) +const lt = __nccwpck_require__(1125) +const eq = __nccwpck_require__(6650) +const neq = __nccwpck_require__(2098) +const gte = __nccwpck_require__(5280) +const lte = __nccwpck_require__(2712) +const cmp = __nccwpck_require__(486) +const coerce = __nccwpck_require__(3669) +const Comparator = __nccwpck_require__(1044) +const Range = __nccwpck_require__(1838) +const satisfies = __nccwpck_require__(8840) +const toComparators = __nccwpck_require__(4017) +const maxSatisfying = __nccwpck_require__(7093) +const minSatisfying = __nccwpck_require__(3916) +const minVersion = __nccwpck_require__(6344) +const validRange = __nccwpck_require__(1757) +const outside = __nccwpck_require__(8437) +const gtr = __nccwpck_require__(1555) +const ltr = __nccwpck_require__(6732) +const intersects = __nccwpck_require__(184) +const simplifyRange = __nccwpck_require__(530) +const subset = __nccwpck_require__(1132) module.exports = { + parse, + valid, + clean, + inc, + diff, + major, + minor, + patch, + prerelease, + compare, + rcompare, + compareLoose, + compareBuild, + sort, + rsort, + gt, + lt, + eq, + neq, + gte, + lte, + cmp, + coerce, + Comparator, + Range, + satisfies, + toComparators, + maxSatisfying, + minSatisfying, + minVersion, + validRange, + outside, + gtr, + ltr, + intersects, + simplifyRange, + subset, + SemVer, re: internalRe.re, src: internalRe.src, tokens: internalRe.t, - SEMVER_SPEC_VERSION: (__nccwpck_require__(5455).SEMVER_SPEC_VERSION), - SemVer: __nccwpck_require__(5501), - compareIdentifiers: (__nccwpck_require__(3226).compareIdentifiers), - rcompareIdentifiers: (__nccwpck_require__(3226).rcompareIdentifiers), - parse: __nccwpck_require__(6020), - valid: __nccwpck_require__(8573), - clean: __nccwpck_require__(9154), - inc: __nccwpck_require__(2100), - diff: __nccwpck_require__(7693), - major: __nccwpck_require__(625), - minor: __nccwpck_require__(2019), - patch: __nccwpck_require__(1215), - prerelease: __nccwpck_require__(8761), - compare: __nccwpck_require__(1366), - rcompare: __nccwpck_require__(8316), - compareLoose: __nccwpck_require__(554), - compareBuild: __nccwpck_require__(4450), - sort: __nccwpck_require__(3211), - rsort: __nccwpck_require__(5090), - gt: __nccwpck_require__(3788), - lt: __nccwpck_require__(1125), - eq: __nccwpck_require__(6650), - neq: __nccwpck_require__(2098), - gte: __nccwpck_require__(5280), - lte: __nccwpck_require__(2712), - cmp: __nccwpck_require__(486), - coerce: __nccwpck_require__(3669), - Comparator: __nccwpck_require__(1044), - Range: __nccwpck_require__(1838), - satisfies: __nccwpck_require__(8840), - toComparators: __nccwpck_require__(4017), - maxSatisfying: __nccwpck_require__(7093), - minSatisfying: __nccwpck_require__(3916), - minVersion: __nccwpck_require__(6344), - validRange: __nccwpck_require__(1757), - outside: __nccwpck_require__(8437), - gtr: __nccwpck_require__(1555), - ltr: __nccwpck_require__(6732), - intersects: __nccwpck_require__(184), - simplifyRange: __nccwpck_require__(530), - subset: __nccwpck_require__(1132), + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, } @@ -23188,16 +23315,29 @@ const SEMVER_SPEC_VERSION = '2.0.0' const MAX_LENGTH = 256 const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/* istanbul ignore next */ 9007199254740991 // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, } @@ -23243,7 +23383,7 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, - rcompareIdentifiers + rcompareIdentifiers, } @@ -23252,16 +23392,20 @@ module.exports = { /***/ 3379: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} module.exports = parseOptions @@ -23276,16 +23420,27 @@ exports = module.exports = {} // The actual regexps go on exports.re const re = exports.re = [] +const safeRe = exports.safeRe = [] const src = exports.src = [] const t = exports.t = {} let R = 0 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++ - debug(index, value) + debug(name, index, value) t[name] = index src[index] = value 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, @@ -23450,8 +23605,8 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + // Star ranges basically just allow anything at all. createToken('STAR', '(<|>)?=?\\s*\\*') // >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), @@ -23474,7 +23629,7 @@ const Range = __nccwpck_require__(1838) const intersects = (r1, r2, options) => { r1 = new Range(r1, options) r2 = new Range(r2, options) - return r1.intersects(r2) + return r1.intersects(r2, options) } module.exports = intersects @@ -23607,8 +23762,9 @@ const minVersion = (range, loose) => { throw new Error(`Unexpected operation: ${comparator.operator}`) } }) - if (setMin && (!minver || gt(minver, setMin))) + if (setMin && (!minver || gt(minver, setMin))) { minver = setMin + } } if (minver && range.test(minver)) { @@ -23627,7 +23783,7 @@ module.exports = minVersion const SemVer = __nccwpck_require__(5501) const Comparator = __nccwpck_require__(1044) -const {ANY} = Comparator +const { ANY } = Comparator const Range = __nccwpck_require__(1838) const satisfies = __nccwpck_require__(8840) const gt = __nccwpck_require__(3788) @@ -23719,38 +23875,41 @@ const satisfies = __nccwpck_require__(8840) const compare = __nccwpck_require__(1366) module.exports = (versions, range, options) => { const set = [] - let min = null + let first = null let prev = null const v = versions.sort((a, b) => compare(a, b, options)) for (const version of v) { const included = satisfies(version, range, options) if (included) { prev = version - if (!min) - min = version + if (!first) { + first = version + } } else { if (prev) { - set.push([min, prev]) + set.push([first, prev]) } prev = null - min = null + first = null } } - if (min) - set.push([min, null]) + if (first) { + set.push([first, null]) + } const ranges = [] for (const [min, max] of set) { - if (min === max) + if (min === max) { ranges.push(min) - else if (!max && min === v[0]) + } else if (!max && min === v[0]) { ranges.push('*') - else if (!max) + } else if (!max) { ranges.push(`>=${min}`) - else if (min === v[0]) + } else if (min === v[0]) { ranges.push(`<=${max}`) - else + } else { ranges.push(`${min} - ${max}`) + } } const simplified = ranges.join(' || ') const original = typeof range.raw === 'string' ? range.raw : String(range) @@ -23806,8 +23965,9 @@ const compare = __nccwpck_require__(1366) // - Else return true const subset = (sub, dom, options = {}) => { - if (sub === dom) + if (sub === dom) { return true + } sub = new Range(sub, options) dom = new Range(dom, options) @@ -23817,73 +23977,87 @@ const subset = (sub, dom, options = {}) => { for (const simpleDom of dom.set) { const isSub = simpleSubset(simpleSub, simpleDom, options) sawNonNull = sawNonNull || isSub !== null - if (isSub) + if (isSub) { continue OUTER + } } // the null set is a subset of everything, but null simple ranges in // a complex range should be ignored. so if we saw a non-null range, // then we know this isn't a subset, but if EVERY simple range was null, // then it is a subset. - if (sawNonNull) + if (sawNonNull) { return false + } } return true } +const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] +const minimumVersion = [new Comparator('>=0.0.0')] + const simpleSubset = (sub, dom, options) => { - if (sub === dom) + if (sub === dom) { return true + } if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) + if (dom.length === 1 && dom[0].semver === ANY) { return true - else if (options.includePrerelease) - sub = [ new Comparator('>=0.0.0-0') ] - else - sub = [ new Comparator('>=0.0.0') ] + } else if (options.includePrerelease) { + sub = minimumVersionWithPreRelease + } else { + sub = minimumVersion + } } if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) + if (options.includePrerelease) { return true - else - dom = [ new Comparator('>=0.0.0') ] + } else { + dom = minimumVersion + } } const eqSet = new Set() let gt, lt for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') + if (c.operator === '>' || c.operator === '>=') { gt = higherGT(gt, c, options) - else if (c.operator === '<' || c.operator === '<=') + } else if (c.operator === '<' || c.operator === '<=') { lt = lowerLT(lt, c, options) - else + } else { eqSet.add(c.semver) + } } - if (eqSet.size > 1) + if (eqSet.size > 1) { return null + } let gtltComp if (gt && lt) { gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) + if (gtltComp > 0) { return null - else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { return null + } } // will iterate one or zero times for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) + if (gt && !satisfies(eq, String(gt), options)) { return null + } - if (lt && !satisfies(eq, String(lt), options)) + if (lt && !satisfies(eq, String(lt), options)) { return null + } for (const c of dom) { - if (!satisfies(eq, String(c), options)) + if (!satisfies(eq, String(c), options)) { return false + } } return true @@ -23919,10 +24093,12 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '>' || c.operator === '>=') { higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) + if (higher === c && higher !== gt) { return false - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + } + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { return false + } } if (lt) { if (needDomLTPre) { @@ -23935,37 +24111,44 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '<' || c.operator === '<=') { lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) + if (lower === c && lower !== lt) { return false - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + } + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { return false + } } - if (!c.operator && (lt || gt) && gtltComp !== 0) + if (!c.operator && (lt || gt) && gtltComp !== 0) { return false + } } // if there was a < or >, and nothing in the dom, then must be false // UNLESS it was limited by another range in the other direction. // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) + if (gt && hasDomLT && !lt && gtltComp !== 0) { return false + } - if (lt && hasDomGT && !gt && gtltComp !== 0) + if (lt && hasDomGT && !gt && gtltComp !== 0) { return false + } // we needed a prerelease range in a specific tuple, but didn't get one // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) + if (needDomGTPre || needDomLTPre) { return false + } return true } // >=1.2.3 is lower than >1.2.3 const higherGT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp > 0 ? a : comp < 0 ? b @@ -23975,8 +24158,9 @@ const higherGT = (a, b, options) => { // <=1.2.3 is higher than <1.2.3 const lowerLT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp < 0 ? a : comp > 0 ? b @@ -31637,7 +31821,6 @@ const github_1 = __nccwpck_require__(2726); const typescript_string_operations_1 = __nccwpck_require__(9363); const manager_1 = __nccwpck_require__(1856); const werf = __importStar(__nccwpck_require__(8525)); -const minimalWerfVersion = 'v1.1.17'; function PrepareEnvironAndRunWerfCommand(args) { return __awaiter(this, void 0, void 0, function* () { try { @@ -31690,15 +31873,10 @@ function ProcessGitHubContext() { exports.ProcessGitHubContext = ProcessGitHubContext; function ValidateWerfVersion(version) { const ver = semver.coerce(version); - if (ver) { - if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) { - throw new Error(typescript_string_operations_1.String.Format('The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})', version.trim(), werf.MAJOR_MINOR_GROUP)); - } - if (semver.gte(ver, minimalWerfVersion)) { - return; - } + if (ver && ver.major === werf.MAJOR) { + return; } - throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported (expected version must be equal or greater than {1})', version.trim(), minimalWerfVersion)); + throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', version.trim(), werf.GROUP)); } exports.ValidateWerfVersion = ValidateWerfVersion; @@ -31899,7 +32077,7 @@ class Manager { const version = this.version.slice('v'.length); return this._constructReleaseUrl(version); } - const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`; + const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}`; try { const resp = yield request .get(url) @@ -31966,10 +32144,9 @@ exports.Manager = Manager; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MINOR = exports.MAJOR = exports.MAJOR_MINOR_GROUP = void 0; -exports.MAJOR_MINOR_GROUP = '1.2'; -exports.MAJOR = 1; -exports.MINOR = 2; +exports.MAJOR = exports.GROUP = void 0; +exports.GROUP = '2'; +exports.MAJOR = 2; /***/ }), diff --git a/install/README.md b/install/README.md index 83d2350..be3f253 100644 --- a/install/README.md +++ b/install/README.md @@ -9,7 +9,7 @@ Using the `channel` input the user can switch the release channel. > This is recommended approach to be up-to-date and to use actual werf version without changing configurations ```yaml -- uses: werf/actions/install@v1.2 +- uses: werf/actions/install@v2 with: channel: alpha ``` @@ -17,9 +17,9 @@ Using the `channel` input the user can switch the release channel. Withal, it is not necessary to work within release channels, and the user might specify certain werf version with `version` input. ```yaml -- uses: werf/actions/install@v1.2 +- uses: werf/actions/install@v2 with: - version: v1.2.9 + version: v2.1.0 ``` ## Inputs @@ -46,7 +46,7 @@ werf: uses: actions/checkout@v4 - name: Install werf CLI - uses: werf/actions/install@v1.2 + uses: werf/actions/install@v2 # For deploy and distributed locks. - name: Create kube config diff --git a/install/index.js b/install/index.js index 05d6e9d..21872d6 100644 --- a/install/index.js +++ b/install/index.js @@ -12265,6 +12265,11 @@ var isArray = Array.isArray || function (xs) { var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; Cookie.prototype.parse = function parse(str, request_domain, request_path) { if (this instanceof Cookie) { + if ( str.length > 32768 ) { + console.warn("Cookie too long for parsing (>32768 characters)"); + return; + } + var parts = str.split(";").filter(function (value) { return !!value; }); @@ -21763,6 +21768,7 @@ class Comparator { static get ANY () { return ANY } + constructor (comp, options) { options = parseOptions(options) @@ -21774,6 +21780,7 @@ class Comparator { } } + comp = comp.trim().split(/\s+/).join(' ') debug('comparator', comp, options) this.options = options this.loose = !!options.loose @@ -21836,13 +21843,6 @@ class Comparator { throw new TypeError('a Comparator is required') } - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (this.operator === '') { if (this.value === '') { return true @@ -21855,39 +21855,50 @@ class Comparator { return new Range(this.value, options).test(comp.semver) } - const sameDirectionIncreasing = - (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 === '>') + options = parseOptions(options) - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) + // Special cases where nothing can possibly be lower + if (options.includePrerelease && + (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { + return false + } + 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 const parseOptions = __nccwpck_require__(3379) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const cmp = __nccwpck_require__(486) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) @@ -21927,19 +21938,26 @@ class Range { this.loose = !!options.loose 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.set = range - .split(/\s*\|\|\s*/) + .trim() + .split(/\s+/) + .join(' ') + + // First, split on || + this.set = this.raw + .split('||') // map the range to a 2d array of comparators - .map(range => this.parseRange(range.trim())) + .map(r => this.parseRange(r)) // throw out any comparator lists that are empty // 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. .filter(c => c.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. @@ -21947,9 +21965,9 @@ class Range { // keep the first one, in case they're all null sets const first = this.set[0] this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) + if (this.set.length === 0) { this.set = [first] - else if (this.set.length > 1) { + } else if (this.set.length > 1) { // if we have any that are *, then the range is just * for (const c of this.set) { if (c.length === 1 && isAny(c[0])) { @@ -21965,9 +21983,7 @@ class Range { format () { this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) + .map((comps) => comps.join(' ').trim()) .join('||') .trim() return this.range @@ -21978,15 +21994,16 @@ class Range { } parseRange (range) { - range = range.trim() - // memoize range parsing for performance. // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range const cached = cache.get(memoKey) - if (cached) + if (cached) { return cached + } const loose = this.options.loose // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` @@ -21995,7 +22012,7 @@ class Range { debug('hyphen replace', range) // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) + debug('comparator trim', range) // `~ 1.2.3` => `~1.2.3` range = range.replace(re[t.TILDETRIM], tildeTrimReplace) @@ -22003,36 +22020,40 @@ class Range { // `^ 1.2.3` => `^1.2.3` range = range.replace(re[t.CARETTRIM], caretTrimReplace) - // normalize spaces - range = range.split(/\s+/).join(' ') - // At this point, the range is completely trimmed and // ready to be split into comparators. - const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const rangeList = range + let rangeList = range .split(' ') .map(comp => parseComparator(comp, this.options)) .join(' ') .split(/\s+/) // >=0.0.0 is equivalent to * .map(comp => replaceGTE0(comp, this.options)) + + if (loose) { // in loose mode, throw out any that are not valid comparators - .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) - .map(comp => new Comparator(comp, this.options)) + rangeList = rangeList.filter(comp => { + debug('loose invalid filter', comp, this.options) + return !!comp.match(re[t.COMPARATORLOOSE]) + }) + } + debug('range list', rangeList) // if any comparators are the null set, then replace with JUST null set // if more than one comparator, remove any * comparators // also, don't include the same comparator more than once - const l = rangeList.length const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) + const comparators = rangeList.map(comp => new Comparator(comp, this.options)) + for (const comp of comparators) { + if (isNullSet(comp)) { return [comp] + } rangeMap.set(comp.value, comp) } - if (rangeMap.size > 1 && rangeMap.has('')) + if (rangeMap.size > 1 && rangeMap.has('')) { rangeMap.delete('') + } const result = [...rangeMap.values()] cache.set(memoKey, result) @@ -22083,6 +22104,7 @@ class Range { return false } } + module.exports = Range const LRU = __nccwpck_require__(9505) @@ -22093,12 +22115,13 @@ const Comparator = __nccwpck_require__(1044) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) const { - re, + safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, - caretTrimReplace + caretTrimReplace, } = __nccwpck_require__(3640) +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __nccwpck_require__(5455) const isNullSet = c => c.value === '<0.0.0-0' const isAny = c => c.value === '' @@ -22145,10 +22168,14 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <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 -const replaceTildes = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceTilde(comp, options) - }).join(' ') +// ~0.0.1 --> >=0.0.1 <0.1.0-0 +const replaceTildes = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceTilde(c, options)) + .join(' ') +} const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] @@ -22184,10 +22211,15 @@ const replaceTilde = (comp, options) => { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 // ^1.2.3 --> >=1.2.3 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0 -const replaceCarets = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceCaret(comp, options) - }).join(' ') +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 +const replaceCarets = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceCaret(c, options)) + .join(' ') +} const replaceCaret = (comp, options) => { debug('caret', comp, options) @@ -22244,9 +22276,10 @@ const replaceCaret = (comp, options) => { const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') + return comp + .split(/\s+/) + .map((c) => replaceXRange(c, options)) + .join(' ') } const replaceXRange = (comp, options) => { @@ -22306,8 +22339,9 @@ const replaceXRange = (comp, options) => { } } - if (gtlt === '<') + if (gtlt === '<') { pr = '-0' + } ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { @@ -22328,12 +22362,15 @@ const replaceXRange = (comp, options) => { const replaceStars = (comp, options) => { debug('replaceStars', comp, options) // 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) => { debug('replaceGTE0', comp, options) - return comp.trim() + return comp + .trim() .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') } @@ -22371,7 +22408,7 @@ const hyphenReplace = incPr => ($0, to = `<=${to}` } - return (`${from} ${to}`).trim() + return `${from} ${to}`.trim() } const testSet = (set, version, options) => { @@ -22418,7 +22455,7 @@ const testSet = (set, version, options) => { const debug = __nccwpck_require__(9408) const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const parseOptions = __nccwpck_require__(3379) const { compareIdentifiers } = __nccwpck_require__(3226) @@ -22434,7 +22471,7 @@ class SemVer { version = version.version } } 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) { @@ -22593,36 +22630,36 @@ class SemVer { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { + inc (release, identifier, identifierBase) { switch (release) { case 'premajor': this.prerelease.length = 0 this.patch = 0 this.minor = 0 this.major++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'preminor': this.prerelease.length = 0 this.patch = 0 this.minor++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) break // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { - this.inc('patch', identifier) + this.inc('patch', identifier, identifierBase) } - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'major': @@ -22664,9 +22701,15 @@ class SemVer { break // This probably shouldn't be used publicly. // 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) { - this.prerelease = [0] + this.prerelease = [base] } else { let i = this.prerelease.length while (--i >= 0) { @@ -22677,27 +22720,36 @@ class SemVer { } if (i === -1) { // 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) { // 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 - if (this.prerelease[0] === identifier) { + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } else { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } break - + } default: throw new Error(`invalid increment argument: ${release}`) } - this.format() - this.raw = this.version + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } return this } } @@ -22733,17 +22785,21 @@ const lte = __nccwpck_require__(2712) const cmp = (a, op, b, loose) => { switch (op) { case '===': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a === b case '!==': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a !== b case '': @@ -22780,7 +22836,7 @@ module.exports = cmp const SemVer = __nccwpck_require__(5501) const parse = __nccwpck_require__(6020) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const coerce = (version, options) => { if (version instanceof SemVer) { @@ -22823,8 +22879,9 @@ const coerce = (version, options) => { re[t.COERCERTL].lastIndex = -1 } - if (match === null) + if (match === null) { return null + } return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) } @@ -22873,27 +22930,69 @@ module.exports = compare /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const parse = __nccwpck_require__(6020) -const eq = __nccwpck_require__(6650) 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 - } 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 - } - } - } - return defaultResult // may be undefined } + + 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' + } + + 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 @@ -22934,14 +23033,18 @@ module.exports = gte const SemVer = __nccwpck_require__(5501) -const inc = (version, release, options, identifier) => { +const inc = (version, release, options, identifier, identifierBase) => { if (typeof (options) === 'string') { + identifierBase = identifier identifier = options options = undefined } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier, identifierBase).version } catch (er) { return null } @@ -23004,35 +23107,18 @@ module.exports = neq /***/ 6020: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) const SemVer = __nccwpck_require__(5501) - -const parseOptions = __nccwpck_require__(3379) -const parse = (version, options) => { - options = parseOptions(options) - +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { 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 { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } @@ -23129,51 +23215,92 @@ module.exports = valid // just pre-load all the stuff that index.js lazily exports const internalRe = __nccwpck_require__(3640) +const constants = __nccwpck_require__(5455) +const SemVer = __nccwpck_require__(5501) +const identifiers = __nccwpck_require__(3226) +const parse = __nccwpck_require__(6020) +const valid = __nccwpck_require__(8573) +const clean = __nccwpck_require__(9154) +const inc = __nccwpck_require__(2100) +const diff = __nccwpck_require__(7693) +const major = __nccwpck_require__(625) +const minor = __nccwpck_require__(2019) +const patch = __nccwpck_require__(1215) +const prerelease = __nccwpck_require__(8761) +const compare = __nccwpck_require__(1366) +const rcompare = __nccwpck_require__(8316) +const compareLoose = __nccwpck_require__(554) +const compareBuild = __nccwpck_require__(4450) +const sort = __nccwpck_require__(3211) +const rsort = __nccwpck_require__(5090) +const gt = __nccwpck_require__(3788) +const lt = __nccwpck_require__(1125) +const eq = __nccwpck_require__(6650) +const neq = __nccwpck_require__(2098) +const gte = __nccwpck_require__(5280) +const lte = __nccwpck_require__(2712) +const cmp = __nccwpck_require__(486) +const coerce = __nccwpck_require__(3669) +const Comparator = __nccwpck_require__(1044) +const Range = __nccwpck_require__(1838) +const satisfies = __nccwpck_require__(8840) +const toComparators = __nccwpck_require__(4017) +const maxSatisfying = __nccwpck_require__(7093) +const minSatisfying = __nccwpck_require__(3916) +const minVersion = __nccwpck_require__(6344) +const validRange = __nccwpck_require__(1757) +const outside = __nccwpck_require__(8437) +const gtr = __nccwpck_require__(1555) +const ltr = __nccwpck_require__(6732) +const intersects = __nccwpck_require__(184) +const simplifyRange = __nccwpck_require__(530) +const subset = __nccwpck_require__(1132) module.exports = { + parse, + valid, + clean, + inc, + diff, + major, + minor, + patch, + prerelease, + compare, + rcompare, + compareLoose, + compareBuild, + sort, + rsort, + gt, + lt, + eq, + neq, + gte, + lte, + cmp, + coerce, + Comparator, + Range, + satisfies, + toComparators, + maxSatisfying, + minSatisfying, + minVersion, + validRange, + outside, + gtr, + ltr, + intersects, + simplifyRange, + subset, + SemVer, re: internalRe.re, src: internalRe.src, tokens: internalRe.t, - SEMVER_SPEC_VERSION: (__nccwpck_require__(5455).SEMVER_SPEC_VERSION), - SemVer: __nccwpck_require__(5501), - compareIdentifiers: (__nccwpck_require__(3226).compareIdentifiers), - rcompareIdentifiers: (__nccwpck_require__(3226).rcompareIdentifiers), - parse: __nccwpck_require__(6020), - valid: __nccwpck_require__(8573), - clean: __nccwpck_require__(9154), - inc: __nccwpck_require__(2100), - diff: __nccwpck_require__(7693), - major: __nccwpck_require__(625), - minor: __nccwpck_require__(2019), - patch: __nccwpck_require__(1215), - prerelease: __nccwpck_require__(8761), - compare: __nccwpck_require__(1366), - rcompare: __nccwpck_require__(8316), - compareLoose: __nccwpck_require__(554), - compareBuild: __nccwpck_require__(4450), - sort: __nccwpck_require__(3211), - rsort: __nccwpck_require__(5090), - gt: __nccwpck_require__(3788), - lt: __nccwpck_require__(1125), - eq: __nccwpck_require__(6650), - neq: __nccwpck_require__(2098), - gte: __nccwpck_require__(5280), - lte: __nccwpck_require__(2712), - cmp: __nccwpck_require__(486), - coerce: __nccwpck_require__(3669), - Comparator: __nccwpck_require__(1044), - Range: __nccwpck_require__(1838), - satisfies: __nccwpck_require__(8840), - toComparators: __nccwpck_require__(4017), - maxSatisfying: __nccwpck_require__(7093), - minSatisfying: __nccwpck_require__(3916), - minVersion: __nccwpck_require__(6344), - validRange: __nccwpck_require__(1757), - outside: __nccwpck_require__(8437), - gtr: __nccwpck_require__(1555), - ltr: __nccwpck_require__(6732), - intersects: __nccwpck_require__(184), - simplifyRange: __nccwpck_require__(530), - subset: __nccwpck_require__(1132), + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, } @@ -23188,16 +23315,29 @@ const SEMVER_SPEC_VERSION = '2.0.0' const MAX_LENGTH = 256 const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/* istanbul ignore next */ 9007199254740991 // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, } @@ -23243,7 +23383,7 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, - rcompareIdentifiers + rcompareIdentifiers, } @@ -23252,16 +23392,20 @@ module.exports = { /***/ 3379: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} module.exports = parseOptions @@ -23276,16 +23420,27 @@ exports = module.exports = {} // The actual regexps go on exports.re const re = exports.re = [] +const safeRe = exports.safeRe = [] const src = exports.src = [] const t = exports.t = {} let R = 0 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++ - debug(index, value) + debug(name, index, value) t[name] = index src[index] = value 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, @@ -23450,8 +23605,8 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + // Star ranges basically just allow anything at all. createToken('STAR', '(<|>)?=?\\s*\\*') // >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), @@ -23474,7 +23629,7 @@ const Range = __nccwpck_require__(1838) const intersects = (r1, r2, options) => { r1 = new Range(r1, options) r2 = new Range(r2, options) - return r1.intersects(r2) + return r1.intersects(r2, options) } module.exports = intersects @@ -23607,8 +23762,9 @@ const minVersion = (range, loose) => { throw new Error(`Unexpected operation: ${comparator.operator}`) } }) - if (setMin && (!minver || gt(minver, setMin))) + if (setMin && (!minver || gt(minver, setMin))) { minver = setMin + } } if (minver && range.test(minver)) { @@ -23627,7 +23783,7 @@ module.exports = minVersion const SemVer = __nccwpck_require__(5501) const Comparator = __nccwpck_require__(1044) -const {ANY} = Comparator +const { ANY } = Comparator const Range = __nccwpck_require__(1838) const satisfies = __nccwpck_require__(8840) const gt = __nccwpck_require__(3788) @@ -23719,38 +23875,41 @@ const satisfies = __nccwpck_require__(8840) const compare = __nccwpck_require__(1366) module.exports = (versions, range, options) => { const set = [] - let min = null + let first = null let prev = null const v = versions.sort((a, b) => compare(a, b, options)) for (const version of v) { const included = satisfies(version, range, options) if (included) { prev = version - if (!min) - min = version + if (!first) { + first = version + } } else { if (prev) { - set.push([min, prev]) + set.push([first, prev]) } prev = null - min = null + first = null } } - if (min) - set.push([min, null]) + if (first) { + set.push([first, null]) + } const ranges = [] for (const [min, max] of set) { - if (min === max) + if (min === max) { ranges.push(min) - else if (!max && min === v[0]) + } else if (!max && min === v[0]) { ranges.push('*') - else if (!max) + } else if (!max) { ranges.push(`>=${min}`) - else if (min === v[0]) + } else if (min === v[0]) { ranges.push(`<=${max}`) - else + } else { ranges.push(`${min} - ${max}`) + } } const simplified = ranges.join(' || ') const original = typeof range.raw === 'string' ? range.raw : String(range) @@ -23806,8 +23965,9 @@ const compare = __nccwpck_require__(1366) // - Else return true const subset = (sub, dom, options = {}) => { - if (sub === dom) + if (sub === dom) { return true + } sub = new Range(sub, options) dom = new Range(dom, options) @@ -23817,73 +23977,87 @@ const subset = (sub, dom, options = {}) => { for (const simpleDom of dom.set) { const isSub = simpleSubset(simpleSub, simpleDom, options) sawNonNull = sawNonNull || isSub !== null - if (isSub) + if (isSub) { continue OUTER + } } // the null set is a subset of everything, but null simple ranges in // a complex range should be ignored. so if we saw a non-null range, // then we know this isn't a subset, but if EVERY simple range was null, // then it is a subset. - if (sawNonNull) + if (sawNonNull) { return false + } } return true } +const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] +const minimumVersion = [new Comparator('>=0.0.0')] + const simpleSubset = (sub, dom, options) => { - if (sub === dom) + if (sub === dom) { return true + } if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) + if (dom.length === 1 && dom[0].semver === ANY) { return true - else if (options.includePrerelease) - sub = [ new Comparator('>=0.0.0-0') ] - else - sub = [ new Comparator('>=0.0.0') ] + } else if (options.includePrerelease) { + sub = minimumVersionWithPreRelease + } else { + sub = minimumVersion + } } if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) + if (options.includePrerelease) { return true - else - dom = [ new Comparator('>=0.0.0') ] + } else { + dom = minimumVersion + } } const eqSet = new Set() let gt, lt for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') + if (c.operator === '>' || c.operator === '>=') { gt = higherGT(gt, c, options) - else if (c.operator === '<' || c.operator === '<=') + } else if (c.operator === '<' || c.operator === '<=') { lt = lowerLT(lt, c, options) - else + } else { eqSet.add(c.semver) + } } - if (eqSet.size > 1) + if (eqSet.size > 1) { return null + } let gtltComp if (gt && lt) { gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) + if (gtltComp > 0) { return null - else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { return null + } } // will iterate one or zero times for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) + if (gt && !satisfies(eq, String(gt), options)) { return null + } - if (lt && !satisfies(eq, String(lt), options)) + if (lt && !satisfies(eq, String(lt), options)) { return null + } for (const c of dom) { - if (!satisfies(eq, String(c), options)) + if (!satisfies(eq, String(c), options)) { return false + } } return true @@ -23919,10 +24093,12 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '>' || c.operator === '>=') { higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) + if (higher === c && higher !== gt) { return false - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + } + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { return false + } } if (lt) { if (needDomLTPre) { @@ -23935,37 +24111,44 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '<' || c.operator === '<=') { lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) + if (lower === c && lower !== lt) { return false - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + } + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { return false + } } - if (!c.operator && (lt || gt) && gtltComp !== 0) + if (!c.operator && (lt || gt) && gtltComp !== 0) { return false + } } // if there was a < or >, and nothing in the dom, then must be false // UNLESS it was limited by another range in the other direction. // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) + if (gt && hasDomLT && !lt && gtltComp !== 0) { return false + } - if (lt && hasDomGT && !gt && gtltComp !== 0) + if (lt && hasDomGT && !gt && gtltComp !== 0) { return false + } // we needed a prerelease range in a specific tuple, but didn't get one // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) + if (needDomGTPre || needDomLTPre) { return false + } return true } // >=1.2.3 is lower than >1.2.3 const higherGT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp > 0 ? a : comp < 0 ? b @@ -23975,8 +24158,9 @@ const higherGT = (a, b, options) => { // <=1.2.3 is higher than <1.2.3 const lowerLT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp < 0 ? a : comp > 0 ? b @@ -31637,7 +31821,6 @@ const github_1 = __nccwpck_require__(2726); const typescript_string_operations_1 = __nccwpck_require__(9363); const manager_1 = __nccwpck_require__(1856); const werf = __importStar(__nccwpck_require__(8525)); -const minimalWerfVersion = 'v1.1.17'; function PrepareEnvironAndRunWerfCommand(args) { return __awaiter(this, void 0, void 0, function* () { try { @@ -31690,15 +31873,10 @@ function ProcessGitHubContext() { exports.ProcessGitHubContext = ProcessGitHubContext; function ValidateWerfVersion(version) { const ver = semver.coerce(version); - if (ver) { - if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) { - throw new Error(typescript_string_operations_1.String.Format('The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})', version.trim(), werf.MAJOR_MINOR_GROUP)); - } - if (semver.gte(ver, minimalWerfVersion)) { - return; - } + if (ver && ver.major === werf.MAJOR) { + return; } - throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported (expected version must be equal or greater than {1})', version.trim(), minimalWerfVersion)); + throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', version.trim(), werf.GROUP)); } exports.ValidateWerfVersion = ValidateWerfVersion; @@ -31901,7 +32079,7 @@ class Manager { const version = this.version.slice('v'.length); return this._constructReleaseUrl(version); } - const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`; + const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}`; try { const resp = yield request .get(url) @@ -31968,10 +32146,9 @@ exports.Manager = Manager; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MINOR = exports.MAJOR = exports.MAJOR_MINOR_GROUP = void 0; -exports.MAJOR_MINOR_GROUP = '1.2'; -exports.MAJOR = 1; -exports.MINOR = 2; +exports.MAJOR = exports.GROUP = void 0; +exports.GROUP = '2'; +exports.MAJOR = 2; /***/ }), diff --git a/run/README.md b/run/README.md index 2efb489..e753a21 100644 --- a/run/README.md +++ b/run/README.md @@ -45,7 +45,7 @@ run: fetch-depth: 0 - name: Run - uses: werf/actions/run@v1.2 + uses: werf/actions/run@v2 with: image: backend args: rails server diff --git a/run/index.js b/run/index.js index a3f8208..db234b5 100644 --- a/run/index.js +++ b/run/index.js @@ -12265,6 +12265,11 @@ var isArray = Array.isArray || function (xs) { var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; Cookie.prototype.parse = function parse(str, request_domain, request_path) { if (this instanceof Cookie) { + if ( str.length > 32768 ) { + console.warn("Cookie too long for parsing (>32768 characters)"); + return; + } + var parts = str.split(";").filter(function (value) { return !!value; }); @@ -21763,6 +21768,7 @@ class Comparator { static get ANY () { return ANY } + constructor (comp, options) { options = parseOptions(options) @@ -21774,6 +21780,7 @@ class Comparator { } } + comp = comp.trim().split(/\s+/).join(' ') debug('comparator', comp, options) this.options = options this.loose = !!options.loose @@ -21836,13 +21843,6 @@ class Comparator { throw new TypeError('a Comparator is required') } - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (this.operator === '') { if (this.value === '') { return true @@ -21855,39 +21855,50 @@ class Comparator { return new Range(this.value, options).test(comp.semver) } - const sameDirectionIncreasing = - (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 === '>') + options = parseOptions(options) - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) + // Special cases where nothing can possibly be lower + if (options.includePrerelease && + (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) { + return false + } + 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 const parseOptions = __nccwpck_require__(3379) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const cmp = __nccwpck_require__(486) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) @@ -21927,19 +21938,26 @@ class Range { this.loose = !!options.loose 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.set = range - .split(/\s*\|\|\s*/) + .trim() + .split(/\s+/) + .join(' ') + + // First, split on || + this.set = this.raw + .split('||') // map the range to a 2d array of comparators - .map(range => this.parseRange(range.trim())) + .map(r => this.parseRange(r)) // throw out any comparator lists that are empty // 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. .filter(c => c.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. @@ -21947,9 +21965,9 @@ class Range { // keep the first one, in case they're all null sets const first = this.set[0] this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) + if (this.set.length === 0) { this.set = [first] - else if (this.set.length > 1) { + } else if (this.set.length > 1) { // if we have any that are *, then the range is just * for (const c of this.set) { if (c.length === 1 && isAny(c[0])) { @@ -21965,9 +21983,7 @@ class Range { format () { this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) + .map((comps) => comps.join(' ').trim()) .join('||') .trim() return this.range @@ -21978,15 +21994,16 @@ class Range { } parseRange (range) { - range = range.trim() - // memoize range parsing for performance. // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` + const memoOpts = + (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | + (this.options.loose && FLAG_LOOSE) + const memoKey = memoOpts + ':' + range const cached = cache.get(memoKey) - if (cached) + if (cached) { return cached + } const loose = this.options.loose // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` @@ -21995,7 +22012,7 @@ class Range { debug('hyphen replace', range) // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) + debug('comparator trim', range) // `~ 1.2.3` => `~1.2.3` range = range.replace(re[t.TILDETRIM], tildeTrimReplace) @@ -22003,36 +22020,40 @@ class Range { // `^ 1.2.3` => `^1.2.3` range = range.replace(re[t.CARETTRIM], caretTrimReplace) - // normalize spaces - range = range.split(/\s+/).join(' ') - // At this point, the range is completely trimmed and // ready to be split into comparators. - const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const rangeList = range + let rangeList = range .split(' ') .map(comp => parseComparator(comp, this.options)) .join(' ') .split(/\s+/) // >=0.0.0 is equivalent to * .map(comp => replaceGTE0(comp, this.options)) + + if (loose) { // in loose mode, throw out any that are not valid comparators - .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) - .map(comp => new Comparator(comp, this.options)) + rangeList = rangeList.filter(comp => { + debug('loose invalid filter', comp, this.options) + return !!comp.match(re[t.COMPARATORLOOSE]) + }) + } + debug('range list', rangeList) // if any comparators are the null set, then replace with JUST null set // if more than one comparator, remove any * comparators // also, don't include the same comparator more than once - const l = rangeList.length const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) + const comparators = rangeList.map(comp => new Comparator(comp, this.options)) + for (const comp of comparators) { + if (isNullSet(comp)) { return [comp] + } rangeMap.set(comp.value, comp) } - if (rangeMap.size > 1 && rangeMap.has('')) + if (rangeMap.size > 1 && rangeMap.has('')) { rangeMap.delete('') + } const result = [...rangeMap.values()] cache.set(memoKey, result) @@ -22083,6 +22104,7 @@ class Range { return false } } + module.exports = Range const LRU = __nccwpck_require__(9505) @@ -22093,12 +22115,13 @@ const Comparator = __nccwpck_require__(1044) const debug = __nccwpck_require__(9408) const SemVer = __nccwpck_require__(5501) const { - re, + safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, - caretTrimReplace + caretTrimReplace, } = __nccwpck_require__(3640) +const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = __nccwpck_require__(5455) const isNullSet = c => c.value === '<0.0.0-0' const isAny = c => c.value === '' @@ -22145,10 +22168,14 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <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 -const replaceTildes = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceTilde(comp, options) - }).join(' ') +// ~0.0.1 --> >=0.0.1 <0.1.0-0 +const replaceTildes = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceTilde(c, options)) + .join(' ') +} const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] @@ -22184,10 +22211,15 @@ const replaceTilde = (comp, options) => { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 // ^1.2.3 --> >=1.2.3 <2.0.0-0 // ^1.2.0 --> >=1.2.0 <2.0.0-0 -const replaceCarets = (comp, options) => - comp.trim().split(/\s+/).map((comp) => { - return replaceCaret(comp, options) - }).join(' ') +// ^0.0.1 --> >=0.0.1 <0.0.2-0 +// ^0.1.0 --> >=0.1.0 <0.2.0-0 +const replaceCarets = (comp, options) => { + return comp + .trim() + .split(/\s+/) + .map((c) => replaceCaret(c, options)) + .join(' ') +} const replaceCaret = (comp, options) => { debug('caret', comp, options) @@ -22244,9 +22276,10 @@ const replaceCaret = (comp, options) => { const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') + return comp + .split(/\s+/) + .map((c) => replaceXRange(c, options)) + .join(' ') } const replaceXRange = (comp, options) => { @@ -22306,8 +22339,9 @@ const replaceXRange = (comp, options) => { } } - if (gtlt === '<') + if (gtlt === '<') { pr = '-0' + } ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { @@ -22328,12 +22362,15 @@ const replaceXRange = (comp, options) => { const replaceStars = (comp, options) => { debug('replaceStars', comp, options) // 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) => { debug('replaceGTE0', comp, options) - return comp.trim() + return comp + .trim() .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') } @@ -22371,7 +22408,7 @@ const hyphenReplace = incPr => ($0, to = `<=${to}` } - return (`${from} ${to}`).trim() + return `${from} ${to}`.trim() } const testSet = (set, version, options) => { @@ -22418,7 +22455,7 @@ const testSet = (set, version, options) => { const debug = __nccwpck_require__(9408) const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const parseOptions = __nccwpck_require__(3379) const { compareIdentifiers } = __nccwpck_require__(3226) @@ -22434,7 +22471,7 @@ class SemVer { version = version.version } } 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) { @@ -22593,36 +22630,36 @@ class SemVer { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { + inc (release, identifier, identifierBase) { switch (release) { case 'premajor': this.prerelease.length = 0 this.patch = 0 this.minor = 0 this.major++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'preminor': this.prerelease.length = 0 this.patch = 0 this.minor++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) break // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { - this.inc('patch', identifier) + this.inc('patch', identifier, identifierBase) } - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'major': @@ -22664,9 +22701,15 @@ class SemVer { break // This probably shouldn't be used publicly. // 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) { - this.prerelease = [0] + this.prerelease = [base] } else { let i = this.prerelease.length while (--i >= 0) { @@ -22677,27 +22720,36 @@ class SemVer { } if (i === -1) { // 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) { // 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 - if (this.prerelease[0] === identifier) { + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } else { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } break - + } default: throw new Error(`invalid increment argument: ${release}`) } - this.format() - this.raw = this.version + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } return this } } @@ -22733,17 +22785,21 @@ const lte = __nccwpck_require__(2712) const cmp = (a, op, b, loose) => { switch (op) { case '===': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a === b case '!==': - if (typeof a === 'object') + if (typeof a === 'object') { a = a.version - if (typeof b === 'object') + } + if (typeof b === 'object') { b = b.version + } return a !== b case '': @@ -22780,7 +22836,7 @@ module.exports = cmp const SemVer = __nccwpck_require__(5501) const parse = __nccwpck_require__(6020) -const {re, t} = __nccwpck_require__(3640) +const { safeRe: re, t } = __nccwpck_require__(3640) const coerce = (version, options) => { if (version instanceof SemVer) { @@ -22823,8 +22879,9 @@ const coerce = (version, options) => { re[t.COERCERTL].lastIndex = -1 } - if (match === null) + if (match === null) { return null + } return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) } @@ -22873,27 +22930,69 @@ module.exports = compare /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const parse = __nccwpck_require__(6020) -const eq = __nccwpck_require__(6650) 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 - } 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 - } - } - } - return defaultResult // may be undefined } + + 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' + } + + 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 @@ -22934,14 +23033,18 @@ module.exports = gte const SemVer = __nccwpck_require__(5501) -const inc = (version, release, options, identifier) => { +const inc = (version, release, options, identifier, identifierBase) => { if (typeof (options) === 'string') { + identifierBase = identifier identifier = options options = undefined } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier, identifierBase).version } catch (er) { return null } @@ -23004,35 +23107,18 @@ module.exports = neq /***/ 6020: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(5455) -const { re, t } = __nccwpck_require__(3640) const SemVer = __nccwpck_require__(5501) - -const parseOptions = __nccwpck_require__(3379) -const parse = (version, options) => { - options = parseOptions(options) - +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { 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 { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } @@ -23129,51 +23215,92 @@ module.exports = valid // just pre-load all the stuff that index.js lazily exports const internalRe = __nccwpck_require__(3640) +const constants = __nccwpck_require__(5455) +const SemVer = __nccwpck_require__(5501) +const identifiers = __nccwpck_require__(3226) +const parse = __nccwpck_require__(6020) +const valid = __nccwpck_require__(8573) +const clean = __nccwpck_require__(9154) +const inc = __nccwpck_require__(2100) +const diff = __nccwpck_require__(7693) +const major = __nccwpck_require__(625) +const minor = __nccwpck_require__(2019) +const patch = __nccwpck_require__(1215) +const prerelease = __nccwpck_require__(8761) +const compare = __nccwpck_require__(1366) +const rcompare = __nccwpck_require__(8316) +const compareLoose = __nccwpck_require__(554) +const compareBuild = __nccwpck_require__(4450) +const sort = __nccwpck_require__(3211) +const rsort = __nccwpck_require__(5090) +const gt = __nccwpck_require__(3788) +const lt = __nccwpck_require__(1125) +const eq = __nccwpck_require__(6650) +const neq = __nccwpck_require__(2098) +const gte = __nccwpck_require__(5280) +const lte = __nccwpck_require__(2712) +const cmp = __nccwpck_require__(486) +const coerce = __nccwpck_require__(3669) +const Comparator = __nccwpck_require__(1044) +const Range = __nccwpck_require__(1838) +const satisfies = __nccwpck_require__(8840) +const toComparators = __nccwpck_require__(4017) +const maxSatisfying = __nccwpck_require__(7093) +const minSatisfying = __nccwpck_require__(3916) +const minVersion = __nccwpck_require__(6344) +const validRange = __nccwpck_require__(1757) +const outside = __nccwpck_require__(8437) +const gtr = __nccwpck_require__(1555) +const ltr = __nccwpck_require__(6732) +const intersects = __nccwpck_require__(184) +const simplifyRange = __nccwpck_require__(530) +const subset = __nccwpck_require__(1132) module.exports = { + parse, + valid, + clean, + inc, + diff, + major, + minor, + patch, + prerelease, + compare, + rcompare, + compareLoose, + compareBuild, + sort, + rsort, + gt, + lt, + eq, + neq, + gte, + lte, + cmp, + coerce, + Comparator, + Range, + satisfies, + toComparators, + maxSatisfying, + minSatisfying, + minVersion, + validRange, + outside, + gtr, + ltr, + intersects, + simplifyRange, + subset, + SemVer, re: internalRe.re, src: internalRe.src, tokens: internalRe.t, - SEMVER_SPEC_VERSION: (__nccwpck_require__(5455).SEMVER_SPEC_VERSION), - SemVer: __nccwpck_require__(5501), - compareIdentifiers: (__nccwpck_require__(3226).compareIdentifiers), - rcompareIdentifiers: (__nccwpck_require__(3226).rcompareIdentifiers), - parse: __nccwpck_require__(6020), - valid: __nccwpck_require__(8573), - clean: __nccwpck_require__(9154), - inc: __nccwpck_require__(2100), - diff: __nccwpck_require__(7693), - major: __nccwpck_require__(625), - minor: __nccwpck_require__(2019), - patch: __nccwpck_require__(1215), - prerelease: __nccwpck_require__(8761), - compare: __nccwpck_require__(1366), - rcompare: __nccwpck_require__(8316), - compareLoose: __nccwpck_require__(554), - compareBuild: __nccwpck_require__(4450), - sort: __nccwpck_require__(3211), - rsort: __nccwpck_require__(5090), - gt: __nccwpck_require__(3788), - lt: __nccwpck_require__(1125), - eq: __nccwpck_require__(6650), - neq: __nccwpck_require__(2098), - gte: __nccwpck_require__(5280), - lte: __nccwpck_require__(2712), - cmp: __nccwpck_require__(486), - coerce: __nccwpck_require__(3669), - Comparator: __nccwpck_require__(1044), - Range: __nccwpck_require__(1838), - satisfies: __nccwpck_require__(8840), - toComparators: __nccwpck_require__(4017), - maxSatisfying: __nccwpck_require__(7093), - minSatisfying: __nccwpck_require__(3916), - minVersion: __nccwpck_require__(6344), - validRange: __nccwpck_require__(1757), - outside: __nccwpck_require__(8437), - gtr: __nccwpck_require__(1555), - ltr: __nccwpck_require__(6732), - intersects: __nccwpck_require__(184), - simplifyRange: __nccwpck_require__(530), - subset: __nccwpck_require__(1132), + SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION, + RELEASE_TYPES: constants.RELEASE_TYPES, + compareIdentifiers: identifiers.compareIdentifiers, + rcompareIdentifiers: identifiers.rcompareIdentifiers, } @@ -23188,16 +23315,29 @@ const SEMVER_SPEC_VERSION = '2.0.0' const MAX_LENGTH = 256 const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/* istanbul ignore next */ 9007199254740991 // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, } @@ -23243,7 +23383,7 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, - rcompareIdentifiers + rcompareIdentifiers, } @@ -23252,16 +23392,20 @@ module.exports = { /***/ 3379: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} module.exports = parseOptions @@ -23276,16 +23420,27 @@ exports = module.exports = {} // The actual regexps go on exports.re const re = exports.re = [] +const safeRe = exports.safeRe = [] const src = exports.src = [] const t = exports.t = {} let R = 0 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++ - debug(index, value) + debug(name, index, value) t[name] = index src[index] = value 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, @@ -23450,8 +23605,8 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + // Star ranges basically just allow anything at all. createToken('STAR', '(<|>)?=?\\s*\\*') // >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), @@ -23474,7 +23629,7 @@ const Range = __nccwpck_require__(1838) const intersects = (r1, r2, options) => { r1 = new Range(r1, options) r2 = new Range(r2, options) - return r1.intersects(r2) + return r1.intersects(r2, options) } module.exports = intersects @@ -23607,8 +23762,9 @@ const minVersion = (range, loose) => { throw new Error(`Unexpected operation: ${comparator.operator}`) } }) - if (setMin && (!minver || gt(minver, setMin))) + if (setMin && (!minver || gt(minver, setMin))) { minver = setMin + } } if (minver && range.test(minver)) { @@ -23627,7 +23783,7 @@ module.exports = minVersion const SemVer = __nccwpck_require__(5501) const Comparator = __nccwpck_require__(1044) -const {ANY} = Comparator +const { ANY } = Comparator const Range = __nccwpck_require__(1838) const satisfies = __nccwpck_require__(8840) const gt = __nccwpck_require__(3788) @@ -23719,38 +23875,41 @@ const satisfies = __nccwpck_require__(8840) const compare = __nccwpck_require__(1366) module.exports = (versions, range, options) => { const set = [] - let min = null + let first = null let prev = null const v = versions.sort((a, b) => compare(a, b, options)) for (const version of v) { const included = satisfies(version, range, options) if (included) { prev = version - if (!min) - min = version + if (!first) { + first = version + } } else { if (prev) { - set.push([min, prev]) + set.push([first, prev]) } prev = null - min = null + first = null } } - if (min) - set.push([min, null]) + if (first) { + set.push([first, null]) + } const ranges = [] for (const [min, max] of set) { - if (min === max) + if (min === max) { ranges.push(min) - else if (!max && min === v[0]) + } else if (!max && min === v[0]) { ranges.push('*') - else if (!max) + } else if (!max) { ranges.push(`>=${min}`) - else if (min === v[0]) + } else if (min === v[0]) { ranges.push(`<=${max}`) - else + } else { ranges.push(`${min} - ${max}`) + } } const simplified = ranges.join(' || ') const original = typeof range.raw === 'string' ? range.raw : String(range) @@ -23806,8 +23965,9 @@ const compare = __nccwpck_require__(1366) // - Else return true const subset = (sub, dom, options = {}) => { - if (sub === dom) + if (sub === dom) { return true + } sub = new Range(sub, options) dom = new Range(dom, options) @@ -23817,73 +23977,87 @@ const subset = (sub, dom, options = {}) => { for (const simpleDom of dom.set) { const isSub = simpleSubset(simpleSub, simpleDom, options) sawNonNull = sawNonNull || isSub !== null - if (isSub) + if (isSub) { continue OUTER + } } // the null set is a subset of everything, but null simple ranges in // a complex range should be ignored. so if we saw a non-null range, // then we know this isn't a subset, but if EVERY simple range was null, // then it is a subset. - if (sawNonNull) + if (sawNonNull) { return false + } } return true } +const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')] +const minimumVersion = [new Comparator('>=0.0.0')] + const simpleSubset = (sub, dom, options) => { - if (sub === dom) + if (sub === dom) { return true + } if (sub.length === 1 && sub[0].semver === ANY) { - if (dom.length === 1 && dom[0].semver === ANY) + if (dom.length === 1 && dom[0].semver === ANY) { return true - else if (options.includePrerelease) - sub = [ new Comparator('>=0.0.0-0') ] - else - sub = [ new Comparator('>=0.0.0') ] + } else if (options.includePrerelease) { + sub = minimumVersionWithPreRelease + } else { + sub = minimumVersion + } } if (dom.length === 1 && dom[0].semver === ANY) { - if (options.includePrerelease) + if (options.includePrerelease) { return true - else - dom = [ new Comparator('>=0.0.0') ] + } else { + dom = minimumVersion + } } const eqSet = new Set() let gt, lt for (const c of sub) { - if (c.operator === '>' || c.operator === '>=') + if (c.operator === '>' || c.operator === '>=') { gt = higherGT(gt, c, options) - else if (c.operator === '<' || c.operator === '<=') + } else if (c.operator === '<' || c.operator === '<=') { lt = lowerLT(lt, c, options) - else + } else { eqSet.add(c.semver) + } } - if (eqSet.size > 1) + if (eqSet.size > 1) { return null + } let gtltComp if (gt && lt) { gtltComp = compare(gt.semver, lt.semver, options) - if (gtltComp > 0) + if (gtltComp > 0) { return null - else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) { return null + } } // will iterate one or zero times for (const eq of eqSet) { - if (gt && !satisfies(eq, String(gt), options)) + if (gt && !satisfies(eq, String(gt), options)) { return null + } - if (lt && !satisfies(eq, String(lt), options)) + if (lt && !satisfies(eq, String(lt), options)) { return null + } for (const c of dom) { - if (!satisfies(eq, String(c), options)) + if (!satisfies(eq, String(c), options)) { return false + } } return true @@ -23919,10 +24093,12 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '>' || c.operator === '>=') { higher = higherGT(gt, c, options) - if (higher === c && higher !== gt) + if (higher === c && higher !== gt) { return false - } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + } + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) { return false + } } if (lt) { if (needDomLTPre) { @@ -23935,37 +24111,44 @@ const simpleSubset = (sub, dom, options) => { } if (c.operator === '<' || c.operator === '<=') { lower = lowerLT(lt, c, options) - if (lower === c && lower !== lt) + if (lower === c && lower !== lt) { return false - } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + } + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) { return false + } } - if (!c.operator && (lt || gt) && gtltComp !== 0) + if (!c.operator && (lt || gt) && gtltComp !== 0) { return false + } } // if there was a < or >, and nothing in the dom, then must be false // UNLESS it was limited by another range in the other direction. // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 - if (gt && hasDomLT && !lt && gtltComp !== 0) + if (gt && hasDomLT && !lt && gtltComp !== 0) { return false + } - if (lt && hasDomGT && !gt && gtltComp !== 0) + if (lt && hasDomGT && !gt && gtltComp !== 0) { return false + } // we needed a prerelease range in a specific tuple, but didn't get one // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0, // because it includes prereleases in the 1.2.3 tuple - if (needDomGTPre || needDomLTPre) + if (needDomGTPre || needDomLTPre) { return false + } return true } // >=1.2.3 is lower than >1.2.3 const higherGT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp > 0 ? a : comp < 0 ? b @@ -23975,8 +24158,9 @@ const higherGT = (a, b, options) => { // <=1.2.3 is higher than <1.2.3 const lowerLT = (a, b, options) => { - if (!a) + if (!a) { return b + } const comp = compare(a.semver, b.semver, options) return comp < 0 ? a : comp > 0 ? b @@ -31689,7 +31873,6 @@ const github_1 = __nccwpck_require__(2726); const typescript_string_operations_1 = __nccwpck_require__(9363); const manager_1 = __nccwpck_require__(1856); const werf = __importStar(__nccwpck_require__(8525)); -const minimalWerfVersion = 'v1.1.17'; function PrepareEnvironAndRunWerfCommand(args) { return __awaiter(this, void 0, void 0, function* () { try { @@ -31742,15 +31925,10 @@ function ProcessGitHubContext() { exports.ProcessGitHubContext = ProcessGitHubContext; function ValidateWerfVersion(version) { const ver = semver.coerce(version); - if (ver) { - if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) { - throw new Error(typescript_string_operations_1.String.Format('The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})', version.trim(), werf.MAJOR_MINOR_GROUP)); - } - if (semver.gte(ver, minimalWerfVersion)) { - return; - } + if (ver && ver.major === werf.MAJOR) { + return; } - throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported (expected version must be equal or greater than {1})', version.trim(), minimalWerfVersion)); + throw new Error(typescript_string_operations_1.String.Format('werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', version.trim(), werf.GROUP)); } exports.ValidateWerfVersion = ValidateWerfVersion; @@ -31899,7 +32077,7 @@ class Manager { const version = this.version.slice('v'.length); return this._constructReleaseUrl(version); } - const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}`; + const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}`; try { const resp = yield request .get(url) @@ -32040,10 +32218,9 @@ run(); "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MINOR = exports.MAJOR = exports.MAJOR_MINOR_GROUP = void 0; -exports.MAJOR_MINOR_GROUP = '1.2'; -exports.MAJOR = 1; -exports.MINOR = 2; +exports.MAJOR = exports.GROUP = void 0; +exports.GROUP = '2'; +exports.MAJOR = 2; /***/ }), diff --git a/src/common.ts b/src/common.ts index 149618e..c4401eb 100644 --- a/src/common.ts +++ b/src/common.ts @@ -7,8 +7,6 @@ import {String} from 'typescript-string-operations' import {Manager} from './manager' import * as werf from './werf' -const minimalWerfVersion = 'v1.1.17' - export async function PrepareEnvironAndRunWerfCommand( args: string[] ): Promise { @@ -67,27 +65,15 @@ export function ProcessGitHubContext(): void { export function ValidateWerfVersion(version: string): void { const ver = semver.coerce(version) - if (ver) { - if (ver.major !== werf.MAJOR || ver.minor !== werf.MINOR) { - throw new Error( - String.Format( - 'The arbitrary version ({0}) must be within the MAJOR.MINOR ({1})', - version.trim(), - werf.MAJOR_MINOR_GROUP - ) - ) - } - - if (semver.gte(ver, minimalWerfVersion)) { - return - } + if (ver && ver.major === werf.MAJOR) { + return } throw new Error( String.Format( - 'werf version {0} is not supported (expected version must be equal or greater than {1})', + 'werf version {0} is not supported: the version must be semver and within the MAJOR ({1})', version.trim(), - minimalWerfVersion + werf.GROUP ) ) } diff --git a/src/manager.ts b/src/manager.ts index db7e781..beaf693 100644 --- a/src/manager.ts +++ b/src/manager.ts @@ -125,7 +125,7 @@ export class Manager { return this._constructReleaseUrl(version) } - const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.MAJOR_MINOR_GROUP}/${this.channel}` + const url = `${WERF_TUF_SERVER_URL}/targets/channels/${werf.GROUP}/${this.channel}` try { const resp = await request .get(url) diff --git a/src/werf.ts b/src/werf.ts index c15579f..e2b4b18 100644 --- a/src/werf.ts +++ b/src/werf.ts @@ -1,3 +1,2 @@ -export const MAJOR_MINOR_GROUP = '1.2' -export const MAJOR = 1 -export const MINOR = 2 +export const GROUP = '2' +export const MAJOR = 2