From 0701e1c3afe0479ac8079052a446272da821eb46 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 8 Aug 2019 21:35:05 -0700 Subject: [PATCH 01/44] Correct typo in doc s/Integer/Number/ Prompted by https://github.com/npm/cli/pull/229 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2293a14f..ac5c4e90 100644 --- a/README.md +++ b/README.md @@ -417,7 +417,7 @@ surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes is not valid). The maximum length for any semver component considered for coercion is 16 characters; longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any -semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value +semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value components are invalid (`9999999999999999.4.7.4` is likely invalid). If the `options.rtl` flag is set, then `coerce` will return the right-most From 07244f913d0502d9400a88629710517ca9b7d702 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 19 Aug 2019 12:17:23 -0700 Subject: [PATCH 02/44] changelog Close #287 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f567dd3f..d366696b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # changes log +## 6.3.0 + +* Expose the token enum on the exports + ## 6.2.0 * Coerce numbers to strings when passed to semver.coerce() From 4b3455dfe4fb7f19dc3486ccdf22f244849e3fc4 Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 6 Nov 2019 09:14:02 -0800 Subject: [PATCH 03/44] Split up module into several files Fix #291 PR-URL: https://github.com/npm/node-semver/pull/295 Credit: @stabbylambda Close: #295 Reviewed-by: @isaacs --- bin/semver.js | 52 +- classes/range.js | 600 +++++++++++ classes/semver.js | 279 +++++ functions/clean.js | 6 + functions/cmp.js | 47 + functions/coerce.js | 53 + functions/compare-build.js | 7 + functions/compare-loose.js | 5 + functions/compare.js | 5 + functions/diff.js | 24 + functions/eq.js | 5 + functions/gt.js | 5 + functions/gte.js | 6 + functions/inc.js | 14 + functions/lt.js | 5 + functions/lte.js | 5 + functions/major.js | 5 + functions/minor.js | 5 + functions/neq.js | 5 + functions/parse.js | 35 + functions/patch.js | 5 + functions/prerelease.js | 6 + functions/rcompare.js | 5 + functions/rsort.js | 7 + functions/sort.js | 7 + functions/valid.js | 6 + index.js | 53 + internal/constants.js | 17 + internal/debug.js | 17 + internal/identifiers.js | 25 + internal/re.js | 179 ++++ package.json | 2 +- ranges/gtr.js | 6 + ranges/intersects.js | 7 + ranges/ltr.js | 6 + ranges/max-satisfying.js | 25 + ranges/min-satisfying.js | 24 + ranges/min-version.js | 56 + ranges/outside.js | 75 ++ ranges/to-comparators.js | 10 + ranges/valid-range.js | 10 + semver.js | 1596 ---------------------------- test/big-numbers.js | 18 +- test/classes/range.js | 36 + test/classes/semver.js | 56 + test/cli.js | 2 +- test/coverage-map.js | 1 + test/{ => functions}/clean.js | 16 +- test/functions/cmp.js | 9 + test/{ => functions}/coerce.js | 91 +- test/functions/compare-build.js | 19 + test/functions/compare-loose.js | 31 + test/functions/diff.js | 30 + test/functions/inc.js | 115 ++ test/functions/major.js | 25 + test/functions/minor.js | 25 + test/functions/patch.js | 25 + test/{ => functions}/prerelease.js | 18 +- test/functions/rcompare.js | 12 + test/functions/rsort.js | 21 + test/functions/sort.js | 22 + test/index.js | 1059 +----------------- test/internal/identifiers.js | 19 + test/internal/re.js | 17 + test/major-minor-patch.js | 72 -- test/{ => ranges}/gtr.js | 30 +- test/ranges/intersects.js | 168 +++ test/{ => ranges}/ltr.js | 30 +- test/ranges/max-satisfying.js | 25 + test/ranges/min-satisfying.js | 25 + test/{ => ranges}/min-version.js | 19 +- test/ranges/outside.js | 10 + test/ranges/satisfies.js | 247 +++++ test/ranges/to-comparators.js | 85 ++ test/ranges/valid-range.js | 90 ++ 75 files changed, 2957 insertions(+), 2823 deletions(-) create mode 100644 classes/range.js create mode 100644 classes/semver.js create mode 100644 functions/clean.js create mode 100644 functions/cmp.js create mode 100644 functions/coerce.js create mode 100644 functions/compare-build.js create mode 100644 functions/compare-loose.js create mode 100644 functions/compare.js create mode 100644 functions/diff.js create mode 100644 functions/eq.js create mode 100644 functions/gt.js create mode 100644 functions/gte.js create mode 100644 functions/inc.js create mode 100644 functions/lt.js create mode 100644 functions/lte.js create mode 100644 functions/major.js create mode 100644 functions/minor.js create mode 100644 functions/neq.js create mode 100644 functions/parse.js create mode 100644 functions/patch.js create mode 100644 functions/prerelease.js create mode 100644 functions/rcompare.js create mode 100644 functions/rsort.js create mode 100644 functions/sort.js create mode 100644 functions/valid.js create mode 100644 index.js create mode 100644 internal/constants.js create mode 100644 internal/debug.js create mode 100644 internal/identifiers.js create mode 100644 internal/re.js create mode 100644 ranges/gtr.js create mode 100644 ranges/intersects.js create mode 100644 ranges/ltr.js create mode 100644 ranges/max-satisfying.js create mode 100644 ranges/min-satisfying.js create mode 100644 ranges/min-version.js create mode 100644 ranges/outside.js create mode 100644 ranges/to-comparators.js create mode 100644 ranges/valid-range.js delete mode 100644 semver.js create mode 100644 test/classes/range.js create mode 100644 test/classes/semver.js create mode 100644 test/coverage-map.js rename test/{ => functions}/clean.js (62%) create mode 100644 test/functions/cmp.js rename test/{ => functions}/coerce.js (51%) create mode 100644 test/functions/compare-build.js create mode 100644 test/functions/compare-loose.js create mode 100644 test/functions/diff.js create mode 100644 test/functions/inc.js create mode 100644 test/functions/major.js create mode 100644 test/functions/minor.js create mode 100644 test/functions/patch.js rename test/{ => functions}/prerelease.js (57%) create mode 100644 test/functions/rcompare.js create mode 100644 test/functions/rsort.js create mode 100644 test/functions/sort.js create mode 100644 test/internal/identifiers.js create mode 100644 test/internal/re.js delete mode 100644 test/major-minor-patch.js rename test/{ => ranges}/gtr.js (88%) create mode 100644 test/ranges/intersects.js rename test/{ => ranges}/ltr.js (89%) create mode 100644 test/ranges/max-satisfying.js create mode 100644 test/ranges/min-satisfying.js rename test/{ => ranges}/min-version.js (80%) create mode 100644 test/ranges/outside.js create mode 100644 test/ranges/satisfies.js create mode 100644 test/ranges/to-comparators.js create mode 100644 test/ranges/valid-range.js diff --git a/bin/semver.js b/bin/semver.js index 666034a7..62bf38e2 100755 --- a/bin/semver.js +++ b/bin/semver.js @@ -3,39 +3,39 @@ // Exits successfully and prints matching version(s) if // any supplied version is valid and passes all tests. -var argv = process.argv.slice(2) +const argv = process.argv.slice(2) -var versions = [] +let versions = [] -var range = [] +const range = [] -var inc = null +let inc = null -var version = require('../package.json').version +const version = require('../package.json').version -var loose = false +let loose = false -var includePrerelease = false +let includePrerelease = false -var coerce = false +let coerce = false -var rtl = false +let rtl = false -var identifier +let identifier -var semver = require('../semver') +const semver = require('../') -var reverse = false +let reverse = false -var options = {} +const options = {} main() function main () { if (!argv.length) return help() while (argv.length) { - var a = argv.shift() - var indexOfEqualSign = a.indexOf('=') + let a = argv.shift() + const indexOfEqualSign = a.indexOf('=') if (indexOfEqualSign !== -1) { a = a.slice(0, indexOfEqualSign) argv.unshift(a.slice(indexOfEqualSign + 1)) @@ -87,18 +87,18 @@ function main () { } } - var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl } + const options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl } - versions = versions.map(function (v) { + versions = versions.map((v) => { return coerce ? (semver.coerce(v, options) || { version: v }).version : v - }).filter(function (v) { + }).filter((v) => { return semver.valid(v) }) if (!versions.length) return fail() if (inc && (versions.length !== 1 || range.length)) { return failInc() } - for (var i = 0, l = range.length; i < l; i++) { - versions = versions.filter(function (v) { + for (let i = 0, l = range.length; i < l; i++) { + versions = versions.filter((v) => { return semver.satisfies(v, range[i], options) }) if (!versions.length) return fail() @@ -114,18 +114,18 @@ function failInc () { function fail () { process.exit(1) } function success () { - var compare = reverse ? 'rcompare' : 'compare' - versions.sort(function (a, b) { + const compare = reverse ? 'rcompare' : 'compare' + versions.sort((a, b) => { return semver[compare](a, b, options) - }).map(function (v) { + }).map((v) => { return semver.clean(v, options) - }).map(function (v) { + }).map((v) => { return inc ? semver.inc(v, inc, options, identifier) : v - }).forEach(function (v, i, _) { console.log(v) }) + }).forEach((v, i, _) => { console.log(v) }) } function help () { - console.log(['SemVer ' + version, + console.log([`SemVer ${ version}`, '', 'A JavaScript implementation of the https://semver.org/ specification', 'Copyright Isaac Z. Schlueter', diff --git a/classes/range.js b/classes/range.js new file mode 100644 index 00000000..8aedd0a2 --- /dev/null +++ b/classes/range.js @@ -0,0 +1,600 @@ +const debug = require('../internal/debug') +const SemVer = require('../classes/semver') +const { re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require('../internal/re') +const cmp = require('../functions/cmp') + +const ANY = {} +class Comparator { + constructor(comp, options) { + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp; + } else { + comp = comp.value; + } + } + + debug("comparator", comp, options); + this.options = options; + this.loose = !!options.loose; + this.parse(comp); + + if (this.semver === ANY) { + this.value = ""; + } else { + this.value = this.operator + this.semver.version; + } + + debug("comp", this); + } + + parse(comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; + const m = comp.match(r); + + if (!m) { + throw new TypeError(`Invalid comparator: ${ comp}`); + } + + this.operator = m[1] !== undefined ? m[1] : ""; + if (this.operator === "=") { + this.operator = ""; + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY; + } else { + this.semver = new SemVer(m[2], this.options.loose); + } + } + + toString() { + return this.value; + } + + test(version) { + debug("Comparator.test", version, this.options.loose); + + if (this.semver === ANY || version === ANY) { + return true; + } + + if (typeof version === "string") { + try { + version = new SemVer(version, this.options); + } catch (er) { + return false; + } + } + + return cmp(version, this.operator, this.semver, this.options); + } + + intersects(comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError("a Comparator is required"); + } + + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; + } + + let rangeTmp; + + if (this.operator === "") { + if (this.value === "") { + return true; + } + rangeTmp = new Range(comp.value, options); + return satisfies(this.value, rangeTmp, options); + } else if (comp.operator === "") { + if (comp.value === "") { + return true; + } + rangeTmp = new Range(this.value, options); + return satisfies(comp.semver, rangeTmp, options); + } + + 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 === ">"); + + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ); + } +} + +class Range { + constructor(range, options) { + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; + } + + if (range instanceof Range) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range; + } else { + return new Range(range.raw, options); + } + } + + if (range instanceof Comparator) { + return new Range(range.value, options); + } + + this.options = options; + this.loose = !!options.loose; + this.includePrerelease = !!options.includePrerelease; + + // First, split based on boolean or || + this.raw = range; + this.set = range + .split(/\s*\|\|\s*/) + .map(function(range) { + return this.parseRange(range.trim()); + }, this) + .filter((c) => { + // throw out any that are not relevant for whatever reason + return c.length; + }); + + if (!this.set.length) { + throw new TypeError(`Invalid SemVer Range: ${ range}`); + } + + this.format(); + } + + format() { + this.range = this.set + .map((comps) => { + return comps.join(" ").trim(); + }) + .join("||") + .trim(); + return this.range; + } + + toString() { + return this.range; + } + + parseRange(range) { + const loose = this.options.loose; + range = range.trim(); + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]; + range = range.replace(hr, hyphenReplace); + 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]); + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace); + + // `^ 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]; + let set = range + .split(" ") + .map(function(comp) { + return parseComparator(comp, this.options); + }, this) + .join(" ") + .split(/\s+/); + if (this.options.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter((comp) => { + return !!comp.match(compRe); + }); + } + set = set.map(function(comp) { + return new Comparator(comp, this.options); + }, this); + + return set; + } + + intersects(range, options) { + if (!(range instanceof Range)) { + throw new TypeError("a Range is required"); + } + + return this.set.some((thisComparators) => { + return ( + isSatisfiable(thisComparators, options) && + range.set.some((rangeComparators) => { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every((thisComparator) => { + return rangeComparators.every((rangeComparator) => { + return thisComparator.intersects(rangeComparator, options); + }); + }) + ); + }) + ); + }); + } + + // if ANY of the sets match ALL of its comparators, then pass + test(version) { + if (!version) { + return false; + } + + if (typeof version === "string") { + try { + version = new SemVer(version, this.options); + } catch (er) { + return false; + } + } + + for (let i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true; + } + } + return false; + } +} + +// take a set of comparators and determine whether there +// exists a version which can satisfy it +function isSatisfiable (comparators, options) { + let result = true + const remainingComparators = comparators.slice() + let testComparator = remainingComparators.pop() + + while (result && remainingComparators.length) { + result = remainingComparators.every((otherComparator) => { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() + } + + return result +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +function parseComparator (comp, options) { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} + +function isX (id) { + return !id || id.toLowerCase() === 'x' || id === '*' +} + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +function replaceTildes (comp, options) { + return comp.trim().split(/\s+/).map((comp) => { + return replaceTilde(comp, options) + }).join(' ') +} + +function replaceTilde (comp, options) { + const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, (_, M, m, p, pr) => { + debug('tilde', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${ M }.0.0 <${ +M + 1 }.0.0` + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0 + ret = `>=${ M }.${ m }.0 <${ M }.${ +m + 1 }.0` + } else if (pr) { + debug('replaceTilde pr', pr) + ret = `>=${ M }.${ m }.${ p }-${ pr + } <${ M }.${ +m + 1 }.0` + } else { + // ~1.2.3 == >=1.2.3 <1.3.0 + ret = `>=${ M }.${ m }.${ p + } <${ M }.${ +m + 1 }.0` + } + + debug('tilde return', ret) + return ret + }) +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 +// ^1.2.3 --> >=1.2.3 <2.0.0 +// ^1.2.0 --> >=1.2.0 <2.0.0 +function replaceCarets (comp, options) { + return comp.trim().split(/\s+/).map((comp) => { + return replaceCaret(comp, options) + }).join(' ') +} + +function replaceCaret (comp, options) { + debug('caret', comp, options) + const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + return comp.replace(r, (_, M, m, p, pr) => { + debug('caret', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${ M }.0.0 <${ +M + 1 }.0.0` + } else if (isX(p)) { + if (M === '0') { + ret = `>=${ M }.${ m }.0 <${ M }.${ +m + 1 }.0` + } else { + ret = `>=${ M }.${ m }.0 <${ +M + 1 }.0.0` + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = `>=${ M }.${ m }.${ p }-${ pr + } <${ M }.${ m }.${ +p + 1}` + } else { + ret = `>=${ M }.${ m }.${ p }-${ pr + } <${ M }.${ +m + 1 }.0` + } + } else { + ret = `>=${ M }.${ m }.${ p }-${ pr + } <${ +M + 1 }.0.0` + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = `>=${ M }.${ m }.${ p + } <${ M }.${ m }.${ +p + 1}` + } else { + ret = `>=${ M }.${ m }.${ p + } <${ M }.${ +m + 1 }.0` + } + } else { + ret = `>=${ M }.${ m }.${ p + } <${ +M + 1 }.0.0` + } + } + + debug('caret return', ret) + return ret + }) +} + +function replaceXRanges (comp, options) { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map((comp) => { + return replaceXRange(comp, options) + }).join(' ') +} + +function replaceXRange (comp, options) { + comp = comp.trim() + const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, (ret, gtlt, M, m, p, pr) => { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + const xM = isX(M) + const xm = xM || isX(m) + const xp = xm || isX(p) + const anyX = xp + + if (gtlt === '=' && anyX) { + gtlt = '' + } + + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + // >1.2.3 => >= 1.2.4 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 + } + } + + ret = `${gtlt + M }.${ m }.${ p }${pr}` + } else if (xm) { + ret = `>=${ M }.0.0${ pr } <${ +M + 1 }.0.0${ pr}` + } else if (xp) { + ret = `>=${ M }.${ m }.0${ pr + } <${ M }.${ +m + 1 }.0${ pr}` + } + + debug('xRange return', ret) + + return ret + }) +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +function 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], '') +} + +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0 +function hyphenReplace ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = `>=${ fM }.0.0` + } else if (isX(fp)) { + from = `>=${ fM }.${ fm }.0` + } else { + from = `>=${ from}` + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = `<${ +tM + 1 }.0.0` + } else if (isX(tp)) { + to = `<${ tM }.${ +tm + 1 }.0` + } else if (tpr) { + to = `<=${ tM }.${ tm }.${ tp }-${ tpr}` + } else { + to = `<=${ to}` + } + + return (`${from } ${ to}`).trim() +} + +function testSet (set, version, options) { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (let i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + const allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true +} + +function satisfies (version, range, options) { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} + +module.exports = { + Comparator, + satisfies, + Range, + ANY +}; \ No newline at end of file diff --git a/classes/semver.js b/classes/semver.js new file mode 100644 index 00000000..a1b22b66 --- /dev/null +++ b/classes/semver.js @@ -0,0 +1,279 @@ +const debug = require("../internal/debug"); +const { MAX_LENGTH, MAX_SAFE_INTEGER } = require("../internal/constants"); +const { re, t } = require("../internal/re"); + +const { compareIdentifiers } = require("../internal/identifiers"); +class SemVer { + constructor(version, options) { + if (!options || typeof options !== "object") { + options = { + loose: !!options, + includePrerelease: false + }; + } + if (version instanceof SemVer) { + if (version.loose === options.loose) { + return version; + } else { + version = version.version; + } + } else if (typeof version !== "string") { + throw new TypeError(`Invalid Version: ${ version}`); + } + + if (version.length > MAX_LENGTH) { + throw new TypeError( + `version is longer than ${ MAX_LENGTH } characters` + ); + } + + debug("SemVer", version, options); + this.options = options; + this.loose = !!options.loose; + + const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); + + if (!m) { + throw new TypeError(`Invalid Version: ${ version}`); + } + + this.raw = version; + + // these are actually numbers + this.major = +m[1]; + this.minor = +m[2]; + this.patch = +m[3]; + + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError("Invalid major version"); + } + + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError("Invalid minor version"); + } + + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError("Invalid patch version"); + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = []; + } else { + this.prerelease = m[4].split(".").map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = +id; + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num; + } + } + return id; + }); + } + + this.build = m[5] ? m[5].split(".") : []; + this.format(); + } + + format() { + this.version = `${this.major }.${ this.minor }.${ this.patch}`; + if (this.prerelease.length) { + this.version += `-${ this.prerelease.join(".")}`; + } + return this.version; + } + + toString() { + return this.version; + } + + compare(other) { + debug("SemVer.compare", this.version, this.options, other); + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options); + } + + return this.compareMain(other) || this.comparePre(other); + } + + compareMain(other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options); + } + + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ); + } + + comparePre(other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options); + } + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1; + } else if (!this.prerelease.length && other.prerelease.length) { + return 1; + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0; + } + + let i = 0; + do { + const a = this.prerelease[i]; + const b = other.prerelease[i]; + debug("prerelease compare", i, a, b); + if (a === undefined && b === undefined) { + return 0; + } else if (b === undefined) { + return 1; + } else if (a === undefined) { + return -1; + } else if (a === b) { + continue; + } else { + return compareIdentifiers(a, b); + } + } while (++i); + } + + compareBuild(other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options); + } + + let i = 0; + do { + const a = this.build[i]; + const b = other.build[i]; + debug("prerelease compare", i, a, b); + if (a === undefined && b === undefined) { + return 0; + } else if (b === undefined) { + return 1; + } else if (a === undefined) { + return -1; + } else if (a === b) { + continue; + } else { + return compareIdentifiers(a, b); + } + } while (++i); + } + + // 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) { + switch (release) { + case "premajor": + this.prerelease.length = 0; + this.patch = 0; + this.minor = 0; + this.major++; + this.inc("pre", identifier); + break; + case "preminor": + this.prerelease.length = 0; + this.patch = 0; + this.minor++; + this.inc("pre", identifier); + 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); + 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("pre", identifier); + break; + + case "major": + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if ( + this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0 + ) { + this.major++; + } + this.minor = 0; + this.patch = 0; + this.prerelease = []; + break; + case "minor": + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++; + } + this.patch = 0; + this.prerelease = []; + break; + case "patch": + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++; + } + this.prerelease = []; + 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": + if (this.prerelease.length === 0) { + this.prerelease = [0]; + } else { + let i = this.prerelease.length; + while (--i >= 0) { + if (typeof this.prerelease[i] === "number") { + this.prerelease[i]++; + i = -2; + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0); + } + } + 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) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0]; + } + } else { + this.prerelease = [identifier, 0]; + } + } + break; + + default: + throw new Error(`invalid increment argument: ${ release}`); + } + this.format(); + this.raw = this.version; + return this; + } +} + +module.exports = SemVer; diff --git a/functions/clean.js b/functions/clean.js new file mode 100644 index 00000000..a611535a --- /dev/null +++ b/functions/clean.js @@ -0,0 +1,6 @@ +const parse = require('./parse') + +module.exports = function clean (version, options) { + const s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} \ No newline at end of file diff --git a/functions/cmp.js b/functions/cmp.js new file mode 100644 index 00000000..181bf2fd --- /dev/null +++ b/functions/cmp.js @@ -0,0 +1,47 @@ +const eq = require('./eq') +const neq = require('./neq') +const gt = require('./gt') +const gte = require('./gte') +const lt = require('./lt') +const lte = require('./lte') + +module.exports = function cmp (a, op, b, loose) { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b + + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError(`Invalid operator: ${ op}`) + } + } \ No newline at end of file diff --git a/functions/coerce.js b/functions/coerce.js new file mode 100644 index 00000000..d2a82632 --- /dev/null +++ b/functions/coerce.js @@ -0,0 +1,53 @@ +const SemVer = require('../classes/semver') +const parse = require('./parse') +const {re, t} = require('../internal/re') + +module.exports = function coerce (version, options) { + if (version instanceof SemVer) { + return version + } + + if (typeof version === 'number') { + version = String(version) + } + + if (typeof version !== 'string') { + return null + } + + options = options || {} + + let match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + let next + while ((next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next + } + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) { + return null + } + + return parse(`${match[2] + }.${ match[3] || '0' + }.${ match[4] || '0'}`, options) + } \ No newline at end of file diff --git a/functions/compare-build.js b/functions/compare-build.js new file mode 100644 index 00000000..cd0ee181 --- /dev/null +++ b/functions/compare-build.js @@ -0,0 +1,7 @@ +const SemVer = require('../classes/semver') + +module.exports = function compareBuild (a, b, loose) { + const versionA = new SemVer(a, loose) + const versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) +} \ No newline at end of file diff --git a/functions/compare-loose.js b/functions/compare-loose.js new file mode 100644 index 00000000..a63521ab --- /dev/null +++ b/functions/compare-loose.js @@ -0,0 +1,5 @@ +const compare = require('./compare') + +module.exports = function compareLoose (a, b) { + return compare(a, b, true) +} \ No newline at end of file diff --git a/functions/compare.js b/functions/compare.js new file mode 100644 index 00000000..76d57b10 --- /dev/null +++ b/functions/compare.js @@ -0,0 +1,5 @@ +const SemVer = require('../classes/semver') + +module.exports = function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} \ No newline at end of file diff --git a/functions/diff.js b/functions/diff.js new file mode 100644 index 00000000..86f1b0cb --- /dev/null +++ b/functions/diff.js @@ -0,0 +1,24 @@ +const parse = require('./parse') +const eq = require('./eq') + +module.exports = function diff (version1, version2) { + if (eq(version1, version2)) { + return null + } else { + const v1 = parse(version1) + const v2 = parse(version2) + let prefix = '' + if (v1.prerelease.length || v2.prerelease.length) { + prefix = 'pre' + var defaultResult = '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 + } +} diff --git a/functions/eq.js b/functions/eq.js new file mode 100644 index 00000000..1d9036b0 --- /dev/null +++ b/functions/eq.js @@ -0,0 +1,5 @@ +const compare = require('./compare') + +module.exports = function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} \ No newline at end of file diff --git a/functions/gt.js b/functions/gt.js new file mode 100644 index 00000000..bbb41d19 --- /dev/null +++ b/functions/gt.js @@ -0,0 +1,5 @@ +const compare = require('./compare') + +module.exports = function gt (a, b, loose) { + return compare(a, b, loose) > 0 +} \ No newline at end of file diff --git a/functions/gte.js b/functions/gte.js new file mode 100644 index 00000000..9c2b5942 --- /dev/null +++ b/functions/gte.js @@ -0,0 +1,6 @@ + +const compare = require('./compare') + +module.exports = function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} \ No newline at end of file diff --git a/functions/inc.js b/functions/inc.js new file mode 100644 index 00000000..13725df5 --- /dev/null +++ b/functions/inc.js @@ -0,0 +1,14 @@ +const SemVer = require('../classes/semver') + +module.exports = function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } + + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } +} \ No newline at end of file diff --git a/functions/lt.js b/functions/lt.js new file mode 100644 index 00000000..ee28dda5 --- /dev/null +++ b/functions/lt.js @@ -0,0 +1,5 @@ +const compare = require('./compare') + +module.exports = function lt (a, b, loose) { + return compare(a, b, loose) < 0 +} \ No newline at end of file diff --git a/functions/lte.js b/functions/lte.js new file mode 100644 index 00000000..f5d00c10 --- /dev/null +++ b/functions/lte.js @@ -0,0 +1,5 @@ +const compare = require('./compare') + +module.exports = function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} \ No newline at end of file diff --git a/functions/major.js b/functions/major.js new file mode 100644 index 00000000..2dc5a533 --- /dev/null +++ b/functions/major.js @@ -0,0 +1,5 @@ +const SemVer = require('../classes/semver') + +module.exports = function major (a, loose) { + return new SemVer(a, loose).major +} \ No newline at end of file diff --git a/functions/minor.js b/functions/minor.js new file mode 100644 index 00000000..040928b7 --- /dev/null +++ b/functions/minor.js @@ -0,0 +1,5 @@ +const SemVer = require('../classes/semver') + +module.exports = function minor (a, loose) { + return new SemVer(a, loose).minor +} \ No newline at end of file diff --git a/functions/neq.js b/functions/neq.js new file mode 100644 index 00000000..4e39de75 --- /dev/null +++ b/functions/neq.js @@ -0,0 +1,5 @@ +const compare = require('./compare') + +module.exports = function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} \ No newline at end of file diff --git a/functions/parse.js b/functions/parse.js new file mode 100644 index 00000000..afa480ff --- /dev/null +++ b/functions/parse.js @@ -0,0 +1,35 @@ +const {MAX_LENGTH} = require('../internal/constants') +const { re, t } = require('../internal/re') +const SemVer = require('../classes/semver') + +module.exports = function parse (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: 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 + } +} \ No newline at end of file diff --git a/functions/patch.js b/functions/patch.js new file mode 100644 index 00000000..4ab8b9a6 --- /dev/null +++ b/functions/patch.js @@ -0,0 +1,5 @@ +const SemVer = require('../classes/semver') + +module.exports = function patch (a, loose) { + return new SemVer(a, loose).patch +} \ No newline at end of file diff --git a/functions/prerelease.js b/functions/prerelease.js new file mode 100644 index 00000000..75511173 --- /dev/null +++ b/functions/prerelease.js @@ -0,0 +1,6 @@ +const parse = require('./parse') + +module.exports =function prerelease (version, options) { + const parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} \ No newline at end of file diff --git a/functions/rcompare.js b/functions/rcompare.js new file mode 100644 index 00000000..cb928828 --- /dev/null +++ b/functions/rcompare.js @@ -0,0 +1,5 @@ +const compare = require('./compare') + +module.exports = function rcompare (a, b, loose) { + return compare(b, a, loose) +} \ No newline at end of file diff --git a/functions/rsort.js b/functions/rsort.js new file mode 100644 index 00000000..b582a30d --- /dev/null +++ b/functions/rsort.js @@ -0,0 +1,7 @@ +const compareBuild = require('./compare-build') + +module.exports = function rsort (list, loose) { + return list.sort((a, b) => { + return compareBuild(b, a, loose) + }) + } \ No newline at end of file diff --git a/functions/sort.js b/functions/sort.js new file mode 100644 index 00000000..4346dc74 --- /dev/null +++ b/functions/sort.js @@ -0,0 +1,7 @@ +const compareBuild = require('./compare-build') + +module.exports = function sort (list, loose) { + return list.sort((a, b) => { + return compareBuild(a, b, loose) + }) + } \ No newline at end of file diff --git a/functions/valid.js b/functions/valid.js new file mode 100644 index 00000000..d23481aa --- /dev/null +++ b/functions/valid.js @@ -0,0 +1,6 @@ +const parse = require('./parse') + +module.exports = function valid (version, options) { + const v = parse(version, options) + return v ? v.version : null +} \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 00000000..309112e8 --- /dev/null +++ b/index.js @@ -0,0 +1,53 @@ +const SemVer = require('./classes/semver') +const { Comparator, Range, satisfies} = require('./classes/range') +const { compareIdentifiers, rcompareIdentifiers } = require('./internal/identifiers') +const { SEMVER_SPEC_VERSION } = require('./internal/constants') +const { re, src, t } = require('./internal/re') + +exports = module.exports = SemVer +exports.re = re +exports.src = src +exports.tokens = t +exports.SEMVER_SPEC_VERSION = SEMVER_SPEC_VERSION + +exports.SemVer = SemVer +exports.compareIdentifiers = compareIdentifiers +exports.rcompareIdentifiers = rcompareIdentifiers + +exports.parse = require('./functions/parse') +exports.valid = require('./functions/valid') +exports.clean = require('./functions/clean') +exports.inc = require('./functions/inc') +exports.diff = require('./functions/diff') +exports.major = require('./functions/major') +exports.minor = require('./functions/minor') +exports.patch = require('./functions/patch') +exports.prerelease = require('./functions/prerelease') +exports.compare = require('./functions/compare') +exports.rcompare = require('./functions/rcompare') +exports.compareLoose = require('./functions/compare-loose') +exports.compareBuild = require('./functions/compare-build') +exports.sort = require('./functions/sort') +exports.rsort = require('./functions/rsort') +exports.gt = require('./functions/gt') +exports.lt = require('./functions/lt') +exports.eq = require('./functions/eq') +exports.neq = require('./functions/neq') +exports.gte = require('./functions/gte') +exports.lte = require('./functions/lte') +exports.cmp = require('./functions/cmp') +exports.coerce = require('./functions/coerce') + +exports.Comparator = Comparator +exports.Range = Range +exports.satisfies = satisfies + +exports.toComparators = require('./ranges/to-comparators') +exports.maxSatisfying = require('./ranges/max-satisfying') +exports.minSatisfying = require('./ranges/min-satisfying') +exports.minVersion = require('./ranges/min-version') +exports.validRange = require('./ranges/valid-range') +exports.outside = require('./ranges/outside') +exports.gtr = require('./ranges/gtr') +exports.ltr = require('./ranges/ltr') +exports.intersects = require('./ranges/intersects') diff --git a/internal/constants.js b/internal/constants.js new file mode 100644 index 00000000..09889484 --- /dev/null +++ b/internal/constants.js @@ -0,0 +1,17 @@ +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +const SEMVER_SPEC_VERSION = '2.0.0' + +const MAX_LENGTH = 256 +const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +const MAX_SAFE_COMPONENT_LENGTH = 16 + +module.exports = { + SEMVER_SPEC_VERSION, + MAX_LENGTH, + MAX_SAFE_INTEGER, + MAX_SAFE_COMPONENT_LENGTH +} \ No newline at end of file diff --git a/internal/debug.js b/internal/debug.js new file mode 100644 index 00000000..0202b360 --- /dev/null +++ b/internal/debug.js @@ -0,0 +1,17 @@ + +let debug +/* istanbul ignore next */ +if (typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG)) { + debug = function () { + const args = Array.prototype.slice.call(arguments, 0) + args.unshift('SEMVER') + console.log.apply(console, args) + } +} else { + debug = function () {} +} + +module.exports = debug diff --git a/internal/identifiers.js b/internal/identifiers.js new file mode 100644 index 00000000..4f9965f8 --- /dev/null +++ b/internal/identifiers.js @@ -0,0 +1,25 @@ +const numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + const anum = numeric.test(a) + const bnum = numeric.test(b) + + if (anum && bnum) { + a = +a + b = +b + } + + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} + +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} + +module.exports = { + compareIdentifiers, + rcompareIdentifiers +} \ No newline at end of file diff --git a/internal/re.js b/internal/re.js new file mode 100644 index 00000000..15422519 --- /dev/null +++ b/internal/re.js @@ -0,0 +1,179 @@ +const { MAX_SAFE_COMPONENT_LENGTH } = require('./constants') +const debug = require('./debug') +exports = module.exports = {} + +// The actual regexps go on exports.re +const re = exports.re = [] +const src = exports.src = [] +const t = exports.t = {} +let R = 0 + +function createToken (name, value, isGlobal) { + const index = R++; + debug(index, value); + t[name] = index; + src[index] = value; + re[index] = new RegExp(value, isGlobal ? 'g' : undefined) +} + +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. + +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. + +createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*'); +createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); + +// ## Main Version +// Three dot-separated numeric identifiers. + +createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})`); + +createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] + }|${src[t.NONNUMERICIDENTIFIER]})`); + +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] + }|${src[t.NONNUMERICIDENTIFIER]})`); + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] + }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); + +createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] + }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] + }(?:\\.${src[t.BUILDIDENTIFIER]})*))`); + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] + }${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`); + +createToken('FULL', `^${src[t.FULLPLAIN]}$`); + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] + }${src[t.PRERELEASELOOSE]}?${ + src[t.BUILD]}?`); + +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`); + +createToken('GTLT', '((?:<|>)?=?)'); + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); +createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); + +createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`); + +createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`); + +createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); +createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); + +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +createToken('COERCE', `${'(^|[^\\d])' + + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH }})` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH }}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH }}))?` + + `(?:$|[^\\d])`); +createToken('COERCERTL', src[t.COERCE], true); + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +createToken('LONETILDE', '(?:~>?)'); + +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true); +exports.tildeTrimReplace = '$1~' + +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +createToken('LONECARET', '(?:\\^)'); + +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true); +exports.caretTrimReplace = '$1^' + +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); +createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] + }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); +exports.comparatorTrimReplace = '$1$2$3' + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAIN]})` + + `\\s*$`); + +createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAINLOOSE]})` + + `\\s*$`); + +// Star ranges basically just allow anything at all. +createToken('STAR', '(<|>)?=?\\s*\\*'); diff --git a/package.json b/package.json index bdd442f5..5db54f33 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "semver", "version": "6.3.0", "description": "The semantic version parser used by npm.", - "main": "semver.js", + "main": "index.js", "scripts": { "test": "tap", "preversion": "npm test", diff --git a/ranges/gtr.js b/ranges/gtr.js new file mode 100644 index 00000000..e6d42e72 --- /dev/null +++ b/ranges/gtr.js @@ -0,0 +1,6 @@ +const outside = require('./outside') + +// Determine if version is greater than all the versions possible in the range. +module.exports = function gtr (version, range, options) { + return outside(version, range, '>', options) +} \ No newline at end of file diff --git a/ranges/intersects.js b/ranges/intersects.js new file mode 100644 index 00000000..1313a614 --- /dev/null +++ b/ranges/intersects.js @@ -0,0 +1,7 @@ +const { Range } = require('../classes/range'); +module.exports = function intersects (r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} + \ No newline at end of file diff --git a/ranges/ltr.js b/ranges/ltr.js new file mode 100644 index 00000000..88ed7eed --- /dev/null +++ b/ranges/ltr.js @@ -0,0 +1,6 @@ +const outside = require('./outside') + +// Determine if version is less than all the versions possible in the range +module.exports = function ltr (version, range, options) { + return outside(version, range, '<', options) +} \ No newline at end of file diff --git a/ranges/max-satisfying.js b/ranges/max-satisfying.js new file mode 100644 index 00000000..511916b4 --- /dev/null +++ b/ranges/max-satisfying.js @@ -0,0 +1,25 @@ +const SemVer = require('../classes/semver') +const { Range } = require('../classes/range') + +module.exports = function maxSatisfying (versions, range, options) { + let max = null + let maxSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max + } + \ No newline at end of file diff --git a/ranges/min-satisfying.js b/ranges/min-satisfying.js new file mode 100644 index 00000000..43581b25 --- /dev/null +++ b/ranges/min-satisfying.js @@ -0,0 +1,24 @@ +const SemVer = require('../classes/semver') +const { Range } = require('../classes/range') + +module.exports = function minSatisfying (versions, range, options) { + let min = null + let minSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) + } + } + }) + return min + } \ No newline at end of file diff --git a/ranges/min-version.js b/ranges/min-version.js new file mode 100644 index 00000000..c3eeaa9a --- /dev/null +++ b/ranges/min-version.js @@ -0,0 +1,56 @@ +const SemVer = require('../classes/semver') +const { Range } = require('../classes/range') +const gt = require('../functions/gt') + +module.exports = function minVersion (range, loose) { + range = new Range(range, loose) + + let minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } + + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } + + minver = null + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + comparators.forEach((comparator) => { + // Clone to avoid manipulating the comparator's semver object. + const compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${ comparator.operator}`) + } + }) + } + + if (minver && range.test(minver)) { + return minver + } + + return null +} \ No newline at end of file diff --git a/ranges/outside.js b/ranges/outside.js new file mode 100644 index 00000000..2f945a02 --- /dev/null +++ b/ranges/outside.js @@ -0,0 +1,75 @@ +const SemVer = require('../classes/semver') +const { Comparator, Range, ANY, satisfies } = require('../classes/range') +const gt = require('../functions/gt') +const lt = require('../functions/lt') +const lte = require('../functions/lte') +const gte = require('../functions/gte') + +module.exports = function outside (version, range, hilo, options) { + version = new SemVer(version, options) + range = new Range(range, options) + + let gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + let high = null + let low = null + + comparators.forEach((comparator) => { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator + } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true +} \ No newline at end of file diff --git a/ranges/to-comparators.js b/ranges/to-comparators.js new file mode 100644 index 00000000..82893b73 --- /dev/null +++ b/ranges/to-comparators.js @@ -0,0 +1,10 @@ +const { Range } = require('../classes/range') + +// Mostly just for testing and legacy API reasons +module.exports = function toComparators (range, options) { + return new Range(range, options).set.map((comp) => { + return comp.map((c) => { + return c.value + }).join(' ').trim().split(' ') + }) +} \ No newline at end of file diff --git a/ranges/valid-range.js b/ranges/valid-range.js new file mode 100644 index 00000000..fd338fdd --- /dev/null +++ b/ranges/valid-range.js @@ -0,0 +1,10 @@ +const { Range } = require('../classes/range') +module.exports = function validRange (range, options) { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } + } \ No newline at end of file diff --git a/semver.js b/semver.js deleted file mode 100644 index 636fa436..00000000 --- a/semver.js +++ /dev/null @@ -1,1596 +0,0 @@ -exports = module.exports = SemVer - -var debug -/* istanbul ignore next */ -if (typeof process === 'object' && - process.env && - process.env.NODE_DEBUG && - /\bsemver\b/i.test(process.env.NODE_DEBUG)) { - debug = function () { - var args = Array.prototype.slice.call(arguments, 0) - args.unshift('SEMVER') - console.log.apply(console, args) - } -} else { - debug = function () {} -} - -// Note: this is the semver.org version of the spec that it implements -// Not necessarily the package version of this code. -exports.SEMVER_SPEC_VERSION = '2.0.0' - -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 - -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 - -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var t = exports.tokens = {} -var R = 0 - -function tok (n) { - t[n] = R++ -} - -// The following Regular Expressions can be used for tokenizing, -// validating, and parsing SemVer version strings. - -// ## Numeric Identifier -// A single `0`, or a non-zero digit followed by zero or more digits. - -tok('NUMERICIDENTIFIER') -src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' -tok('NUMERICIDENTIFIERLOOSE') -src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' - -// ## Non-numeric Identifier -// Zero or more digits, followed by a letter or hyphen, and then zero or -// more letters, digits, or hyphens. - -tok('NONNUMERICIDENTIFIER') -src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' - -// ## Main Version -// Three dot-separated numeric identifiers. - -tok('MAINVERSION') -src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')' - -tok('MAINVERSIONLOOSE') -src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' - -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. - -tok('PRERELEASEIDENTIFIER') -src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -tok('PRERELEASEIDENTIFIERLOOSE') -src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. - -tok('PRERELEASE') -src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' - -tok('PRERELEASELOOSE') -src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' - -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. - -tok('BUILDIDENTIFIER') -src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' - -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. - -tok('BUILD') -src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + - '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))' - -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. - -// Note that the only major, minor, patch, and pre-release sections of -// the version string are capturing groups. The build metadata is not a -// capturing group, because it should not ever be used in version -// comparison. - -tok('FULL') -tok('FULLPLAIN') -src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + - src[t.PRERELEASE] + '?' + - src[t.BUILD] + '?' - -src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' - -// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. -// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty -// common in the npm registry. -tok('LOOSEPLAIN') -src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + - src[t.PRERELEASELOOSE] + '?' + - src[t.BUILD] + '?' - -tok('LOOSE') -src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' - -tok('GTLT') -src[t.GTLT] = '((?:<|>)?=?)' - -// Something like "2.*" or "1.2.x". -// Note that "x.x" is a valid xRange identifer, meaning "any version" -// Only the first item is strictly required. -tok('XRANGEIDENTIFIERLOOSE') -src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -tok('XRANGEIDENTIFIER') -src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' - -tok('XRANGEPLAIN') -src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:' + src[t.PRERELEASE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGEPLAINLOOSE') -src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[t.PRERELEASELOOSE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGE') -src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' -tok('XRANGELOOSE') -src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' - -// Coercion. -// Extract anything that could conceivably be a part of a valid semver -tok('COERCE') -src[t.COERCE] = '(^|[^\\d])' + - '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:$|[^\\d])' -tok('COERCERTL') -re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g') - -// Tilde ranges. -// Meaning is "reasonably at or greater than" -tok('LONETILDE') -src[t.LONETILDE] = '(?:~>?)' - -tok('TILDETRIM') -src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' -re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') -var tildeTrimReplace = '$1~' - -tok('TILDE') -src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' -tok('TILDELOOSE') -src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' - -// Caret ranges. -// Meaning is "at least and backwards compatible with" -tok('LONECARET') -src[t.LONECARET] = '(?:\\^)' - -tok('CARETTRIM') -src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' -re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') -var caretTrimReplace = '$1^' - -tok('CARET') -src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' -tok('CARETLOOSE') -src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' - -// A simple gt/lt/eq thing, or just "" to indicate "any version" -tok('COMPARATORLOOSE') -src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$' -tok('COMPARATOR') -src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$' - -// An expression to strip any whitespace between the gtlt and the thing -// it modifies, so that `> 1.2.3` ==> `>1.2.3` -tok('COMPARATORTRIM') -src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + - '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')' - -// this one has to use the /g flag -re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') -var comparatorTrimReplace = '$1$2$3' - -// Something like `1.2.3 - 1.2.4` -// Note that these all use the loose form, because they'll be -// checked against either the strict or loose comparator form -// later. -tok('HYPHENRANGE') -src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAIN] + ')' + - '\\s*$' - -tok('HYPHENRANGELOOSE') -src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s*$' - -// Star ranges basically just allow anything at all. -tok('STAR') -src[t.STAR] = '(<|>)?=?\\s*\\*' - -// Compile to actual regexp objects. -// All are flag-free, unless they were created above with a flag. -for (var i = 0; i < R; i++) { - debug(i, src[i]) - if (!re[i]) { - re[i] = new RegExp(src[i]) - } -} - -exports.parse = parse -function parse (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - - if (version instanceof SemVer) { - return version - } - - if (typeof version !== 'string') { - return null - } - - if (version.length > MAX_LENGTH) { - return null - } - - var 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 - } -} - -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null -} - -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} - -exports.SemVer = SemVer - -function SemVer (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (version instanceof SemVer) { - if (version.loose === options.loose) { - return version - } else { - version = version.version - } - } else if (typeof version !== 'string') { - throw new TypeError('Invalid Version: ' + version) - } - - if (version.length > MAX_LENGTH) { - throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') - } - - if (!(this instanceof SemVer)) { - return new SemVer(version, options) - } - - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose - - var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) - - if (!m) { - throw new TypeError('Invalid Version: ' + version) - } - - this.raw = version - - // these are actually numbers - this.major = +m[1] - this.minor = +m[2] - this.patch = +m[3] - - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError('Invalid major version') - } - - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError('Invalid minor version') - } - - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError('Invalid patch version') - } - - // numberify any prerelease numeric ids - if (!m[4]) { - this.prerelease = [] - } else { - this.prerelease = m[4].split('.').map(function (id) { - if (/^[0-9]+$/.test(id)) { - var num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num - } - } - return id - }) - } - - this.build = m[5] ? m[5].split('.') : [] - this.format() -} - -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') - } - return this.version -} - -SemVer.prototype.toString = function () { - return this.version -} - -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - return this.compareMain(other) || this.comparePre(other) -} - -SemVer.prototype.compareMain = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - return compareIdentifiers(this.major, other.major) || - compareIdentifiers(this.minor, other.minor) || - compareIdentifiers(this.patch, other.patch) -} - -SemVer.prototype.comparePre = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - // NOT having a prerelease is > having one - if (this.prerelease.length && !other.prerelease.length) { - return -1 - } else if (!this.prerelease.length && other.prerelease.length) { - return 1 - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0 - } - - var i = 0 - do { - var a = this.prerelease[i] - var b = other.prerelease[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) -} - -SemVer.prototype.compareBuild = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - var i = 0 - do { - var a = this.build[i] - var b = other.build[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) -} - -// preminor will bump the version up to the next minor release, and immediately -// down to pre-release. premajor and prepatch work the same way. -SemVer.prototype.inc = function (release, identifier) { - switch (release) { - case 'premajor': - this.prerelease.length = 0 - this.patch = 0 - this.minor = 0 - this.major++ - this.inc('pre', identifier) - break - case 'preminor': - this.prerelease.length = 0 - this.patch = 0 - this.minor++ - this.inc('pre', identifier) - 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) - 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('pre', identifier) - break - - case 'major': - // If this is a pre-major version, bump up to the same major version. - // Otherwise increment major. - // 1.0.0-5 bumps to 1.0.0 - // 1.1.0 bumps to 2.0.0 - if (this.minor !== 0 || - this.patch !== 0 || - this.prerelease.length === 0) { - this.major++ - } - this.minor = 0 - this.patch = 0 - this.prerelease = [] - break - case 'minor': - // If this is a pre-minor version, bump up to the same minor version. - // Otherwise increment minor. - // 1.2.0-5 bumps to 1.2.0 - // 1.2.1 bumps to 1.3.0 - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++ - } - this.patch = 0 - this.prerelease = [] - break - case 'patch': - // If this is not a pre-release version, it will increment the patch. - // If it is a pre-release it will bump up to the same patch version. - // 1.2.0-5 patches to 1.2.0 - // 1.2.0 patches to 1.2.1 - if (this.prerelease.length === 0) { - this.patch++ - } - this.prerelease = [] - 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': - if (this.prerelease.length === 0) { - this.prerelease = [0] - } else { - var i = this.prerelease.length - while (--i >= 0) { - if (typeof this.prerelease[i] === 'number') { - this.prerelease[i]++ - i = -2 - } - } - if (i === -1) { - // didn't increment anything - this.prerelease.push(0) - } - } - 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) { - if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] - } - } else { - this.prerelease = [identifier, 0] - } - } - break - - default: - throw new Error('invalid increment argument: ' + release) - } - this.format() - this.raw = this.version - return this -} - -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined - } - - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { - return null - } -} - -exports.diff = diff -function diff (version1, version2) { - if (eq(version1, version2)) { - return null - } else { - var v1 = parse(version1) - var v2 = parse(version2) - var prefix = '' - if (v1.prerelease.length || v2.prerelease.length) { - prefix = 'pre' - var defaultResult = 'prerelease' - } - for (var key in v1) { - if (key === 'major' || key === 'minor' || key === 'patch') { - if (v1[key] !== v2[key]) { - return prefix + key - } - } - } - return defaultResult // may be undefined - } -} - -exports.compareIdentifiers = compareIdentifiers - -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var bnum = numeric.test(b) - - if (anum && bnum) { - a = +a - b = +b - } - - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 -} - -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) -} - -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major -} - -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor -} - -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch -} - -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} - -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} - -exports.compareBuild = compareBuild -function compareBuild (a, b, loose) { - var versionA = new SemVer(a, loose) - var versionB = new SemVer(b, loose) - return versionA.compare(versionB) || versionA.compareBuild(versionB) -} - -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) -} - -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(a, b, loose) - }) -} - -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(b, a, loose) - }) -} - -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 -} - -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 -} - -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} - -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} - -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} - -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 -} - -exports.cmp = cmp -function cmp (a, op, b, loose) { - switch (op) { - case '===': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a === b - - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b - - case '': - case '=': - case '==': - return eq(a, b, loose) - - case '!=': - return neq(a, b, loose) - - case '>': - return gt(a, b, loose) - - case '>=': - return gte(a, b, loose) - - case '<': - return lt(a, b, loose) - - case '<=': - return lte(a, b, loose) - - default: - throw new TypeError('Invalid operator: ' + op) - } -} - -exports.Comparator = Comparator -function Comparator (comp, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } - } - - if (!(this instanceof Comparator)) { - return new Comparator(comp, options) - } - - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) - - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version - } - - debug('comp', this) -} - -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var m = comp.match(r) - - if (!m) { - throw new TypeError('Invalid comparator: ' + comp) - } - - this.operator = m[1] !== undefined ? m[1] : '' - if (this.operator === '=') { - this.operator = '' - } - - // if it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY - } else { - this.semver = new SemVer(m[2], this.options.loose) - } -} - -Comparator.prototype.toString = function () { - return this.value -} - -Comparator.prototype.test = function (version) { - debug('Comparator.test', version, this.options.loose) - - if (this.semver === ANY || version === ANY) { - return true - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } - - return cmp(version, this.operator, this.semver, this.options) -} - -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } - - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - - var rangeTmp - - if (this.operator === '') { - if (this.value === '') { - return true - } - rangeTmp = new Range(comp.value, options) - return satisfies(this.value, rangeTmp, options) - } else if (comp.operator === '') { - if (comp.value === '') { - return true - } - rangeTmp = new Range(this.value, options) - return satisfies(comp.semver, rangeTmp, options) - } - - var sameDirectionIncreasing = - (this.operator === '>=' || this.operator === '>') && - (comp.operator === '>=' || comp.operator === '>') - var sameDirectionDecreasing = - (this.operator === '<=' || this.operator === '<') && - (comp.operator === '<=' || comp.operator === '<') - var sameSemVer = this.semver.version === comp.semver.version - var differentDirectionsInclusive = - (this.operator === '>=' || this.operator === '<=') && - (comp.operator === '>=' || comp.operator === '<=') - var oppositeDirectionsLessThan = - cmp(this.semver, '<', comp.semver, options) && - ((this.operator === '>=' || this.operator === '>') && - (comp.operator === '<=' || comp.operator === '<')) - var oppositeDirectionsGreaterThan = - cmp(this.semver, '>', comp.semver, options) && - ((this.operator === '<=' || this.operator === '<') && - (comp.operator === '>=' || comp.operator === '>')) - - return sameDirectionIncreasing || sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || oppositeDirectionsGreaterThan -} - -exports.Range = Range -function Range (range, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - - if (range instanceof Range) { - if (range.loose === !!options.loose && - range.includePrerelease === !!options.includePrerelease) { - return range - } else { - return new Range(range.raw, options) - } - } - - if (range instanceof Comparator) { - return new Range(range.value, options) - } - - if (!(this instanceof Range)) { - return new Range(range, options) - } - - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease - - // First, split based on boolean or || - this.raw = range - this.set = range.split(/\s*\|\|\s*/).map(function (range) { - return this.parseRange(range.trim()) - }, this).filter(function (c) { - // throw out any that are not relevant for whatever reason - return c.length - }) - - if (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) - } - - this.format() -} - -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} - -Range.prototype.toString = function () { - return this.range -} - -Range.prototype.parseRange = function (range) { - var loose = this.options.loose - range = range.trim() - // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] - range = range.replace(hr, hyphenReplace) - 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]) - - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[t.TILDETRIM], tildeTrimReplace) - - // `^ 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. - - var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var set = range.split(' ').map(function (comp) { - return parseComparator(comp, this.options) - }, this).join(' ').split(/\s+/) - if (this.options.loose) { - // in loose mode, throw out any that are not valid comparators - set = set.filter(function (comp) { - return !!comp.match(compRe) - }) - } - set = set.map(function (comp) { - return new Comparator(comp, this.options) - }, this) - - return set -} - -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } - - return this.set.some(function (thisComparators) { - return ( - isSatisfiable(thisComparators, options) && - range.set.some(function (rangeComparators) { - return ( - isSatisfiable(rangeComparators, options) && - thisComparators.every(function (thisComparator) { - return rangeComparators.every(function (rangeComparator) { - return thisComparator.intersects(rangeComparator, options) - }) - }) - ) - }) - ) - }) -} - -// take a set of comparators and determine whether there -// exists a version which can satisfy it -function isSatisfiable (comparators, options) { - var result = true - var remainingComparators = comparators.slice() - var testComparator = remainingComparators.pop() - - while (result && remainingComparators.length) { - result = remainingComparators.every(function (otherComparator) { - return testComparator.intersects(otherComparator, options) - }) - - testComparator = remainingComparators.pop() - } - - return result -} - -// Mostly just for testing and legacy API reasons -exports.toComparators = toComparators -function toComparators (range, options) { - return new Range(range, options).set.map(function (comp) { - return comp.map(function (c) { - return c.value - }).join(' ').trim().split(' ') - }) -} - -// comprised of xranges, tildes, stars, and gtlt's at this point. -// already replaced the hyphen ranges -// turn into a set of JUST comparators. -function parseComparator (comp, options) { - debug('comp', comp, options) - comp = replaceCarets(comp, options) - debug('caret', comp) - comp = replaceTildes(comp, options) - debug('tildes', comp) - comp = replaceXRanges(comp, options) - debug('xrange', comp) - comp = replaceStars(comp, options) - debug('stars', comp) - return comp -} - -function isX (id) { - return !id || id.toLowerCase() === 'x' || id === '*' -} - -// ~, ~> --> * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceTilde(comp, options) - }).join(' ') -} - -function replaceTilde (comp, options) { - var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] - return comp.replace(r, function (_, M, m, p, pr) { - debug('tilde', comp, _, M, m, p, pr) - var ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0 - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else if (pr) { - debug('replaceTilde pr', pr) - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } else { - // ~1.2.3 == >=1.2.3 <1.3.0 - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - - debug('tilde return', ret) - return ret - }) -} - -// ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 -// ^1.2.3 --> >=1.2.3 <2.0.0 -// ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceCaret(comp, options) - }).join(' ') -} - -function replaceCaret (comp, options) { - debug('caret', comp, options) - var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] - return comp.replace(r, function (_, M, m, p, pr) { - debug('caret', comp, _, M, m, p, pr) - var ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - if (M === '0') { - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else { - ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' - } - } else if (pr) { - debug('replaceCaret pr', pr) - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + (+M + 1) + '.0.0' - } - } else { - debug('no pr') - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + (+M + 1) + '.0.0' - } - } - - debug('caret return', ret) - return ret - }) -} - -function replaceXRanges (comp, options) { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map(function (comp) { - return replaceXRange(comp, options) - }).join(' ') -} - -function replaceXRange (comp, options) { - comp = comp.trim() - var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] - return comp.replace(r, function (ret, gtlt, M, m, p, pr) { - debug('xRange', comp, ret, gtlt, M, m, p, pr) - var xM = isX(M) - var xm = xM || isX(m) - var xp = xm || isX(p) - var anyX = xp - - if (gtlt === '=' && anyX) { - gtlt = '' - } - - // if we're including prereleases in the match, then we need - // to fix this to -0, the lowest possible prerelease value - pr = options.includePrerelease ? '-0' : '' - - if (xM) { - if (gtlt === '>' || gtlt === '<') { - // nothing is allowed - ret = '<0.0.0-0' - } else { - // nothing is forbidden - ret = '*' - } - } else if (gtlt && anyX) { - // we know patch is an x, because we have any x at all. - // replace X with 0 - if (xm) { - m = 0 - } - p = 0 - - if (gtlt === '>') { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - // >1.2.3 => >= 1.2.4 - gtlt = '>=' - if (xm) { - M = +M + 1 - m = 0 - p = 0 - } else { - m = +m + 1 - p = 0 - } - } else if (gtlt === '<=') { - // <=0.7.x is actually <0.8.0, since any 0.7.x should - // pass. Similarly, <=7.x is actually <8.0.0, etc. - gtlt = '<' - if (xm) { - M = +M + 1 - } else { - m = +m + 1 - } - } - - ret = gtlt + M + '.' + m + '.' + p + pr - } else if (xm) { - ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr - } else if (xp) { - ret = '>=' + M + '.' + m + '.0' + pr + - ' <' + M + '.' + (+m + 1) + '.0' + pr - } - - debug('xRange return', ret) - - return ret - }) -} - -// Because * is AND-ed with everything else in the comparator, -// and '' means "any version", just remove the *s entirely. -function 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], '') -} - -// This function is passed to string.replace(re[t.HYPHENRANGE]) -// M, m, patch, prerelease, build -// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 -// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0 -function hyphenReplace ($0, - from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr, tb) { - if (isX(fM)) { - from = '' - } else if (isX(fm)) { - from = '>=' + fM + '.0.0' - } else if (isX(fp)) { - from = '>=' + fM + '.' + fm + '.0' - } else { - from = '>=' + from - } - - if (isX(tM)) { - to = '' - } else if (isX(tm)) { - to = '<' + (+tM + 1) + '.0.0' - } else if (isX(tp)) { - to = '<' + tM + '.' + (+tm + 1) + '.0' - } else if (tpr) { - to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr - } else { - to = '<=' + to - } - - return (from + ' ' + to).trim() -} - -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } - - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } - return false -} - -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false - } - } - - if (version.prerelease.length && !options.includePrerelease) { - // Find the set of versions that are allowed to have prereleases - // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 - // That should allow `1.2.3-pr.2` to pass. - // However, `1.2.4-alpha.notready` should NOT be allowed, - // even though it's within the range set by the comparators. - for (i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === ANY) { - continue - } - - if (set[i].semver.prerelease.length > 0) { - var allowed = set[i].semver - if (allowed.major === version.major && - allowed.minor === version.minor && - allowed.patch === version.patch) { - return true - } - } - } - - // Version has a -pre, but it's not one of the ones we like. - return false - } - - return true -} - -exports.satisfies = satisfies -function satisfies (version, range, options) { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) -} - -exports.maxSatisfying = maxSatisfying -function maxSatisfying (versions, range, options) { - var max = null - var maxSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!max || maxSV.compare(v) === -1) { - // compare(max, v, true) - max = v - maxSV = new SemVer(max, options) - } - } - }) - return max -} - -exports.minSatisfying = minSatisfying -function minSatisfying (versions, range, options) { - var min = null - var minSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!min || minSV.compare(v) === 1) { - // compare(min, v, true) - min = v - minSV = new SemVer(min, options) - } - } - }) - return min -} - -exports.minVersion = minVersion -function minVersion (range, loose) { - range = new Range(range, loose) - - var minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver - } - - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver - } - - minver = null - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] - - comparators.forEach(function (comparator) { - // Clone to avoid manipulating the comparator's semver object. - var compver = new SemVer(comparator.semver.version) - switch (comparator.operator) { - case '>': - if (compver.prerelease.length === 0) { - compver.patch++ - } else { - compver.prerelease.push(0) - } - compver.raw = compver.format() - /* fallthrough */ - case '': - case '>=': - if (!minver || gt(minver, compver)) { - minver = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error('Unexpected operation: ' + comparator.operator) - } - }) - } - - if (minver && range.test(minver)) { - return minver - } - - return null -} - -exports.validRange = validRange -function validRange (range, options) { - try { - // Return '*' instead of '' so that truthiness works. - // This will throw if it's invalid anyway - return new Range(range, options).range || '*' - } catch (er) { - return null - } -} - -// Determine if version is less than all the versions possible in the range -exports.ltr = ltr -function ltr (version, range, options) { - return outside(version, range, '<', options) -} - -// Determine if version is greater than all the versions possible in the range. -exports.gtr = gtr -function gtr (version, range, options) { - return outside(version, range, '>', options) -} - -exports.outside = outside -function outside (version, range, hilo, options) { - version = new SemVer(version, options) - range = new Range(range, options) - - var gtfn, ltefn, ltfn, comp, ecomp - switch (hilo) { - case '>': - gtfn = gt - ltefn = lte - ltfn = lt - comp = '>' - ecomp = '>=' - break - case '<': - gtfn = lt - ltefn = gte - ltfn = gt - comp = '<' - ecomp = '<=' - break - default: - throw new TypeError('Must provide a hilo val of "<" or ">"') - } - - // If it satisifes the range it is not outside - if (satisfies(version, range, options)) { - return false - } - - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. - - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] - - var high = null - var low = null - - comparators.forEach(function (comparator) { - if (comparator.semver === ANY) { - comparator = new Comparator('>=0.0.0') - } - high = high || comparator - low = low || comparator - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator - } - }) - - // If the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false - } - - // If the lowest version comparator has an operator and our version - // is less than it then it isn't higher than the range - if ((!low.operator || low.operator === comp) && - ltefn(version, low.semver)) { - return false - } else if (low.operator === ecomp && ltfn(version, low.semver)) { - return false - } - } - return true -} - -exports.prerelease = prerelease -function prerelease (version, options) { - var parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} - -exports.intersects = intersects -function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) -} - -exports.coerce = coerce -function coerce (version, options) { - if (version instanceof SemVer) { - return version - } - - if (typeof version === 'number') { - version = String(version) - } - - if (typeof version !== 'string') { - return null - } - - options = options || {} - - var match = null - if (!options.rtl) { - match = version.match(re[t.COERCE]) - } else { - // Find the right-most coercible string that does not share - // a terminus with a more left-ward coercible string. - // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' - // - // Walk through the string checking with a /g regexp - // Manually set the index so as to pick up overlapping matches. - // Stop when we get a match that ends at the string end, since no - // coercible string can be more right-ward without the same terminus. - var next - while ((next = re[t.COERCERTL].exec(version)) && - (!match || match.index + match[0].length !== version.length) - ) { - if (!match || - next.index + next[0].length !== match.index + match[0].length) { - match = next - } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length - } - // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 - } - - if (match === null) { - return null - } - - return parse(match[2] + - '.' + (match[3] || '0') + - '.' + (match[4] || '0'), options) -} diff --git a/test/big-numbers.js b/test/big-numbers.js index 779d521b..e5268fb1 100644 --- a/test/big-numbers.js +++ b/test/big-numbers.js @@ -1,9 +1,9 @@ -var test = require('tap').test -var semver = require('../') +const { test } = require('tap') +const semver = require('../') -test('long version is too long', function (t) { - var v = '1.2.' + new Array(256).join('1') - t.throws(function () { +test('long version is too long', (t) => { + const v = `1.2.${ new Array(256).join('1')}` + t.throws(() => { new semver.SemVer(v) // eslint-disable-line no-new }) t.equal(semver.valid(v, false), null) @@ -12,9 +12,9 @@ test('long version is too long', function (t) { t.end() }) -test('big number is like too long version', function (t) { - var v = '1.2.' + new Array(100).join('1') - t.throws(function () { +test('big number is like too long version', (t) => { + const v = `1.2.${ new Array(100).join('1')}` + t.throws(() => { new semver.SemVer(v) // eslint-disable-line no-new }) t.equal(semver.valid(v, false), null) @@ -23,7 +23,7 @@ test('big number is like too long version', function (t) { t.end() }) -test('parsing null does not throw', function (t) { +test('parsing null does not throw', (t) => { t.equal(semver.parse(null), null) t.equal(semver.parse({}), null) t.equal(semver.parse(new semver.SemVer('1.2.3')).version, '1.2.3') diff --git a/test/classes/range.js b/test/classes/range.js new file mode 100644 index 00000000..ba16b848 --- /dev/null +++ b/test/classes/range.js @@ -0,0 +1,36 @@ +const { test } = require('tap') +const { Range, Comparator } = require('../../classes/range') + +test('strict vs loose ranges', (t) => { + [['>=01.02.03', '>=1.2.3'], + ['~1.02.03beta', '>=1.2.3-beta <1.3.0'] + ].forEach((v) => { + const loose = v[0] + const comps = v[1] + t.throws(() => { + new Range(loose) // eslint-disable-line no-new + }) + t.equal(new Range(loose, true).range, comps) + }) + t.end() + }) + + test("comparator testing", t => { + const c = new Comparator(">=1.2.3"); + t.ok(c.test("1.2.4")); + const c2 = new Comparator(c); + t.ok(c2.test("1.2.4")); + const c3 = new Comparator(c, true); + t.ok(c3.test("1.2.4")); + // test an invalid version, should not throw + const c4 = new Comparator(c); + t.notOk(c4.test("not a version string")); + t.end(); + }); + + test('tostrings', (t) => { + t.equal(new Range('>= v1.2.3').toString(), '>=1.2.3') + t.equal(new Comparator('>= v1.2.3').toString(), '>=1.2.3') + t.end() + }) + \ No newline at end of file diff --git a/test/classes/semver.js b/test/classes/semver.js new file mode 100644 index 00000000..907476c7 --- /dev/null +++ b/test/classes/semver.js @@ -0,0 +1,56 @@ +const { test } = require('tap') +const SemVer = require('../../classes/semver') + +test('really big numeric prerelease value', (t) => { + const r = new SemVer(`1.2.3-beta.${ Number.MAX_SAFE_INTEGER }0`) + t.strictSame(r.prerelease, [ 'beta', '90071992547409910' ]) + t.end() + }) + +test('invalid version numbers', (t) => { + ['1.2.3.4', + 'NOT VALID', + 1.2, + null, + 'Infinity.NaN.Infinity' + ].forEach((v) => { + t.throws(() => { + new SemVer(v) // eslint-disable-line no-new + }, { name: 'TypeError', message: `Invalid Version: ${ v}` }) + }) + + t.end() + }) + +test('compare main vs pre', (t) => { + const s = new SemVer('1.2.3') + t.equal(s.compareMain('2.3.4'), -1) + t.equal(s.compareMain('1.2.4'), -1) + t.equal(s.compareMain('0.1.2'), 1) + t.equal(s.compareMain('1.2.2'), 1) + t.equal(s.compareMain('1.2.3-pre'), 0) + + const p = new SemVer('1.2.3-alpha.0.pr.1') + t.equal(p.comparePre('9.9.9-alpha.0.pr.1'), 0) + t.equal(p.comparePre('1.2.3'), -1) + t.equal(p.comparePre('1.2.3-alpha.0.pr.2'), -1) + t.equal(p.comparePre('1.2.3-alpha.0.2'), 1) + + t.end() + }) + +test('invalid version numbers', (t) => { + ['1.2.3.4', + 'NOT VALID', + 1.2, + null, + 'Infinity.NaN.Infinity' + ].forEach((v) => { + t.throws(() => { + new SemVer(v) // eslint-disable-line no-new + }, { name: 'TypeError', message: `Invalid Version: ${ v}` }) + }) + + t.end() + }) + \ No newline at end of file diff --git a/test/cli.js b/test/cli.js index 0f273db0..4820c1b2 100644 --- a/test/cli.js +++ b/test/cli.js @@ -1,5 +1,5 @@ 'use strict' -var t = require('tap') +const t = require('tap') const thisVersion = require('../package.json').version t.cleanSnapshot = str => str.split(thisVersion).join('@@VERSION@@') diff --git a/test/coverage-map.js b/test/coverage-map.js new file mode 100644 index 00000000..c89a58c2 --- /dev/null +++ b/test/coverage-map.js @@ -0,0 +1 @@ +module.exports = testFile => testFile.replace(/test\//, ''); \ No newline at end of file diff --git a/test/clean.js b/test/functions/clean.js similarity index 62% rename from test/clean.js rename to test/functions/clean.js index d48c149e..56886c60 100644 --- a/test/clean.js +++ b/test/functions/clean.js @@ -1,9 +1,7 @@ -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') -var clean = semver.clean +const { test } = require('tap') +const clean = require('../../functions/clean') -test('\nclean tests', function (t) { +test('clean tests', (t) => { // [range, version] // Version should be detectable despite extra characters [ @@ -19,10 +17,10 @@ test('\nclean tests', function (t) { ['~1.2.3', null], ['<=1.2.3', null], ['1.2.x', null] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var msg = 'clean(' + range + ') = ' + version + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const msg = `clean(${ range }) = ${ version}` t.equal(clean(range), version, msg) }) t.end() diff --git a/test/functions/cmp.js b/test/functions/cmp.js new file mode 100644 index 00000000..2895898a --- /dev/null +++ b/test/functions/cmp.js @@ -0,0 +1,9 @@ +const { test } = require('tap') +const cmp = require('../../functions/cmp') + +test('invalid cmp usage', (t) => { + t.throws(() => { + cmp('1.2.3', 'a frog', '4.5.6') + }, new TypeError('Invalid operator: a frog')) + t.end() + }) \ No newline at end of file diff --git a/test/coerce.js b/test/functions/coerce.js similarity index 51% rename from test/coerce.js rename to test/functions/coerce.js index 42f206c6..615aa01e 100644 --- a/test/coerce.js +++ b/test/functions/coerce.js @@ -1,8 +1,7 @@ -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') -var coerce = semver.coerce -var valid = semver.valid +const { test } = require('tap') +const coerce = require('../../functions/coerce') +const parse = require('../../functions/parse') +const valid = require('../../functions/valid') function r (text) { return function (count) { @@ -10,7 +9,7 @@ function r (text) { } } -test('\ncoerce tests', function (t) { +test('coerce tests', (t) => { // Expected to be null (cannot be coerced). [ null, @@ -21,22 +20,22 @@ test('\ncoerce tests', function (t) { 'version one', r('9')(16), r('1')(17), - 'a' + r('9')(16), - 'a' + r('1')(17), - r('9')(16) + 'a', - r('1')(17) + 'a', - r('9')(16) + '.4.7.4', - r('9')(16) + '.' + r('2')(16) + '.' + r('3')(16), - r('1')(16) + '.' + r('9')(16) + '.' + r('3')(16), - r('1')(16) + '.' + r('2')(16) + '.' + r('9')(16) - ].forEach(function (input) { - var msg = 'coerce(' + input + ') should be null' + `a${ r('9')(16)}`, + `a${ r('1')(17)}`, + `${r('9')(16) }a`, + `${r('1')(17) }a`, + `${r('9')(16) }.4.7.4`, + `${r('9')(16) }.${ r('2')(16) }.${ r('3')(16)}`, + `${r('1')(16) }.${ r('9')(16) }.${ r('3')(16)}`, + `${r('1')(16) }.${ r('2')(16) }.${ r('9')(16)}` + ].forEach((input) => { + const msg = `coerce(${ input }) should be null` t.same(coerce(input), null, msg) }); // Expected to be the valid. [ - [semver.parse('1.2.3'), '1.2.3'], + [parse('1.2.3'), '1.2.3'], ['.1', '1.0.0'], ['.1.', '1.0.0'], ['..1', '1.0.0'], @@ -80,30 +79,30 @@ test('\ncoerce tests', function (t) { ['v2', '2.0.0'], ['v3.4 replaces v3.3.1', '3.4.0'], ['4.6.3.9.2-alpha2', '4.6.3'], - [r('1')(17) + '.2', '2.0.0'], - [r('1')(17) + '.2.3', '2.3.0'], - ['1.' + r('2')(17) + '.3', '1.0.0'], - ['1.2.' + r('3')(17), '1.2.0'], - [r('1')(17) + '.2.3.4', '2.3.4'], - ['1.' + r('2')(17) + '.3.4', '1.0.0'], - ['1.2.' + r('3')(17) + '.4', '1.2.0'], - [r('1')(17) + '.' + r('2')(16) + '.' + r('3')(16), - r('2')(16) + '.' + r('3')(16) + '.0'], - [r('1')(16) + '.' + r('2')(17) + '.' + r('3')(16), - r('1')(16) + '.0.0'], - [r('1')(16) + '.' + r('2')(16) + '.' + r('3')(17), - r('1')(16) + '.' + r('2')(16) + '.0'], - ['11' + r('.1')(126), '11.1.1'], - [r('1')(16), r('1')(16) + '.0.0'], - ['a' + r('1')(16), r('1')(16) + '.0.0'], - [r('1')(16) + '.2.3.4', r('1')(16) + '.2.3'], - ['1.' + r('2')(16) + '.3.4', '1.' + r('2')(16) + '.3'], - ['1.2.' + r('3')(16) + '.4', '1.2.' + r('3')(16)], - [r('1')(16) + '.' + r('2')(16) + '.' + r('3')(16), - r('1')(16) + '.' + r('2')(16) + '.' + r('3')(16)], - ['1.2.3.' + r('4')(252) + '.5', '1.2.3'], - ['1.2.3.' + r('4')(1024), '1.2.3'], - [r('1')(17) + '.4.7.4', '4.7.4'], + [`${r('1')(17) }.2`, '2.0.0'], + [`${r('1')(17) }.2.3`, '2.3.0'], + [`1.${ r('2')(17) }.3`, '1.0.0'], + [`1.2.${ r('3')(17)}`, '1.2.0'], + [`${r('1')(17) }.2.3.4`, '2.3.4'], + [`1.${ r('2')(17) }.3.4`, '1.0.0'], + [`1.2.${ r('3')(17) }.4`, '1.2.0'], + [`${r('1')(17) }.${ r('2')(16) }.${ r('3')(16)}`, + `${r('2')(16) }.${ r('3')(16) }.0`], + [`${r('1')(16) }.${ r('2')(17) }.${ r('3')(16)}`, + `${r('1')(16) }.0.0`], + [`${r('1')(16) }.${ r('2')(16) }.${ r('3')(17)}`, + `${r('1')(16) }.${ r('2')(16) }.0`], + [`11${ r('.1')(126)}`, '11.1.1'], + [r('1')(16), `${r('1')(16) }.0.0`], + [`a${ r('1')(16)}`, `${r('1')(16) }.0.0`], + [`${r('1')(16) }.2.3.4`, `${r('1')(16) }.2.3`], + [`1.${ r('2')(16) }.3.4`, `1.${ r('2')(16) }.3`], + [`1.2.${ r('3')(16) }.4`, `1.2.${ r('3')(16)}`], + [`${r('1')(16) }.${ r('2')(16) }.${ r('3')(16)}`, + `${r('1')(16) }.${ r('2')(16) }.${ r('3')(16)}`], + [`1.2.3.${ r('4')(252) }.5`, '1.2.3'], + [`1.2.3.${ r('4')(1024)}`, '1.2.3'], + [`${r('1')(17) }.4.7.4`, '4.7.4'], [10, '10.0.0'], ['1.2.3/a/b/c/2.3.4', '2.3.4', { rtl: true }], ['1.2.3.4.5.6', '4.5.6', { rtl: true }], @@ -114,11 +113,11 @@ test('\ncoerce tests', function (t) { ['1.2.3/6', '6.0.0', { rtl: true }], ['1.2.3.4', '2.3.4', { rtl: true }], ['1.2.3.4xyz', '2.3.4', { rtl: true }], - ].forEach(function (tuple, i) { - var input = tuple[0] - var expected = tuple[1] - var options = tuple[2] - var msg = 'coerce(' + input + ') should become ' + expected + ].forEach((tuple, i) => { + const input = tuple[0] + const expected = tuple[1] + const options = tuple[2] + const msg = `coerce(${ input }) should become ${ expected}` t.same((coerce(input, options) || {}).version, expected, msg) }) diff --git a/test/functions/compare-build.js b/test/functions/compare-build.js new file mode 100644 index 00000000..94abf47b --- /dev/null +++ b/test/functions/compare-build.js @@ -0,0 +1,19 @@ +const { test } = require('tap') +const SemVer = require('../../classes/semver') + +test('compareBuild', (t) => { + const noBuild = new SemVer('1.0.0') + const build0 = new SemVer('1.0.0+0') + const build1 = new SemVer('1.0.0+1') + const build10 = new SemVer('1.0.0+1.0') + t.equal(noBuild.compareBuild(build0), -1) + t.equal(build0.compareBuild(build0), 0) + t.equal(build0.compareBuild(noBuild), 1) + + t.equal(build0.compareBuild('1.0.0+0.0'), -1) + t.equal(build0.compareBuild(build1), -1) + t.equal(build1.compareBuild(build0), 1) + t.equal(build10.compareBuild(build1), 1) + + t.end() +}) \ No newline at end of file diff --git a/test/functions/compare-loose.js b/test/functions/compare-loose.js new file mode 100644 index 00000000..ad588d47 --- /dev/null +++ b/test/functions/compare-loose.js @@ -0,0 +1,31 @@ +const { test } = require('tap') +const compareLoose = require('../../functions/compare-loose') +const SemVer = require('../../classes/semver') +const eq = require('../../functions/eq') + +test('strict vs loose version numbers', (t) => { + [['=1.2.3', '1.2.3'], + ['01.02.03', '1.2.3'], + ['1.2.3-beta.01', '1.2.3-beta.1'], + [' =1.2.3', '1.2.3'], + ['1.2.3foo', '1.2.3-foo'] + ].forEach((v) => { + const loose = v[0] + const strict = v[1] + t.throws(() => { + SemVer(loose) // eslint-disable-line no-new + }) + const lv = new SemVer(loose, true) + t.equal(lv.version, strict) + t.ok(eq(loose, strict, true)) + t.throws(() => { + eq(loose, strict) + }) + t.throws(() => { + new SemVer(strict).compare(loose) + }) + t.equal(compareLoose(v[0], v[1]), 0) + }) + t.end() + }) + \ No newline at end of file diff --git a/test/functions/diff.js b/test/functions/diff.js new file mode 100644 index 00000000..a94b3816 --- /dev/null +++ b/test/functions/diff.js @@ -0,0 +1,30 @@ +const { test } = require('tap') +const diff = require('../../functions/diff') + +test('diff versions test', (t) => { +// [version1, version2, result] +// diff(version1, version2) -> result + [['1.2.3', '0.2.3', 'major'], + ['1.4.5', '0.2.3', 'major'], + ['1.2.3', '2.0.0-pre', 'premajor'], + ['1.2.3', '1.3.3', 'minor'], + ['1.0.1', '1.1.0-pre', 'preminor'], + ['1.2.3', '1.2.4', 'patch'], + ['1.2.3', '1.2.4-pre', 'prepatch'], + ['0.0.1', '0.0.1-pre', 'prerelease'], + ['0.0.1', '0.0.1-pre-2', 'prerelease'], + ['1.1.0', '1.1.0-pre', 'prerelease'], + ['1.1.0-pre-1', '1.1.0-pre-2', 'prerelease'], + ['1.0.0', '1.0.0', null] + + ].forEach((v) => { + const version1 = v[0] + const version2 = v[1] + const wanted = v[2] + const found = diff(version1, version2) + const cmd = `diff(${ version1 }, ${ version2 })` + t.equal(found, wanted, `${cmd } === ${ wanted}`) + }) + + t.end() +}) diff --git a/test/functions/inc.js b/test/functions/inc.js new file mode 100644 index 00000000..40bca58b --- /dev/null +++ b/test/functions/inc.js @@ -0,0 +1,115 @@ +const { test } = require('tap') +const inc = require('../../functions/inc') +const parse = require('../../functions/parse') + +test('increment versions test', (t) => { +// [version, inc, result, identifier] +// inc(version, inc) -> result + [['1.2.3', 'major', '2.0.0'], + ['1.2.3', 'minor', '1.3.0'], + ['1.2.3', 'patch', '1.2.4'], + ['1.2.3tag', 'major', '2.0.0', true], + ['1.2.3-tag', 'major', '2.0.0'], + ['1.2.3', 'fake', null], + ['1.2.0-0', 'patch', '1.2.0'], + ['fake', 'major', null], + ['1.2.3-4', 'major', '2.0.0'], + ['1.2.3-4', 'minor', '1.3.0'], + ['1.2.3-4', 'patch', '1.2.3'], + ['1.2.3-alpha.0.beta', 'major', '2.0.0'], + ['1.2.3-alpha.0.beta', 'minor', '1.3.0'], + ['1.2.3-alpha.0.beta', 'patch', '1.2.3'], + ['1.2.4', 'prerelease', '1.2.5-0'], + ['1.2.3-0', 'prerelease', '1.2.3-1'], + ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'], + ['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'], + ['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'], + ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'], + ['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'], + ['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'], + ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'], + ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'], + ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'], + ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'], + ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'], + ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'], + ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'], + ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'], + ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'], + ['1.2.0', 'prepatch', '1.2.1-0'], + ['1.2.0-1', 'prepatch', '1.2.1-0'], + ['1.2.0', 'preminor', '1.3.0-0'], + ['1.2.3-1', 'preminor', '1.3.0-0'], + ['1.2.0', 'premajor', '2.0.0-0'], + ['1.2.3-1', 'premajor', '2.0.0-0'], + ['1.2.0-1', 'minor', '1.2.0'], + ['1.0.0-1', 'major', '1.0.0'], + + ['1.2.3', 'major', '2.0.0', false, 'dev'], + ['1.2.3', 'minor', '1.3.0', false, 'dev'], + ['1.2.3', 'patch', '1.2.4', false, 'dev'], + ['1.2.3tag', 'major', '2.0.0', true, 'dev'], + ['1.2.3-tag', 'major', '2.0.0', false, 'dev'], + ['1.2.3', 'fake', null, false, 'dev'], + ['1.2.0-0', 'patch', '1.2.0', false, 'dev'], + ['fake', 'major', null, false, 'dev'], + ['1.2.3-4', 'major', '2.0.0', false, 'dev'], + ['1.2.3-4', 'minor', '1.3.0', false, 'dev'], + ['1.2.3-4', 'patch', '1.2.3', false, 'dev'], + ['1.2.3-alpha.0.beta', 'major', '2.0.0', false, 'dev'], + ['1.2.3-alpha.0.beta', 'minor', '1.3.0', false, 'dev'], + ['1.2.3-alpha.0.beta', 'patch', '1.2.3', false, 'dev'], + ['1.2.4', 'prerelease', '1.2.5-dev.0', false, 'dev'], + ['1.2.3-0', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1', false, 'alpha'], + ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta', false, 'alpha'], + ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta', false, 'alpha'], + ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta', false, 'alpha'], + ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta', false, 'alpha'], + ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1', false, 'alpha'], + ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2', false, 'alpha'], + ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3', false, 'alpha'], + ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'], + ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'], + ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'], + ['1.2.0', 'prepatch', '1.2.1-dev.0', false, 'dev'], + ['1.2.0-1', 'prepatch', '1.2.1-dev.0', false, 'dev'], + ['1.2.0', 'preminor', '1.3.0-dev.0', false, 'dev'], + ['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'], + ['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev'], + ['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev'], + ['1.2.0-1', 'minor', '1.2.0', false, 'dev'], + ['1.0.0-1', 'major', '1.0.0', 'dev'], + ['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev'] + + ].forEach((v) => { + const pre = v[0] + const what = v[1] + const wanted = v[2] + const loose = v[3] + const id = v[4] + const found = inc(pre, what, loose, id) + const cmd = `inc(${ pre }, ${ what }, ${ id })` + t.equal(found, wanted, `${cmd } === ${ wanted}`) + + const parsed = parse(pre, loose) + if (wanted) { + parsed.inc(what, id) + t.equal(parsed.version, wanted, `${cmd } object version updated`) + t.equal(parsed.raw, wanted, `${cmd } object raw field updated`) + } else if (parsed) { + t.throws(() => { + parsed.inc(what, id) + }) + } else { + t.equal(parsed, null) + } + }) + + t.end() +}) diff --git a/test/functions/major.js b/test/functions/major.js new file mode 100644 index 00000000..dd013a45 --- /dev/null +++ b/test/functions/major.js @@ -0,0 +1,25 @@ +const { test } = require('tap') +const major = require('../../functions/major') + +test('major tests', (t) => { + // [range, version] + // Version should be detectable despite extra characters + [ + ['1.2.3', 1], + [' 1.2.3 ', 1], + [' 2.2.3-4 ', 2], + [' 3.2.3-pre ', 3], + ['v5.2.3', 5], + [' v8.2.3 ', 8], + ['\t13.2.3', 13], + ['=21.2.3', 21, true], + ['v=34.2.3', 34, true] + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `major(${ range }) = ${ version}` + t.equal(major(range, loose), version, msg) + }) + t.end() +}) diff --git a/test/functions/minor.js b/test/functions/minor.js new file mode 100644 index 00000000..e54d8451 --- /dev/null +++ b/test/functions/minor.js @@ -0,0 +1,25 @@ +const { test } = require('tap') +const minor = require('../../functions/minor') + +test('minor tests', (t) => { + // [range, version] + // Version should be detectable despite extra characters + [ + ['1.1.3', 1], + [' 1.1.3 ', 1], + [' 1.2.3-4 ', 2], + [' 1.3.3-pre ', 3], + ['v1.5.3', 5], + [' v1.8.3 ', 8], + ['\t1.13.3', 13], + ['=1.21.3', 21, true], + ['v=1.34.3', 34, true] + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `minor(${ range }) = ${ version}` + t.equal(minor(range, loose), version, msg) + }) + t.end() +}) diff --git a/test/functions/patch.js b/test/functions/patch.js new file mode 100644 index 00000000..dbf5640d --- /dev/null +++ b/test/functions/patch.js @@ -0,0 +1,25 @@ +const { test } = require('tap') +const patch = require('../../functions/patch') + +test('patch tests', (t) => { + // [range, version] + // Version should be detectable despite extra characters + [ + ['1.2.1', 1], + [' 1.2.1 ', 1], + [' 1.2.2-4 ', 2], + [' 1.2.3-pre ', 3], + ['v1.2.5', 5], + [' v1.2.8 ', 8], + ['\t1.2.13', 13], + ['=1.2.21', 21, true], + ['v=1.2.34', 34, true] + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `patch(${ range }) = ${ version}` + t.equal(patch(range, loose), version, msg) + }) + t.end() +}) diff --git a/test/prerelease.js b/test/functions/prerelease.js similarity index 57% rename from test/prerelease.js rename to test/functions/prerelease.js index 77c14e40..48b54ef6 100644 --- a/test/prerelease.js +++ b/test/functions/prerelease.js @@ -1,9 +1,7 @@ -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') -var prerelease = semver.prerelease +const { test } = require('tap') +const prerelease = require('../../functions/prerelease') -test('\nprerelease', function (t) { +test('prerelease', (t) => { // [prereleaseParts, version, loose] [ [['alpha', 1], '1.2.2-alpha.1'], @@ -15,11 +13,11 @@ test('\nprerelease', function (t) { [null, '1.0.0', true], [null, '~2.0.0-alpha.1', false], [null, 'invalid version'] - ].forEach(function (tuple) { - var expected = tuple[0] - var version = tuple[1] - var loose = tuple[2] - var msg = 'prerelease(' + version + ')' + ].forEach((tuple) => { + const expected = tuple[0] + const version = tuple[1] + const loose = tuple[2] + const msg = `prerelease(${ version })` t.same(prerelease(version, loose), expected, msg) }) t.end() diff --git a/test/functions/rcompare.js b/test/functions/rcompare.js new file mode 100644 index 00000000..b354e894 --- /dev/null +++ b/test/functions/rcompare.js @@ -0,0 +1,12 @@ +const { test } = require('tap') +const rcompare = require('../../functions/rcompare') + +test('rcompare', (t) => { + t.equal(rcompare('1.0.0', '1.0.1'), 1) + t.equal(rcompare('1.0.0', '1.0.0'), 0) + t.equal(rcompare('1.0.0+0', '1.0.0'), 0) + t.equal(rcompare('1.0.1', '1.0.0'), -1) + + t.end() +}) + diff --git a/test/functions/rsort.js b/test/functions/rsort.js new file mode 100644 index 00000000..bfe2538e --- /dev/null +++ b/test/functions/rsort.js @@ -0,0 +1,21 @@ +const { test } = require('tap') +const rsort = require('../../functions/rsort') + +test('sorting', (t) => { + const list = [ + '1.2.3+1', + '1.2.3+0', + '1.2.3', + '5.9.6', + '0.1.2' + ] + const rsorted = [ + '5.9.6', + '1.2.3+1', + '1.2.3+0', + '1.2.3', + '0.1.2' + ] + t.same(rsort(list), rsorted) + t.end() + }) \ No newline at end of file diff --git a/test/functions/sort.js b/test/functions/sort.js new file mode 100644 index 00000000..3cde1c0c --- /dev/null +++ b/test/functions/sort.js @@ -0,0 +1,22 @@ +const { test } = require('tap') +const sort = require('../../functions/sort') + +test('sorting', (t) => { + const list = [ + '1.2.3+1', + '1.2.3+0', + '1.2.3', + '5.9.6', + '0.1.2' + ] + const sorted = [ + '0.1.2', + '1.2.3', + '1.2.3+0', + '1.2.3+1', + '5.9.6' + ] + + t.same(sort(list), sorted) + t.end() + }) \ No newline at end of file diff --git a/test/index.js b/test/index.js index cd325556..68be7015 100644 --- a/test/index.js +++ b/test/index.js @@ -1,39 +1,15 @@ -'use strict' - -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') -var eq = semver.eq -var gt = semver.gt -var lt = semver.lt -var neq = semver.neq -var cmp = semver.cmp -var gte = semver.gte -var lte = semver.lte -var satisfies = semver.satisfies -var validRange = semver.validRange -var inc = semver.inc -var diff = semver.diff -var toComparators = semver.toComparators -var SemVer = semver.SemVer -var Range = semver.Range -var Comparator = semver.Comparator - -test('has a list of src, re, and tokens', function (t) { - t.match(Object.assign({}, semver), { - src: Array, - re: Array, - tokens: Object - }) - semver.re.forEach(r => t.match(r, RegExp, 'regexps are regexps')) - semver.src.forEach(s => t.match(s, String, 'src is strings')) - for (const i in semver.tokens) { - t.match(semver.tokens[i], Number, 'tokens are numbers') - } - t.end() -}) - -test('comparison tests', function (t) { +const { test } = require('tap') +const semver = require('../') +const eq = semver.eq +const gt = semver.gt +const lt = semver.lt +const neq = semver.neq +const cmp = semver.cmp +const gte = semver.gte +const lte = semver.lte +const SemVer = semver.SemVer + +test('comparison tests', (t) => { // [version1, version2] // version1 should be greater than version2 [['0.0.0', '0.0.0-foo'], @@ -67,26 +43,26 @@ test('comparison tests', function (t) { ['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100'], ['1.2.3-r2', '1.2.3-r100'], ['1.2.3-r100', '1.2.3-R2'], - ].forEach(function (v) { - var v0 = v[0] - var v1 = v[1] - var loose = v[2] - t.ok(gt(v0, v1, loose), "gt('" + v0 + "', '" + v1 + "')") - t.ok(lt(v1, v0, loose), "lt('" + v1 + "', '" + v0 + "')") - t.ok(!gt(v1, v0, loose), "!gt('" + v1 + "', '" + v0 + "')") - t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')") - t.ok(eq(v0, v0, loose), "eq('" + v0 + "', '" + v0 + "')") - t.ok(eq(v1, v1, loose), "eq('" + v1 + "', '" + v1 + "')") - t.ok(neq(v0, v1, loose), "neq('" + v0 + "', '" + v1 + "')") - t.ok(cmp(v1, '==', v1, loose), "cmp('" + v1 + "' == '" + v1 + "')") - t.ok(cmp(v0, '>=', v1, loose), "cmp('" + v0 + "' >= '" + v1 + "')") - t.ok(cmp(v1, '<=', v0, loose), "cmp('" + v1 + "' <= '" + v0 + "')") - t.ok(cmp(v0, '!=', v1, loose), "cmp('" + v0 + "' != '" + v1 + "')") - }) - t.end() -}) - -test('equality tests', function (t) { + ].forEach((v) => { + const v0 = v[0] + const v1 = v[1] + const loose = v[2] + t.ok(gt(v0, v1, loose), `gt('${ v0 }', '${ v1 }')`) + t.ok(lt(v1, v0, loose), `lt('${ v1 }', '${ v0 }')`) + t.ok(!gt(v1, v0, loose), `!gt('${ v1 }', '${ v0 }')`) + t.ok(!lt(v0, v1, loose), `!lt('${ v0 }', '${ v1 }')`) + t.ok(eq(v0, v0, loose), `eq('${ v0 }', '${ v0 }')`) + t.ok(eq(v1, v1, loose), `eq('${ v1 }', '${ v1 }')`) + t.ok(neq(v0, v1, loose), `neq('${ v0 }', '${ v1 }')`) + t.ok(cmp(v1, '==', v1, loose), `cmp('${ v1 }' == '${ v1 }')`) + t.ok(cmp(v0, '>=', v1, loose), `cmp('${ v0 }' >= '${ v1 }')`) + t.ok(cmp(v1, '<=', v0, loose), `cmp('${ v1 }' <= '${ v0 }')`) + t.ok(cmp(v0, '!=', v1, loose), `cmp('${ v0 }' != '${ v1 }')`) + }) + t.end() +}) + +test('equality tests', (t) => { // [version1, version2] // version1 should be equivalent to version2 [['1.2.3', 'v1.2.3', true], @@ -126,969 +102,30 @@ test('equality tests', function (t) { ['1.2.3-beta+build', '1.2.3-beta+otherbuild'], ['1.2.3+build', '1.2.3+otherbuild'], [' v1.2.3+build', '1.2.3+otherbuild'] - ].forEach(function (v) { - var v0 = v[0] - var v1 = v[1] - var loose = v[2] - t.ok(eq(v0, v1, loose), "eq('" + v0 + "', '" + v1 + "')") - t.ok(!neq(v0, v1, loose), "!neq('" + v0 + "', '" + v1 + "')") - t.ok(cmp(v0, '==', v1, loose), 'cmp(' + v0 + '==' + v1 + ')') - t.ok(!cmp(v0, '!=', v1, loose), '!cmp(' + v0 + '!=' + v1 + ')') - t.ok(!cmp(v0, '===', v1, loose), '!cmp(' + v0 + '===' + v1 + ')') + ].forEach((v) => { + const v0 = v[0] + const v1 = v[1] + const loose = v[2] + t.ok(eq(v0, v1, loose), `eq('${ v0 }', '${ v1 }')`) + t.ok(!neq(v0, v1, loose), `!neq('${ v0 }', '${ v1 }')`) + t.ok(cmp(v0, '==', v1, loose), `cmp(${ v0 }==${ v1 })`) + t.ok(!cmp(v0, '!=', v1, loose), `!cmp(${ v0 }!=${ v1 })`) + t.ok(!cmp(v0, '===', v1, loose), `!cmp(${ v0 }===${ v1 })`) // also test with an object. they are === because obj.version matches t.ok(cmp(new SemVer(v0, { loose: loose }), '===', new SemVer(v1, { loose: loose })), - '!cmp(' + v0 + '===' + v1 + ') object') + `!cmp(${ v0 }===${ v1 }) object`) - t.ok(cmp(v0, '!==', v1, loose), 'cmp(' + v0 + '!==' + v1 + ')') + t.ok(cmp(v0, '!==', v1, loose), `cmp(${ v0 }!==${ v1 })`) t.ok(!cmp(new SemVer(v0, loose), '!==', new SemVer(v1, loose)), - 'cmp(' + v0 + '!==' + v1 + ') object') - - t.ok(!gt(v0, v1, loose), "!gt('" + v0 + "', '" + v1 + "')") - t.ok(gte(v0, v1, loose), "gte('" + v0 + "', '" + v1 + "')") - t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')") - t.ok(lte(v0, v1, loose), "lte('" + v0 + "', '" + v1 + "')") - }) - t.end() -}) - -test('range tests', function (t) { - // [range, version] - // version should be included by range - [['1.0.0 - 2.0.0', '1.2.3'], - ['^1.2.3+build', '1.2.3'], - ['^1.2.3+build', '1.3.0'], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'], - ['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true], - ['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true], - ['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'], - ['1.2.3+asdf - 2.4.3+asdf', '1.2.3'], - ['1.0.0', '1.0.0'], - ['>=*', '0.2.4'], - ['', '1.0.0'], - ['*', '1.2.3', {}], - ['*', 'v1.2.3', { loose: 123 }], - ['>=1.0.0', '1.0.0', /asdf/], - ['>=1.0.0', '1.0.1', { loose: null }], - ['>=1.0.0', '1.1.0', { loose: 0 }], - ['>1.0.0', '1.0.1', { loose: undefined }], - ['>1.0.0', '1.1.0'], - ['<=2.0.0', '2.0.0'], - ['<=2.0.0', '1.9999.9999'], - ['<=2.0.0', '0.2.9'], - ['<2.0.0', '1.9999.9999'], - ['<2.0.0', '0.2.9'], - ['>= 1.0.0', '1.0.0'], - ['>= 1.0.0', '1.0.1'], - ['>= 1.0.0', '1.1.0'], - ['> 1.0.0', '1.0.1'], - ['> 1.0.0', '1.1.0'], - ['<= 2.0.0', '2.0.0'], - ['<= 2.0.0', '1.9999.9999'], - ['<= 2.0.0', '0.2.9'], - ['< 2.0.0', '1.9999.9999'], - ['<\t2.0.0', '0.2.9'], - ['>=0.1.97', 'v0.1.97', true], - ['>=0.1.97', '0.1.97'], - ['0.1.20 || 1.2.4', '1.2.4'], - ['>=0.2.3 || <0.0.1', '0.0.0'], - ['>=0.2.3 || <0.0.1', '0.2.3'], - ['>=0.2.3 || <0.0.1', '0.2.4'], - ['||', '1.3.4'], - ['2.x.x', '2.1.3'], - ['1.2.x', '1.2.3'], - ['1.2.x || 2.x', '2.1.3'], - ['1.2.x || 2.x', '1.2.3'], - ['x', '1.2.3'], - ['2.*.*', '2.1.3'], - ['1.2.*', '1.2.3'], - ['1.2.* || 2.*', '2.1.3'], - ['1.2.* || 2.*', '1.2.3'], - ['*', '1.2.3'], - ['2', '2.1.2'], - ['2.3', '2.3.1'], - ['~0.0.1', '0.0.1'], - ['~0.0.1', '0.0.2'], - ['~x', '0.0.9'], // >=2.4.0 <2.5.0 - ['~2', '2.0.9'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.5'], - ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0, - ['~1', '1.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '1.2.3'], - ['~> 1', '1.2.3'], - ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0, - ['~ 1.0', '1.0.2'], - ['~ 1.0.3', '1.0.12'], - ['~ 1.0.3alpha', '1.0.12', { loose: true }], - ['>=1', '1.0.0'], - ['>= 1', '1.0.0'], - ['<1.2', '1.1.1'], - ['< 1.2', '1.1.1'], - ['~v0.5.4-pre', '0.5.5'], - ['~v0.5.4-pre', '0.5.4'], - ['=0.7.x', '0.7.2'], - ['<=0.7.x', '0.7.2'], - ['>=0.7.x', '0.7.2'], - ['<=0.7.x', '0.6.2'], - ['~1.2.1 >=1.2.3', '1.2.3'], - ['~1.2.1 =1.2.3', '1.2.3'], - ['~1.2.1 1.2.3', '1.2.3'], - ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'], - ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'], - ['~1.2.1 1.2.3', '1.2.3'], - ['>=1.2.1 1.2.3', '1.2.3'], - ['1.2.3 >=1.2.1', '1.2.3'], - ['>=1.2.3 >=1.2.1', '1.2.3'], - ['>=1.2.1 >=1.2.3', '1.2.3'], - ['>=1.2', '1.2.8'], - ['^1.2.3', '1.8.1'], - ['^0.1.2', '0.1.2'], - ['^0.1', '0.1.2'], - ['^0.0.1', '0.0.1'], - ['^1.2', '1.4.2'], - ['^1.2 ^1', '1.4.2'], - ['^1.2.3-alpha', '1.2.3-pre'], - ['^1.2.0-alpha', '1.2.0-pre'], - ['^0.0.1-alpha', '0.0.1-beta'], - ['^0.0.1-alpha', '0.0.1'], - ['^0.1.1-alpha', '0.1.1-beta'], - ['^x', '1.2.3'], - ['x - 1.0.0', '0.9.7'], - ['x - 1.x', '0.9.7'], - ['1.0.0 - x', '1.9.7'], - ['1.x - x', '1.9.7'], - ['<=7.x', '7.9.9'], - ['2.x', '2.0.0-pre.0', { includePrerelease: true }], - ['2.x', '2.1.0-pre.0', { includePrerelease: true }], - ].forEach(function (v) { - var range = v[0] - var ver = v[1] - var options = v[2] - t.ok(satisfies(ver, range, options), range + ' satisfied by ' + ver) - }) - t.end() -}) - -test('negative range tests', function (t) { - // [range, version] - // version should not be included by range - [['1.0.0 - 2.0.0', '2.2.3'], - ['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'], - ['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'], - ['^1.2.3+build', '2.0.0'], - ['^1.2.3+build', '1.2.0'], - ['^1.2.3', '1.2.3-pre'], - ['^1.2', '1.2.0-pre'], - ['>1.2', '1.3.0-beta'], - ['<=1.2.3', '1.2.3-beta'], - ['^1.2.3', '1.2.3-beta'], - ['=0.7.x', '0.7.0-asdf'], - ['>=0.7.x', '0.7.0-asdf'], - ['1', '1.0.0beta', { loose: 420 }], - ['<1', '1.0.0beta', true], - ['< 1', '1.0.0beta', true], - ['1.0.0', '1.0.1'], - ['>=1.0.0', '0.0.0'], - ['>=1.0.0', '0.0.1'], - ['>=1.0.0', '0.1.0'], - ['>1.0.0', '0.0.1'], - ['>1.0.0', '0.1.0'], - ['<=2.0.0', '3.0.0'], - ['<=2.0.0', '2.9999.9999'], - ['<=2.0.0', '2.2.9'], - ['<2.0.0', '2.9999.9999'], - ['<2.0.0', '2.2.9'], - ['>=0.1.97', 'v0.1.93', true], - ['>=0.1.97', '0.1.93'], - ['0.1.20 || 1.2.4', '1.2.3'], - ['>=0.2.3 || <0.0.1', '0.0.3'], - ['>=0.2.3 || <0.0.1', '0.2.2'], - ['2.x.x', '1.1.3', { loose: NaN }], - ['2.x.x', '3.1.3'], - ['1.2.x', '1.3.3'], - ['1.2.x || 2.x', '3.1.3'], - ['1.2.x || 2.x', '1.1.3'], - ['2.*.*', '1.1.3'], - ['2.*.*', '3.1.3'], - ['1.2.*', '1.3.3'], - ['1.2.* || 2.*', '3.1.3'], - ['1.2.* || 2.*', '1.1.3'], - ['2', '1.1.2'], - ['2.3', '2.4.1'], - ['~0.0.1', '0.1.0-alpha'], - ['~0.0.1', '0.1.0'], - ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.3.9'], - ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 - ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 - ['~1', '0.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '2.2.3'], - ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 - ['<1', '1.0.0'], - ['>=1.2', '1.1.1'], - ['1', '2.0.0beta', true], - ['~v0.5.4-beta', '0.5.4-alpha'], - ['=0.7.x', '0.8.2'], - ['>=0.7.x', '0.6.2'], - ['<0.7.x', '0.7.2'], - ['<1.2.3', '1.2.3-beta'], - ['=1.2.3', '1.2.3-beta'], - ['>1.2', '1.2.8'], - ['^0.0.1', '0.0.2-alpha'], - ['^0.0.1', '0.0.2'], - ['^1.2.3', '2.0.0-alpha'], - ['^1.2.3', '1.2.2'], - ['^1.2', '1.1.9'], - ['*', 'v1.2.3-foo', true], - // invalid ranges never satisfied! - ['blerg', '1.2.3'], - ['git+https://user:password0123@github.com/foo', '123.0.0', true], - ['^1.2.3', '2.0.0-pre'], - ['0.x', undefined], - ['*', undefined], - // invalid versions never satisfy, but shouldn't throw - ['*', 'not a version'], - ['>=2', 'glorp'], - ['2.x', '3.0.0-pre.0', { includePrerelease: true }], - ].forEach(function (v) { - var range = v[0] - var ver = v[1] - var options = v[2] - var found = satisfies(ver, range, options) - t.ok(!found, ver + ' not satisfied by ' + range) - }) - t.end() -}) - -test('unlocked prerelease range tests', function (t) { - // [range, version] - // version should be included by range - [['*', '1.0.0-rc1'], - ['^1.0.0', '2.0.0-rc1'], - ['^1.0.0-0', '1.0.1-rc1'], - ['^1.0.0-rc2', '1.0.1-rc1'], - ['^1.0.0', '1.0.1-rc1'], - ['^1.0.0', '1.1.0-rc1'] - ].forEach(function (v) { - var range = v[0] - var ver = v[1] - var options = { includePrerelease: true } - t.ok(satisfies(ver, range, options), range + ' satisfied by ' + ver) - }) - t.end() -}) - -test('negative unlocked prerelease range tests', function (t) { - // [range, version] - // version should not be included by range - [['^1.0.0', '1.0.0-rc1'], - ['^1.2.3-rc2', '2.0.0'] - ].forEach(function (v) { - var range = v[0] - var ver = v[1] - var options = { includePrerelease: true } - var found = satisfies(ver, range, options) - t.ok(!found, ver + ' not satisfied by ' + range) - }) - t.end() -}) - -test('increment versions test', function (t) { -// [version, inc, result, identifier] -// inc(version, inc) -> result - [['1.2.3', 'major', '2.0.0'], - ['1.2.3', 'minor', '1.3.0'], - ['1.2.3', 'patch', '1.2.4'], - ['1.2.3tag', 'major', '2.0.0', true], - ['1.2.3-tag', 'major', '2.0.0'], - ['1.2.3', 'fake', null], - ['1.2.0-0', 'patch', '1.2.0'], - ['fake', 'major', null], - ['1.2.3-4', 'major', '2.0.0'], - ['1.2.3-4', 'minor', '1.3.0'], - ['1.2.3-4', 'patch', '1.2.3'], - ['1.2.3-alpha.0.beta', 'major', '2.0.0'], - ['1.2.3-alpha.0.beta', 'minor', '1.3.0'], - ['1.2.3-alpha.0.beta', 'patch', '1.2.3'], - ['1.2.4', 'prerelease', '1.2.5-0'], - ['1.2.3-0', 'prerelease', '1.2.3-1'], - ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'], - ['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'], - ['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'], - ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'], - ['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'], - ['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'], - ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'], - ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'], - ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'], - ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'], - ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'], - ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'], - ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'], - ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'], - ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'], - ['1.2.0', 'prepatch', '1.2.1-0'], - ['1.2.0-1', 'prepatch', '1.2.1-0'], - ['1.2.0', 'preminor', '1.3.0-0'], - ['1.2.3-1', 'preminor', '1.3.0-0'], - ['1.2.0', 'premajor', '2.0.0-0'], - ['1.2.3-1', 'premajor', '2.0.0-0'], - ['1.2.0-1', 'minor', '1.2.0'], - ['1.0.0-1', 'major', '1.0.0'], - - ['1.2.3', 'major', '2.0.0', false, 'dev'], - ['1.2.3', 'minor', '1.3.0', false, 'dev'], - ['1.2.3', 'patch', '1.2.4', false, 'dev'], - ['1.2.3tag', 'major', '2.0.0', true, 'dev'], - ['1.2.3-tag', 'major', '2.0.0', false, 'dev'], - ['1.2.3', 'fake', null, false, 'dev'], - ['1.2.0-0', 'patch', '1.2.0', false, 'dev'], - ['fake', 'major', null, false, 'dev'], - ['1.2.3-4', 'major', '2.0.0', false, 'dev'], - ['1.2.3-4', 'minor', '1.3.0', false, 'dev'], - ['1.2.3-4', 'patch', '1.2.3', false, 'dev'], - ['1.2.3-alpha.0.beta', 'major', '2.0.0', false, 'dev'], - ['1.2.3-alpha.0.beta', 'minor', '1.3.0', false, 'dev'], - ['1.2.3-alpha.0.beta', 'patch', '1.2.3', false, 'dev'], - ['1.2.4', 'prerelease', '1.2.5-dev.0', false, 'dev'], - ['1.2.3-0', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1', false, 'alpha'], - ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta', false, 'alpha'], - ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta', false, 'alpha'], - ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta', false, 'alpha'], - ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta', false, 'alpha'], - ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1', false, 'alpha'], - ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2', false, 'alpha'], - ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3', false, 'alpha'], - ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'], - ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'], - ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'], - ['1.2.0', 'prepatch', '1.2.1-dev.0', false, 'dev'], - ['1.2.0-1', 'prepatch', '1.2.1-dev.0', false, 'dev'], - ['1.2.0', 'preminor', '1.3.0-dev.0', false, 'dev'], - ['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'], - ['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev'], - ['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev'], - ['1.2.0-1', 'minor', '1.2.0', false, 'dev'], - ['1.0.0-1', 'major', '1.0.0', 'dev'], - ['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev'] - - ].forEach(function (v) { - var pre = v[0] - var what = v[1] - var wanted = v[2] - var loose = v[3] - var id = v[4] - var found = inc(pre, what, loose, id) - var cmd = 'inc(' + pre + ', ' + what + ', ' + id + ')' - t.equal(found, wanted, cmd + ' === ' + wanted) - - var parsed = semver.parse(pre, loose) - if (wanted) { - parsed.inc(what, id) - t.equal(parsed.version, wanted, cmd + ' object version updated') - t.equal(parsed.raw, wanted, cmd + ' object raw field updated') - } else if (parsed) { - t.throws(function () { - parsed.inc(what, id) - }) - } else { - t.equal(parsed, null) - } - }) - - t.end() -}) - -test('diff versions test', function (t) { -// [version1, version2, result] -// diff(version1, version2) -> result - [['1.2.3', '0.2.3', 'major'], - ['1.4.5', '0.2.3', 'major'], - ['1.2.3', '2.0.0-pre', 'premajor'], - ['1.2.3', '1.3.3', 'minor'], - ['1.0.1', '1.1.0-pre', 'preminor'], - ['1.2.3', '1.2.4', 'patch'], - ['1.2.3', '1.2.4-pre', 'prepatch'], - ['0.0.1', '0.0.1-pre', 'prerelease'], - ['0.0.1', '0.0.1-pre-2', 'prerelease'], - ['1.1.0', '1.1.0-pre', 'prerelease'], - ['1.1.0-pre-1', '1.1.0-pre-2', 'prerelease'], - ['1.0.0', '1.0.0', null] - - ].forEach(function (v) { - var version1 = v[0] - var version2 = v[1] - var wanted = v[2] - var found = diff(version1, version2) - var cmd = 'diff(' + version1 + ', ' + version2 + ')' - t.equal(found, wanted, cmd + ' === ' + wanted) - }) - - t.end() -}) - -test('valid range test', function (t) { - // [range, result] - // validRange(range) -> result - // translate ranges into their canonical form - [['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], - ['1.0.0', '1.0.0'], - ['>=*', '*'], - ['', '*'], - ['*', '*'], - ['*', '*'], - ['>=1.0.0', '>=1.0.0'], - ['>1.0.0', '>1.0.0'], - ['<=2.0.0', '<=2.0.0'], - ['1', '>=1.0.0 <2.0.0'], - ['<=2.0.0', '<=2.0.0'], - ['<=2.0.0', '<=2.0.0'], - ['<2.0.0', '<2.0.0'], - ['<2.0.0', '<2.0.0'], - ['>= 1.0.0', '>=1.0.0'], - ['>= 1.0.0', '>=1.0.0'], - ['>= 1.0.0', '>=1.0.0'], - ['> 1.0.0', '>1.0.0'], - ['> 1.0.0', '>1.0.0'], - ['<= 2.0.0', '<=2.0.0'], - ['<= 2.0.0', '<=2.0.0'], - ['<= 2.0.0', '<=2.0.0'], - ['< 2.0.0', '<2.0.0'], - ['<\t2.0.0', '<2.0.0'], - ['>=0.1.97', '>=0.1.97'], - ['>=0.1.97', '>=0.1.97'], - ['0.1.20 || 1.2.4', '0.1.20||1.2.4'], - ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], - ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], - ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], - ['||', '||'], - ['2.x.x', '>=2.0.0 <3.0.0'], - ['1.2.x', '>=1.2.0 <1.3.0'], - ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], - ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], - ['x', '*'], - ['2.*.*', '>=2.0.0 <3.0.0'], - ['1.2.*', '>=1.2.0 <1.3.0'], - ['1.2.* || 2.*', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], - ['*', '*'], - ['2', '>=2.0.0 <3.0.0'], - ['2.3', '>=2.3.0 <2.4.0'], - ['~2.4', '>=2.4.0 <2.5.0'], - ['~2.4', '>=2.4.0 <2.5.0'], - ['~>3.2.1', '>=3.2.1 <3.3.0'], - ['~1', '>=1.0.0 <2.0.0'], - ['~>1', '>=1.0.0 <2.0.0'], - ['~> 1', '>=1.0.0 <2.0.0'], - ['~1.0', '>=1.0.0 <1.1.0'], - ['~ 1.0', '>=1.0.0 <1.1.0'], - ['^0', '>=0.0.0 <1.0.0'], - ['^ 1', '>=1.0.0 <2.0.0'], - ['^0.1', '>=0.1.0 <0.2.0'], - ['^1.0', '>=1.0.0 <2.0.0'], - ['^1.2', '>=1.2.0 <2.0.0'], - ['^0.0.1', '>=0.0.1 <0.0.2'], - ['^0.0.1-beta', '>=0.0.1-beta <0.0.2'], - ['^0.1.2', '>=0.1.2 <0.2.0'], - ['^1.2.3', '>=1.2.3 <2.0.0'], - ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0'], - ['<1', '<1.0.0'], - ['< 1', '<1.0.0'], - ['>=1', '>=1.0.0'], - ['>= 1', '>=1.0.0'], - ['<1.2', '<1.2.0'], - ['< 1.2', '<1.2.0'], - ['1', '>=1.0.0 <2.0.0'], - ['>01.02.03', '>1.2.3', true], - ['>01.02.03', null], - ['~1.2.3beta', '>=1.2.3-beta <1.3.0', true], - ['~1.2.3beta', null], - ['^ 1.2 ^ 1', '>=1.2.0 <2.0.0 >=1.0.0 <2.0.0'] - ].forEach(function (v) { - var pre = v[0] - var wanted = v[1] - var loose = v[2] - var found = validRange(pre, loose) - - t.equal(found, wanted, 'validRange(' + pre + ') === ' + wanted) - }) - - t.end() -}) - -test('comparators test', function (t) { - // [range, comparators] - // turn range into a set of individual comparators - [['1.0.0 - 2.0.0', [['>=1.0.0', '<=2.0.0']]], - ['1.0.0', [['1.0.0']]], - ['>=*', [['']]], - ['', [['']]], - ['*', [['']]], - ['*', [['']]], - ['>=1.0.0', [['>=1.0.0']]], - ['>=1.0.0', [['>=1.0.0']]], - ['>=1.0.0', [['>=1.0.0']]], - ['>1.0.0', [['>1.0.0']]], - ['>1.0.0', [['>1.0.0']]], - ['<=2.0.0', [['<=2.0.0']]], - ['1', [['>=1.0.0', '<2.0.0']]], - ['<=2.0.0', [['<=2.0.0']]], - ['<=2.0.0', [['<=2.0.0']]], - ['<2.0.0', [['<2.0.0']]], - ['<2.0.0', [['<2.0.0']]], - ['>= 1.0.0', [['>=1.0.0']]], - ['>= 1.0.0', [['>=1.0.0']]], - ['>= 1.0.0', [['>=1.0.0']]], - ['> 1.0.0', [['>1.0.0']]], - ['> 1.0.0', [['>1.0.0']]], - ['<= 2.0.0', [['<=2.0.0']]], - ['<= 2.0.0', [['<=2.0.0']]], - ['<= 2.0.0', [['<=2.0.0']]], - ['< 2.0.0', [['<2.0.0']]], - ['<\t2.0.0', [['<2.0.0']]], - ['>=0.1.97', [['>=0.1.97']]], - ['>=0.1.97', [['>=0.1.97']]], - ['0.1.20 || 1.2.4', [['0.1.20'], ['1.2.4']]], - ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], - ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], - ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], - ['||', [[''], ['']]], - ['2.x.x', [['>=2.0.0', '<3.0.0']]], - ['1.2.x', [['>=1.2.0', '<1.3.0']]], - ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], - ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], - ['x', [['']]], - ['2.*.*', [['>=2.0.0', '<3.0.0']]], - ['1.2.*', [['>=1.2.0', '<1.3.0']]], - ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], - ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], - ['*', [['']]], - ['2', [['>=2.0.0', '<3.0.0']]], - ['2.3', [['>=2.3.0', '<2.4.0']]], - ['~2.4', [['>=2.4.0', '<2.5.0']]], - ['~2.4', [['>=2.4.0', '<2.5.0']]], - ['~>3.2.1', [['>=3.2.1', '<3.3.0']]], - ['~1', [['>=1.0.0', '<2.0.0']]], - ['~>1', [['>=1.0.0', '<2.0.0']]], - ['~> 1', [['>=1.0.0', '<2.0.0']]], - ['~1.0', [['>=1.0.0', '<1.1.0']]], - ['~ 1.0', [['>=1.0.0', '<1.1.0']]], - ['~ 1.0.3', [['>=1.0.3', '<1.1.0']]], - ['~> 1.0.3', [['>=1.0.3', '<1.1.0']]], - ['<1', [['<1.0.0']]], - ['< 1', [['<1.0.0']]], - ['>=1', [['>=1.0.0']]], - ['>= 1', [['>=1.0.0']]], - ['<1.2', [['<1.2.0']]], - ['< 1.2', [['<1.2.0']]], - ['1', [['>=1.0.0', '<2.0.0']]], - ['1 2', [['>=1.0.0', '<2.0.0', '>=2.0.0', '<3.0.0']]], - ['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]], - ['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0']]], - ['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]], - ['>*', [['<0.0.0-0']]], - ['<*', [['<0.0.0-0']]] - ].forEach(function (v) { - var pre = v[0] - var wanted = v[1] - var found = toComparators(v[0]) - var jw = JSON.stringify(wanted) - t.equivalent(found, wanted, 'toComparators(' + pre + ') === ' + jw) - }) - - t.end() -}) - -test('invalid version numbers', function (t) { - ['1.2.3.4', - 'NOT VALID', - 1.2, - null, - 'Infinity.NaN.Infinity' - ].forEach(function (v) { - t.throws(function () { - new SemVer(v) // eslint-disable-line no-new - }, { name: 'TypeError', message: 'Invalid Version: ' + v }) - }) - - t.end() -}) - -test('strict vs loose version numbers', function (t) { - [['=1.2.3', '1.2.3'], - ['01.02.03', '1.2.3'], - ['1.2.3-beta.01', '1.2.3-beta.1'], - [' =1.2.3', '1.2.3'], - ['1.2.3foo', '1.2.3-foo'] - ].forEach(function (v) { - var loose = v[0] - var strict = v[1] - t.throws(function () { - SemVer(loose) // eslint-disable-line no-new - }) - var lv = new SemVer(loose, true) - t.equal(lv.version, strict) - t.ok(eq(loose, strict, true)) - t.throws(function () { - eq(loose, strict) - }) - t.throws(function () { - new SemVer(strict).compare(loose) - }) - t.equal(semver.compareLoose(v[0], v[1]), 0) - }) - t.end() -}) - -test('compare main vs pre', function (t) { - var s = new SemVer('1.2.3') - t.equal(s.compareMain('2.3.4'), -1) - t.equal(s.compareMain('1.2.4'), -1) - t.equal(s.compareMain('0.1.2'), 1) - t.equal(s.compareMain('1.2.2'), 1) - t.equal(s.compareMain('1.2.3-pre'), 0) - - const p = new SemVer('1.2.3-alpha.0.pr.1') - t.equal(p.comparePre('9.9.9-alpha.0.pr.1'), 0) - t.equal(p.comparePre('1.2.3'), -1) - t.equal(p.comparePre('1.2.3-alpha.0.pr.2'), -1) - t.equal(p.comparePre('1.2.3-alpha.0.2'), 1) - - t.end() -}) - -test('compareBuild', function (t) { - var noBuild = new SemVer('1.0.0') - var build0 = new SemVer('1.0.0+0') - var build1 = new SemVer('1.0.0+1') - var build10 = new SemVer('1.0.0+1.0') - t.equal(noBuild.compareBuild(build0), -1) - t.equal(build0.compareBuild(build0), 0) - t.equal(build0.compareBuild(noBuild), 1) - - t.equal(build0.compareBuild('1.0.0+0.0'), -1) - t.equal(build0.compareBuild(build1), -1) - t.equal(build1.compareBuild(build0), 1) - t.equal(build10.compareBuild(build1), 1) - - t.end() -}) - -test('rcompare', function (t) { - t.equal(semver.rcompare('1.0.0', '1.0.1'), 1) - t.equal(semver.rcompare('1.0.0', '1.0.0'), 0) - t.equal(semver.rcompare('1.0.0+0', '1.0.0'), 0) - t.equal(semver.rcompare('1.0.1', '1.0.0'), -1) - - t.end() -}) - -test('rcompareIdentifiers and compareIdentifiers', function (t) { - var set = [ - ['1', '2'], - ['alpha', 'beta'], - ['0', 'beta'], - ] - set.forEach(function (ab) { - var a = ab[0] - var b = ab[1] - t.equal(semver.compareIdentifiers(a, b), -1) - t.equal(semver.rcompareIdentifiers(a, b), 1) - }) - t.equal(semver.compareIdentifiers('0', '0'), 0) - t.equal(semver.rcompareIdentifiers('0', '0'), 0) - t.end() -}) - -test('strict vs loose ranges', function (t) { - [['>=01.02.03', '>=1.2.3'], - ['~1.02.03beta', '>=1.2.3-beta <1.3.0'] - ].forEach(function (v) { - var loose = v[0] - var comps = v[1] - t.throws(function () { - new Range(loose) // eslint-disable-line no-new - }) - t.equal(new Range(loose, true).range, comps) - }) - t.end() -}) - -test('max satisfying', function (t) { - [[['1.2.3', '1.2.4'], '1.2', '1.2.4'], - [['1.2.4', '1.2.3'], '1.2', '1.2.4'], - [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'], - [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] - ].forEach(function (v) { - var versions = v[0] - var range = v[1] - var expect = v[2] - var loose = v[3] - var actual = semver.maxSatisfying(versions, range, loose) - t.equal(actual, expect) - }) - t.end() -}) - -test('min satisfying', function (t) { - [[['1.2.3', '1.2.4'], '1.2', '1.2.3'], - [['1.2.4', '1.2.3'], '1.2', '1.2.3'], - [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.3'], - [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] - ].forEach(function (v) { - var versions = v[0] - var range = v[1] - var expect = v[2] - var loose = v[3] - var actual = semver.minSatisfying(versions, range, loose) - t.equal(actual, expect) - }) - t.end() -}) - -test('intersect comparators', function (t) { - [ - // One is a Version - ['1.3.0', '>=1.3.0', true], - ['1.3.0', '>1.3.0', false], - ['>=1.3.0', '1.3.0', true], - ['>1.3.0', '1.3.0', false], - // Same direction increasing - ['>1.3.0', '>1.2.0', true], - ['>1.2.0', '>1.3.0', true], - ['>=1.2.0', '>1.3.0', true], - ['>1.2.0', '>=1.3.0', true], - // Same direction decreasing - ['<1.3.0', '<1.2.0', true], - ['<1.2.0', '<1.3.0', true], - ['<=1.2.0', '<1.3.0', true], - ['<1.2.0', '<=1.3.0', true], - // Different directions, same semver and inclusive operator - ['>=1.3.0', '<=1.3.0', true], - ['>=v1.3.0', '<=1.3.0', true], - ['>=1.3.0', '>=1.3.0', true], - ['<=1.3.0', '<=1.3.0', true], - ['<=1.3.0', '<=v1.3.0', true], - ['>1.3.0', '<=1.3.0', false], - ['>=1.3.0', '<1.3.0', false], - // Opposite matching directions - ['>1.0.0', '<2.0.0', true], - ['>=1.0.0', '<2.0.0', true], - ['>=1.0.0', '<=2.0.0', true], - ['>1.0.0', '<=2.0.0', true], - ['<=2.0.0', '>1.0.0', true], - ['<=1.0.0', '>=2.0.0', false] - ].forEach(function (v) { - var comparator1 = new Comparator(v[0]) - var comparator2 = new Comparator(v[1]) - var expect = v[2] + `cmp(${ v0 }!==${ v1 }) object`) - var actual1 = comparator1.intersects(comparator2, false) - var actual2 = comparator2.intersects(comparator1, { loose: false }) - var actual3 = semver.intersects(comparator1, comparator2) - var actual4 = semver.intersects(comparator2, comparator1) - var actual5 = semver.intersects(comparator1, comparator2, true) - var actual6 = semver.intersects(comparator2, comparator1, true) - var actual7 = semver.intersects(v[0], v[1]) - var actual8 = semver.intersects(v[1], v[0]) - var actual9 = semver.intersects(v[0], v[1], true) - var actual10 = semver.intersects(v[1], v[0], true) - t.equal(actual1, expect) - t.equal(actual2, expect) - t.equal(actual3, expect) - t.equal(actual4, expect) - t.equal(actual5, expect) - t.equal(actual6, expect) - t.equal(actual7, expect) - t.equal(actual8, expect) - t.equal(actual9, expect) - t.equal(actual10, expect) + t.ok(!gt(v0, v1, loose), `!gt('${ v0 }', '${ v1 }')`) + t.ok(gte(v0, v1, loose), `gte('${ v0 }', '${ v1 }')`) + t.ok(!lt(v0, v1, loose), `!lt('${ v0 }', '${ v1 }')`) + t.ok(lte(v0, v1, loose), `lte('${ v0 }', '${ v1 }')`) }) t.end() }) - -test('missing comparator parameter in intersect comparators', function (t) { - t.throws(function () { - new Comparator('>1.0.0').intersects() - }, new TypeError('a Comparator is required'), - 'throws type error') - t.end() -}) - -test('ranges intersect', function (t) { - [ - ['1.3.0 || <1.0.0 >2.0.0', '1.3.0 || <1.0.0 >2.0.0', true], - ['<1.0.0 >2.0.0', '>0.0.0', false], - ['>0.0.0', '<1.0.0 >2.0.0', false], - ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0', false], - ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], - ['>1.0.0 <=2.0.0', '2.0.0', true], - ['<1.0.0 >=2.0.0', '2.1.0', false], - ['<1.0.0 >=2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], - ['1.5.x', '<1.5.0 || >=1.6.0', false], - ['<1.5.0 || >=1.6.0', '1.5.x', false], - ['<1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', false], - ['<=1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', true], - ['>=1.0.0', '<=1.0.0', true], - ['>1.0.0 <1.0.0', '<=0.0.0', false], - ['*', '0.0.1', true], - ['*', '>=1.0.0', true], - ['*', '>1.0.0', true], - ['*', '~1.0.0', true], - ['*', '<1.6.0', true], - ['*', '<=1.6.0', true], - ['1.*', '0.0.1', false], - ['1.*', '2.0.0', false], - ['1.*', '1.0.0', true], - ['1.*', '<2.0.0', true], - ['1.*', '>1.0.0', true], - ['1.*', '<=1.0.0', true], - ['1.*', '^1.0.0', true], - ['1.0.*', '0.0.1', false], - ['1.0.*', '<0.0.1', false], - ['1.0.*', '>0.0.1', true], - ['*', '1.3.0 || <1.0.0 >2.0.0', true], - ['1.3.0 || <1.0.0 >2.0.0', '*', true], - ['1.*', '1.3.0 || <1.0.0 >2.0.0', true], - ['x', '0.0.1', true], - ['x', '>=1.0.0', true], - ['x', '>1.0.0', true], - ['x', '~1.0.0', true], - ['x', '<1.6.0', true], - ['x', '<=1.6.0', true], - ['1.x', '0.0.1', false], - ['1.x', '2.0.0', false], - ['1.x', '1.0.0', true], - ['1.x', '<2.0.0', true], - ['1.x', '>1.0.0', true], - ['1.x', '<=1.0.0', true], - ['1.x', '^1.0.0', true], - ['1.0.x', '0.0.1', false], - ['1.0.x', '<0.0.1', false], - ['1.0.x', '>0.0.1', true], - ['x', '1.3.0 || <1.0.0 >2.0.0', true], - ['1.3.0 || <1.0.0 >2.0.0', 'x', true], - ['1.x', '1.3.0 || <1.0.0 >2.0.0', true], - ['*', '*', true], - ['x', '', true], - ].forEach(function (v) { - t.test(v[0] + ' <~> ' + v[1], t => { - var range1 = new Range(v[0]) - var range2 = new Range(v[1]) - var expect = v[2] - var actual1 = range1.intersects(range2) - var actual2 = range2.intersects(range1) - var actual3 = semver.intersects(v[1], v[0]) - var actual4 = semver.intersects(v[0], v[1]) - var actual5 = semver.intersects(v[1], v[0], true) - var actual6 = semver.intersects(v[0], v[1], true) - var actual7 = semver.intersects(range1, range2) - var actual8 = semver.intersects(range2, range1) - var actual9 = semver.intersects(range1, range2, true) - var actual0 = semver.intersects(range2, range1, true) - t.equal(actual1, expect) - t.equal(actual2, expect) - t.equal(actual3, expect) - t.equal(actual4, expect) - t.equal(actual5, expect) - t.equal(actual6, expect) - t.equal(actual7, expect) - t.equal(actual8, expect) - t.equal(actual9, expect) - t.equal(actual0, expect) - t.end() - }) - }) - t.end() -}) - -test('missing range parameter in range intersect', function (t) { - t.throws(function () { - new Range('1.0.0').intersects() - }, new TypeError('a Range is required'), - 'throws type error') - t.end() -}) - -test('outside with bad hilo throws', function (t) { - t.throws(function () { - semver.outside('1.2.3', '>1.5.0', 'blerg', true) - }, new TypeError('Must provide a hilo val of "<" or ">"')) - t.end() -}) - -test('comparator testing', function (t) { - var c = new Comparator('>=1.2.3') - t.ok(c.test('1.2.4')) - var c2 = new Comparator(c) - t.ok(c2.test('1.2.4')) - var c3 = new Comparator(c, true) - t.ok(c3.test('1.2.4')) - // test an invalid version, should not throw - var c4 = new Comparator(c) - t.notOk(c4.test('not a version string')) - t.end() -}) - -test('tostrings', function (t) { - t.equal(Range('>= v1.2.3').toString(), '>=1.2.3') - t.equal(Comparator('>= v1.2.3').toString(), '>=1.2.3') - t.end() -}) - -test('invalid cmp usage', function (t) { - t.throws(function () { - cmp('1.2.3', 'a frog', '4.5.6') - }, new TypeError('Invalid operator: a frog')) - t.end() -}) - -test('sorting', function (t) { - var list = [ - '1.2.3+1', - '1.2.3+0', - '1.2.3', - '5.9.6', - '0.1.2' - ] - var sorted = [ - '0.1.2', - '1.2.3', - '1.2.3+0', - '1.2.3+1', - '5.9.6' - ] - var rsorted = [ - '5.9.6', - '1.2.3+1', - '1.2.3+0', - '1.2.3', - '0.1.2' - ] - t.same(semver.sort(list), sorted) - t.same(semver.rsort(list), rsorted) - t.end() -}) - -test('bad ranges in max/min satisfying', function (t) { - var r = 'some frogs and sneks-v2.5.6' - t.equal(semver.maxSatisfying([], r), null) - t.equal(semver.minSatisfying([], r), null) - t.end() -}) - -test('really big numeric prerelease value', function (t) { - var r = SemVer('1.2.3-beta.' + Number.MAX_SAFE_INTEGER + '0') - t.strictSame(r.prerelease, [ 'beta', '90071992547409910' ]) - t.end() -}) diff --git a/test/internal/identifiers.js b/test/internal/identifiers.js new file mode 100644 index 00000000..a7a833b7 --- /dev/null +++ b/test/internal/identifiers.js @@ -0,0 +1,19 @@ +const { test } = require('tap') +const { compareIdentifiers, rcompareIdentifiers } = require('../../internal/identifiers'); + +test('rcompareIdentifiers and compareIdentifiers', (t) => { + const set = [ + ['1', '2'], + ['alpha', 'beta'], + ['0', 'beta'], + ] + set.forEach((ab) => { + const a = ab[0] + const b = ab[1] + t.equal(compareIdentifiers(a, b), -1) + t.equal(rcompareIdentifiers(a, b), 1) + }) + t.equal(compareIdentifiers('0', '0'), 0) + t.equal(rcompareIdentifiers('0', '0'), 0) + t.end() + }) \ No newline at end of file diff --git a/test/internal/re.js b/test/internal/re.js new file mode 100644 index 00000000..dc26ec56 --- /dev/null +++ b/test/internal/re.js @@ -0,0 +1,17 @@ +const { test } = require('tap') +const { src, re } = require('../../internal/re') +const semver = require('../../') + +test('has a list of src, re, and tokens', (t) => { + t.match(Object.assign({}, semver), { + src: Array, + re: Array, + tokens: Object + }) + re.forEach(r => t.match(r, RegExp, 'regexps are regexps')) + src.forEach(s => t.match(s, String, 'src is strings')) + for (const i in semver.tokens) { + t.match(semver.tokens[i], Number, 'tokens are numbers') + } + t.end() + }) \ No newline at end of file diff --git a/test/major-minor-patch.js b/test/major-minor-patch.js deleted file mode 100644 index a074878e..00000000 --- a/test/major-minor-patch.js +++ /dev/null @@ -1,72 +0,0 @@ -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') - -test('\nmajor tests', function (t) { - // [range, version] - // Version should be detectable despite extra characters - [ - ['1.2.3', 1], - [' 1.2.3 ', 1], - [' 2.2.3-4 ', 2], - [' 3.2.3-pre ', 3], - ['v5.2.3', 5], - [' v8.2.3 ', 8], - ['\t13.2.3', 13], - ['=21.2.3', 21, true], - ['v=34.2.3', 34, true] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = 'major(' + range + ') = ' + version - t.equal(semver.major(range, loose), version, msg) - }) - t.end() -}) - -test('\nminor tests', function (t) { - // [range, version] - // Version should be detectable despite extra characters - [ - ['1.1.3', 1], - [' 1.1.3 ', 1], - [' 1.2.3-4 ', 2], - [' 1.3.3-pre ', 3], - ['v1.5.3', 5], - [' v1.8.3 ', 8], - ['\t1.13.3', 13], - ['=1.21.3', 21, true], - ['v=1.34.3', 34, true] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = 'minor(' + range + ') = ' + version - t.equal(semver.minor(range, loose), version, msg) - }) - t.end() -}) - -test('\npatch tests', function (t) { - // [range, version] - // Version should be detectable despite extra characters - [ - ['1.2.1', 1], - [' 1.2.1 ', 1], - [' 1.2.2-4 ', 2], - [' 1.2.3-pre ', 3], - ['v1.2.5', 5], - [' v1.2.8 ', 8], - ['\t1.2.13', 13], - ['=1.2.21', 21, true], - ['v=1.2.34', 34, true] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = 'patch(' + range + ') = ' + version - t.equal(semver.patch(range, loose), version, msg) - }) - t.end() -}) diff --git a/test/gtr.js b/test/ranges/gtr.js similarity index 88% rename from test/gtr.js rename to test/ranges/gtr.js index dc3ec833..c0c3bcc6 100644 --- a/test/gtr.js +++ b/test/ranges/gtr.js @@ -1,9 +1,7 @@ -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') -var gtr = semver.gtr +const { test } = require('tap') +const gtr = require('../../ranges/gtr') -test('\ngtr tests', function (t) { +test('gtr tests', (t) => { // [range, version, loose] // Version should be greater than range [ @@ -67,17 +65,17 @@ test('\ngtr tests', function (t) { ['< 1', '1.0.0beta', true], ['=0.7.x', '0.8.2'], ['<0.7.x', '0.7.2'] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = 'gtr(' + version + ', ' + range + ', ' + loose + ')' + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `gtr(${ version }, ${ range }, ${ loose })` t.ok(gtr(version, range, loose), msg) }) t.end() }) -test('\nnegative gtr tests', function (t) { +test('negative gtr tests', (t) => { // [range, version, loose] // Version should NOT be greater than range [ @@ -162,11 +160,11 @@ test('\nnegative gtr tests', function (t) { ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = '!gtr(' + version + ', ' + range + ', ' + loose + ')' + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `!gtr(${ version }, ${ range }, ${ loose })` t.notOk(gtr(version, range, loose), msg) }) t.end() diff --git a/test/ranges/intersects.js b/test/ranges/intersects.js new file mode 100644 index 00000000..86db46d5 --- /dev/null +++ b/test/ranges/intersects.js @@ -0,0 +1,168 @@ +const { test } = require('tap') +const intersects = require('../../ranges/intersects') +const { Comparator, Range } = require('../../classes/range') + +test('intersect comparators', (t) => { + [ + // One is a Version + ['1.3.0', '>=1.3.0', true], + ['1.3.0', '>1.3.0', false], + ['>=1.3.0', '1.3.0', true], + ['>1.3.0', '1.3.0', false], + // Same direction increasing + ['>1.3.0', '>1.2.0', true], + ['>1.2.0', '>1.3.0', true], + ['>=1.2.0', '>1.3.0', true], + ['>1.2.0', '>=1.3.0', true], + // Same direction decreasing + ['<1.3.0', '<1.2.0', true], + ['<1.2.0', '<1.3.0', true], + ['<=1.2.0', '<1.3.0', true], + ['<1.2.0', '<=1.3.0', true], + // Different directions, same semver and inclusive operator + ['>=1.3.0', '<=1.3.0', true], + ['>=v1.3.0', '<=1.3.0', true], + ['>=1.3.0', '>=1.3.0', true], + ['<=1.3.0', '<=1.3.0', true], + ['<=1.3.0', '<=v1.3.0', true], + ['>1.3.0', '<=1.3.0', false], + ['>=1.3.0', '<1.3.0', false], + // Opposite matching directions + ['>1.0.0', '<2.0.0', true], + ['>=1.0.0', '<2.0.0', true], + ['>=1.0.0', '<=2.0.0', true], + ['>1.0.0', '<=2.0.0', true], + ['<=2.0.0', '>1.0.0', true], + ['<=1.0.0', '>=2.0.0', false] + ].forEach((v) => { + const comparator1 = new Comparator(v[0]) + const comparator2 = new Comparator(v[1]) + const expect = v[2] + + const actual1 = comparator1.intersects(comparator2, false) + const actual2 = comparator2.intersects(comparator1, { loose: false }) + const actual3 = intersects(comparator1, comparator2) + const actual4 = intersects(comparator2, comparator1) + const actual5 = intersects(comparator1, comparator2, true) + const actual6 = intersects(comparator2, comparator1, true) + const actual7 = intersects(v[0], v[1]) + const actual8 = intersects(v[1], v[0]) + const actual9 = intersects(v[0], v[1], true) + const actual10 = intersects(v[1], v[0], true) + t.equal(actual1, expect) + t.equal(actual2, expect) + t.equal(actual3, expect) + t.equal(actual4, expect) + t.equal(actual5, expect) + t.equal(actual6, expect) + t.equal(actual7, expect) + t.equal(actual8, expect) + t.equal(actual9, expect) + t.equal(actual10, expect) + }) + t.end() +}) + +test('ranges intersect', (t) => { + [ + ['1.3.0 || <1.0.0 >2.0.0', '1.3.0 || <1.0.0 >2.0.0', true], + ['<1.0.0 >2.0.0', '>0.0.0', false], + ['>0.0.0', '<1.0.0 >2.0.0', false], + ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0', false], + ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], + ['>1.0.0 <=2.0.0', '2.0.0', true], + ['<1.0.0 >=2.0.0', '2.1.0', false], + ['<1.0.0 >=2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], + ['1.5.x', '<1.5.0 || >=1.6.0', false], + ['<1.5.0 || >=1.6.0', '1.5.x', false], + ['<1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', false], + ['<=1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', true], + ['>=1.0.0', '<=1.0.0', true], + ['>1.0.0 <1.0.0', '<=0.0.0', false], + ['*', '0.0.1', true], + ['*', '>=1.0.0', true], + ['*', '>1.0.0', true], + ['*', '~1.0.0', true], + ['*', '<1.6.0', true], + ['*', '<=1.6.0', true], + ['1.*', '0.0.1', false], + ['1.*', '2.0.0', false], + ['1.*', '1.0.0', true], + ['1.*', '<2.0.0', true], + ['1.*', '>1.0.0', true], + ['1.*', '<=1.0.0', true], + ['1.*', '^1.0.0', true], + ['1.0.*', '0.0.1', false], + ['1.0.*', '<0.0.1', false], + ['1.0.*', '>0.0.1', true], + ['*', '1.3.0 || <1.0.0 >2.0.0', true], + ['1.3.0 || <1.0.0 >2.0.0', '*', true], + ['1.*', '1.3.0 || <1.0.0 >2.0.0', true], + ['x', '0.0.1', true], + ['x', '>=1.0.0', true], + ['x', '>1.0.0', true], + ['x', '~1.0.0', true], + ['x', '<1.6.0', true], + ['x', '<=1.6.0', true], + ['1.x', '0.0.1', false], + ['1.x', '2.0.0', false], + ['1.x', '1.0.0', true], + ['1.x', '<2.0.0', true], + ['1.x', '>1.0.0', true], + ['1.x', '<=1.0.0', true], + ['1.x', '^1.0.0', true], + ['1.0.x', '0.0.1', false], + ['1.0.x', '<0.0.1', false], + ['1.0.x', '>0.0.1', true], + ['x', '1.3.0 || <1.0.0 >2.0.0', true], + ['1.3.0 || <1.0.0 >2.0.0', 'x', true], + ['1.x', '1.3.0 || <1.0.0 >2.0.0', true], + ['*', '*', true], + ['x', '', true], + ].forEach((v) => { + t.test(`${v[0] } <~> ${ v[1]}`, t => { + const range1 = new Range(v[0]) + const range2 = new Range(v[1]) + const expect = v[2] + const actual1 = range1.intersects(range2) + const actual2 = range2.intersects(range1) + const actual3 = intersects(v[1], v[0]) + const actual4 = intersects(v[0], v[1]) + const actual5 = intersects(v[1], v[0], true) + const actual6 = intersects(v[0], v[1], true) + const actual7 = intersects(range1, range2) + const actual8 = intersects(range2, range1) + const actual9 = intersects(range1, range2, true) + const actual0 = intersects(range2, range1, true) + t.equal(actual1, expect) + t.equal(actual2, expect) + t.equal(actual3, expect) + t.equal(actual4, expect) + t.equal(actual5, expect) + t.equal(actual6, expect) + t.equal(actual7, expect) + t.equal(actual8, expect) + t.equal(actual9, expect) + t.equal(actual0, expect) + t.end() + }) + }) + t.end() +}) + +test('missing comparator parameter in intersect comparators', (t) => { + t.throws(() => { + new Comparator('>1.0.0').intersects() + }, new TypeError('a Comparator is required'), + 'throws type error') + t.end() +}) + + +test('missing range parameter in range intersect', (t) => { + t.throws(() => { + new Range('1.0.0').intersects() + }, new TypeError('a Range is required'), + 'throws type error') + t.end() +}) \ No newline at end of file diff --git a/test/ltr.js b/test/ranges/ltr.js similarity index 89% rename from test/ltr.js rename to test/ranges/ltr.js index b6376668..35578d71 100644 --- a/test/ltr.js +++ b/test/ranges/ltr.js @@ -1,9 +1,7 @@ -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') -var ltr = semver.ltr +const { test } = require('tap') +const ltr = require('../../ranges/ltr') -test('\nltr tests', function (t) { +test('ltr tests', (t) => { // [range, version, loose] // Version should be less than range [ @@ -72,17 +70,17 @@ test('\nltr tests', function (t) { ['1', '1.0.0beta', true], ['>=0.7.x', '0.6.2'], ['>1.2.3', '1.3.0-alpha'] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = 'ltr(' + version + ', ' + range + ', ' + loose + ')' + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `ltr(${ version }, ${ range }, ${ loose })` t.ok(ltr(version, range, loose), msg) }) t.end() }) -test('\nnegative ltr tests', function (t) { +test('negative ltr tests', (t) => { // [range, version, loose] // Version should NOT be less than range [ @@ -170,11 +168,11 @@ test('\nnegative ltr tests', function (t) { ['^1.0.0-alpha', '1.0.0-beta'], ['~1.0.0-alpha', '1.0.0-beta'], ['=0.1.0', '1.0.0'] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = '!ltr(' + version + ', ' + range + ', ' + loose + ')' + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `!ltr(${ version }, ${ range }, ${ loose })` t.notOk(ltr(version, range, loose), msg) }) t.end() diff --git a/test/ranges/max-satisfying.js b/test/ranges/max-satisfying.js new file mode 100644 index 00000000..a811e251 --- /dev/null +++ b/test/ranges/max-satisfying.js @@ -0,0 +1,25 @@ +const { test } = require('tap') +const maxSatisfying = require('../../ranges/max-satisfying') + +test('max satisfying', (t) => { + [[['1.2.3', '1.2.4'], '1.2', '1.2.4'], + [['1.2.4', '1.2.3'], '1.2', '1.2.4'], + [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'], + [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] + ].forEach((v) => { + const versions = v[0] + const range = v[1] + const expect = v[2] + const loose = v[3] + const actual = maxSatisfying(versions, range, loose) + t.equal(actual, expect) + }) + t.end() + }) + + +test('bad ranges in max satisfying', (t) => { + const r = 'some frogs and sneks-v2.5.6' + t.equal(maxSatisfying([], r), null) + t.end() + }) diff --git a/test/ranges/min-satisfying.js b/test/ranges/min-satisfying.js new file mode 100644 index 00000000..ebda0765 --- /dev/null +++ b/test/ranges/min-satisfying.js @@ -0,0 +1,25 @@ +const { test } = require('tap') +const minSatisfying = require('../../ranges/min-satisfying') + +test('min satisfying', (t) => { + [[['1.2.3', '1.2.4'], '1.2', '1.2.3'], + [['1.2.4', '1.2.3'], '1.2', '1.2.3'], + [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.3'], + [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] + ].forEach((v) => { + const versions = v[0] + const range = v[1] + const expect = v[2] + const loose = v[3] + const actual = minSatisfying(versions, range, loose) + t.equal(actual, expect) + }) + t.end() + }) + + + test('bad ranges in min satisfying', (t) => { + const r = 'some frogs and sneks-v2.5.6' + t.equal(minSatisfying([], r), null) + t.end() + }) \ No newline at end of file diff --git a/test/min-version.js b/test/ranges/min-version.js similarity index 80% rename from test/min-version.js rename to test/ranges/min-version.js index 54350c81..8577144b 100644 --- a/test/min-version.js +++ b/test/ranges/min-version.js @@ -1,8 +1,7 @@ -var tap = require('tap') -var test = tap.test -var semver = require('../semver.js') +const { test } = require('tap') +const minVersion = require('../../ranges/min-version') -test('\nminimum version in range tests', function (t) { +test('minimum version in range tests', (t) => { // [range, minimum, loose] [ // Stars @@ -64,12 +63,12 @@ test('\nminimum version in range tests', function (t) { // Impossible range ['>4 <3', null] - ].forEach(function (tuple) { - var range = tuple[0] - var version = tuple[1] - var loose = tuple[2] || false - var msg = 'minVersion(' + range + ', ' + loose + ') = ' + version - var min = semver.minVersion(range, loose) + ].forEach((tuple) => { + const range = tuple[0] + const version = tuple[1] + const loose = tuple[2] || false + const msg = `minVersion(${ range }, ${ loose }) = ${ version}` + const min = minVersion(range, loose) t.ok(min === version || (min && min.version === version), msg) }) t.end() diff --git a/test/ranges/outside.js b/test/ranges/outside.js new file mode 100644 index 00000000..54b7f95c --- /dev/null +++ b/test/ranges/outside.js @@ -0,0 +1,10 @@ +const { test } = require('tap') +const outside = require('../../ranges/outside') + +test('outside with bad hilo throws', (t) => { + t.throws(() => { + outside('1.2.3', '>1.5.0', 'blerg', true) + }, new TypeError('Must provide a hilo val of "<" or ">"')) + t.end() + }) + \ No newline at end of file diff --git a/test/ranges/satisfies.js b/test/ranges/satisfies.js new file mode 100644 index 00000000..51cf8946 --- /dev/null +++ b/test/ranges/satisfies.js @@ -0,0 +1,247 @@ +const { test } = require('tap') +const { satisfies } = require('../../classes/range') + +test('range tests', (t) => { + // [range, version] + // version should be included by range + [['1.0.0 - 2.0.0', '1.2.3'], + ['^1.2.3+build', '1.2.3'], + ['^1.2.3+build', '1.3.0'], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'], + ['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true], + ['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true], + ['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'], + ['1.2.3+asdf - 2.4.3+asdf', '1.2.3'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0'], + ['*', '1.2.3', {}], + ['*', 'v1.2.3', { loose: 123 }], + ['>=1.0.0', '1.0.0', /asdf/], + ['>=1.0.0', '1.0.1', { loose: null }], + ['>=1.0.0', '1.1.0', { loose: 0 }], + ['>1.0.0', '1.0.1', { loose: undefined }], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97', true], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~0.0.1', '0.0.1'], + ['~0.0.1', '0.0.2'], + ['~x', '0.0.9'], // >=2.4.0 <2.5.0 + ['~2', '2.0.9'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0, + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0, + ['~ 1.0', '1.0.2'], + ['~ 1.0.3', '1.0.12'], + ['~ 1.0.3alpha', '1.0.12', { loose: true }], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['<=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['<=0.7.x', '0.6.2'], + ['~1.2.1 >=1.2.3', '1.2.3'], + ['~1.2.1 =1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'], + ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['>=1.2.1 1.2.3', '1.2.3'], + ['1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.1 >=1.2.3', '1.2.3'], + ['>=1.2', '1.2.8'], + ['^1.2.3', '1.8.1'], + ['^0.1.2', '0.1.2'], + ['^0.1', '0.1.2'], + ['^0.0.1', '0.0.1'], + ['^1.2', '1.4.2'], + ['^1.2 ^1', '1.4.2'], + ['^1.2.3-alpha', '1.2.3-pre'], + ['^1.2.0-alpha', '1.2.0-pre'], + ['^0.0.1-alpha', '0.0.1-beta'], + ['^0.0.1-alpha', '0.0.1'], + ['^0.1.1-alpha', '0.1.1-beta'], + ['^x', '1.2.3'], + ['x - 1.0.0', '0.9.7'], + ['x - 1.x', '0.9.7'], + ['1.0.0 - x', '1.9.7'], + ['1.x - x', '1.9.7'], + ['<=7.x', '7.9.9'], + ['2.x', '2.0.0-pre.0', { includePrerelease: true }], + ['2.x', '2.1.0-pre.0', { includePrerelease: true }], + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = v[2] + t.ok(satisfies(ver, range, options), `${range } satisfied by ${ ver}`) + }) + t.end() + }) + + test('negative range tests', (t) => { + // [range, version] + // version should not be included by range + [['1.0.0 - 2.0.0', '2.2.3'], + ['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'], + ['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'], + ['^1.2.3+build', '2.0.0'], + ['^1.2.3+build', '1.2.0'], + ['^1.2.3', '1.2.3-pre'], + ['^1.2', '1.2.0-pre'], + ['>1.2', '1.3.0-beta'], + ['<=1.2.3', '1.2.3-beta'], + ['^1.2.3', '1.2.3-beta'], + ['=0.7.x', '0.7.0-asdf'], + ['>=0.7.x', '0.7.0-asdf'], + ['1', '1.0.0beta', { loose: 420 }], + ['<1', '1.0.0beta', true], + ['< 1', '1.0.0beta', true], + ['1.0.0', '1.0.1'], + ['>=1.0.0', '0.0.0'], + ['>=1.0.0', '0.0.1'], + ['>=1.0.0', '0.1.0'], + ['>1.0.0', '0.0.1'], + ['>1.0.0', '0.1.0'], + ['<=2.0.0', '3.0.0'], + ['<=2.0.0', '2.9999.9999'], + ['<=2.0.0', '2.2.9'], + ['<2.0.0', '2.9999.9999'], + ['<2.0.0', '2.2.9'], + ['>=0.1.97', 'v0.1.93', true], + ['>=0.1.97', '0.1.93'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['>=0.2.3 || <0.0.1', '0.0.3'], + ['>=0.2.3 || <0.0.1', '0.2.2'], + ['2.x.x', '1.1.3', { loose: NaN }], + ['2.x.x', '3.1.3'], + ['1.2.x', '1.3.3'], + ['1.2.x || 2.x', '3.1.3'], + ['1.2.x || 2.x', '1.1.3'], + ['2.*.*', '1.1.3'], + ['2.*.*', '3.1.3'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '3.1.3'], + ['1.2.* || 2.*', '1.1.3'], + ['2', '1.1.2'], + ['2.3', '2.4.1'], + ['~0.0.1', '0.1.0-alpha'], + ['~0.0.1', '0.1.0'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.3.9'], + ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 + ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.3'], + ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 + ['<1', '1.0.0'], + ['>=1.2', '1.1.1'], + ['1', '2.0.0beta', true], + ['~v0.5.4-beta', '0.5.4-alpha'], + ['=0.7.x', '0.8.2'], + ['>=0.7.x', '0.6.2'], + ['<0.7.x', '0.7.2'], + ['<1.2.3', '1.2.3-beta'], + ['=1.2.3', '1.2.3-beta'], + ['>1.2', '1.2.8'], + ['^0.0.1', '0.0.2-alpha'], + ['^0.0.1', '0.0.2'], + ['^1.2.3', '2.0.0-alpha'], + ['^1.2.3', '1.2.2'], + ['^1.2', '1.1.9'], + ['*', 'v1.2.3-foo', true], + // invalid ranges never satisfied! + ['blerg', '1.2.3'], + ['git+https://user:password0123@github.com/foo', '123.0.0', true], + ['^1.2.3', '2.0.0-pre'], + ['0.x', undefined], + ['*', undefined], + // invalid versions never satisfy, but shouldn't throw + ['*', 'not a version'], + ['>=2', 'glorp'], + ['2.x', '3.0.0-pre.0', { includePrerelease: true }], + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = v[2] + const found = satisfies(ver, range, options) + t.ok(!found, `${ver } not satisfied by ${ range}`) + }) + t.end() + }) + + test('unlocked prerelease range tests', (t) => { + // [range, version] + // version should be included by range + [['*', '1.0.0-rc1'], + ['^1.0.0', '2.0.0-rc1'], + ['^1.0.0-0', '1.0.1-rc1'], + ['^1.0.0-rc2', '1.0.1-rc1'], + ['^1.0.0', '1.0.1-rc1'], + ['^1.0.0', '1.1.0-rc1'] + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = { includePrerelease: true } + t.ok(satisfies(ver, range, options), `${range } satisfied by ${ ver}`) + }) + t.end() + }) + + test('negative unlocked prerelease range tests', (t) => { + // [range, version] + // version should not be included by range + [['^1.0.0', '1.0.0-rc1'], + ['^1.2.3-rc2', '2.0.0'] + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = { includePrerelease: true } + const found = satisfies(ver, range, options) + t.ok(!found, `${ver } not satisfied by ${ range}`) + }) + t.end() + }) + \ No newline at end of file diff --git a/test/ranges/to-comparators.js b/test/ranges/to-comparators.js new file mode 100644 index 00000000..da8f99e2 --- /dev/null +++ b/test/ranges/to-comparators.js @@ -0,0 +1,85 @@ +const { test } = require('tap') +const toComparators = require('../../ranges/to-comparators') + +test('comparators test', (t) => { + // [range, comparators] + // turn range into a set of individual comparators + [['1.0.0 - 2.0.0', [['>=1.0.0', '<=2.0.0']]], + ['1.0.0', [['1.0.0']]], + ['>=*', [['']]], + ['', [['']]], + ['*', [['']]], + ['*', [['']]], + ['>=1.0.0', [['>=1.0.0']]], + ['>=1.0.0', [['>=1.0.0']]], + ['>=1.0.0', [['>=1.0.0']]], + ['>1.0.0', [['>1.0.0']]], + ['>1.0.0', [['>1.0.0']]], + ['<=2.0.0', [['<=2.0.0']]], + ['1', [['>=1.0.0', '<2.0.0']]], + ['<=2.0.0', [['<=2.0.0']]], + ['<=2.0.0', [['<=2.0.0']]], + ['<2.0.0', [['<2.0.0']]], + ['<2.0.0', [['<2.0.0']]], + ['>= 1.0.0', [['>=1.0.0']]], + ['>= 1.0.0', [['>=1.0.0']]], + ['>= 1.0.0', [['>=1.0.0']]], + ['> 1.0.0', [['>1.0.0']]], + ['> 1.0.0', [['>1.0.0']]], + ['<= 2.0.0', [['<=2.0.0']]], + ['<= 2.0.0', [['<=2.0.0']]], + ['<= 2.0.0', [['<=2.0.0']]], + ['< 2.0.0', [['<2.0.0']]], + ['<\t2.0.0', [['<2.0.0']]], + ['>=0.1.97', [['>=0.1.97']]], + ['>=0.1.97', [['>=0.1.97']]], + ['0.1.20 || 1.2.4', [['0.1.20'], ['1.2.4']]], + ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], + ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], + ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], + ['||', [[''], ['']]], + ['2.x.x', [['>=2.0.0', '<3.0.0']]], + ['1.2.x', [['>=1.2.0', '<1.3.0']]], + ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], + ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], + ['x', [['']]], + ['2.*.*', [['>=2.0.0', '<3.0.0']]], + ['1.2.*', [['>=1.2.0', '<1.3.0']]], + ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], + ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], + ['*', [['']]], + ['2', [['>=2.0.0', '<3.0.0']]], + ['2.3', [['>=2.3.0', '<2.4.0']]], + ['~2.4', [['>=2.4.0', '<2.5.0']]], + ['~2.4', [['>=2.4.0', '<2.5.0']]], + ['~>3.2.1', [['>=3.2.1', '<3.3.0']]], + ['~1', [['>=1.0.0', '<2.0.0']]], + ['~>1', [['>=1.0.0', '<2.0.0']]], + ['~> 1', [['>=1.0.0', '<2.0.0']]], + ['~1.0', [['>=1.0.0', '<1.1.0']]], + ['~ 1.0', [['>=1.0.0', '<1.1.0']]], + ['~ 1.0.3', [['>=1.0.3', '<1.1.0']]], + ['~> 1.0.3', [['>=1.0.3', '<1.1.0']]], + ['<1', [['<1.0.0']]], + ['< 1', [['<1.0.0']]], + ['>=1', [['>=1.0.0']]], + ['>= 1', [['>=1.0.0']]], + ['<1.2', [['<1.2.0']]], + ['< 1.2', [['<1.2.0']]], + ['1', [['>=1.0.0', '<2.0.0']]], + ['1 2', [['>=1.0.0', '<2.0.0', '>=2.0.0', '<3.0.0']]], + ['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]], + ['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0']]], + ['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]], + ['>*', [['<0.0.0-0']]], + ['<*', [['<0.0.0-0']]] + ].forEach((v) => { + const pre = v[0] + const wanted = v[1] + const found = toComparators(v[0]) + const jw = JSON.stringify(wanted) + t.equivalent(found, wanted, `toComparators(${ pre }) === ${ jw}`) + }) + + t.end() +}) \ No newline at end of file diff --git a/test/ranges/valid-range.js b/test/ranges/valid-range.js new file mode 100644 index 00000000..f7689332 --- /dev/null +++ b/test/ranges/valid-range.js @@ -0,0 +1,90 @@ +const { test } = require('tap') +const validRange = require('../../ranges/valid-range') + +test('valid range test', (t) => { + // [range, result] + // validRange(range) -> result + // translate ranges into their canonical form + [['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], + ['1.0.0', '1.0.0'], + ['>=*', '*'], + ['', '*'], + ['*', '*'], + ['*', '*'], + ['>=1.0.0', '>=1.0.0'], + ['>1.0.0', '>1.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['1', '>=1.0.0 <2.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['<2.0.0', '<2.0.0'], + ['<2.0.0', '<2.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['> 1.0.0', '>1.0.0'], + ['> 1.0.0', '>1.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['< 2.0.0', '<2.0.0'], + ['<\t2.0.0', '<2.0.0'], + ['>=0.1.97', '>=0.1.97'], + ['>=0.1.97', '>=0.1.97'], + ['0.1.20 || 1.2.4', '0.1.20||1.2.4'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], + ['||', '||'], + ['2.x.x', '>=2.0.0 <3.0.0'], + ['1.2.x', '>=1.2.0 <1.3.0'], + ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['x', '*'], + ['2.*.*', '>=2.0.0 <3.0.0'], + ['1.2.*', '>=1.2.0 <1.3.0'], + ['1.2.* || 2.*', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['*', '*'], + ['2', '>=2.0.0 <3.0.0'], + ['2.3', '>=2.3.0 <2.4.0'], + ['~2.4', '>=2.4.0 <2.5.0'], + ['~2.4', '>=2.4.0 <2.5.0'], + ['~>3.2.1', '>=3.2.1 <3.3.0'], + ['~1', '>=1.0.0 <2.0.0'], + ['~>1', '>=1.0.0 <2.0.0'], + ['~> 1', '>=1.0.0 <2.0.0'], + ['~1.0', '>=1.0.0 <1.1.0'], + ['~ 1.0', '>=1.0.0 <1.1.0'], + ['^0', '>=0.0.0 <1.0.0'], + ['^ 1', '>=1.0.0 <2.0.0'], + ['^0.1', '>=0.1.0 <0.2.0'], + ['^1.0', '>=1.0.0 <2.0.0'], + ['^1.2', '>=1.2.0 <2.0.0'], + ['^0.0.1', '>=0.0.1 <0.0.2'], + ['^0.0.1-beta', '>=0.0.1-beta <0.0.2'], + ['^0.1.2', '>=0.1.2 <0.2.0'], + ['^1.2.3', '>=1.2.3 <2.0.0'], + ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0'], + ['<1', '<1.0.0'], + ['< 1', '<1.0.0'], + ['>=1', '>=1.0.0'], + ['>= 1', '>=1.0.0'], + ['<1.2', '<1.2.0'], + ['< 1.2', '<1.2.0'], + ['1', '>=1.0.0 <2.0.0'], + ['>01.02.03', '>1.2.3', true], + ['>01.02.03', null], + ['~1.2.3beta', '>=1.2.3-beta <1.3.0', true], + ['~1.2.3beta', null], + ['^ 1.2 ^ 1', '>=1.2.0 <2.0.0 >=1.0.0 <2.0.0'] + ].forEach((v) => { + const pre = v[0] + const wanted = v[1] + const loose = v[2] + const found = validRange(pre, loose) + + t.equal(found, wanted, `validRange(${ pre }) === ${ wanted}`) + }) + + t.end() +}) \ No newline at end of file From fe9240696182ecbb57367f11b9cde78847c00b68 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 21 Nov 2019 18:19:31 -0800 Subject: [PATCH 04/44] More splitting and code cleanup --- bin/semver.js | 107 +- classes/comparator.js | 139 +++ classes/index.js | 5 + classes/range.js | 390 ++---- classes/semver.js | 254 ++-- functions/clean.js | 6 +- functions/cmp.js | 81 +- functions/coerce.js | 88 +- functions/compare-build.js | 6 +- functions/compare-loose.js | 6 +- functions/compare.js | 6 +- functions/diff.js | 3 +- functions/eq.js | 6 +- functions/gt.js | 6 +- functions/gte.js | 7 +- functions/inc.js | 5 +- functions/lt.js | 6 +- functions/lte.js | 6 +- functions/major.js | 6 +- functions/minor.js | 6 +- functions/neq.js | 6 +- functions/parse.js | 6 +- functions/patch.js | 6 +- functions/prerelease.js | 6 +- functions/rcompare.js | 6 +- functions/rsort.js | 8 +- functions/satisfies.js | 10 + functions/sort.js | 8 +- functions/valid.js | 6 +- index.js | 113 +- internal/constants.js | 10 +- internal/debug.js | 22 +- internal/identifiers.js | 12 +- internal/re.js | 116 +- map.js | 1 + package-lock.json | 1110 +++++++++--------- package.json | 6 +- ranges/gtr.js | 8 +- ranges/intersects.js | 12 +- ranges/ltr.js | 6 +- ranges/max-satisfying.js | 44 +- ranges/min-satisfying.js | 44 +- ranges/min-version.js | 9 +- ranges/outside.js | 11 +- ranges/to-comparators.js | 14 +- ranges/valid-range.js | 21 +- tap-snapshots/test-bin-semver.js-TAP.test.js | 222 ++++ test/big-numbers.js | 4 +- test/{cli.js => bin/semver.js} | 10 +- test/classes/comparator.js | 20 + test/classes/index.js | 6 + test/classes/range.js | 44 +- test/classes/semver.js | 87 +- test/coverage-map.js | 1 - test/fixtures/comparisons.js | 36 + test/fixtures/equality.js | 41 + test/fixtures/version-gt-range.js | 64 + test/fixtures/version-lt-range.js | 69 ++ test/fixtures/version-not-gt-range.js | 85 ++ test/fixtures/version-not-lt-range.js | 88 ++ test/functions/clean.js | 6 +- test/functions/cmp.js | 50 +- test/functions/coerce.js | 97 +- test/functions/compare-build.js | 2 +- test/functions/compare-loose.js | 45 +- test/functions/compare.js | 35 + test/functions/diff.js | 4 +- test/functions/eq.js | 26 + test/functions/gt.js | 24 + test/functions/gte.js | 24 + test/functions/inc.js | 8 +- test/functions/lt.js | 24 + test/functions/lte.js | 24 + test/functions/major.js | 2 +- test/functions/minor.js | 2 +- test/functions/neq.js | 26 + test/functions/parse.js | 26 + test/functions/patch.js | 2 +- test/functions/prerelease.js | 2 +- test/functions/rcompare.js | 1 - test/functions/rsort.js | 34 +- test/functions/satisfies.js | 246 ++++ test/functions/sort.js | 36 +- test/functions/valid.js | 25 + test/index.js | 144 +-- test/internal/constants.js | 9 + test/internal/debug.js | 36 + test/internal/identifiers.js | 32 +- test/internal/re.js | 24 +- test/ranges/gtr.js | 153 +-- test/ranges/intersects.js | 10 +- test/ranges/ltr.js | 167 +-- test/ranges/max-satisfying.js | 35 +- test/ranges/min-satisfying.js | 37 +- test/ranges/min-version.js | 2 +- test/ranges/outside.js | 55 +- test/ranges/satisfies.js | 247 ---- test/ranges/to-comparators.js | 10 +- test/ranges/valid-range.js | 4 +- 99 files changed, 2911 insertions(+), 2362 deletions(-) create mode 100644 classes/comparator.js create mode 100644 classes/index.js create mode 100644 functions/satisfies.js create mode 100644 map.js create mode 100644 tap-snapshots/test-bin-semver.js-TAP.test.js rename test/{cli.js => bin/semver.js} (91%) create mode 100644 test/classes/comparator.js create mode 100644 test/classes/index.js delete mode 100644 test/coverage-map.js create mode 100644 test/fixtures/comparisons.js create mode 100644 test/fixtures/equality.js create mode 100644 test/fixtures/version-gt-range.js create mode 100644 test/fixtures/version-lt-range.js create mode 100644 test/fixtures/version-not-gt-range.js create mode 100644 test/fixtures/version-not-lt-range.js create mode 100644 test/functions/compare.js create mode 100644 test/functions/eq.js create mode 100644 test/functions/gt.js create mode 100644 test/functions/gte.js create mode 100644 test/functions/lt.js create mode 100644 test/functions/lte.js create mode 100644 test/functions/neq.js create mode 100644 test/functions/parse.js create mode 100644 test/functions/satisfies.js create mode 100644 test/functions/valid.js create mode 100644 test/internal/constants.js create mode 100644 test/internal/debug.js delete mode 100644 test/ranges/satisfies.js diff --git a/bin/semver.js b/bin/semver.js index 62bf38e2..73fe2953 100755 --- a/bin/semver.js +++ b/bin/semver.js @@ -29,9 +29,7 @@ let reverse = false const options = {} -main() - -function main () { +const main = () => { if (!argv.length) return help() while (argv.length) { let a = argv.shift() @@ -106,14 +104,15 @@ function main () { return success(versions) } -function failInc () { + +const failInc = () => { console.error('--inc can only be used on a single version with no range') fail() } -function fail () { process.exit(1) } +const fail = () => process.exit(1) -function success () { +const success = () => { const compare = reverse ? 'rcompare' : 'compare' versions.sort((a, b) => { return semver[compare](a, b, options) @@ -124,51 +123,51 @@ function success () { }).forEach((v, i, _) => { console.log(v) }) } -function help () { - console.log([`SemVer ${ version}`, - '', - 'A JavaScript implementation of the https://semver.org/ specification', - 'Copyright Isaac Z. Schlueter', - '', - 'Usage: semver [options] [ [...]]', - 'Prints valid versions sorted by SemVer precedence', - '', - 'Options:', - '-r --range ', - ' Print versions that match the specified range.', - '', - '-i --increment []', - ' Increment a version by the specified level. Level can', - ' be one of: major, minor, patch, premajor, preminor,', - " prepatch, or prerelease. Default level is 'patch'.", - ' Only one version may be specified.', - '', - '--preid ', - ' Identifier to be used to prefix premajor, preminor,', - ' prepatch or prerelease version increments.', - '', - '-l --loose', - ' Interpret versions and ranges loosely', - '', - '-p --include-prerelease', - ' Always include prerelease versions in range matching', - '', - '-c --coerce', - ' Coerce a string into SemVer if possible', - ' (does not imply --loose)', - '', - '--rtl', - ' Coerce version strings right to left', - '', - '--ltr', - ' Coerce version strings left to right (default)', - '', - 'Program exits successfully if any valid version satisfies', - 'all supplied ranges, and prints all satisfying versions.', - '', - 'If no satisfying versions are found, then exits failure.', - '', - 'Versions are printed in ascending order, so supplying', - 'multiple versions to the utility will just sort them.' - ].join('\n')) -} +const help = () => console.log( +`SemVer ${version} + +A JavaScript implementation of the https://semver.org/ specification +Copyright Isaac Z. Schlueter + +Usage: semver [options] [ [...]] +Prints valid versions sorted by SemVer precedence + +Options: +-r --range + Print versions that match the specified range. + +-i --increment [] + Increment a version by the specified level. Level can + be one of: major, minor, patch, premajor, preminor, + prepatch, or prerelease. Default level is 'patch'. + Only one version may be specified. + +--preid + Identifier to be used to prefix premajor, preminor, + prepatch or prerelease version increments. + +-l --loose + Interpret versions and ranges loosely + +-p --include-prerelease + Always include prerelease versions in range matching + +-c --coerce + Coerce a string into SemVer if possible + (does not imply --loose) + +--rtl + Coerce version strings right to left + +--ltr + Coerce version strings left to right (default) + +Program exits successfully if any valid version satisfies +all supplied ranges, and prints all satisfying versions. + +If no satisfying versions are found, then exits failure. + +Versions are printed in ascending order, so supplying +multiple versions to the utility will just sort them.`) + +main() diff --git a/classes/comparator.js b/classes/comparator.js new file mode 100644 index 00000000..3595792d --- /dev/null +++ b/classes/comparator.js @@ -0,0 +1,139 @@ +const ANY = Symbol('SemVer ANY') +// hoisted class for cyclic dependency +class Comparator { + static get ANY () { + return ANY + } + constructor (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) + + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } + + debug('comp', this) + } + + parse (comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + const m = comp.match(r) + + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`) + } + + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } + } + + toString () { + return this.value + } + + test (version) { + debug('Comparator.test', version, this.options.loose) + + if (this.semver === ANY || version === ANY) { + return true + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + return cmp(version, this.operator, this.semver, this.options) + } + + intersects (comp, options) { + if (!(comp instanceof 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 + } + return new Range(comp.value, options).test(this.value) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + 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 === '>') + + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ) + } +} + +module.exports = Comparator + +const {re, t} = require('../internal/re') +const cmp = require('../functions/cmp') +const debug = require('../internal/debug') +const SemVer = require('./semver') +const Range = require('./range') diff --git a/classes/index.js b/classes/index.js new file mode 100644 index 00000000..198b84d6 --- /dev/null +++ b/classes/index.js @@ -0,0 +1,5 @@ +module.exports = { + SemVer: require('./semver.js'), + Range: require('./range.js'), + Comparator: require('./comparator.js') +} diff --git a/classes/range.js b/classes/range.js index 8aedd0a2..b05b8537 100644 --- a/classes/range.js +++ b/classes/range.js @@ -1,147 +1,11 @@ -const debug = require('../internal/debug') -const SemVer = require('../classes/semver') -const { re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require('../internal/re') -const cmp = require('../functions/cmp') - -const ANY = {} -class Comparator { - constructor(comp, options) { - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp; - } else { - comp = comp.value; - } - } - - debug("comparator", comp, options); - this.options = options; - this.loose = !!options.loose; - this.parse(comp); - - if (this.semver === ANY) { - this.value = ""; - } else { - this.value = this.operator + this.semver.version; - } - - debug("comp", this); - } - - parse(comp) { - const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; - const m = comp.match(r); - - if (!m) { - throw new TypeError(`Invalid comparator: ${ comp}`); - } - - this.operator = m[1] !== undefined ? m[1] : ""; - if (this.operator === "=") { - this.operator = ""; - } - - // if it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY; - } else { - this.semver = new SemVer(m[2], this.options.loose); - } - } - - toString() { - return this.value; - } - - test(version) { - debug("Comparator.test", version, this.options.loose); - - if (this.semver === ANY || version === ANY) { - return true; - } - - if (typeof version === "string") { - try { - version = new SemVer(version, this.options); - } catch (er) { - return false; - } - } - - return cmp(version, this.operator, this.semver, this.options); - } - - intersects(comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError("a Comparator is required"); - } - - if (!options || typeof options !== "object") { - options = { - loose: !!options, - includePrerelease: false - }; - } - - let rangeTmp; - - if (this.operator === "") { - if (this.value === "") { - return true; - } - rangeTmp = new Range(comp.value, options); - return satisfies(this.value, rangeTmp, options); - } else if (comp.operator === "") { - if (comp.value === "") { - return true; - } - rangeTmp = new Range(this.value, options); - return satisfies(comp.semver, rangeTmp, options); - } - - 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 === ">"); - - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ); - } -} - +// hoisted class for cyclic dependency class Range { - constructor(range, options) { - if (!options || typeof options !== "object") { + constructor (range, options) { + if (!options || typeof options !== 'object') { options = { loose: !!options, includePrerelease: false - }; + } } if (range instanceof Range) { @@ -149,100 +13,88 @@ class Range { range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease ) { - return range; + return range } else { - return new Range(range.raw, options); + return new Range(range.raw, options) } } if (range instanceof Comparator) { - return new Range(range.value, options); + return new Range(range.value, options) } - this.options = options; - this.loose = !!options.loose; - this.includePrerelease = !!options.includePrerelease; + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease // First, split based on boolean or || - this.raw = range; + this.raw = range this.set = range .split(/\s*\|\|\s*/) - .map(function(range) { - return this.parseRange(range.trim()); - }, this) + .map(range => this.parseRange(range.trim())) .filter((c) => { // throw out any that are not relevant for whatever reason - return c.length; - }); + return c.length + }) if (!this.set.length) { - throw new TypeError(`Invalid SemVer Range: ${ range}`); + throw new TypeError(`Invalid SemVer Range: ${range}`) } - this.format(); + this.format() } - format() { + format () { this.range = this.set .map((comps) => { - return comps.join(" ").trim(); + return comps.join(' ').trim() }) - .join("||") - .trim(); - return this.range; + .join('||') + .trim() + return this.range } - toString() { - return this.range; + toString () { + return this.range } - parseRange(range) { - const loose = this.options.loose; - range = range.trim(); + parseRange (range) { + const loose = this.options.loose + range = range.trim() // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]; - range = range.replace(hr, hyphenReplace); - debug("hyphen replace", range); + const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace) + 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]); + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[t.COMPARATORTRIM]) // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[t.TILDETRIM], tildeTrimReplace); + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[t.CARETTRIM], caretTrimReplace); + range = range.replace(re[t.CARETTRIM], caretTrimReplace) // normalize spaces - range = range.split(/\s+/).join(" "); + 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]; - let set = range - .split(" ") - .map(function(comp) { - return parseComparator(comp, this.options); - }, this) - .join(" ") - .split(/\s+/); - if (this.options.loose) { + const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + return range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) // in loose mode, throw out any that are not valid comparators - set = set.filter((comp) => { - return !!comp.match(compRe); - }); - } - set = set.map(function(comp) { - return new Comparator(comp, this.options); - }, this); - - return set; + .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) + .map(comp => new Comparator(comp, this.options)) } - intersects(range, options) { + intersects (range, options) { if (!(range instanceof Range)) { - throw new TypeError("a Range is required"); + throw new TypeError('a Range is required') } return this.set.some((thisComparators) => { @@ -253,41 +105,53 @@ class Range { isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => { return rangeComparators.every((rangeComparator) => { - return thisComparator.intersects(rangeComparator, options); - }); + return thisComparator.intersects(rangeComparator, options) + }) }) - ); + ) }) - ); - }); + ) + }) } // if ANY of the sets match ALL of its comparators, then pass - test(version) { + test (version) { if (!version) { - return false; + return false } - if (typeof version === "string") { + if (typeof version === 'string') { try { - version = new SemVer(version, this.options); + version = new SemVer(version, this.options) } catch (er) { - return false; + return false } } for (let i = 0; i < this.set.length; i++) { if (testSet(this.set[i], version, this.options)) { - return true; + return true } } - return false; + return false } } +module.exports = Range + +const Comparator = require('./comparator') +const debug = require('../internal/debug') +const SemVer = require('./semver') +const { + re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace +} = require('../internal/re') // take a set of comparators and determine whether there // exists a version which can satisfy it -function isSatisfiable (comparators, options) { +const isSatisfiable = (comparators, options) => { let result = true const remainingComparators = comparators.slice() let testComparator = remainingComparators.pop() @@ -306,7 +170,7 @@ function isSatisfiable (comparators, options) { // comprised of xranges, tildes, stars, and gtlt's at this point. // already replaced the hyphen ranges // turn into a set of JUST comparators. -function parseComparator (comp, options) { +const parseComparator = (comp, options) => { debug('comp', comp, options) comp = replaceCarets(comp, options) debug('caret', comp) @@ -319,9 +183,7 @@ function parseComparator (comp, options) { return comp } -function isX (id) { - return !id || id.toLowerCase() === 'x' || id === '*' -} +const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~, ~> --> * (any, kinda silly) // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 @@ -329,13 +191,12 @@ function isX (id) { // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes (comp, options) { - return comp.trim().split(/\s+/).map((comp) => { +const replaceTildes = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { return replaceTilde(comp, options) }).join(' ') -} -function replaceTilde (comp, options) { +const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] return comp.replace(r, (_, M, m, p, pr) => { debug('tilde', comp, _, M, m, p, pr) @@ -344,18 +205,18 @@ function replaceTilde (comp, options) { if (isX(M)) { ret = '' } else if (isX(m)) { - ret = `>=${ M }.0.0 <${ +M + 1 }.0.0` + ret = `>=${M}.0.0 <${+M + 1}.0.0` } else if (isX(p)) { // ~1.2 == >=1.2.0 <1.3.0 - ret = `>=${ M }.${ m }.0 <${ M }.${ +m + 1 }.0` + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0` } else if (pr) { debug('replaceTilde pr', pr) - ret = `>=${ M }.${ m }.${ p }-${ pr - } <${ M }.${ +m + 1 }.0` + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0` } else { // ~1.2.3 == >=1.2.3 <1.3.0 - ret = `>=${ M }.${ m }.${ p - } <${ M }.${ +m + 1 }.0` + ret = `>=${M}.${m}.${p + } <${M}.${+m + 1}.0` } debug('tilde return', ret) @@ -369,13 +230,12 @@ function replaceTilde (comp, options) { // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 // ^1.2.3 --> >=1.2.3 <2.0.0 // ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets (comp, options) { - return comp.trim().split(/\s+/).map((comp) => { +const replaceCarets = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { return replaceCaret(comp, options) }).join(' ') -} -function replaceCaret (comp, options) { +const replaceCaret = (comp, options) => { debug('caret', comp, options) const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] return comp.replace(r, (_, M, m, p, pr) => { @@ -385,40 +245,40 @@ function replaceCaret (comp, options) { if (isX(M)) { ret = '' } else if (isX(m)) { - ret = `>=${ M }.0.0 <${ +M + 1 }.0.0` + ret = `>=${M}.0.0 <${+M + 1}.0.0` } else if (isX(p)) { if (M === '0') { - ret = `>=${ M }.${ m }.0 <${ M }.${ +m + 1 }.0` + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0` } else { - ret = `>=${ M }.${ m }.0 <${ +M + 1 }.0.0` + ret = `>=${M}.${m}.0 <${+M + 1}.0.0` } } else if (pr) { debug('replaceCaret pr', pr) if (M === '0') { if (m === '0') { - ret = `>=${ M }.${ m }.${ p }-${ pr - } <${ M }.${ m }.${ +p + 1}` + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${m}.${+p + 1}` } else { - ret = `>=${ M }.${ m }.${ p }-${ pr - } <${ M }.${ +m + 1 }.0` + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0` } } else { - ret = `>=${ M }.${ m }.${ p }-${ pr - } <${ +M + 1 }.0.0` + ret = `>=${M}.${m}.${p}-${pr + } <${+M + 1}.0.0` } } else { debug('no pr') if (M === '0') { if (m === '0') { - ret = `>=${ M }.${ m }.${ p - } <${ M }.${ m }.${ +p + 1}` + ret = `>=${M}.${m}.${p + } <${M}.${m}.${+p + 1}` } else { - ret = `>=${ M }.${ m }.${ p - } <${ M }.${ +m + 1 }.0` + ret = `>=${M}.${m}.${p + } <${M}.${+m + 1}.0` } } else { - ret = `>=${ M }.${ m }.${ p - } <${ +M + 1 }.0.0` + ret = `>=${M}.${m}.${p + } <${+M + 1}.0.0` } } @@ -427,14 +287,14 @@ function replaceCaret (comp, options) { }) } -function replaceXRanges (comp, options) { +const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options) return comp.split(/\s+/).map((comp) => { return replaceXRange(comp, options) }).join(' ') } -function replaceXRange (comp, options) { +const replaceXRange = (comp, options) => { comp = comp.trim() const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] return comp.replace(r, (ret, gtlt, M, m, p, pr) => { @@ -492,12 +352,12 @@ function replaceXRange (comp, options) { } } - ret = `${gtlt + M }.${ m }.${ p }${pr}` + ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { - ret = `>=${ M }.0.0${ pr } <${ +M + 1 }.0.0${ pr}` + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0${pr}` } else if (xp) { - ret = `>=${ M }.${ m }.0${ pr - } <${ M }.${ +m + 1 }.0${ pr}` + ret = `>=${M}.${m}.0${pr + } <${M}.${+m + 1}.0${pr}` } debug('xRange return', ret) @@ -508,7 +368,7 @@ function replaceXRange (comp, options) { // Because * is AND-ed with everything else in the comparator, // and '' means "any version", just remove the *s entirely. -function replaceStars (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], '') @@ -519,35 +379,35 @@ function replaceStars (comp, options) { // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do // 1.2 - 3.4 => >=1.2.0 <3.5.0 -function hyphenReplace ($0, +const hyphenReplace = ($0, from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr, tb) { + to, tM, tm, tp, tpr, tb) => { if (isX(fM)) { from = '' } else if (isX(fm)) { - from = `>=${ fM }.0.0` + from = `>=${fM}.0.0` } else if (isX(fp)) { - from = `>=${ fM }.${ fm }.0` + from = `>=${fM}.${fm}.0` } else { - from = `>=${ from}` + from = `>=${from}` } if (isX(tM)) { to = '' } else if (isX(tm)) { - to = `<${ +tM + 1 }.0.0` + to = `<${+tM + 1}.0.0` } else if (isX(tp)) { - to = `<${ tM }.${ +tm + 1 }.0` + to = `<${tM}.${+tm + 1}.0` } else if (tpr) { - to = `<=${ tM }.${ tm }.${ tp }-${ tpr}` + to = `<=${tM}.${tm}.${tp}-${tpr}` } else { - to = `<=${ to}` + to = `<=${to}` } - return (`${from } ${ to}`).trim() + return (`${from} ${to}`).trim() } -function testSet (set, version, options) { +const testSet = (set, version, options) => { for (let i = 0; i < set.length; i++) { if (!set[i].test(version)) { return false @@ -562,7 +422,7 @@ function testSet (set, version, options) { // even though it's within the range set by the comparators. for (let i = 0; i < set.length; i++) { debug(set[i].semver) - if (set[i].semver === ANY) { + if (set[i].semver === Comparator.ANY) { continue } @@ -582,19 +442,3 @@ function testSet (set, version, options) { return true } - -function satisfies (version, range, options) { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) -} - -module.exports = { - Comparator, - satisfies, - Range, - ANY -}; \ No newline at end of file diff --git a/classes/semver.js b/classes/semver.js index a1b22b66..3ab5b5bb 100644 --- a/classes/semver.js +++ b/classes/semver.js @@ -1,205 +1,205 @@ -const debug = require("../internal/debug"); -const { MAX_LENGTH, MAX_SAFE_INTEGER } = require("../internal/constants"); -const { re, t } = require("../internal/re"); +const debug = require('../internal/debug') +const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants') +const { re, t } = require('../internal/re') -const { compareIdentifiers } = require("../internal/identifiers"); +const { compareIdentifiers } = require('../internal/identifiers') class SemVer { - constructor(version, options) { - if (!options || typeof options !== "object") { + constructor (version, options) { + if (!options || typeof options !== 'object') { options = { loose: !!options, includePrerelease: false - }; + } } if (version instanceof SemVer) { if (version.loose === options.loose) { - return version; + return version } else { - version = version.version; + version = version.version } - } else if (typeof version !== "string") { - throw new TypeError(`Invalid Version: ${ version}`); + } else if (typeof version !== 'string') { + throw new TypeError(`Invalid Version: ${version}`) } if (version.length > MAX_LENGTH) { throw new TypeError( - `version is longer than ${ MAX_LENGTH } characters` - ); + `version is longer than ${MAX_LENGTH} characters` + ) } - debug("SemVer", version, options); - this.options = options; - this.loose = !!options.loose; + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose - const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); + const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) if (!m) { - throw new TypeError(`Invalid Version: ${ version}`); + throw new TypeError(`Invalid Version: ${version}`) } - this.raw = version; + this.raw = version // these are actually numbers - this.major = +m[1]; - this.minor = +m[2]; - this.patch = +m[3]; + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError("Invalid major version"); + throw new TypeError('Invalid major version') } if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError("Invalid minor version"); + throw new TypeError('Invalid minor version') } if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError("Invalid patch version"); + throw new TypeError('Invalid patch version') } // numberify any prerelease numeric ids if (!m[4]) { - this.prerelease = []; + this.prerelease = [] } else { - this.prerelease = m[4].split(".").map((id) => { + this.prerelease = m[4].split('.').map((id) => { if (/^[0-9]+$/.test(id)) { - const num = +id; + const num = +id if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num; + return num } } - return id; - }); + return id + }) } - this.build = m[5] ? m[5].split(".") : []; - this.format(); + this.build = m[5] ? m[5].split('.') : [] + this.format() } - format() { - this.version = `${this.major }.${ this.minor }.${ this.patch}`; + format () { + this.version = `${this.major}.${this.minor}.${this.patch}` if (this.prerelease.length) { - this.version += `-${ this.prerelease.join(".")}`; + this.version += `-${this.prerelease.join('.')}` } - return this.version; + return this.version } - toString() { - return this.version; + toString () { + return this.version } - compare(other) { - debug("SemVer.compare", this.version, this.options, other); + compare (other) { + debug('SemVer.compare', this.version, this.options, other) if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); + other = new SemVer(other, this.options) } - return this.compareMain(other) || this.comparePre(other); + return this.compareMain(other) || this.comparePre(other) } - compareMain(other) { + compareMain (other) { if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); + other = new SemVer(other, this.options) } return ( compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch) - ); + ) } - comparePre(other) { + comparePre (other) { if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); + other = new SemVer(other, this.options) } // NOT having a prerelease is > having one if (this.prerelease.length && !other.prerelease.length) { - return -1; + return -1 } else if (!this.prerelease.length && other.prerelease.length) { - return 1; + return 1 } else if (!this.prerelease.length && !other.prerelease.length) { - return 0; + return 0 } - let i = 0; + let i = 0 do { - const a = this.prerelease[i]; - const b = other.prerelease[i]; - debug("prerelease compare", i, a, b); + const a = this.prerelease[i] + const b = other.prerelease[i] + debug('prerelease compare', i, a, b) if (a === undefined && b === undefined) { - return 0; + return 0 } else if (b === undefined) { - return 1; + return 1 } else if (a === undefined) { - return -1; + return -1 } else if (a === b) { - continue; + continue } else { - return compareIdentifiers(a, b); + return compareIdentifiers(a, b) } - } while (++i); + } while (++i) } - compareBuild(other) { + compareBuild (other) { if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options); + other = new SemVer(other, this.options) } - let i = 0; + let i = 0 do { - const a = this.build[i]; - const b = other.build[i]; - debug("prerelease compare", i, a, b); + const a = this.build[i] + const b = other.build[i] + debug('prerelease compare', i, a, b) if (a === undefined && b === undefined) { - return 0; + return 0 } else if (b === undefined) { - return 1; + return 1 } else if (a === undefined) { - return -1; + return -1 } else if (a === b) { - continue; + continue } else { - return compareIdentifiers(a, b); + return compareIdentifiers(a, b) } - } while (++i); + } while (++i) } // 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) { switch (release) { - case "premajor": - this.prerelease.length = 0; - this.patch = 0; - this.minor = 0; - this.major++; - this.inc("pre", identifier); - break; - case "preminor": - this.prerelease.length = 0; - this.patch = 0; - this.minor++; - this.inc("pre", identifier); - break; - case "prepatch": + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + 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); - break; + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break // If the input is a non-prerelease version, this acts the same as // prepatch. - case "prerelease": + case 'prerelease': if (this.prerelease.length === 0) { - this.inc("patch", identifier); + this.inc('patch', identifier) } - this.inc("pre", identifier); - break; + this.inc('pre', identifier) + break - case "major": + case 'major': // If this is a pre-major version, bump up to the same major version. // Otherwise increment major. // 1.0.0-5 bumps to 1.0.0 @@ -209,49 +209,49 @@ class SemVer { this.patch !== 0 || this.prerelease.length === 0 ) { - this.major++; + this.major++ } - this.minor = 0; - this.patch = 0; - this.prerelease = []; - break; - case "minor": + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': // If this is a pre-minor version, bump up to the same minor version. // Otherwise increment minor. // 1.2.0-5 bumps to 1.2.0 // 1.2.1 bumps to 1.3.0 if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++; + this.minor++ } - this.patch = 0; - this.prerelease = []; - break; - case "patch": + this.patch = 0 + this.prerelease = [] + break + case 'patch': // If this is not a pre-release version, it will increment the patch. // If it is a pre-release it will bump up to the same patch version. // 1.2.0-5 patches to 1.2.0 // 1.2.0 patches to 1.2.1 if (this.prerelease.length === 0) { - this.patch++; + this.patch++ } - this.prerelease = []; - break; + this.prerelease = [] + 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": + // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. + case 'pre': if (this.prerelease.length === 0) { - this.prerelease = [0]; + this.prerelease = [0] } else { - let i = this.prerelease.length; + let i = this.prerelease.length while (--i >= 0) { - if (typeof this.prerelease[i] === "number") { - this.prerelease[i]++; - i = -2; + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 } } if (i === -1) { // didn't increment anything - this.prerelease.push(0); + this.prerelease.push(0) } } if (identifier) { @@ -259,21 +259,21 @@ class SemVer { // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 if (this.prerelease[0] === identifier) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0]; + this.prerelease = [identifier, 0] } } else { - this.prerelease = [identifier, 0]; + this.prerelease = [identifier, 0] } } - break; + break default: - throw new Error(`invalid increment argument: ${ release}`); + throw new Error(`invalid increment argument: ${release}`) } - this.format(); - this.raw = this.version; - return this; + this.format() + this.raw = this.version + return this } } -module.exports = SemVer; +module.exports = SemVer diff --git a/functions/clean.js b/functions/clean.js index a611535a..811fe6b8 100644 --- a/functions/clean.js +++ b/functions/clean.js @@ -1,6 +1,6 @@ const parse = require('./parse') - -module.exports = function clean (version, options) { +const clean = (version, options) => { const s = parse(version.trim().replace(/^[=v]+/, ''), options) return s ? s.version : null -} \ No newline at end of file +} +module.exports = clean diff --git a/functions/cmp.js b/functions/cmp.js index 181bf2fd..3b89db77 100644 --- a/functions/cmp.js +++ b/functions/cmp.js @@ -5,43 +5,44 @@ const gte = require('./gte') const lt = require('./lt') const lte = require('./lte') -module.exports = function cmp (a, op, b, loose) { - switch (op) { - case '===': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a === b - - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b - - case '': - case '=': - case '==': - return eq(a, b, loose) - - case '!=': - return neq(a, b, loose) - - case '>': - return gt(a, b, loose) - - case '>=': - return gte(a, b, loose) - - case '<': - return lt(a, b, loose) - - case '<=': - return lte(a, b, loose) - - default: - throw new TypeError(`Invalid operator: ${ op}`) - } - } \ No newline at end of file +const cmp = (a, op, b, loose) => { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b + + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError(`Invalid operator: ${op}`) + } +} +module.exports = cmp diff --git a/functions/coerce.js b/functions/coerce.js index d2a82632..106ca71c 100644 --- a/functions/coerce.js +++ b/functions/coerce.js @@ -2,52 +2,50 @@ const SemVer = require('../classes/semver') const parse = require('./parse') const {re, t} = require('../internal/re') -module.exports = function coerce (version, options) { - if (version instanceof SemVer) { - return version - } - - if (typeof version === 'number') { - version = String(version) - } - - if (typeof version !== 'string') { - return null - } - - options = options || {} - - let match = null - if (!options.rtl) { - match = version.match(re[t.COERCE]) - } else { - // Find the right-most coercible string that does not share - // a terminus with a more left-ward coercible string. - // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' - // - // Walk through the string checking with a /g regexp - // Manually set the index so as to pick up overlapping matches. - // Stop when we get a match that ends at the string end, since no - // coercible string can be more right-ward without the same terminus. - let next - while ((next = re[t.COERCERTL].exec(version)) && +const coerce = (version, options) => { + if (version instanceof SemVer) { + return version + } + + if (typeof version === 'number') { + version = String(version) + } + + if (typeof version !== 'string') { + return null + } + + options = options || {} + + let match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + let next + while ((next = re[t.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length) - ) { - if (!match || + ) { + if (!match || next.index + next[0].length !== match.index + match[0].length) { - match = next - } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + match = next } - // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 - } - - if (match === null) { - return null + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length } - - return parse(`${match[2] - }.${ match[3] || '0' - }.${ match[4] || '0'}`, options) - } \ No newline at end of file + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) + return null + + return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) +} +module.exports = coerce diff --git a/functions/compare-build.js b/functions/compare-build.js index cd0ee181..9eb881be 100644 --- a/functions/compare-build.js +++ b/functions/compare-build.js @@ -1,7 +1,7 @@ const SemVer = require('../classes/semver') - -module.exports = function compareBuild (a, b, loose) { +const compareBuild = (a, b, loose) => { const versionA = new SemVer(a, loose) const versionB = new SemVer(b, loose) return versionA.compare(versionB) || versionA.compareBuild(versionB) -} \ No newline at end of file +} +module.exports = compareBuild diff --git a/functions/compare-loose.js b/functions/compare-loose.js index a63521ab..4881fbe0 100644 --- a/functions/compare-loose.js +++ b/functions/compare-loose.js @@ -1,5 +1,3 @@ const compare = require('./compare') - -module.exports = function compareLoose (a, b) { - return compare(a, b, true) -} \ No newline at end of file +const compareLoose = (a, b) => compare(a, b, true) +module.exports = compareLoose diff --git a/functions/compare.js b/functions/compare.js index 76d57b10..748b7afa 100644 --- a/functions/compare.js +++ b/functions/compare.js @@ -1,5 +1,5 @@ const SemVer = require('../classes/semver') +const compare = (a, b, loose) => + new SemVer(a, loose).compare(new SemVer(b, loose)) -module.exports = function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} \ No newline at end of file +module.exports = compare diff --git a/functions/diff.js b/functions/diff.js index 86f1b0cb..1493666e 100644 --- a/functions/diff.js +++ b/functions/diff.js @@ -1,7 +1,7 @@ const parse = require('./parse') const eq = require('./eq') -module.exports = function diff (version1, version2) { +const diff = (version1, version2) => { if (eq(version1, version2)) { return null } else { @@ -22,3 +22,4 @@ module.exports = function diff (version1, version2) { return defaultResult // may be undefined } } +module.exports = diff diff --git a/functions/eq.js b/functions/eq.js index 1d9036b0..271fed97 100644 --- a/functions/eq.js +++ b/functions/eq.js @@ -1,5 +1,3 @@ const compare = require('./compare') - -module.exports = function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} \ No newline at end of file +const eq = (a, b, loose) => compare(a, b, loose) === 0 +module.exports = eq diff --git a/functions/gt.js b/functions/gt.js index bbb41d19..d9b2156d 100644 --- a/functions/gt.js +++ b/functions/gt.js @@ -1,5 +1,3 @@ const compare = require('./compare') - -module.exports = function gt (a, b, loose) { - return compare(a, b, loose) > 0 -} \ No newline at end of file +const gt = (a, b, loose) => compare(a, b, loose) > 0 +module.exports = gt diff --git a/functions/gte.js b/functions/gte.js index 9c2b5942..5aeaa634 100644 --- a/functions/gte.js +++ b/functions/gte.js @@ -1,6 +1,3 @@ - const compare = require('./compare') - -module.exports = function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} \ No newline at end of file +const gte = (a, b, loose) => compare(a, b, loose) >= 0 +module.exports = gte diff --git a/functions/inc.js b/functions/inc.js index 13725df5..fc0fd92b 100644 --- a/functions/inc.js +++ b/functions/inc.js @@ -1,6 +1,6 @@ const SemVer = require('../classes/semver') -module.exports = function inc (version, release, loose, identifier) { +const inc = (version, release, loose, identifier) => { if (typeof (loose) === 'string') { identifier = loose loose = undefined @@ -11,4 +11,5 @@ module.exports = function inc (version, release, loose, identifier) { } catch (er) { return null } -} \ No newline at end of file +} +module.exports = inc diff --git a/functions/lt.js b/functions/lt.js index ee28dda5..b440ab7d 100644 --- a/functions/lt.js +++ b/functions/lt.js @@ -1,5 +1,3 @@ const compare = require('./compare') - -module.exports = function lt (a, b, loose) { - return compare(a, b, loose) < 0 -} \ No newline at end of file +const lt = (a, b, loose) => compare(a, b, loose) < 0 +module.exports = lt diff --git a/functions/lte.js b/functions/lte.js index f5d00c10..6dcc9565 100644 --- a/functions/lte.js +++ b/functions/lte.js @@ -1,5 +1,3 @@ const compare = require('./compare') - -module.exports = function lte (a, b, loose) { - return compare(a, b, loose) <= 0 -} \ No newline at end of file +const lte = (a, b, loose) => compare(a, b, loose) <= 0 +module.exports = lte diff --git a/functions/major.js b/functions/major.js index 2dc5a533..4283165e 100644 --- a/functions/major.js +++ b/functions/major.js @@ -1,5 +1,3 @@ const SemVer = require('../classes/semver') - -module.exports = function major (a, loose) { - return new SemVer(a, loose).major -} \ No newline at end of file +const major = (a, loose) => new SemVer(a, loose).major +module.exports = major diff --git a/functions/minor.js b/functions/minor.js index 040928b7..57b3455f 100644 --- a/functions/minor.js +++ b/functions/minor.js @@ -1,5 +1,3 @@ const SemVer = require('../classes/semver') - -module.exports = function minor (a, loose) { - return new SemVer(a, loose).minor -} \ No newline at end of file +const minor = (a, loose) => new SemVer(a, loose).minor +module.exports = minor diff --git a/functions/neq.js b/functions/neq.js index 4e39de75..f944c015 100644 --- a/functions/neq.js +++ b/functions/neq.js @@ -1,5 +1,3 @@ const compare = require('./compare') - -module.exports = function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} \ No newline at end of file +const neq = (a, b, loose) => compare(a, b, loose) !== 0 +module.exports = neq diff --git a/functions/parse.js b/functions/parse.js index afa480ff..457fee04 100644 --- a/functions/parse.js +++ b/functions/parse.js @@ -2,7 +2,7 @@ const {MAX_LENGTH} = require('../internal/constants') const { re, t } = require('../internal/re') const SemVer = require('../classes/semver') -module.exports = function parse (version, options) { +const parse = (version, options) => { if (!options || typeof options !== 'object') { options = { loose: !!options, @@ -32,4 +32,6 @@ module.exports = function parse (version, options) { } catch (er) { return null } -} \ No newline at end of file +} + +module.exports = parse diff --git a/functions/patch.js b/functions/patch.js index 4ab8b9a6..63afca25 100644 --- a/functions/patch.js +++ b/functions/patch.js @@ -1,5 +1,3 @@ const SemVer = require('../classes/semver') - -module.exports = function patch (a, loose) { - return new SemVer(a, loose).patch -} \ No newline at end of file +const patch = (a, loose) => new SemVer(a, loose).patch +module.exports = patch diff --git a/functions/prerelease.js b/functions/prerelease.js index 75511173..06aa1324 100644 --- a/functions/prerelease.js +++ b/functions/prerelease.js @@ -1,6 +1,6 @@ const parse = require('./parse') - -module.exports =function prerelease (version, options) { +const prerelease = (version, options) => { const parsed = parse(version, options) return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} \ No newline at end of file +} +module.exports = prerelease diff --git a/functions/rcompare.js b/functions/rcompare.js index cb928828..0ac509e7 100644 --- a/functions/rcompare.js +++ b/functions/rcompare.js @@ -1,5 +1,3 @@ const compare = require('./compare') - -module.exports = function rcompare (a, b, loose) { - return compare(b, a, loose) -} \ No newline at end of file +const rcompare = (a, b, loose) => compare(b, a, loose) +module.exports = rcompare diff --git a/functions/rsort.js b/functions/rsort.js index b582a30d..82404c5c 100644 --- a/functions/rsort.js +++ b/functions/rsort.js @@ -1,7 +1,3 @@ const compareBuild = require('./compare-build') - -module.exports = function rsort (list, loose) { - return list.sort((a, b) => { - return compareBuild(b, a, loose) - }) - } \ No newline at end of file +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) +module.exports = rsort diff --git a/functions/satisfies.js b/functions/satisfies.js new file mode 100644 index 00000000..50af1c19 --- /dev/null +++ b/functions/satisfies.js @@ -0,0 +1,10 @@ +const Range = require('../classes/range') +const satisfies = (version, range, options) => { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} +module.exports = satisfies diff --git a/functions/sort.js b/functions/sort.js index 4346dc74..4d10917a 100644 --- a/functions/sort.js +++ b/functions/sort.js @@ -1,7 +1,3 @@ const compareBuild = require('./compare-build') - -module.exports = function sort (list, loose) { - return list.sort((a, b) => { - return compareBuild(a, b, loose) - }) - } \ No newline at end of file +const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) +module.exports = sort diff --git a/functions/valid.js b/functions/valid.js index d23481aa..f27bae10 100644 --- a/functions/valid.js +++ b/functions/valid.js @@ -1,6 +1,6 @@ const parse = require('./parse') - -module.exports = function valid (version, options) { +const valid = (version, options) => { const v = parse(version, options) return v ? v.version : null -} \ No newline at end of file +} +module.exports = valid diff --git a/index.js b/index.js index 309112e8..9be4fac8 100644 --- a/index.js +++ b/index.js @@ -1,53 +1,64 @@ -const SemVer = require('./classes/semver') -const { Comparator, Range, satisfies} = require('./classes/range') -const { compareIdentifiers, rcompareIdentifiers } = require('./internal/identifiers') -const { SEMVER_SPEC_VERSION } = require('./internal/constants') -const { re, src, t } = require('./internal/re') +const lrCache = {} +const lazyRequire = (path, subkey) => { + const module = lrCache[path] || (lrCache[path] = require(path)) + return subkey ? module[subkey] : module +} -exports = module.exports = SemVer -exports.re = re -exports.src = src -exports.tokens = t -exports.SEMVER_SPEC_VERSION = SEMVER_SPEC_VERSION +const lazyExport = (key, path, subkey) => { + Object.defineProperty(exports, key, { + get: () => { + const res = lazyRequire(path, subkey) + Object.defineProperty(exports, key, { + value: res, + enumerable: true, + configurable: true + }) + return res + }, + configurable: true, + enumerable: true + }) +} -exports.SemVer = SemVer -exports.compareIdentifiers = compareIdentifiers -exports.rcompareIdentifiers = rcompareIdentifiers - -exports.parse = require('./functions/parse') -exports.valid = require('./functions/valid') -exports.clean = require('./functions/clean') -exports.inc = require('./functions/inc') -exports.diff = require('./functions/diff') -exports.major = require('./functions/major') -exports.minor = require('./functions/minor') -exports.patch = require('./functions/patch') -exports.prerelease = require('./functions/prerelease') -exports.compare = require('./functions/compare') -exports.rcompare = require('./functions/rcompare') -exports.compareLoose = require('./functions/compare-loose') -exports.compareBuild = require('./functions/compare-build') -exports.sort = require('./functions/sort') -exports.rsort = require('./functions/rsort') -exports.gt = require('./functions/gt') -exports.lt = require('./functions/lt') -exports.eq = require('./functions/eq') -exports.neq = require('./functions/neq') -exports.gte = require('./functions/gte') -exports.lte = require('./functions/lte') -exports.cmp = require('./functions/cmp') -exports.coerce = require('./functions/coerce') - -exports.Comparator = Comparator -exports.Range = Range -exports.satisfies = satisfies - -exports.toComparators = require('./ranges/to-comparators') -exports.maxSatisfying = require('./ranges/max-satisfying') -exports.minSatisfying = require('./ranges/min-satisfying') -exports.minVersion = require('./ranges/min-version') -exports.validRange = require('./ranges/valid-range') -exports.outside = require('./ranges/outside') -exports.gtr = require('./ranges/gtr') -exports.ltr = require('./ranges/ltr') -exports.intersects = require('./ranges/intersects') +lazyExport('re', './internal/re', 're') +lazyExport('src', './internal/re', 'src') +lazyExport('tokens', './internal/re', 't') +lazyExport('SEMVER_SPEC_VERSION', './internal/constants', 'SEMVER_SPEC_VERSION') +lazyExport('SemVer', './classes/semver') +lazyExport('compareIdentifiers', './internal/identifiers', 'compareIdentifiers') +lazyExport('rcompareIdentifiers', './internal/identifiers', 'rcompareIdentifiers') +lazyExport('parse', './functions/parse') +lazyExport('valid', './functions/valid') +lazyExport('clean', './functions/clean') +lazyExport('inc', './functions/inc') +lazyExport('diff', './functions/diff') +lazyExport('major', './functions/major') +lazyExport('minor', './functions/minor') +lazyExport('patch', './functions/patch') +lazyExport('prerelease', './functions/prerelease') +lazyExport('compare', './functions/compare') +lazyExport('rcompare', './functions/rcompare') +lazyExport('compareLoose', './functions/compare-loose') +lazyExport('compareBuild', './functions/compare-build') +lazyExport('sort', './functions/sort') +lazyExport('rsort', './functions/rsort') +lazyExport('gt', './functions/gt') +lazyExport('lt', './functions/lt') +lazyExport('eq', './functions/eq') +lazyExport('neq', './functions/neq') +lazyExport('gte', './functions/gte') +lazyExport('lte', './functions/lte') +lazyExport('cmp', './functions/cmp') +lazyExport('coerce', './functions/coerce') +lazyExport('Comparator', './classes/comparator') +lazyExport('Range', './classes/range') +lazyExport('satisfies', './functions/satisfies') +lazyExport('toComparators', './ranges/to-comparators') +lazyExport('maxSatisfying', './ranges/max-satisfying') +lazyExport('minSatisfying', './ranges/min-satisfying') +lazyExport('minVersion', './ranges/min-version') +lazyExport('validRange', './ranges/valid-range') +lazyExport('outside', './ranges/outside') +lazyExport('gtr', './ranges/gtr') +lazyExport('ltr', './ranges/ltr') +lazyExport('intersects', './ranges/intersects') diff --git a/internal/constants.js b/internal/constants.js index 09889484..49df215a 100644 --- a/internal/constants.js +++ b/internal/constants.js @@ -10,8 +10,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || const MAX_SAFE_COMPONENT_LENGTH = 16 module.exports = { - SEMVER_SPEC_VERSION, - MAX_LENGTH, - MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH -} \ No newline at end of file + SEMVER_SPEC_VERSION, + MAX_LENGTH, + MAX_SAFE_INTEGER, + MAX_SAFE_COMPONENT_LENGTH +} diff --git a/internal/debug.js b/internal/debug.js index 0202b360..1c00e136 100644 --- a/internal/debug.js +++ b/internal/debug.js @@ -1,17 +1,9 @@ - -let debug -/* istanbul ignore next */ -if (typeof process === 'object' && - process.env && - process.env.NODE_DEBUG && - /\bsemver\b/i.test(process.env.NODE_DEBUG)) { - debug = function () { - const args = Array.prototype.slice.call(arguments, 0) - args.unshift('SEMVER') - console.log.apply(console, args) - } -} else { - debug = function () {} -} +const debug = ( + typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG) +) ? (...args) => console.error('SEMVER', ...args) + : () => {} module.exports = debug diff --git a/internal/identifiers.js b/internal/identifiers.js index 4f9965f8..ed130942 100644 --- a/internal/identifiers.js +++ b/internal/identifiers.js @@ -1,5 +1,5 @@ const numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { +const compareIdentifiers = (a, b) => { const anum = numeric.test(a) const bnum = numeric.test(b) @@ -15,11 +15,9 @@ function compareIdentifiers (a, b) { : 1 } -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) -} +const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { - compareIdentifiers, - rcompareIdentifiers -} \ No newline at end of file + compareIdentifiers, + rcompareIdentifiers +} diff --git a/internal/re.js b/internal/re.js index 15422519..0e8fb528 100644 --- a/internal/re.js +++ b/internal/re.js @@ -8,11 +8,11 @@ const src = exports.src = [] const t = exports.t = {} let R = 0 -function createToken (name, value, isGlobal) { - const index = R++; - debug(index, value); - t[name] = index; - src[index] = value; +const createToken = (name, value, isGlobal) => { + const index = R++ + debug(index, value) + t[name] = index + src[index] = value re[index] = new RegExp(value, isGlobal ? 'g' : undefined) } @@ -22,56 +22,56 @@ function createToken (name, value, isGlobal) { // ## Numeric Identifier // A single `0`, or a non-zero digit followed by zero or more digits. -createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*'); -createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); +createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') +createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+') // ## Non-numeric Identifier // Zero or more digits, followed by a letter or hyphen, and then zero or // more letters, digits, or hyphens. -createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); +createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*') // ## Main Version // Three dot-separated numeric identifiers. createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + - `(${src[t.NUMERICIDENTIFIER]})`); + `(${src[t.NUMERICIDENTIFIER]})`) createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + - `(${src[t.NUMERICIDENTIFIERLOOSE]})`); + `(${src[t.NUMERICIDENTIFIERLOOSE]})`) // ## Pre-release Version Identifier // A numeric identifier, or a non-numeric identifier. -createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] - }|${src[t.NONNUMERICIDENTIFIER]})`); +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] +}|${src[t.NONNUMERICIDENTIFIER]})`) -createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] - }|${src[t.NONNUMERICIDENTIFIER]})`); +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] +}|${src[t.NONNUMERICIDENTIFIER]})`) // ## Pre-release Version // Hyphen, followed by one or more dot-separated pre-release version // identifiers. createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] - }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); +}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`) createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] - }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); +}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) // ## Build Metadata Identifier // Any combination of digits, letters, or hyphens. -createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); +createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+') // ## Build Metadata // Plus sign, followed by one or more period-separated build metadata // identifiers. -createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] - }(?:\\.${src[t.BUILDIDENTIFIER]})*))`); +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] +}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) // ## Full Version String // A main version, followed optionally by a pre-release version and @@ -82,83 +82,83 @@ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] // capturing group, because it should not ever be used in version // comparison. -createToken('FULLPLAIN', `v?${src[t.MAINVERSION] - }${src[t.PRERELEASE]}?${ - src[t.BUILD]}?`); +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] +}${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`) -createToken('FULL', `^${src[t.FULLPLAIN]}$`); +createToken('FULL', `^${src[t.FULLPLAIN]}$`) // like full, but allows v1.2.3 and =1.2.3, which people do sometimes. // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty // common in the npm registry. -createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] - }${src[t.PRERELEASELOOSE]}?${ - src[t.BUILD]}?`); +createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] +}${src[t.PRERELEASELOOSE]}?${ + src[t.BUILD]}?`) -createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`); +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) -createToken('GTLT', '((?:<|>)?=?)'); +createToken('GTLT', '((?:<|>)?=?)') // Something like "2.*" or "1.2.x". // Note that "x.x" is a valid xRange identifer, meaning "any version" // Only the first item is strictly required. -createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); -createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); +createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`) +createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`) createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + - `(?:${src[t.PRERELEASE]})?${ - src[t.BUILD]}?` + - `)?)?`); + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`) createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + - `(?:${src[t.PRERELEASELOOSE]})?${ - src[t.BUILD]}?` + - `)?)?`); + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`) -createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); -createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); +createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) +createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) // Coercion. // Extract anything that could conceivably be a part of a valid semver createToken('COERCE', `${'(^|[^\\d])' + - '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH }})` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH }}))?` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH }}))?` + - `(?:$|[^\\d])`); -createToken('COERCERTL', src[t.COERCE], true); + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:$|[^\\d])`) +createToken('COERCERTL', src[t.COERCE], true) // Tilde ranges. // Meaning is "reasonably at or greater than" -createToken('LONETILDE', '(?:~>?)'); +createToken('LONETILDE', '(?:~>?)') -createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true); +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) exports.tildeTrimReplace = '$1~' -createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); -createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) // Caret ranges. // Meaning is "at least and backwards compatible with" -createToken('LONECARET', '(?:\\^)'); +createToken('LONECARET', '(?:\\^)') -createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true); +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) exports.caretTrimReplace = '$1^' -createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); -createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) // A simple gt/lt/eq thing, or just "" to indicate "any version" -createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); -createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); +createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`) +createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`) // An expression to strip any whitespace between the gtlt and the thing // it modifies, so that `> 1.2.3` ==> `>1.2.3` -createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] - }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); +createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] +}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true) exports.comparatorTrimReplace = '$1$2$3' // Something like `1.2.3 - 1.2.4` @@ -168,12 +168,12 @@ exports.comparatorTrimReplace = '$1$2$3' createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + - `\\s*$`); + `\\s*$`) createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + - `\\s*$`); + `\\s*$`) // Star ranges basically just allow anything at all. -createToken('STAR', '(<|>)?=?\\s*\\*'); +createToken('STAR', '(<|>)?=?\\s*\\*') diff --git a/map.js b/map.js new file mode 100644 index 00000000..293f6b01 --- /dev/null +++ b/map.js @@ -0,0 +1 @@ +module.exports = testFile => testFile.replace(/test\//, '') diff --git a/package-lock.json b/package-lock.json index f86c7542..e412a4ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,25 +5,24 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", - "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", "dev": true, "requires": { "@babel/highlight": "^7.0.0" } }, "@babel/generator": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.4.tgz", - "integrity": "sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.2.tgz", + "integrity": "sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ==", "dev": true, "requires": { - "@babel/types": "^7.4.4", + "@babel/types": "^7.7.2", "jsesc": "^2.5.1", - "lodash": "^4.17.11", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" + "lodash": "^4.17.13", + "source-map": "^0.5.0" }, "dependencies": { "source-map": { @@ -35,38 +34,38 @@ } }, "@babel/helper-function-name": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", - "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz", + "integrity": "sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.0.0", - "@babel/template": "^7.1.0", - "@babel/types": "^7.0.0" + "@babel/helper-get-function-arity": "^7.7.0", + "@babel/template": "^7.7.0", + "@babel/types": "^7.7.0" } }, "@babel/helper-get-function-arity": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", - "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz", + "integrity": "sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw==", "dev": true, "requires": { - "@babel/types": "^7.0.0" + "@babel/types": "^7.7.0" } }, "@babel/helper-split-export-declaration": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", - "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz", + "integrity": "sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA==", "dev": true, "requires": { - "@babel/types": "^7.4.4" + "@babel/types": "^7.7.0" } }, "@babel/highlight": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", - "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", "dev": true, "requires": { "chalk": "^2.0.0", @@ -75,63 +74,80 @@ } }, "@babel/parser": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.5.tgz", - "integrity": "sha512-9mUqkL1FF5T7f0WDFfAoDdiMVPWsdD1gZYzSnaXsxUCUqzuch/8of9G3VUSNiZmMBoRxT3neyVsqeiL/ZPcjew==", + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.3.tgz", + "integrity": "sha512-bqv+iCo9i+uLVbI0ILzKkvMorqxouI+GbV13ivcARXn9NNEabi2IEz912IgNpT/60BNXac5dgcfjb94NjsF33A==", "dev": true }, "@babel/runtime": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.5.tgz", - "integrity": "sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.2.tgz", + "integrity": "sha512-JONRbXbTXc9WQE2mAZd1p0Z3DZ/6vaQIkgYMSTP3KjRCyd7rCZCcfhCyX+YjwcKxcZ82UrxbRD358bpExNgrjw==", "dev": true, "requires": { "regenerator-runtime": "^0.13.2" } }, "@babel/template": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", - "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.0.tgz", + "integrity": "sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.4.4", - "@babel/types": "^7.4.4" + "@babel/parser": "^7.7.0", + "@babel/types": "^7.7.0" } }, "@babel/traverse": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.5.tgz", - "integrity": "sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.2.tgz", + "integrity": "sha512-TM01cXib2+rgIZrGJOLaHV/iZUAxf4A0dt5auY6KNZ+cm6aschuJGqKJM3ROTt3raPUdIDk9siAufIFEleRwtw==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.4", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.4.5", - "@babel/types": "^7.4.4", + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.2", + "@babel/helper-function-name": "^7.7.0", + "@babel/helper-split-export-declaration": "^7.7.0", + "@babel/parser": "^7.7.2", + "@babel/types": "^7.7.2", "debug": "^4.1.0", "globals": "^11.1.0", - "lodash": "^4.17.11" + "lodash": "^4.17.13" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "@babel/types": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz", - "integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.2.tgz", + "integrity": "sha512-YTf6PXoh3+eZgRCBzzP25Bugd2ngmpQVrk7kXX0i5N9BO7TFBtIgZYs7WtxtOGs8e6A4ZI7ECkbBCEHeXocvOA==", "dev": true, "requires": { "esutils": "^2.0.2", - "lodash": "^4.17.11", + "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } }, "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -156,9 +172,9 @@ } }, "anymatch": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.0.2.tgz", - "integrity": "sha512-rUe9SxpRQlVg4EM8It7JMNWWYHAirTPpbTuvaSKybb5IejNgWB3PGBBX9rrPKDx2pM/p3Wh+7+ASaWRyyAbxmQ==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", + "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", "dev": true, "requires": { "normalize-path": "^3.0.0", @@ -181,9 +197,9 @@ "dev": true }, "arg": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.0.tgz", - "integrity": "sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", + "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", "dev": true }, "argparse": { @@ -210,16 +226,10 @@ "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, - "async-each": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true - }, "async-hook-domain": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/async-hook-domain/-/async-hook-domain-1.1.0.tgz", - "integrity": "sha512-NH7V97d1yCbIanu2oDLyPT2GFNct0esPeJyRfkk8J5hTztHVSQp4UiNfL2O42sCA9XZPU8OgHvzOmt9ewBhVqA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/async-hook-domain/-/async-hook-domain-1.1.3.tgz", + "integrity": "sha512-ZovMxSbADV3+biB7oR1GL5lGyptI24alp0LWHlmz1OFc5oL47pz3EiIF6nXOkDW7yLqih4NtsiYduzdDW0i+Wg==", "dev": true, "requires": { "source-map-support": "^0.5.11" @@ -295,6 +305,12 @@ "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", "dev": true }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -332,12 +348,6 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true }, - "capture-stack-trace": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz", - "integrity": "sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw==", - "dev": true - }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", @@ -353,23 +363,39 @@ "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" + }, + "dependencies": { + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "chokidar": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.0.1.tgz", - "integrity": "sha512-2ww34sJWehnbpV0Q4k4V5Hh7juo7po6z7LUWkcIQnSGN1lHOL8GGtLtfwabKvLFQw/hbSUQ0u6V7OgGYgBzlkQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", + "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", "dev": true, "requires": { - "anymatch": "^3.0.1", - "async-each": "^1.0.3", - "braces": "^3.0.2", - "fsevents": "^2.0.6", - "glob-parent": "^5.0.0", - "is-binary-path": "^2.1.0", - "is-glob": "^4.0.1", - "normalize-path": "^3.0.0", - "readdirp": "^3.0.2" + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.1.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.2.0" } }, "cliui": { @@ -383,6 +409,16 @@ "wrap-ansi": "^2.0.0" } }, + "cobertura-parse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/cobertura-parse/-/cobertura-parse-1.0.5.tgz", + "integrity": "sha512-uYJfkGhzw1wibe/8jqqHmSaPNWFguzq/IlSj83u3cSnZho/lUnfj0mLTmZGmB3AiKCOTYr22TYwpR1sXy2JEkg==", + "dev": true, + "requires": { + "mocha": "5.0.5", + "xml2js": "0.4.19" + } + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -420,11 +456,10 @@ } }, "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "dev": true, - "optional": true + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true }, "commondir": { "version": "1.0.1", @@ -439,12 +474,20 @@ "dev": true }, "convert-source-map": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", - "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", "dev": true, "requires": { "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "core-util-is": { @@ -454,17 +497,17 @@ "dev": true }, "coveralls": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.4.tgz", - "integrity": "sha512-eyqUWA/7RT0JagiL0tThVhjbIjoiEUyWCjtUJoOPcWoeofP5WK/jb2OJYoBFrR6DvplR+AxOyuBqk4JHkk5ykA==", + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.8.tgz", + "integrity": "sha512-lkQlg29RhV9zwB0gDaEAWoap8xPgFxtPsVIpTNiDDtWNrvtP1/RmGJRRAV/Loz2gihmppObkSL0wnptEGUXaOQ==", "dev": true, "requires": { - "growl": "~> 1.10.0", - "js-yaml": "^3.11.0", - "lcov-parse": "^0.0.10", + "cobertura-parse": "^1.0.5", + "js-yaml": "^3.13.1", + "lcov-parse": "^1.0.0", "log-driver": "^1.2.7", "minimist": "^1.2.0", - "request": "^2.86.0" + "request": "^2.88.0" } }, "cp-file": { @@ -488,6 +531,17 @@ "requires": { "lru-cache": "^4.0.1", "which": "^1.2.9" + }, + "dependencies": { + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } } }, "dashdash": { @@ -500,12 +554,12 @@ } }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.0.0" } }, "decamelize": { @@ -535,6 +589,12 @@ "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", "dev": true }, + "diff-frag": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/diff-frag/-/diff-frag-1.0.1.tgz", + "integrity": "sha512-6/v2PC/6UTGcWPPetb9acL8foberUg/CtPdALeJUdD1B/weHNvzftoo00gYznqHGRhHEbykUGzqfG9RWOSr5yw==", + "dev": true + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -551,15 +611,6 @@ "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", "dev": true }, - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", - "dev": true, - "requires": { - "once": "^1.4.0" - } - }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -594,9 +645,9 @@ "dev": true }, "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, "events-to-array": { @@ -605,36 +656,6 @@ "integrity": "sha1-LUH1Y+H+QA7Uli/hpNXGp1Od9/Y=", "dev": true }, - "execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - }, - "dependencies": { - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - } - } - }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -695,18 +716,18 @@ "dev": true }, "flow-parser": { - "version": "0.101.1", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.101.1.tgz", - "integrity": "sha512-5XI7KnnndL1E0bmZp+SURCeNe0mZ86QHtwnmmn91J7Q3VptG26QEpH8pEecN+UgKRFm23K9zzTeesJhmuGA+mg==", + "version": "0.112.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.112.0.tgz", + "integrity": "sha512-sxjnwhR76B/fUN6n/XerYzn8R1HvtVo3SM8Il3WiZ4nkAlb2BBzKe1TSVKGSyZgD6FW9Bsxom/57ktkqrqmXGA==", "dev": true }, "flow-remove-types": { - "version": "2.101.0", - "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.101.0.tgz", - "integrity": "sha512-87C0OgvfgvAWZeA4/0UxmLVbqZUxzntc6knAF2QzwwnUUSQMx7J4UtpCB8COIf9wehkWOEmcIa2XnQdz2lgYyg==", + "version": "2.112.0", + "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.112.0.tgz", + "integrity": "sha512-h3bwcfh41nR9kvlhZFr5ySGmzzOyG4VUsnN4OBl9R6anbWAiX4H5lPhKTwZ7AelWF8Rtqmw/Vnq+VLEMg7PdAw==", "dev": true, "requires": { - "flow-parser": "^0.101.0", + "flow-parser": "^0.112.0", "pirates": "^3.0.2", "vlq": "^0.2.1" } @@ -751,9 +772,9 @@ "dev": true }, "fsevents": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.0.7.tgz", - "integrity": "sha512-a7YT0SV3RB+DjYcppwVDLtn13UQnmg0SWZS7ezZD0UjnLwXmy8Zm21GMVGLaFGimIqcvyMQaOJBrop8MyOp1kQ==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", + "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", "dev": true, "optional": true }, @@ -769,15 +790,6 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -788,9 +800,9 @@ } }, "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -802,9 +814,9 @@ } }, "glob-parent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", - "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", "dev": true, "requires": { "is-glob": "^4.0.1" @@ -817,21 +829,21 @@ "dev": true }, "graceful-fs": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", - "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", "dev": true }, "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", - "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", + "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", "dev": true, "requires": { "neo-async": "^2.6.0", @@ -857,9 +869,9 @@ } }, "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, "hasha": { @@ -871,10 +883,16 @@ "is-stream": "^1.0.1" } }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, "hosted-git-info": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", - "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", + "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", "dev": true }, "http-signature": { @@ -910,12 +928,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "invert-kv": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", - "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", - "dev": true - }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -1020,9 +1032,9 @@ }, "dependencies": { "semver": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.3.tgz", - "integrity": "sha512-aymF+56WJJMyXQHcd4hlK4N75rwj5RQpfW8ePlQnJsTYOBLlLbcIErR/G1s9SkIvKBqOudR3KAx4wEqP+F1hNQ==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true } } @@ -1052,6 +1064,15 @@ "shebang-command": "^1.2.0", "which": "^1.2.9" } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } } } }, @@ -1066,6 +1087,12 @@ "supports-color": "^6.1.0" }, "dependencies": { + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, "supports-color": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", @@ -1088,6 +1115,23 @@ "make-dir": "^2.1.0", "rimraf": "^2.6.3", "source-map": "^0.6.1" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "istanbul-reports": { @@ -1172,19 +1216,10 @@ "verror": "1.10.0" } }, - "lcid": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", - "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", - "dev": true, - "requires": { - "invert-kv": "^2.0.0" - } - }, "lcov-parse": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", - "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz", + "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", "dev": true }, "load-json-file": { @@ -1218,9 +1253,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, "lodash.flattendeep": { @@ -1261,26 +1296,6 @@ "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", "dev": true }, - "map-age-cleaner": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", - "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", - "dev": true, - "requires": { - "p-defer": "^1.0.0" - } - }, - "mem": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", - "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", - "dev": true, - "requires": { - "map-age-cleaner": "^0.1.1", - "mimic-fn": "^2.0.0", - "p-is-promise": "^2.0.0" - } - }, "merge-source-map": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", @@ -1291,26 +1306,20 @@ } }, "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", + "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==", "dev": true }, "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "version": "2.1.25", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", + "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", "dev": true, "requires": { - "mime-db": "1.40.0" + "mime-db": "1.42.0" } }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -1327,19 +1336,18 @@ "dev": true }, "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.1.tgz", + "integrity": "sha512-UFqVihv6PQgwj8/yTGvl9kPz7xIAY+R5z6XYjRInD3Gk3qx6QGSD6zEcpeG4Dy/lQnv1J6zv8ejV90hyYIKf3w==", "dev": true, "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" + "yallist": "^4.0.0" }, "dependencies": { "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true } } @@ -1361,10 +1369,50 @@ } } }, + "mocha": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.5.tgz", + "integrity": "sha512-3MM3UjZ5p8EJrYpG7s+29HAI9G7sTzKEe4+w37Dg0QP7qL4XGsV+Q2xet2cE37AqdgN1OtYQB6Vl98YiPV3PgA==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + }, + "dependencies": { + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, "neo-async": { @@ -1409,15 +1457,6 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "^2.0.0" - } - }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", @@ -1502,17 +1541,6 @@ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, - "os-locale": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", - "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", - "dev": true, - "requires": { - "execa": "^1.0.0", - "lcid": "^2.0.0", - "mem": "^4.0.0" - } - }, "own-or": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/own-or/-/own-or-1.0.0.tgz", @@ -1528,28 +1556,10 @@ "own-or": "^1.0.0" } }, - "p-defer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", - "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", - "dev": true - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, - "p-is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", - "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", - "dev": true - }, "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -1640,9 +1650,9 @@ "dev": true }, "picomatch": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", - "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz", + "integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==", "dev": true }, "pify": { @@ -1683,21 +1693,11 @@ "dev": true }, "psl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz", - "integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", + "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==", "dev": true }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -1745,21 +1745,30 @@ "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, + "optional": true + } } }, "readdirp": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.0.2.tgz", - "integrity": "sha512-LbyJYv48eywrhOlScq16H/VkCiGKGPC2TpOdZCJ7QXnYEjn3NN/Oblh8QEU3vqfSRBB7OGvh5x45NKiVeNujIQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", + "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", "dev": true, "requires": { "picomatch": "^2.0.4" } }, "regenerator-runtime": { - "version": "0.13.2", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz", - "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==", + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", + "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", "dev": true }, "release-zalgo": { @@ -1812,9 +1821,9 @@ "dev": true }, "resolve": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", - "integrity": "sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1827,18 +1836,18 @@ "dev": true }, "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", "dev": true, "requires": { "glob": "^7.1.3" } }, "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", "dev": true }, "safer-buffer": { @@ -1847,10 +1856,16 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true }, "set-blocking": { @@ -1887,9 +1902,9 @@ "dev": true }, "source-map-support": { - "version": "0.5.12", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", - "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", + "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -1897,9 +1912,9 @@ } }, "spawn-wrap": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-1.4.2.tgz", - "integrity": "sha512-vMwR3OmmDhnxCVxM8M+xO/FtIp6Ju/mNaDfCMMW7FDcLRTPFWUswec4LXJHTJE2hwTI9O0YBfygu4DalFl7Ylg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-1.4.3.tgz", + "integrity": "sha512-IgB8md0QW/+tWqcavuFgKYR/qIRvJkRLPJDFaoXtLLUaVcCDK0+HeFTkmQHj3eprcYhc+gOl0aEA1w7qZlYezw==", "dev": true, "requires": { "foreground-child": "^1.5.6", @@ -1908,6 +1923,17 @@ "rimraf": "^2.6.2", "signal-exit": "^3.0.2", "which": "^1.3.0" + }, + "dependencies": { + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } } }, "spdx-correct": { @@ -1937,9 +1963,9 @@ } }, "spdx-license-ids": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz", - "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, "sprintf-js": { @@ -1989,6 +2015,15 @@ "optional": true, "requires": { "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, + "optional": true + } } }, "strip-ansi": { @@ -2006,38 +2041,31 @@ "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", "dev": true }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true - }, "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "^2.0.0" } }, "tap": { - "version": "14.3.1", - "resolved": "https://registry.npmjs.org/tap/-/tap-14.3.1.tgz", - "integrity": "sha512-xDjfHKRwhrsAgV4DtKwhJ278rqRV8t1jTCM2P+1vDllvzGUIuzYFatC8vHosLg/HnGGLr/28BuTVeE64JwnRPg==", + "version": "14.10.1", + "resolved": "https://registry.npmjs.org/tap/-/tap-14.10.1.tgz", + "integrity": "sha512-GsjAtKf9WKe2Cj5/5OckVdwyz4kv4pjlidDPpNY32ikR6rkBnicU/gxwckXvV/pQ5uTDx+od6XqmVAB7ityXWg==", "dev": true, "requires": { - "async-hook-domain": "^1.1.0", + "async-hook-domain": "^1.1.2", "bind-obj-methods": "^2.0.0", "browser-process-hrtime": "^1.0.0", - "capture-stack-trace": "^1.0.0", - "chokidar": "^3.0.1", + "chokidar": "^3.0.2", "color-support": "^1.1.0", - "coveralls": "^3.0.4", + "coveralls": "^3.0.6", "diff": "^4.0.1", "esm": "^3.2.25", "findit": "^2.0.0", - "flow-remove-types": "^2.101.0", + "flow-remove-types": "^2.107.0", "foreground-child": "^1.3.3", "fs-exists-cached": "^1.0.0", "function-loop": "^1.0.2", @@ -2047,33 +2075,33 @@ "isexe": "^2.0.0", "istanbul-lib-processinfo": "^1.0.0", "jackspeak": "^1.4.0", - "minipass": "^2.3.5", + "minipass": "^3.0.0", "mkdirp": "^0.5.1", "nyc": "^14.1.1", "opener": "^1.5.1", "own-or": "^1.0.0", "own-or-env": "^1.0.1", - "react": "^16.8.6", - "rimraf": "^2.6.3", + "react": "^16.9.0", + "rimraf": "^2.7.1", "signal-exit": "^3.0.0", - "source-map-support": "^0.5.12", + "source-map-support": "^0.5.16", "stack-utils": "^1.0.2", - "tap-mocha-reporter": "^4.0.1", - "tap-parser": "^9.3.2", + "tap-mocha-reporter": "^5.0.0", + "tap-parser": "^10.0.1", "tap-yaml": "^1.0.0", - "tcompare": "^2.3.0", - "treport": "^0.4.0", + "tcompare": "^3.0.0", + "treport": "^0.5.0", "trivial-deferred": "^1.0.1", "ts-node": "^8.3.0", - "typescript": "^3.5.2", - "which": "^1.3.1", + "typescript": "^3.6.3", + "which": "^2.0.1", "write-file-atomic": "^3.0.0", "yaml": "^1.6.0", "yapool": "^1.0.0" }, "dependencies": { "@babel/runtime": { - "version": "7.4.5", + "version": "7.6.3", "bundled": true, "dev": true, "requires": { @@ -2081,19 +2109,19 @@ }, "dependencies": { "regenerator-runtime": { - "version": "0.13.2", + "version": "0.13.3", "bundled": true, "dev": true } } }, "@types/prop-types": { - "version": "15.7.1", + "version": "15.7.3", "bundled": true, "dev": true }, "@types/react": { - "version": "16.8.22", + "version": "16.9.5", "bundled": true, "dev": true, "requires": { @@ -2102,9 +2130,12 @@ } }, "ansi-escapes": { - "version": "3.2.0", + "version": "4.2.1", "bundled": true, - "dev": true + "dev": true, + "requires": { + "type-fest": "^0.5.2" + } }, "ansi-regex": { "version": "2.1.1", @@ -2132,7 +2163,7 @@ "dev": true }, "auto-bind": { - "version": "2.1.0", + "version": "2.1.1", "bundled": true, "dev": true, "requires": { @@ -2452,15 +2483,22 @@ "dev": true, "requires": { "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true + } } }, "core-js": { - "version": "2.6.5", + "version": "2.6.10", "bundled": true, "dev": true }, "csstype": { - "version": "2.6.5", + "version": "2.6.7", "bundled": true, "dev": true }, @@ -2496,7 +2534,7 @@ "dev": true }, "esutils": { - "version": "2.0.2", + "version": "2.0.3", "bundled": true, "dev": true }, @@ -2546,11 +2584,12 @@ } }, "ink": { - "version": "2.3.0", + "version": "2.5.0", "bundled": true, "dev": true, "requires": { "@types/react": "^16.8.6", + "ansi-escapes": "^4.2.1", "arrify": "^1.0.1", "auto-bind": "^2.0.0", "chalk": "^2.4.1", @@ -2560,8 +2599,8 @@ "lodash.throttle": "^4.1.1", "log-update": "^3.0.0", "prop-types": "^15.6.2", - "react-reconciler": "^0.20.0", - "scheduler": "^0.13.2", + "react-reconciler": "^0.21.0", + "scheduler": "^0.15.0", "signal-exit": "^3.0.2", "slice-ansi": "^1.0.0", "string-length": "^2.0.0", @@ -2570,11 +2609,6 @@ "yoga-layout-prebuilt": "^1.9.3" }, "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "bundled": true, - "dev": true - }, "ansi-styles": { "version": "3.2.1", "bundled": true, @@ -2593,24 +2627,6 @@ "supports-color": "^5.3.0" } }, - "string-width": { - "version": "3.1.0", - "bundled": true, - "dev": true, - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - }, "supports-color": { "version": "5.5.0", "bundled": true, @@ -2618,16 +2634,6 @@ "requires": { "has-flag": "^3.0.0" } - }, - "wrap-ansi": { - "version": "5.1.0", - "bundled": true, - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "string-width": "^3.0.0", - "strip-ansi": "^5.0.0" - } } } }, @@ -2676,7 +2682,7 @@ "dev": true }, "lodash": { - "version": "4.17.11", + "version": "4.17.15", "bundled": true, "dev": true }, @@ -2686,7 +2692,7 @@ "dev": true }, "log-update": { - "version": "3.2.0", + "version": "3.3.0", "bundled": true, "dev": true, "requires": { @@ -2695,46 +2701,10 @@ "wrap-ansi": "^5.0.0" }, "dependencies": { - "ansi-regex": { - "version": "4.1.0", + "ansi-escapes": { + "version": "3.2.0", "bundled": true, "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "bundled": true, - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "string-width": { - "version": "3.1.0", - "bundled": true, - "dev": true, - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "wrap-ansi": { - "version": "5.1.0", - "bundled": true, - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "string-width": "^3.0.0", - "strip-ansi": "^5.0.0" - } } } }, @@ -2746,6 +2716,11 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, + "mimic-fn": { + "version": "1.2.0", + "bundled": true, + "dev": true + }, "minimatch": { "version": "3.0.4", "bundled": true, @@ -2755,16 +2730,15 @@ } }, "minipass": { - "version": "2.3.5", + "version": "3.0.1", "bundled": true, "dev": true, "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" + "yallist": "^4.0.0" }, "dependencies": { "yallist": { - "version": "3.0.3", + "version": "4.0.0", "bundled": true, "dev": true } @@ -2806,13 +2780,6 @@ "dev": true, "requires": { "mimic-fn": "^1.0.0" - }, - "dependencies": { - "mimic-fn": { - "version": "1.2.0", - "bundled": true, - "dev": true - } } }, "os-homedir": { @@ -2851,30 +2818,29 @@ "dev": true }, "react": { - "version": "16.8.6", + "version": "16.10.2", "bundled": true, "dev": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", - "prop-types": "^15.6.2", - "scheduler": "^0.13.6" + "prop-types": "^15.6.2" } }, "react-is": { - "version": "16.8.6", + "version": "16.10.2", "bundled": true, "dev": true }, "react-reconciler": { - "version": "0.20.4", + "version": "0.21.0", "bundled": true, "dev": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.2", - "scheduler": "^0.13.6" + "scheduler": "^0.15.0" } }, "redeyed": { @@ -2912,13 +2878,8 @@ "signal-exit": "^3.0.2" } }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "dev": true - }, "scheduler": { - "version": "0.13.6", + "version": "0.15.0", "bundled": true, "dev": true, "requires": { @@ -3006,12 +2967,12 @@ "dev": true }, "tap-parser": { - "version": "9.3.2", + "version": "10.0.1", "bundled": true, "dev": true, "requires": { "events-to-array": "^1.0.1", - "minipass": "^2.2.0", + "minipass": "^3.0.0", "tap-yaml": "^1.0.0" } }, @@ -3029,7 +2990,7 @@ "dev": true }, "treport": { - "version": "0.4.0", + "version": "0.5.0", "bundled": true, "dev": true, "requires": { @@ -3040,7 +3001,7 @@ "ms": "^2.1.1", "react": "^16.8.6", "string-length": "^2.0.0", - "tap-parser": "^9.3.2", + "tap-parser": "^10.0.1", "unicode-length": "^2.0.1" }, "dependencies": { @@ -3063,7 +3024,7 @@ } }, "ms": { - "version": "2.1.1", + "version": "2.1.2", "bundled": true, "dev": true }, @@ -3076,7 +3037,7 @@ } }, "unicode-length": { - "version": "2.0.1", + "version": "2.0.2", "bundled": true, "dev": true, "requires": { @@ -3091,6 +3052,11 @@ "bundled": true, "dev": true }, + "type-fest": { + "version": "0.5.2", + "bundled": true, + "dev": true + }, "widest-line": { "version": "2.0.1", "bundled": true, @@ -3099,12 +3065,55 @@ "string-width": "^2.1.1" } }, + "wrap-ansi": { + "version": "5.1.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "bundled": true, + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "bundled": true, + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "string-width": { + "version": "3.1.0", + "bundled": true, + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "yaml": { - "version": "1.6.0", + "version": "1.7.1", "bundled": true, "dev": true, "requires": { - "@babel/runtime": "^7.4.5" + "@babel/runtime": "^7.5.5" } }, "yoga-layout-prebuilt": { @@ -3115,9 +3124,9 @@ } }, "tap-mocha-reporter": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/tap-mocha-reporter/-/tap-mocha-reporter-4.0.1.tgz", - "integrity": "sha512-/KfXaaYeSPn8qBi5Be8WSIP3iKV83s2uj2vzImJAXmjNu22kzqZ+1Dv1riYWa53sPCiyo1R1w1jbJrftF8SpcQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/tap-mocha-reporter/-/tap-mocha-reporter-5.0.0.tgz", + "integrity": "sha512-8HlAtdmYGlDZuW83QbF/dc46L7cN+AGhLZcanX3I9ILvxUAl+G2/mtucNPSXecTlG/4iP1hv6oMo0tMhkn3Tsw==", "dev": true, "requires": { "color-support": "^1.1.0", @@ -3126,8 +3135,8 @@ "escape-string-regexp": "^1.0.3", "glob": "^7.0.5", "readable-stream": "^2.1.5", - "tap-parser": "^8.0.0", - "tap-yaml": "0 || 1", + "tap-parser": "^10.0.0", + "tap-yaml": "^1.0.0", "unicode-length": "^1.0.0" }, "dependencies": { @@ -3145,24 +3154,18 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", "dev": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true } } }, "tap-parser": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-8.1.0.tgz", - "integrity": "sha512-GgOzgDwThYLxhVR83RbS1JUR1TxcT+jfZsrETgPAvFdr12lUOnuvrHOBaUQgpkAp6ZyeW6r2Nwd91t88M0ru3w==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/tap-parser/-/tap-parser-10.0.1.tgz", + "integrity": "sha512-qdT15H0DoJIi7zOqVXDn9X0gSM68JjNy1w3VemwTJlDnETjbi6SutnqmBfjDJAwkFS79NJ97gZKqie00ZCGmzg==", "dev": true, "requires": { "events-to-array": "^1.0.1", - "minipass": "^2.2.0", - "tap-yaml": "0 || 1" + "minipass": "^3.0.0", + "tap-yaml": "^1.0.0" } }, "tap-yaml": { @@ -3175,10 +3178,13 @@ } }, "tcompare": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/tcompare/-/tcompare-2.3.0.tgz", - "integrity": "sha512-fAfA73uFtFGybWGt4+IYT6UPLYVZQ4NfsP+IXEZGY0vh8e2IF7LVKafcQNMRBLqP0wzEA65LM9Tqj+FSmO8GLw==", - "dev": true + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tcompare/-/tcompare-3.0.0.tgz", + "integrity": "sha512-lRD40wHaBoVvmcCT0L7qJmR+jBl1nVP0WxbMYyOtsFza+SXD9aiRVir9aWogdQwNzY6ZwOvwDp5vg3XWQGOIVQ==", + "dev": true, + "requires": { + "diff-frag": "^1.0.1" + } }, "test-exclude": { "version": "5.2.3", @@ -3225,12 +3231,6 @@ } } }, - "trim-right": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", - "dev": true - }, "trivial-deferred": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trivial-deferred/-/trivial-deferred-1.0.1.tgz", @@ -3238,9 +3238,9 @@ "dev": true }, "ts-node": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz", - "integrity": "sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==", + "version": "8.5.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.2.tgz", + "integrity": "sha512-W1DK/a6BGoV/D4x/SXXm6TSQx6q3blECUzd5TN+j56YEMX3yPVMpHsICLedUw3DvGF3aTQ8hfdR9AKMaHjIi+A==", "dev": true, "requires": { "arg": "^4.1.0", @@ -3275,20 +3275,29 @@ } }, "typescript": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", - "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", "dev": true }, "uglify-js": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", - "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", + "version": "3.6.9", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.9.tgz", + "integrity": "sha512-pcnnhaoG6RtrvHJ1dFncAe8Od6Nuy30oaJ82ts6//sGSXOP5UjBMEthiProjXmMNHOfd93sqlkztifFMcb+4yw==", "dev": true, "optional": true, "requires": { - "commander": "~2.20.0", + "commander": "~2.20.3", "source-map": "~0.6.1" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "optional": true + } } }, "unicode-length": { @@ -3341,9 +3350,9 @@ "optional": true }, "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", + "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", "dev": true }, "validate-npm-package-license": { @@ -3374,9 +3383,9 @@ "dev": true }, "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "requires": { "isexe": "^2.0.0" @@ -3448,9 +3457,9 @@ "dev": true }, "write-file-atomic": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.0.tgz", - "integrity": "sha512-EIgkf60l2oWsffja2Sf2AL384dx328c0B+cIYPTQq5q2rOYuDV00/iPFBOUiDKKwKMOhkymH8AidPaRvzfxY+Q==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.1.tgz", + "integrity": "sha512-JPStrIyyVJ6oCSz/691fAjFtefZ6q+fP6tm+OS4Qw6o+TGQxNp1ziY2PgS+X/m0V8OWhZiO/m4xSj+Pr4RrZvw==", "dev": true, "requires": { "imurmurhash": "^0.1.4", @@ -3459,6 +3468,22 @@ "typedarray-to-buffer": "^3.1.5" } }, + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "dev": true, + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", + "dev": true + }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", @@ -3472,12 +3497,12 @@ "dev": true }, "yaml": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.6.0.tgz", - "integrity": "sha512-iZfse3lwrJRoSlfs/9KQ9iIXxs9++RvBFVzAqbbBiFT+giYtyanevreF9r61ZTbGMgWQBxAua3FzJiniiJXWWw==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz", + "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==", "dev": true, "requires": { - "@babel/runtime": "^7.4.5" + "@babel/runtime": "^7.6.3" } }, "yapool": { @@ -3487,22 +3512,21 @@ "dev": true }, "yargs": { - "version": "13.2.4", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.4.tgz", - "integrity": "sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg==", + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", "dev": true, "requires": { "cliui": "^5.0.0", "find-up": "^3.0.0", "get-caller-file": "^2.0.1", - "os-locale": "^3.1.0", "require-directory": "^2.1.1", "require-main-filename": "^2.0.0", "set-blocking": "^2.0.0", "string-width": "^3.0.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^13.1.0" + "yargs-parser": "^13.1.1" }, "dependencies": { "ansi-regex": { @@ -3566,9 +3590,9 @@ } }, "yn": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.0.tgz", - "integrity": "sha512-kKfnnYkbTfrAdd0xICNFw7Atm8nKpLcLv9AZGEt+kczL/WQVai4e2V6ZN8U/O+iI6WrNuJjNNOyu4zfhl9D3Hg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true } } diff --git a/package.json b/package.json index 5db54f33..4b095984 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,13 @@ "main": "index.js", "scripts": { "test": "tap", + "snap": "tap", "preversion": "npm test", "postversion": "npm publish", "postpublish": "git push origin --follow-tags" }, "devDependencies": { - "tap": "^14.3.1" + "tap": "^14.10.1" }, "license": "ISC", "repository": "https://github.com/npm/node-semver", @@ -23,6 +24,7 @@ "semver.js" ], "tap": { - "check-coverage": true + "check-coverage": true, + "coverage-map": "map.js" } } diff --git a/ranges/gtr.js b/ranges/gtr.js index e6d42e72..db7e3559 100644 --- a/ranges/gtr.js +++ b/ranges/gtr.js @@ -1,6 +1,4 @@ -const outside = require('./outside') - // Determine if version is greater than all the versions possible in the range. -module.exports = function gtr (version, range, options) { - return outside(version, range, '>', options) -} \ No newline at end of file +const outside = require('./outside') +const gtr = (version, range, options) => outside(version, range, '>', options) +module.exports = gtr diff --git a/ranges/intersects.js b/ranges/intersects.js index 1313a614..3d1a6f31 100644 --- a/ranges/intersects.js +++ b/ranges/intersects.js @@ -1,7 +1,7 @@ -const { Range } = require('../classes/range'); -module.exports = function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) +const Range = require('../classes/range') +const intersects = (r1, r2, options) => { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) } - \ No newline at end of file +module.exports = intersects diff --git a/ranges/ltr.js b/ranges/ltr.js index 88ed7eed..528a885e 100644 --- a/ranges/ltr.js +++ b/ranges/ltr.js @@ -1,6 +1,4 @@ const outside = require('./outside') - // Determine if version is less than all the versions possible in the range -module.exports = function ltr (version, range, options) { - return outside(version, range, '<', options) -} \ No newline at end of file +const ltr = (version, range, options) => outside(version, range, '<', options) +module.exports = ltr diff --git a/ranges/max-satisfying.js b/ranges/max-satisfying.js index 511916b4..6e3d993c 100644 --- a/ranges/max-satisfying.js +++ b/ranges/max-satisfying.js @@ -1,25 +1,25 @@ const SemVer = require('../classes/semver') -const { Range } = require('../classes/range') +const Range = require('../classes/range') -module.exports = function maxSatisfying (versions, range, options) { - let max = null - let maxSV = null - let rangeObj = null - try { - rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!max || maxSV.compare(v) === -1) { - // compare(max, v, true) - max = v - maxSV = new SemVer(max, options) - } - } - }) - return max +const maxSatisfying = (versions, range, options) => { + let max = null + let maxSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null } - \ No newline at end of file + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max +} +module.exports = maxSatisfying diff --git a/ranges/min-satisfying.js b/ranges/min-satisfying.js index 43581b25..9b60974e 100644 --- a/ranges/min-satisfying.js +++ b/ranges/min-satisfying.js @@ -1,24 +1,24 @@ const SemVer = require('../classes/semver') -const { Range } = require('../classes/range') - -module.exports = function minSatisfying (versions, range, options) { - let min = null - let minSV = null - let rangeObj = null - try { - rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach((v) => { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!min || minSV.compare(v) === 1) { - // compare(min, v, true) - min = v - minSV = new SemVer(min, options) - } +const Range = require('../classes/range') +const minSatisfying = (versions, range, options) => { + let min = null + let minSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) } - }) - return min - } \ No newline at end of file + } + }) + return min +} +module.exports = minSatisfying diff --git a/ranges/min-version.js b/ranges/min-version.js index c3eeaa9a..7118d237 100644 --- a/ranges/min-version.js +++ b/ranges/min-version.js @@ -1,8 +1,8 @@ const SemVer = require('../classes/semver') -const { Range } = require('../classes/range') +const Range = require('../classes/range') const gt = require('../functions/gt') -module.exports = function minVersion (range, loose) { +const minVersion = (range, loose) => { range = new Range(range, loose) let minver = new SemVer('0.0.0') @@ -43,7 +43,7 @@ module.exports = function minVersion (range, loose) { break /* istanbul ignore next */ default: - throw new Error(`Unexpected operation: ${ comparator.operator}`) + throw new Error(`Unexpected operation: ${comparator.operator}`) } }) } @@ -53,4 +53,5 @@ module.exports = function minVersion (range, loose) { } return null -} \ No newline at end of file +} +module.exports = minVersion diff --git a/ranges/outside.js b/ranges/outside.js index 2f945a02..e35ed117 100644 --- a/ranges/outside.js +++ b/ranges/outside.js @@ -1,11 +1,14 @@ const SemVer = require('../classes/semver') -const { Comparator, Range, ANY, satisfies } = require('../classes/range') +const Comparator = require('../classes/comparator') +const {ANY} = Comparator +const Range = require('../classes/range') +const satisfies = require('../functions/satisfies') const gt = require('../functions/gt') const lt = require('../functions/lt') const lte = require('../functions/lte') const gte = require('../functions/gte') -module.exports = function outside (version, range, hilo, options) { +const outside = (version, range, hilo, options) => { version = new SemVer(version, options) range = new Range(range, options) @@ -72,4 +75,6 @@ module.exports = function outside (version, range, hilo, options) { } } return true -} \ No newline at end of file +} + +module.exports = outside diff --git a/ranges/to-comparators.js b/ranges/to-comparators.js index 82893b73..6c8bc7e6 100644 --- a/ranges/to-comparators.js +++ b/ranges/to-comparators.js @@ -1,10 +1,8 @@ -const { Range } = require('../classes/range') +const Range = require('../classes/range') // Mostly just for testing and legacy API reasons -module.exports = function toComparators (range, options) { - return new Range(range, options).set.map((comp) => { - return comp.map((c) => { - return c.value - }).join(' ').trim().split(' ') - }) -} \ No newline at end of file +const toComparators = (range, options) => + new Range(range, options).set + .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) + +module.exports = toComparators diff --git a/ranges/valid-range.js b/ranges/valid-range.js index fd338fdd..365f3568 100644 --- a/ranges/valid-range.js +++ b/ranges/valid-range.js @@ -1,10 +1,11 @@ -const { Range } = require('../classes/range') -module.exports = function validRange (range, options) { - try { - // Return '*' instead of '' so that truthiness works. - // This will throw if it's invalid anyway - return new Range(range, options).range || '*' - } catch (er) { - return null - } - } \ No newline at end of file +const Range = require('../classes/range') +const validRange = (range, options) => { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } +} +module.exports = validRange diff --git a/tap-snapshots/test-bin-semver.js-TAP.test.js b/tap-snapshots/test-bin-semver.js-TAP.test.js new file mode 100644 index 00000000..a41ecd14 --- /dev/null +++ b/tap-snapshots/test-bin-semver.js-TAP.test.js @@ -0,0 +1,222 @@ +/* IMPORTANT + * This snapshot file is auto-generated, but designed for humans. + * It should be checked into source control and tracked carefully. + * Re-generate by setting TAP_SNAPSHOT=1 and running tests. + * Make sure to inspect the output below. Do not ignore changes! + */ +'use strict' +exports[`test/bin/semver.js TAP coercing > 1.2.3.4.5.6 -c --rtl --ltr 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP coercing > 1.2.3.4.5.6 -c --rtl 1`] = ` +Object { + "code": 0, + "err": "", + "out": "4.5.6\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP coercing > 1.2.3.4.5.6 -c 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP coercing > not a version -c 1`] = ` +Object { + "code": 1, + "err": "", + "out": "", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP coercing > not a version 1.2.3 -c 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP help output > (no args) 1`] = ` +Object { + "code": 0, + "err": "", + "out": "SemVer @@VERSION@@\\n\\nA JavaScript implementation of the https://semver.org/ specification\\nCopyright Isaac Z. Schlueter\\n\\nUsage: semver [options] [ [...]]\\nPrints valid versions sorted by SemVer precedence\\n\\nOptions:\\n-r --range \\n Print versions that match the specified range.\\n\\n-i --increment []\\n Increment a version by the specified level. Level can\\n be one of: major, minor, patch, premajor, preminor,\\n prepatch, or prerelease. Default level is 'patch'.\\n Only one version may be specified.\\n\\n--preid \\n Identifier to be used to prefix premajor, preminor,\\n prepatch or prerelease version increments.\\n\\n-l --loose\\n Interpret versions and ranges loosely\\n\\n-p --include-prerelease\\n Always include prerelease versions in range matching\\n\\n-c --coerce\\n Coerce a string into SemVer if possible\\n (does not imply --loose)\\n\\n--rtl\\n Coerce version strings right to left\\n\\n--ltr\\n Coerce version strings left to right (default)\\n\\nProgram exits successfully if any valid version satisfies\\nall supplied ranges, and prints all satisfying versions.\\n\\nIf no satisfying versions are found, then exits failure.\\n\\nVersions are printed in ascending order, so supplying\\nmultiple versions to the utility will just sort them.\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP help output > --help 1`] = ` +Object { + "code": 0, + "err": "", + "out": "SemVer @@VERSION@@\\n\\nA JavaScript implementation of the https://semver.org/ specification\\nCopyright Isaac Z. Schlueter\\n\\nUsage: semver [options] [ [...]]\\nPrints valid versions sorted by SemVer precedence\\n\\nOptions:\\n-r --range \\n Print versions that match the specified range.\\n\\n-i --increment []\\n Increment a version by the specified level. Level can\\n be one of: major, minor, patch, premajor, preminor,\\n prepatch, or prerelease. Default level is 'patch'.\\n Only one version may be specified.\\n\\n--preid \\n Identifier to be used to prefix premajor, preminor,\\n prepatch or prerelease version increments.\\n\\n-l --loose\\n Interpret versions and ranges loosely\\n\\n-p --include-prerelease\\n Always include prerelease versions in range matching\\n\\n-c --coerce\\n Coerce a string into SemVer if possible\\n (does not imply --loose)\\n\\n--rtl\\n Coerce version strings right to left\\n\\n--ltr\\n Coerce version strings left to right (default)\\n\\nProgram exits successfully if any valid version satisfies\\nall supplied ranges, and prints all satisfying versions.\\n\\nIf no satisfying versions are found, then exits failure.\\n\\nVersions are printed in ascending order, so supplying\\nmultiple versions to the utility will just sort them.\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP help output > -? 1`] = ` +Object { + "code": 0, + "err": "", + "out": "SemVer @@VERSION@@\\n\\nA JavaScript implementation of the https://semver.org/ specification\\nCopyright Isaac Z. Schlueter\\n\\nUsage: semver [options] [ [...]]\\nPrints valid versions sorted by SemVer precedence\\n\\nOptions:\\n-r --range \\n Print versions that match the specified range.\\n\\n-i --increment []\\n Increment a version by the specified level. Level can\\n be one of: major, minor, patch, premajor, preminor,\\n prepatch, or prerelease. Default level is 'patch'.\\n Only one version may be specified.\\n\\n--preid \\n Identifier to be used to prefix premajor, preminor,\\n prepatch or prerelease version increments.\\n\\n-l --loose\\n Interpret versions and ranges loosely\\n\\n-p --include-prerelease\\n Always include prerelease versions in range matching\\n\\n-c --coerce\\n Coerce a string into SemVer if possible\\n (does not imply --loose)\\n\\n--rtl\\n Coerce version strings right to left\\n\\n--ltr\\n Coerce version strings left to right (default)\\n\\nProgram exits successfully if any valid version satisfies\\nall supplied ranges, and prints all satisfying versions.\\n\\nIf no satisfying versions are found, then exits failure.\\n\\nVersions are printed in ascending order, so supplying\\nmultiple versions to the utility will just sort them.\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP help output > -h 1`] = ` +Object { + "code": 0, + "err": "", + "out": "SemVer @@VERSION@@\\n\\nA JavaScript implementation of the https://semver.org/ specification\\nCopyright Isaac Z. Schlueter\\n\\nUsage: semver [options] [ [...]]\\nPrints valid versions sorted by SemVer precedence\\n\\nOptions:\\n-r --range \\n Print versions that match the specified range.\\n\\n-i --increment []\\n Increment a version by the specified level. Level can\\n be one of: major, minor, patch, premajor, preminor,\\n prepatch, or prerelease. Default level is 'patch'.\\n Only one version may be specified.\\n\\n--preid \\n Identifier to be used to prefix premajor, preminor,\\n prepatch or prerelease version increments.\\n\\n-l --loose\\n Interpret versions and ranges loosely\\n\\n-p --include-prerelease\\n Always include prerelease versions in range matching\\n\\n-c --coerce\\n Coerce a string into SemVer if possible\\n (does not imply --loose)\\n\\n--rtl\\n Coerce version strings right to left\\n\\n--ltr\\n Coerce version strings left to right (default)\\n\\nProgram exits successfully if any valid version satisfies\\nall supplied ranges, and prints all satisfying versions.\\n\\nIf no satisfying versions are found, then exits failure.\\n\\nVersions are printed in ascending order, so supplying\\nmultiple versions to the utility will just sort them.\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP inc tests > -i 1.2.3 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.4\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP inc tests > -i major 1.0.0 1`] = ` +Object { + "code": 0, + "err": "", + "out": "2.0.0\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP inc tests > -i major 1.0.0 1.0.1 1`] = ` +Object { + "code": 1, + "err": "--inc can only be used on a single version with no range\\n", + "out": "", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP inc tests > -i premajor 1.0.0 --preid=beta 1`] = ` +Object { + "code": 0, + "err": "", + "out": "2.0.0-0\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 -v 3.2.1 --version 2.3.4 -rv 1`] = ` +Object { + "code": 0, + "err": "", + "out": "3.2.1\\n2.3.4\\n1.2.3\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 -v 3.2.1 --version 2.3.4 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3\\n2.3.4\\n3.2.1\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 -r 2.x 1`] = ` +Object { + "code": 1, + "err": "", + "out": "", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 -r 2.x 2.3.4 1`] = ` +Object { + "code": 0, + "err": "", + "out": "2.3.4\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3\\n2.3.4\\n3.2.1\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 2.3.4-beta 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3\\n2.3.4-beta\\n2.3.4\\n3.2.1\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 2.3.4-beta 2.0.0asdf -r 2.x -p 1`] = ` +Object { + "code": 0, + "err": "", + "out": "2.3.4-beta\\n2.3.4\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3 3.2.1 2.3.4 2.3.4-beta 2.0.0asdf -r 2.x 1`] = ` +Object { + "code": 0, + "err": "", + "out": "2.3.4\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3foo 1.2.3-bar -l 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3-bar\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 1.2.3foo 1.2.3-bar 1`] = ` +Object { + "code": 0, + "err": "", + "out": "1.2.3-bar\\n", + "signal": null, +} +` + +exports[`test/bin/semver.js TAP sorting and filtering > 3.2.1 2.3.4 2.3.4-beta 2.0.0asdf -r 2.x -p -l 1`] = ` +Object { + "code": 0, + "err": "", + "out": "2.3.4-beta\\n2.3.4\\n", + "signal": null, +} +` diff --git a/test/big-numbers.js b/test/big-numbers.js index e5268fb1..5d49a7b1 100644 --- a/test/big-numbers.js +++ b/test/big-numbers.js @@ -2,7 +2,7 @@ const { test } = require('tap') const semver = require('../') test('long version is too long', (t) => { - const v = `1.2.${ new Array(256).join('1')}` + const v = `1.2.${new Array(256).join('1')}` t.throws(() => { new semver.SemVer(v) // eslint-disable-line no-new }) @@ -13,7 +13,7 @@ test('long version is too long', (t) => { }) test('big number is like too long version', (t) => { - const v = `1.2.${ new Array(100).join('1')}` + const v = `1.2.${new Array(100).join('1')}` t.throws(() => { new semver.SemVer(v) // eslint-disable-line no-new }) diff --git a/test/cli.js b/test/bin/semver.js similarity index 91% rename from test/cli.js rename to test/bin/semver.js index 4820c1b2..697f7127 100644 --- a/test/cli.js +++ b/test/bin/semver.js @@ -1,11 +1,11 @@ 'use strict' const t = require('tap') -const thisVersion = require('../package.json').version +const thisVersion = require('../../package.json').version t.cleanSnapshot = str => str.split(thisVersion).join('@@VERSION@@') const spawn = require('child_process').spawn -const bin = require.resolve('../bin/semver') +const bin = require.resolve('../../bin/semver') const run = args => new Promise((resolve, reject) => { const c = spawn(process.execPath, [bin].concat(args)) c.on('error', reject) @@ -29,7 +29,7 @@ t.test('inc tests', t => Promise.all([ ['-i', 'major', '1.0.0'], ['-i', 'major', '1.0.0', '1.0.1'], ['-i', 'premajor', '1.0.0', '--preid=beta'], - ['-i', '1.2.3'], + ['-i', '1.2.3'] ].map(args => t.resolveMatchSnapshot(run(args), args.join(' '))))) t.test('help output', t => Promise.all([ @@ -50,7 +50,7 @@ t.test('sorting and filtering', t => Promise.all([ ['1.2.3', '3.2.1', '2.3.4', '2.3.4-beta', '2.0.0asdf', '-r', '2.x'], ['1.2.3', '3.2.1', '2.3.4', '2.3.4-beta', '2.0.0asdf', '-r', '2.x', '-p'], ['3.2.1', '2.3.4', '2.3.4-beta', '2.0.0asdf', '-r', '2.x', '-p', '-l'], - ['1.2.3', '3.2.1', '-r', '2.x'], + ['1.2.3', '3.2.1', '-r', '2.x'] ].map(args => t.resolveMatchSnapshot(run(args), args.join(' '))))) t.test('coercing', t => Promise.all([ @@ -58,5 +58,5 @@ t.test('coercing', t => Promise.all([ ['1.2.3.4.5.6', '-c', '--rtl'], ['1.2.3.4.5.6', '-c', '--rtl', '--ltr'], ['not a version', '1.2.3', '-c'], - ['not a version', '-c'], + ['not a version', '-c'] ].map(args => t.resolveMatchSnapshot(run(args), args.join(' '))))) diff --git a/test/classes/comparator.js b/test/classes/comparator.js new file mode 100644 index 00000000..1faaaa49 --- /dev/null +++ b/test/classes/comparator.js @@ -0,0 +1,20 @@ +const { test } = require('tap') +const Comparator = require('../../classes/comparator') + +test('comparator testing', t => { + const c = new Comparator('>=1.2.3') + t.ok(c.test('1.2.4')) + const c2 = new Comparator(c) + t.ok(c2.test('1.2.4')) + const c3 = new Comparator(c, true) + t.ok(c3.test('1.2.4')) + // test an invalid version, should not throw + const c4 = new Comparator(c) + t.notOk(c4.test('not a version string')) + t.end() +}) + +test('tostrings', (t) => { + t.equal(new Comparator('>= v1.2.3').toString(), '>=1.2.3') + t.end() +}) diff --git a/test/classes/index.js b/test/classes/index.js new file mode 100644 index 00000000..2a56c025 --- /dev/null +++ b/test/classes/index.js @@ -0,0 +1,6 @@ +const t = require('tap') +t.same(require('../../classes'), { + SemVer: require('../../classes/semver'), + Range: require('../../classes/range'), + Comparator: require('../../classes/comparator') +}, 'export all classes at semver/classes') diff --git a/test/classes/range.js b/test/classes/range.js index ba16b848..5c70fb58 100644 --- a/test/classes/range.js +++ b/test/classes/range.js @@ -1,36 +1,18 @@ const { test } = require('tap') -const { Range, Comparator } = require('../../classes/range') +const Range = require('../../classes/range') test('strict vs loose ranges', (t) => { - [['>=01.02.03', '>=1.2.3'], - ['~1.02.03beta', '>=1.2.3-beta <1.3.0'] - ].forEach((v) => { - const loose = v[0] - const comps = v[1] - t.throws(() => { - new Range(loose) // eslint-disable-line no-new - }) - t.equal(new Range(loose, true).range, comps) - }) - t.end() + [ + ['>=01.02.03', '>=1.2.3'], + ['~1.02.03beta', '>=1.2.3-beta <1.3.0'] + ].forEach(([loose, comps]) => { + t.throws(() => new Range(loose)) + t.equal(new Range(loose, true).range, comps) }) + t.end() +}) - test("comparator testing", t => { - const c = new Comparator(">=1.2.3"); - t.ok(c.test("1.2.4")); - const c2 = new Comparator(c); - t.ok(c2.test("1.2.4")); - const c3 = new Comparator(c, true); - t.ok(c3.test("1.2.4")); - // test an invalid version, should not throw - const c4 = new Comparator(c); - t.notOk(c4.test("not a version string")); - t.end(); - }); - - test('tostrings', (t) => { - t.equal(new Range('>= v1.2.3').toString(), '>=1.2.3') - t.equal(new Comparator('>= v1.2.3').toString(), '>=1.2.3') - t.end() - }) - \ No newline at end of file +test('tostrings', (t) => { + t.equal(new Range('>= v1.2.3').toString(), '>=1.2.3') + t.end() +}) diff --git a/test/classes/semver.js b/test/classes/semver.js index 907476c7..775e87d4 100644 --- a/test/classes/semver.js +++ b/test/classes/semver.js @@ -2,55 +2,54 @@ const { test } = require('tap') const SemVer = require('../../classes/semver') test('really big numeric prerelease value', (t) => { - const r = new SemVer(`1.2.3-beta.${ Number.MAX_SAFE_INTEGER }0`) - t.strictSame(r.prerelease, [ 'beta', '90071992547409910' ]) - t.end() - }) + const r = new SemVer(`1.2.3-beta.${Number.MAX_SAFE_INTEGER}0`) + t.strictSame(r.prerelease, [ 'beta', '90071992547409910' ]) + t.end() +}) test('invalid version numbers', (t) => { - ['1.2.3.4', - 'NOT VALID', - 1.2, - null, - 'Infinity.NaN.Infinity' - ].forEach((v) => { - t.throws(() => { - new SemVer(v) // eslint-disable-line no-new - }, { name: 'TypeError', message: `Invalid Version: ${ v}` }) - }) - - t.end() + ['1.2.3.4', + 'NOT VALID', + 1.2, + null, + 'Infinity.NaN.Infinity' + ].forEach((v) => { + t.throws(() => { + new SemVer(v) // eslint-disable-line no-new + }, { name: 'TypeError', message: `Invalid Version: ${v}` }) }) + t.end() +}) + test('compare main vs pre', (t) => { - const s = new SemVer('1.2.3') - t.equal(s.compareMain('2.3.4'), -1) - t.equal(s.compareMain('1.2.4'), -1) - t.equal(s.compareMain('0.1.2'), 1) - t.equal(s.compareMain('1.2.2'), 1) - t.equal(s.compareMain('1.2.3-pre'), 0) - - const p = new SemVer('1.2.3-alpha.0.pr.1') - t.equal(p.comparePre('9.9.9-alpha.0.pr.1'), 0) - t.equal(p.comparePre('1.2.3'), -1) - t.equal(p.comparePre('1.2.3-alpha.0.pr.2'), -1) - t.equal(p.comparePre('1.2.3-alpha.0.2'), 1) - - t.end() - }) + const s = new SemVer('1.2.3') + t.equal(s.compareMain('2.3.4'), -1) + t.equal(s.compareMain('1.2.4'), -1) + t.equal(s.compareMain('0.1.2'), 1) + t.equal(s.compareMain('1.2.2'), 1) + t.equal(s.compareMain('1.2.3-pre'), 0) + + const p = new SemVer('1.2.3-alpha.0.pr.1') + t.equal(p.comparePre('9.9.9-alpha.0.pr.1'), 0) + t.equal(p.comparePre('1.2.3'), -1) + t.equal(p.comparePre('1.2.3-alpha.0.pr.2'), -1) + t.equal(p.comparePre('1.2.3-alpha.0.2'), 1) + + t.end() +}) test('invalid version numbers', (t) => { - ['1.2.3.4', - 'NOT VALID', - 1.2, - null, - 'Infinity.NaN.Infinity' - ].forEach((v) => { - t.throws(() => { - new SemVer(v) // eslint-disable-line no-new - }, { name: 'TypeError', message: `Invalid Version: ${ v}` }) - }) - - t.end() + ['1.2.3.4', + 'NOT VALID', + 1.2, + null, + 'Infinity.NaN.Infinity' + ].forEach((v) => { + t.throws(() => { + new SemVer(v) // eslint-disable-line no-new + }, { name: 'TypeError', message: `Invalid Version: ${v}` }) }) - \ No newline at end of file + + t.end() +}) diff --git a/test/coverage-map.js b/test/coverage-map.js deleted file mode 100644 index c89a58c2..00000000 --- a/test/coverage-map.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = testFile => testFile.replace(/test\//, ''); \ No newline at end of file diff --git a/test/fixtures/comparisons.js b/test/fixtures/comparisons.js new file mode 100644 index 00000000..cf136e9e --- /dev/null +++ b/test/fixtures/comparisons.js @@ -0,0 +1,36 @@ +// [version1, version2] +// version1 should be greater than version2 +// used by the cmp, eq, gt, lt, and neq tests +module.exports = [ + ['0.0.0', '0.0.0-foo'], + ['0.0.1', '0.0.0'], + ['1.0.0', '0.9.9'], + ['0.10.0', '0.9.0'], + ['0.99.0', '0.10.0', {}], + ['2.0.0', '1.2.3', { loose: false }], + ['v0.0.0', '0.0.0-foo', true], + ['v0.0.1', '0.0.0', { loose: true }], + ['v1.0.0', '0.9.9', true], + ['v0.10.0', '0.9.0', true], + ['v0.99.0', '0.10.0', true], + ['v2.0.0', '1.2.3', true], + ['0.0.0', 'v0.0.0-foo', true], + ['0.0.1', 'v0.0.0', true], + ['1.0.0', 'v0.9.9', true], + ['0.10.0', 'v0.9.0', true], + ['0.99.0', 'v0.10.0', true], + ['2.0.0', 'v1.2.3', true], + ['1.2.3', '1.2.3-asdf'], + ['1.2.3', '1.2.3-4'], + ['1.2.3', '1.2.3-4-foo'], + ['1.2.3-5-foo', '1.2.3-5'], + ['1.2.3-5', '1.2.3-4'], + ['1.2.3-5-foo', '1.2.3-5-Foo'], + ['3.0.0', '2.7.2+asdf'], + ['1.2.3-a.10', '1.2.3-a.5'], + ['1.2.3-a.b', '1.2.3-a.5'], + ['1.2.3-a.b', '1.2.3-a'], + ['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100'], + ['1.2.3-r2', '1.2.3-r100'], + ['1.2.3-r100', '1.2.3-R2'] +] diff --git a/test/fixtures/equality.js b/test/fixtures/equality.js new file mode 100644 index 00000000..f8d14011 --- /dev/null +++ b/test/fixtures/equality.js @@ -0,0 +1,41 @@ +// [version1, version2] +// version1 should be equivalent to version2 +module.exports = [ + ['1.2.3', 'v1.2.3', true], + ['1.2.3', '=1.2.3', true], + ['1.2.3', 'v 1.2.3', true], + ['1.2.3', '= 1.2.3', true], + ['1.2.3', ' v1.2.3', true], + ['1.2.3', ' =1.2.3', true], + ['1.2.3', ' v 1.2.3', true], + ['1.2.3', ' = 1.2.3', true], + ['1.2.3-0', 'v1.2.3-0', true], + ['1.2.3-0', '=1.2.3-0', true], + ['1.2.3-0', 'v 1.2.3-0', true], + ['1.2.3-0', '= 1.2.3-0', true], + ['1.2.3-0', ' v1.2.3-0', true], + ['1.2.3-0', ' =1.2.3-0', true], + ['1.2.3-0', ' v 1.2.3-0', true], + ['1.2.3-0', ' = 1.2.3-0', true], + ['1.2.3-1', 'v1.2.3-1', true], + ['1.2.3-1', '=1.2.3-1', true], + ['1.2.3-1', 'v 1.2.3-1', true], + ['1.2.3-1', '= 1.2.3-1', true], + ['1.2.3-1', ' v1.2.3-1', true], + ['1.2.3-1', ' =1.2.3-1', true], + ['1.2.3-1', ' v 1.2.3-1', true], + ['1.2.3-1', ' = 1.2.3-1', true], + ['1.2.3-beta', 'v1.2.3-beta', true], + ['1.2.3-beta', '=1.2.3-beta', true], + ['1.2.3-beta', 'v 1.2.3-beta', true], + ['1.2.3-beta', '= 1.2.3-beta', true], + ['1.2.3-beta', ' v1.2.3-beta', true], + ['1.2.3-beta', ' =1.2.3-beta', true], + ['1.2.3-beta', ' v 1.2.3-beta', true], + ['1.2.3-beta', ' = 1.2.3-beta', true], + ['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild', true], + ['1.2.3+build', ' = 1.2.3+otherbuild', true], + ['1.2.3-beta+build', '1.2.3-beta+otherbuild'], + ['1.2.3+build', '1.2.3+otherbuild'], + [' v1.2.3+build', '1.2.3+otherbuild'] +] diff --git a/test/fixtures/version-gt-range.js b/test/fixtures/version-gt-range.js new file mode 100644 index 00000000..24afa025 --- /dev/null +++ b/test/fixtures/version-gt-range.js @@ -0,0 +1,64 @@ +// [range, version, loose] +// Version should be greater than range +module.exports = [ + ['~1.2.2', '1.3.0'], + ['~0.6.1-1', '0.7.1-1'], + ['1.0.0 - 2.0.0', '2.0.1'], + ['1.0.0', '1.0.1-beta1'], + ['1.0.0', '2.0.0'], + ['<=2.0.0', '2.1.1'], + ['<=2.0.0', '3.2.9'], + ['<2.0.0', '2.0.0'], + ['0.1.20 || 1.2.4', '1.2.5'], + ['2.x.x', '3.0.0'], + ['1.2.x', '1.3.0'], + ['1.2.x || 2.x', '3.0.0'], + ['2.*.*', '5.0.1'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '4.0.0'], + ['2', '3.0.0'], + ['2.3', '2.4.2'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.5.5'], + ['~>3.2.1', '3.3.0'], // >=3.2.1 <3.3.0 + ['~1', '2.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.4'], + ['~> 1', '3.2.3'], + ['~1.0', '1.1.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '1.1.0'], + ['<1.2', '1.2.0'], + ['< 1.2', '1.2.1'], + ['1', '2.0.0beta', true], + ['~v0.5.4-pre', '0.6.0'], + ['~v0.5.4-pre', '0.6.1-pre'], + ['=0.7.x', '0.8.0'], + ['=0.7.x', '0.8.0-asdf'], + ['<0.7.x', '0.7.0'], + ['~1.2.2', '1.3.0'], + ['1.0.0 - 2.0.0', '2.2.3'], + ['1.0.0', '1.0.1'], + ['<=2.0.0', '3.0.0'], + ['<=2.0.0', '2.9999.9999'], + ['<=2.0.0', '2.2.9'], + ['<2.0.0', '2.9999.9999'], + ['<2.0.0', '2.2.9'], + ['2.x.x', '3.1.3'], + ['1.2.x', '1.3.3'], + ['1.2.x || 2.x', '3.1.3'], + ['2.*.*', '3.1.3'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '3.1.3'], + ['2', '3.1.2'], + ['2.3', '2.4.1'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 + ['~1', '2.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.3'], + ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 + ['<1', '1.0.0'], + ['1', '2.0.0beta', true], + ['<1', '1.0.0beta', true], + ['< 1', '1.0.0beta', true], + ['=0.7.x', '0.8.2'], + ['<0.7.x', '0.7.2'] +] diff --git a/test/fixtures/version-lt-range.js b/test/fixtures/version-lt-range.js new file mode 100644 index 00000000..4e85a1bf --- /dev/null +++ b/test/fixtures/version-lt-range.js @@ -0,0 +1,69 @@ +// [range, version, loose] +// Version should be less than range +module.exports = [ + ['~1.2.2', '1.2.1'], + ['~0.6.1-1', '0.6.1-0'], + ['1.0.0 - 2.0.0', '0.0.1'], + ['1.0.0-beta.2', '1.0.0-beta.1'], + ['1.0.0', '0.0.0'], + ['>=2.0.0', '1.1.1'], + ['>=2.0.0', '1.2.9'], + ['>2.0.0', '2.0.0'], + ['0.1.20 || 1.2.4', '0.1.5'], + ['2.x.x', '1.0.0'], + ['1.2.x', '1.1.0'], + ['1.2.x || 2.x', '1.0.0'], + ['2.*.*', '1.0.1'], + ['1.2.*', '1.1.3'], + ['1.2.* || 2.*', '1.1.9999'], + ['2', '1.0.0'], + ['2.3', '2.2.2'], + ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.3.5'], + ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '0.2.4'], + ['~> 1', '0.2.3'], + ['~1.0', '0.1.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '0.1.0'], + ['>1.2', '1.2.0'], + ['> 1.2', '1.2.1'], + ['1', '0.0.0beta', true], + ['~v0.5.4-pre', '0.5.4-alpha'], + ['~v0.5.4-pre', '0.5.4-alpha'], + ['=0.7.x', '0.6.0'], + ['=0.7.x', '0.6.0-asdf'], + ['>=0.7.x', '0.6.0'], + ['~1.2.2', '1.2.1'], + ['1.0.0 - 2.0.0', '0.2.3'], + ['1.0.0', '0.0.1'], + ['>=2.0.0', '1.0.0'], + ['>=2.0.0', '1.9999.9999'], + ['>=2.0.0', '1.2.9'], + ['>2.0.0', '2.0.0'], + ['>2.0.0', '1.2.9'], + ['2.x.x', '1.1.3'], + ['1.2.x', '1.1.3'], + ['1.2.x || 2.x', '1.1.3'], + ['2.*.*', '1.1.3'], + ['1.2.*', '1.1.3'], + ['1.2.* || 2.*', '1.1.3'], + ['2', '1.9999.9999'], + ['2.3', '2.2.1'], + ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0 + ['~>3.2.1', '2.3.2'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '0.2.3'], + ['~1.0', '0.0.0'], // >=1.0.0 <1.1.0 + ['>1', '1.0.0'], + ['2', '1.0.0beta', true], + ['>1', '1.0.0beta', true], + ['> 1', '1.0.0beta', true], + ['=0.7.x', '0.6.2'], + ['=0.7.x', '0.7.0-asdf'], + ['^1', '1.0.0-0'], + ['>=0.7.x', '0.7.0-asdf'], + ['1', '1.0.0beta', true], + ['>=0.7.x', '0.6.2'], + ['>1.2.3', '1.3.0-alpha'] +] diff --git a/test/fixtures/version-not-gt-range.js b/test/fixtures/version-not-gt-range.js new file mode 100644 index 00000000..926123ab --- /dev/null +++ b/test/fixtures/version-not-gt-range.js @@ -0,0 +1,85 @@ +// [range, version, loose] +// Version should NOT be greater than range +module.exports = [ + ['~0.6.1-1', '0.6.1-1'], + ['1.0.0 - 2.0.0', '1.2.3'], + ['1.0.0 - 2.0.0', '0.9.9'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0', true], + ['*', '1.2.3'], + ['*', 'v1.2.3-foo'], + ['>=1.0.0', '1.0.0'], + ['>=1.0.0', '1.0.1'], + ['>=1.0.0', '1.1.0'], + ['>1.0.0', '1.0.1'], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97'], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['0.1.20 || >1.2.4', '1.2.4'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['0.1.20 || 1.2.4', '0.1.20'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0 + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '1.0.2'], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['1', '1.0.0beta', true], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['=0.7.x', '0.7.0-asdf'], + ['>=0.7.x', '0.7.0-asdf'], + ['<=0.7.x', '0.6.2'], + ['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'], + ['>=0.2.3 <=0.2.4', '0.2.4'], + ['1.0.0 - 2.0.0', '2.0.0'], + ['^1', '0.0.0-0'], + ['^3.0.0', '2.0.0'], + ['^1.0.0 || ~2.0.1', '2.0.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], + ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], + ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'] +] diff --git a/test/fixtures/version-not-lt-range.js b/test/fixtures/version-not-lt-range.js new file mode 100644 index 00000000..a9558b84 --- /dev/null +++ b/test/fixtures/version-not-lt-range.js @@ -0,0 +1,88 @@ +// [range, version, loose] +// Version should NOT be less than range +module.exports = [ + ['~ 1.0', '1.1.0'], + ['~0.6.1-1', '0.6.1-1'], + ['1.0.0 - 2.0.0', '1.2.3'], + ['1.0.0 - 2.0.0', '2.9.9'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0', true], + ['*', '1.2.3'], + ['>=1.0.0', '1.0.0'], + ['>=1.0.0', '1.0.1'], + ['>=1.0.0', '1.1.0'], + ['>1.0.0', '1.0.1'], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97'], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['0.1.20 || >1.2.4', '1.2.4'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['0.1.20 || 1.2.4', '0.1.20'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0 + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '1.0.2'], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['<=0.7.x', '0.6.2'], + ['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'], + ['>=0.2.3 <=0.2.4', '0.2.4'], + ['1.0.0 - 2.0.0', '2.0.0'], + ['^3.0.0', '4.0.0'], + ['^1.0.0 || ~2.0.1', '2.0.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], + ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], + ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'], + ['^1.0.0alpha', '1.0.0beta', true], + ['~1.0.0alpha', '1.0.0beta', true], + ['^1.0.0-alpha', '1.0.0beta', true], + ['~1.0.0-alpha', '1.0.0beta', true], + ['^1.0.0-alpha', '1.0.0-beta'], + ['~1.0.0-alpha', '1.0.0-beta'], + ['=0.1.0', '1.0.0'] +] diff --git a/test/functions/clean.js b/test/functions/clean.js index 56886c60..632adfa0 100644 --- a/test/functions/clean.js +++ b/test/functions/clean.js @@ -17,10 +17,8 @@ test('clean tests', (t) => { ['~1.2.3', null], ['<=1.2.3', null], ['1.2.x', null] - ].forEach((tuple) => { - const range = tuple[0] - const version = tuple[1] - const msg = `clean(${ range }) = ${ version}` + ].forEach(([range, version]) => { + const msg = `clean(${range}) = ${version}` t.equal(clean(range), version, msg) }) t.end() diff --git a/test/functions/cmp.js b/test/functions/cmp.js index 2895898a..d7f572a2 100644 --- a/test/functions/cmp.js +++ b/test/functions/cmp.js @@ -1,9 +1,49 @@ const { test } = require('tap') const cmp = require('../../functions/cmp') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') +const SemVer = require('../../classes/semver') test('invalid cmp usage', (t) => { - t.throws(() => { - cmp('1.2.3', 'a frog', '4.5.6') - }, new TypeError('Invalid operator: a frog')) - t.end() - }) \ No newline at end of file + t.throws(() => { + cmp('1.2.3', 'a frog', '4.5.6') + }, new TypeError('Invalid operator: a frog')) + t.end() +}) + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(8) + t.ok(cmp(v0, '>', v1, loose), `cmp('${v0}' > '${v1}')`) + t.ok(cmp(v1, '<', v0, loose), `cmp('${v1}' < '${v0}')`) + t.ok(!cmp(v1, '>', v0, loose), `!cmp('${v1}' > '${v0}')`) + t.ok(!cmp(v0, '<', v1, loose), `!cmp('${v0}' < '${v1}')`) + t.ok(cmp(v1, '==', v1, loose), `cmp('${v1}' == '${v1}')`) + t.ok(cmp(v0, '>=', v1, loose), `cmp('${v0}' >= '${v1}')`) + t.ok(cmp(v1, '<=', v0, loose), `cmp('${v1}' <= '${v0}')`) + t.ok(cmp(v0, '!=', v1, loose), `cmp('${v0}' != '${v1}')`) + })) +}) + +test('equality tests', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(8) + t.ok(cmp(v0, '', v1, loose), `cmp(${v0} "" ${v1})`) + t.ok(cmp(v0, '=', v1, loose), `cmp(${v0}=${v1})`) + t.ok(cmp(v0, '==', v1, loose), `cmp(${v0}==${v1})`) + t.ok(!cmp(v0, '!=', v1, loose), `!cmp(${v0}!=${v1})`) + t.ok(!cmp(v0, '===', v1, loose), `!cmp(${v0}===${v1})`) + + // also test with an object. they are === because obj.version matches + t.ok(cmp(new SemVer(v0, { loose: loose }), '===', + new SemVer(v1, { loose: loose })), + `!cmp(${v0}===${v1}) object`) + + t.ok(cmp(v0, '!==', v1, loose), `cmp(${v0}!==${v1})`) + + t.ok(!cmp(new SemVer(v0, loose), '!==', new SemVer(v1, loose)), + `cmp(${v0}!==${v1}) object`) + })) +}) diff --git a/test/functions/coerce.js b/test/functions/coerce.js index 615aa01e..02af8f42 100644 --- a/test/functions/coerce.js +++ b/test/functions/coerce.js @@ -3,38 +3,33 @@ const coerce = require('../../functions/coerce') const parse = require('../../functions/parse') const valid = require('../../functions/valid') -function r (text) { - return function (count) { - return text.repeat(count) - } -} - test('coerce tests', (t) => { // Expected to be null (cannot be coerced). - [ + const coerceToNull = [ null, { version: '1.2.3' }, function () { return '1.2.3' }, '', '.', 'version one', - r('9')(16), - r('1')(17), - `a${ r('9')(16)}`, - `a${ r('1')(17)}`, - `${r('9')(16) }a`, - `${r('1')(17) }a`, - `${r('9')(16) }.4.7.4`, - `${r('9')(16) }.${ r('2')(16) }.${ r('3')(16)}`, - `${r('1')(16) }.${ r('9')(16) }.${ r('3')(16)}`, - `${r('1')(16) }.${ r('2')(16) }.${ r('9')(16)}` - ].forEach((input) => { - const msg = `coerce(${ input }) should be null` + '9'.repeat(16), + '1'.repeat(17), + `a${'9'.repeat(16)}`, + `a${'1'.repeat(17)}`, + `${'9'.repeat(16)}a`, + `${'1'.repeat(17)}a`, + `${'9'.repeat(16)}.4.7.4`, + `${'9'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(16)}`, + `${'1'.repeat(16)}.${'9'.repeat(16)}.${'3'.repeat(16)}`, + `${'1'.repeat(16)}.${'2'.repeat(16)}.${'9'.repeat(16)}` + ] + coerceToNull.forEach((input) => { + const msg = `coerce(${input}) should be null` t.same(coerce(input), null, msg) - }); + }) - // Expected to be the valid. - [ + // Expected to be valid. + const coerceToValid = [ [parse('1.2.3'), '1.2.3'], ['.1', '1.0.0'], ['.1.', '1.0.0'], @@ -79,30 +74,30 @@ test('coerce tests', (t) => { ['v2', '2.0.0'], ['v3.4 replaces v3.3.1', '3.4.0'], ['4.6.3.9.2-alpha2', '4.6.3'], - [`${r('1')(17) }.2`, '2.0.0'], - [`${r('1')(17) }.2.3`, '2.3.0'], - [`1.${ r('2')(17) }.3`, '1.0.0'], - [`1.2.${ r('3')(17)}`, '1.2.0'], - [`${r('1')(17) }.2.3.4`, '2.3.4'], - [`1.${ r('2')(17) }.3.4`, '1.0.0'], - [`1.2.${ r('3')(17) }.4`, '1.2.0'], - [`${r('1')(17) }.${ r('2')(16) }.${ r('3')(16)}`, - `${r('2')(16) }.${ r('3')(16) }.0`], - [`${r('1')(16) }.${ r('2')(17) }.${ r('3')(16)}`, - `${r('1')(16) }.0.0`], - [`${r('1')(16) }.${ r('2')(16) }.${ r('3')(17)}`, - `${r('1')(16) }.${ r('2')(16) }.0`], - [`11${ r('.1')(126)}`, '11.1.1'], - [r('1')(16), `${r('1')(16) }.0.0`], - [`a${ r('1')(16)}`, `${r('1')(16) }.0.0`], - [`${r('1')(16) }.2.3.4`, `${r('1')(16) }.2.3`], - [`1.${ r('2')(16) }.3.4`, `1.${ r('2')(16) }.3`], - [`1.2.${ r('3')(16) }.4`, `1.2.${ r('3')(16)}`], - [`${r('1')(16) }.${ r('2')(16) }.${ r('3')(16)}`, - `${r('1')(16) }.${ r('2')(16) }.${ r('3')(16)}`], - [`1.2.3.${ r('4')(252) }.5`, '1.2.3'], - [`1.2.3.${ r('4')(1024)}`, '1.2.3'], - [`${r('1')(17) }.4.7.4`, '4.7.4'], + [`${'1'.repeat(17)}.2`, '2.0.0'], + [`${'1'.repeat(17)}.2.3`, '2.3.0'], + [`1.${'2'.repeat(17)}.3`, '1.0.0'], + [`1.2.${'3'.repeat(17)}`, '1.2.0'], + [`${'1'.repeat(17)}.2.3.4`, '2.3.4'], + [`1.${'2'.repeat(17)}.3.4`, '1.0.0'], + [`1.2.${'3'.repeat(17)}.4`, '1.2.0'], + [`${'1'.repeat(17)}.${'2'.repeat(16)}.${'3'.repeat(16)}`, + `${'2'.repeat(16)}.${'3'.repeat(16)}.0`], + [`${'1'.repeat(16)}.${'2'.repeat(17)}.${'3'.repeat(16)}`, + `${'1'.repeat(16)}.0.0`], + [`${'1'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(17)}`, + `${'1'.repeat(16)}.${'2'.repeat(16)}.0`], + [`11${'.1'.repeat(126)}`, '11.1.1'], + ['1'.repeat(16), `${'1'.repeat(16)}.0.0`], + [`a${'1'.repeat(16)}`, `${'1'.repeat(16)}.0.0`], + [`${'1'.repeat(16)}.2.3.4`, `${'1'.repeat(16)}.2.3`], + [`1.${'2'.repeat(16)}.3.4`, `1.${'2'.repeat(16)}.3`], + [`1.2.${'3'.repeat(16)}.4`, `1.2.${'3'.repeat(16)}`], + [`${'1'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(16)}`, + `${'1'.repeat(16)}.${'2'.repeat(16)}.${'3'.repeat(16)}`], + [`1.2.3.${'4'.repeat(252)}.5`, '1.2.3'], + [`1.2.3.${'4'.repeat(1024)}`, '1.2.3'], + [`${'1'.repeat(17)}.4.7.4`, '4.7.4'], [10, '10.0.0'], ['1.2.3/a/b/c/2.3.4', '2.3.4', { rtl: true }], ['1.2.3.4.5.6', '4.5.6', { rtl: true }], @@ -112,12 +107,10 @@ test('coerce tests', (t) => { ['1.2.3./6', '6.0.0', { rtl: true }], ['1.2.3/6', '6.0.0', { rtl: true }], ['1.2.3.4', '2.3.4', { rtl: true }], - ['1.2.3.4xyz', '2.3.4', { rtl: true }], - ].forEach((tuple, i) => { - const input = tuple[0] - const expected = tuple[1] - const options = tuple[2] - const msg = `coerce(${ input }) should become ${ expected}` + ['1.2.3.4xyz', '2.3.4', { rtl: true }] + ] + coerceToValid.forEach(([input, expected, options]) => { + const msg = `coerce(${input}) should become ${expected}` t.same((coerce(input, options) || {}).version, expected, msg) }) diff --git a/test/functions/compare-build.js b/test/functions/compare-build.js index 94abf47b..bfb7782c 100644 --- a/test/functions/compare-build.js +++ b/test/functions/compare-build.js @@ -16,4 +16,4 @@ test('compareBuild', (t) => { t.equal(build10.compareBuild(build1), 1) t.end() -}) \ No newline at end of file +}) diff --git a/test/functions/compare-loose.js b/test/functions/compare-loose.js index ad588d47..572c39dc 100644 --- a/test/functions/compare-loose.js +++ b/test/functions/compare-loose.js @@ -4,28 +4,27 @@ const SemVer = require('../../classes/semver') const eq = require('../../functions/eq') test('strict vs loose version numbers', (t) => { - [['=1.2.3', '1.2.3'], - ['01.02.03', '1.2.3'], - ['1.2.3-beta.01', '1.2.3-beta.1'], - [' =1.2.3', '1.2.3'], - ['1.2.3foo', '1.2.3-foo'] - ].forEach((v) => { - const loose = v[0] - const strict = v[1] - t.throws(() => { - SemVer(loose) // eslint-disable-line no-new - }) - const lv = new SemVer(loose, true) - t.equal(lv.version, strict) - t.ok(eq(loose, strict, true)) - t.throws(() => { - eq(loose, strict) - }) - t.throws(() => { - new SemVer(strict).compare(loose) - }) - t.equal(compareLoose(v[0], v[1]), 0) + [['=1.2.3', '1.2.3'], + ['01.02.03', '1.2.3'], + ['1.2.3-beta.01', '1.2.3-beta.1'], + [' =1.2.3', '1.2.3'], + ['1.2.3foo', '1.2.3-foo'] + ].forEach((v) => { + const loose = v[0] + const strict = v[1] + t.throws(() => { + SemVer(loose) // eslint-disable-line no-new }) - t.end() + const lv = new SemVer(loose, true) + t.equal(lv.version, strict) + t.ok(eq(loose, strict, true)) + t.throws(() => { + eq(loose, strict) + }) + t.throws(() => { + new SemVer(strict).compare(loose) + }) + t.equal(compareLoose(v[0], v[1]), 0) }) - \ No newline at end of file + t.end() +}) diff --git a/test/functions/compare.js b/test/functions/compare.js new file mode 100644 index 00000000..6c519893 --- /dev/null +++ b/test/functions/compare.js @@ -0,0 +1,35 @@ +const { test } = require('tap') +const compare = require('../../functions/compare.js') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') +const SemVer = require('../../classes/semver.js') + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.equal(compare(v0, v1, loose), 1, `compare('${v0}', '${v1}')`) + t.equal(compare(v1, v0, loose), -1, `compare('${v1}', '${v0}')`) + t.equal(compare(v0, v0, loose), 0, `compare('${v0}', '${v0}')`) + t.equal(compare(v1, v1, loose), 0, `compare('${v1}', '${v1}')`) + })) +}) + +test('equality tests', (t) => { + // [version1, version2] + // version1 should be equivalent to version2 + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(5) + t.equal(compare(v0, v1, loose), 0, `${v0} ${v1}`) + t.equal(compare(v1, v0, loose), 0, `${v1} ${v0}`) + t.equal(compare(v0, v0, loose), 0, `${v0} ${v0}`) + t.equal(compare(v1, v1, loose), 0, `${v1} ${v1}`) + + // also test with an object. they are === because obj.version matches + t.equal(compare(new SemVer(v0, { loose: loose }), + new SemVer(v1, { loose: loose })), 0, + `compare(${v0}, ${v1}) object`) + })) + t.end() +}) diff --git a/test/functions/diff.js b/test/functions/diff.js index a94b3816..14c62819 100644 --- a/test/functions/diff.js +++ b/test/functions/diff.js @@ -22,8 +22,8 @@ test('diff versions test', (t) => { const version2 = v[1] const wanted = v[2] const found = diff(version1, version2) - const cmd = `diff(${ version1 }, ${ version2 })` - t.equal(found, wanted, `${cmd } === ${ wanted}`) + const cmd = `diff(${version1}, ${version2})` + t.equal(found, wanted, `${cmd} === ${wanted}`) }) t.end() diff --git a/test/functions/eq.js b/test/functions/eq.js new file mode 100644 index 00000000..24ce7724 --- /dev/null +++ b/test/functions/eq.js @@ -0,0 +1,26 @@ +const { test } = require('tap') +const eq = require('../../functions/eq') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.notOk(eq(v0, v1, loose), `!eq(${v0}, ${v1})`) + t.notOk(eq(v1, v0, loose), `!eq(${v1}, ${v0})`) + t.ok(eq(v1, v1, loose), `eq('${v1}', '${v1}')`) + t.ok(eq(v0, v0, loose), `eq('${v0}', '${v0}')`) + })) +}) + +test('equality tests', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.ok(eq(v0, v1, loose), `eq(${v0}, ${v1})`) + t.ok(eq(v1, v0, loose), `eq(${v1}, ${v0})`) + t.ok(eq(v0, v0, loose), `eq(${v0}, ${v0})`) + t.ok(eq(v1, v1, loose), `eq(${v1}, ${v1})`) + })) +}) diff --git a/test/functions/gt.js b/test/functions/gt.js new file mode 100644 index 00000000..04c774c5 --- /dev/null +++ b/test/functions/gt.js @@ -0,0 +1,24 @@ +const { test } = require('tap') +const gt = require('../../functions/gt') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.ok(gt(v0, v1, loose), `gt('${v0}', '${v1}')`) + t.ok(!gt(v1, v0, loose), `!gt('${v1}', '${v0}')`) + t.ok(!gt(v1, v1, loose), `!gt('${v1}', '${v1}')`) + t.ok(!gt(v0, v0, loose), `!gt('${v0}', '${v0}')`) + })) +}) + +test('equality tests', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(2) + t.ok(!gt(v0, v1, loose), `!gt(${v0}, ${v1})`) + t.ok(!gt(v1, v0, loose), `!gt(${v1}, ${v0})`) + })) +}) diff --git a/test/functions/gte.js b/test/functions/gte.js new file mode 100644 index 00000000..c70e764a --- /dev/null +++ b/test/functions/gte.js @@ -0,0 +1,24 @@ +const { test } = require('tap') +const gte = require('../../functions/gte') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.ok(gte(v0, v1, loose), `gte('${v0}', '${v1}')`) + t.ok(!gte(v1, v0, loose), `!gte('${v1}', '${v0}')`) + t.ok(gte(v1, v1, loose), `gte('${v1}', '${v1}')`) + t.ok(gte(v0, v0, loose), `gte('${v0}', '${v0}')`) + })) +}) + +test('equality tests', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(2) + t.ok(gte(v0, v1, loose), `gte(${v0}, ${v1})`) + t.ok(gte(v1, v0, loose), `gte(${v1}, ${v0})`) + })) +}) diff --git a/test/functions/inc.js b/test/functions/inc.js index 40bca58b..711027a6 100644 --- a/test/functions/inc.js +++ b/test/functions/inc.js @@ -94,14 +94,14 @@ test('increment versions test', (t) => { const loose = v[3] const id = v[4] const found = inc(pre, what, loose, id) - const cmd = `inc(${ pre }, ${ what }, ${ id })` - t.equal(found, wanted, `${cmd } === ${ wanted}`) + const cmd = `inc(${pre}, ${what}, ${id})` + t.equal(found, wanted, `${cmd} === ${wanted}`) const parsed = parse(pre, loose) if (wanted) { parsed.inc(what, id) - t.equal(parsed.version, wanted, `${cmd } object version updated`) - t.equal(parsed.raw, wanted, `${cmd } object raw field updated`) + t.equal(parsed.version, wanted, `${cmd} object version updated`) + t.equal(parsed.raw, wanted, `${cmd} object raw field updated`) } else if (parsed) { t.throws(() => { parsed.inc(what, id) diff --git a/test/functions/lt.js b/test/functions/lt.js new file mode 100644 index 00000000..f8760f69 --- /dev/null +++ b/test/functions/lt.js @@ -0,0 +1,24 @@ +const { test } = require('tap') +const lt = require('../../functions/lt') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.ok(!lt(v0, v1, loose), `!lt('${v0}', '${v1}')`) + t.ok(lt(v1, v0, loose), `lt('${v1}', '${v0}')`) + t.ok(!lt(v1, v1, loose), `!lt('${v1}', '${v1}')`) + t.ok(!lt(v0, v0, loose), `!lt('${v0}', '${v0}')`) + })) +}) + +test('equality tests', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(2) + t.ok(!lt(v0, v1, loose), `!lt(${v0}, ${v1})`) + t.ok(!lt(v1, v0, loose), `!lt(${v1}, ${v0})`) + })) +}) diff --git a/test/functions/lte.js b/test/functions/lte.js new file mode 100644 index 00000000..074ce614 --- /dev/null +++ b/test/functions/lte.js @@ -0,0 +1,24 @@ +const { test } = require('tap') +const lte = require('../../functions/lte') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.ok(!lte(v0, v1, loose), `!lte('${v0}', '${v1}')`) + t.ok(lte(v1, v0, loose), `lte('${v1}', '${v0}')`) + t.ok(lte(v1, v1, loose), `lte('${v1}', '${v1}')`) + t.ok(lte(v0, v0, loose), `lte('${v0}', '${v0}')`) + })) +}) + +test('equality tests', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(2) + t.ok(lte(v0, v1, loose), `lte(${v0}, ${v1})`) + t.ok(lte(v1, v0, loose), `lte(${v1}, ${v0})`) + })) +}) diff --git a/test/functions/major.js b/test/functions/major.js index dd013a45..ce924a18 100644 --- a/test/functions/major.js +++ b/test/functions/major.js @@ -18,7 +18,7 @@ test('major tests', (t) => { const range = tuple[0] const version = tuple[1] const loose = tuple[2] || false - const msg = `major(${ range }) = ${ version}` + const msg = `major(${range}) = ${version}` t.equal(major(range, loose), version, msg) }) t.end() diff --git a/test/functions/minor.js b/test/functions/minor.js index e54d8451..ae88e60e 100644 --- a/test/functions/minor.js +++ b/test/functions/minor.js @@ -18,7 +18,7 @@ test('minor tests', (t) => { const range = tuple[0] const version = tuple[1] const loose = tuple[2] || false - const msg = `minor(${ range }) = ${ version}` + const msg = `minor(${range}) = ${version}` t.equal(minor(range, loose), version, msg) }) t.end() diff --git a/test/functions/neq.js b/test/functions/neq.js new file mode 100644 index 00000000..c259369b --- /dev/null +++ b/test/functions/neq.js @@ -0,0 +1,26 @@ +const { test } = require('tap') +const neq = require('../../functions/neq') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') + +test('comparison tests', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.ok(neq(v0, v1, loose), `neq(${v0}, ${v1})`) + t.ok(neq(v1, v0, loose), `neq(${v1}, ${v0})`) + t.notOk(neq(v1, v1, loose), `!neq('${v1}', '${v1}')`) + t.notOk(neq(v0, v0, loose), `!neq('${v0}', '${v0}')`) + })) +}) + +test('equality tests', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + t.plan(4) + t.notOk(neq(v0, v1, loose), `!neq(${v0}, ${v1})`) + t.notOk(neq(v1, v0, loose), `!neq(${v1}, ${v0})`) + t.notOk(neq(v0, v0, loose), `!neq(${v0}, ${v0})`) + t.notOk(neq(v1, v1, loose), `!neq(${v1}, ${v1})`) + })) +}) diff --git a/test/functions/parse.js b/test/functions/parse.js new file mode 100644 index 00000000..190e40af --- /dev/null +++ b/test/functions/parse.js @@ -0,0 +1,26 @@ +const t = require('tap') +const parse = require('../../functions/parse') +const SemVer = require('../../classes/semver') +const {MAX_LENGTH, MAX_SAFE_INTEGER} = require('../../internal/constants') + +t.test('returns null instead of throwing when presented with garbage', t => { + t.equal(parse(new Array(MAX_LENGTH).join('1') + '.0.0'), null, 'too long') + t.equal(parse(`${MAX_SAFE_INTEGER}0.0.0`), null, 'too big') + t.equal(parse('hello, world'), null, 'not a version') + t.equal(parse('hello, world', true), null, 'even loose, its still junk') + t.equal(parse('xyz', { loose: true }), null, 'even loose as an opt, same') + t.equal(parse(/a regexp/), null, 'regexp is not a string') + t.equal(parse(/1.2.3/), null, 'semver-ish regexp is not a string') + t.equal(parse({toString: () => '1.2.3'}), null, 'obj with a tostring is not a string') + t.end() +}) + +t.test('parse a version into a SemVer object', t => { + t.match(parse('1.2.3'), new SemVer('1.2.3')) + const s = new SemVer('4.5.6') + t.equal(parse(s), s, 'just return it if its a SemVer obj') + const loose = new SemVer('4.2.0', { loose: true }) + t.match(parse('4.2.0', true), loose, 'looseness as a boolean') + t.match(parse('4.2.0', { loose: true }), loose, 'looseness as an option') + t.end() +}) diff --git a/test/functions/patch.js b/test/functions/patch.js index dbf5640d..0e03d74d 100644 --- a/test/functions/patch.js +++ b/test/functions/patch.js @@ -18,7 +18,7 @@ test('patch tests', (t) => { const range = tuple[0] const version = tuple[1] const loose = tuple[2] || false - const msg = `patch(${ range }) = ${ version}` + const msg = `patch(${range}) = ${version}` t.equal(patch(range, loose), version, msg) }) t.end() diff --git a/test/functions/prerelease.js b/test/functions/prerelease.js index 48b54ef6..ae7ba5cb 100644 --- a/test/functions/prerelease.js +++ b/test/functions/prerelease.js @@ -17,7 +17,7 @@ test('prerelease', (t) => { const expected = tuple[0] const version = tuple[1] const loose = tuple[2] - const msg = `prerelease(${ version })` + const msg = `prerelease(${version})` t.same(prerelease(version, loose), expected, msg) }) t.end() diff --git a/test/functions/rcompare.js b/test/functions/rcompare.js index b354e894..8225d0aa 100644 --- a/test/functions/rcompare.js +++ b/test/functions/rcompare.js @@ -9,4 +9,3 @@ test('rcompare', (t) => { t.end() }) - diff --git a/test/functions/rsort.js b/test/functions/rsort.js index bfe2538e..06326ab6 100644 --- a/test/functions/rsort.js +++ b/test/functions/rsort.js @@ -2,20 +2,20 @@ const { test } = require('tap') const rsort = require('../../functions/rsort') test('sorting', (t) => { - const list = [ - '1.2.3+1', - '1.2.3+0', - '1.2.3', - '5.9.6', - '0.1.2' - ] - const rsorted = [ - '5.9.6', - '1.2.3+1', - '1.2.3+0', - '1.2.3', - '0.1.2' - ] - t.same(rsort(list), rsorted) - t.end() - }) \ No newline at end of file + const list = [ + '1.2.3+1', + '1.2.3+0', + '1.2.3', + '5.9.6', + '0.1.2' + ] + const rsorted = [ + '5.9.6', + '1.2.3+1', + '1.2.3+0', + '1.2.3', + '0.1.2' + ] + t.same(rsort(list), rsorted) + t.end() +}) diff --git a/test/functions/satisfies.js b/test/functions/satisfies.js new file mode 100644 index 00000000..4a6ec182 --- /dev/null +++ b/test/functions/satisfies.js @@ -0,0 +1,246 @@ +const { test } = require('tap') +const satisfies = require('../../functions/satisfies') + +test('range tests', (t) => { + // [range, version] + // version should be included by range + [['1.0.0 - 2.0.0', '1.2.3'], + ['^1.2.3+build', '1.2.3'], + ['^1.2.3+build', '1.3.0'], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'], + ['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true], + ['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true], + ['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'], + ['1.2.3+asdf - 2.4.3+asdf', '1.2.3'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0'], + ['*', '1.2.3', {}], + ['*', 'v1.2.3', { loose: 123 }], + ['>=1.0.0', '1.0.0', /asdf/], + ['>=1.0.0', '1.0.1', { loose: null }], + ['>=1.0.0', '1.1.0', { loose: 0 }], + ['>1.0.0', '1.0.1', { loose: undefined }], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97', true], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~0.0.1', '0.0.1'], + ['~0.0.1', '0.0.2'], + ['~x', '0.0.9'], // >=2.4.0 <2.5.0 + ['~2', '2.0.9'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0, + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0, + ['~ 1.0', '1.0.2'], + ['~ 1.0.3', '1.0.12'], + ['~ 1.0.3alpha', '1.0.12', { loose: true }], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['<=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['<=0.7.x', '0.6.2'], + ['~1.2.1 >=1.2.3', '1.2.3'], + ['~1.2.1 =1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'], + ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['>=1.2.1 1.2.3', '1.2.3'], + ['1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.1 >=1.2.3', '1.2.3'], + ['>=1.2', '1.2.8'], + ['^1.2.3', '1.8.1'], + ['^0.1.2', '0.1.2'], + ['^0.1', '0.1.2'], + ['^0.0.1', '0.0.1'], + ['^1.2', '1.4.2'], + ['^1.2 ^1', '1.4.2'], + ['^1.2.3-alpha', '1.2.3-pre'], + ['^1.2.0-alpha', '1.2.0-pre'], + ['^0.0.1-alpha', '0.0.1-beta'], + ['^0.0.1-alpha', '0.0.1'], + ['^0.1.1-alpha', '0.1.1-beta'], + ['^x', '1.2.3'], + ['x - 1.0.0', '0.9.7'], + ['x - 1.x', '0.9.7'], + ['1.0.0 - x', '1.9.7'], + ['1.x - x', '1.9.7'], + ['<=7.x', '7.9.9'], + ['2.x', '2.0.0-pre.0', { includePrerelease: true }], + ['2.x', '2.1.0-pre.0', { includePrerelease: true }] + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = v[2] + t.ok(satisfies(ver, range, options), `${range} satisfied by ${ver}`) + }) + t.end() +}) + +test('negative range tests', (t) => { + // [range, version] + // version should not be included by range + [['1.0.0 - 2.0.0', '2.2.3'], + ['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'], + ['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'], + ['^1.2.3+build', '2.0.0'], + ['^1.2.3+build', '1.2.0'], + ['^1.2.3', '1.2.3-pre'], + ['^1.2', '1.2.0-pre'], + ['>1.2', '1.3.0-beta'], + ['<=1.2.3', '1.2.3-beta'], + ['^1.2.3', '1.2.3-beta'], + ['=0.7.x', '0.7.0-asdf'], + ['>=0.7.x', '0.7.0-asdf'], + ['1', '1.0.0beta', { loose: 420 }], + ['<1', '1.0.0beta', true], + ['< 1', '1.0.0beta', true], + ['1.0.0', '1.0.1'], + ['>=1.0.0', '0.0.0'], + ['>=1.0.0', '0.0.1'], + ['>=1.0.0', '0.1.0'], + ['>1.0.0', '0.0.1'], + ['>1.0.0', '0.1.0'], + ['<=2.0.0', '3.0.0'], + ['<=2.0.0', '2.9999.9999'], + ['<=2.0.0', '2.2.9'], + ['<2.0.0', '2.9999.9999'], + ['<2.0.0', '2.2.9'], + ['>=0.1.97', 'v0.1.93', true], + ['>=0.1.97', '0.1.93'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['>=0.2.3 || <0.0.1', '0.0.3'], + ['>=0.2.3 || <0.0.1', '0.2.2'], + ['2.x.x', '1.1.3', { loose: NaN }], + ['2.x.x', '3.1.3'], + ['1.2.x', '1.3.3'], + ['1.2.x || 2.x', '3.1.3'], + ['1.2.x || 2.x', '1.1.3'], + ['2.*.*', '1.1.3'], + ['2.*.*', '3.1.3'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '3.1.3'], + ['1.2.* || 2.*', '1.1.3'], + ['2', '1.1.2'], + ['2.3', '2.4.1'], + ['~0.0.1', '0.1.0-alpha'], + ['~0.0.1', '0.1.0'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.3.9'], + ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 + ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.3'], + ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 + ['<1', '1.0.0'], + ['>=1.2', '1.1.1'], + ['1', '2.0.0beta', true], + ['~v0.5.4-beta', '0.5.4-alpha'], + ['=0.7.x', '0.8.2'], + ['>=0.7.x', '0.6.2'], + ['<0.7.x', '0.7.2'], + ['<1.2.3', '1.2.3-beta'], + ['=1.2.3', '1.2.3-beta'], + ['>1.2', '1.2.8'], + ['^0.0.1', '0.0.2-alpha'], + ['^0.0.1', '0.0.2'], + ['^1.2.3', '2.0.0-alpha'], + ['^1.2.3', '1.2.2'], + ['^1.2', '1.1.9'], + ['*', 'v1.2.3-foo', true], + // invalid ranges never satisfied! + ['blerg', '1.2.3'], + ['git+https://user:password0123@github.com/foo', '123.0.0', true], + ['^1.2.3', '2.0.0-pre'], + ['0.x', undefined], + ['*', undefined], + // invalid versions never satisfy, but shouldn't throw + ['*', 'not a version'], + ['>=2', 'glorp'], + ['2.x', '3.0.0-pre.0', { includePrerelease: true }] + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = v[2] + const found = satisfies(ver, range, options) + t.ok(!found, `${ver} not satisfied by ${range}`) + }) + t.end() +}) + +test('unlocked prerelease range tests', (t) => { + // [range, version] + // version should be included by range + [['*', '1.0.0-rc1'], + ['^1.0.0', '2.0.0-rc1'], + ['^1.0.0-0', '1.0.1-rc1'], + ['^1.0.0-rc2', '1.0.1-rc1'], + ['^1.0.0', '1.0.1-rc1'], + ['^1.0.0', '1.1.0-rc1'] + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = { includePrerelease: true } + t.ok(satisfies(ver, range, options), `${range} satisfied by ${ver}`) + }) + t.end() +}) + +test('negative unlocked prerelease range tests', (t) => { + // [range, version] + // version should not be included by range + [['^1.0.0', '1.0.0-rc1'], + ['^1.2.3-rc2', '2.0.0'] + ].forEach((v) => { + const range = v[0] + const ver = v[1] + const options = { includePrerelease: true } + const found = satisfies(ver, range, options) + t.ok(!found, `${ver} not satisfied by ${range}`) + }) + t.end() +}) diff --git a/test/functions/sort.js b/test/functions/sort.js index 3cde1c0c..d4c12788 100644 --- a/test/functions/sort.js +++ b/test/functions/sort.js @@ -2,21 +2,21 @@ const { test } = require('tap') const sort = require('../../functions/sort') test('sorting', (t) => { - const list = [ - '1.2.3+1', - '1.2.3+0', - '1.2.3', - '5.9.6', - '0.1.2' - ] - const sorted = [ - '0.1.2', - '1.2.3', - '1.2.3+0', - '1.2.3+1', - '5.9.6' - ] - - t.same(sort(list), sorted) - t.end() - }) \ No newline at end of file + const list = [ + '1.2.3+1', + '1.2.3+0', + '1.2.3', + '5.9.6', + '0.1.2' + ] + const sorted = [ + '0.1.2', + '1.2.3', + '1.2.3+0', + '1.2.3+1', + '5.9.6' + ] + + t.same(sort(list), sorted) + t.end() +}) diff --git a/test/functions/valid.js b/test/functions/valid.js new file mode 100644 index 00000000..2b3c7053 --- /dev/null +++ b/test/functions/valid.js @@ -0,0 +1,25 @@ +const t = require('tap') +const valid = require('../../functions/valid') +const SemVer = require('../../classes/semver') +const {MAX_LENGTH, MAX_SAFE_INTEGER} = require('../../internal/constants') + +t.test('returns null instead of throwing when presented with garbage', t => { + t.equal(valid(new Array(MAX_LENGTH).join('1') + '.0.0'), null, 'too long') + t.equal(valid(`${MAX_SAFE_INTEGER}0.0.0`), null, 'too big') + t.equal(valid('hello, world'), null, 'not a version') + t.equal(valid('hello, world', true), null, 'even loose, its still junk') + t.equal(valid('xyz', { loose: true }), null, 'even loose as an opt, same') + t.equal(valid(/a regexp/), null, 'regexp is not a string') + t.equal(valid(/1.2.3/), null, 'semver-ish regexp is not a string') + t.equal(valid({toString: () => '1.2.3'}), null, 'obj with a tostring is not a string') + t.end() +}) + +t.test('validate a version into a SemVer object', t => { + t.equal(valid('1.2.3'), '1.2.3') + const s = new SemVer('4.5.6') + t.equal(valid(s), '4.5.6', 'return the version if a SemVer obj') + t.equal(valid('4.2.0foo', true), '4.2.0-foo', 'looseness as a boolean') + t.equal(valid('4.2.0foo', { loose: true }), '4.2.0-foo', 'looseness as an option') + t.end() +}) diff --git a/test/index.js b/test/index.js index 68be7015..7a25fe6c 100644 --- a/test/index.js +++ b/test/index.js @@ -1,131 +1,21 @@ -const { test } = require('tap') +const t = require('tap') const semver = require('../') -const eq = semver.eq -const gt = semver.gt -const lt = semver.lt -const neq = semver.neq -const cmp = semver.cmp -const gte = semver.gte -const lte = semver.lte -const SemVer = semver.SemVer -test('comparison tests', (t) => { - // [version1, version2] - // version1 should be greater than version2 - [['0.0.0', '0.0.0-foo'], - ['0.0.1', '0.0.0'], - ['1.0.0', '0.9.9'], - ['0.10.0', '0.9.0'], - ['0.99.0', '0.10.0', {}], - ['2.0.0', '1.2.3', { loose: false }], - ['v0.0.0', '0.0.0-foo', true], - ['v0.0.1', '0.0.0', { loose: true }], - ['v1.0.0', '0.9.9', true], - ['v0.10.0', '0.9.0', true], - ['v0.99.0', '0.10.0', true], - ['v2.0.0', '1.2.3', true], - ['0.0.0', 'v0.0.0-foo', true], - ['0.0.1', 'v0.0.0', true], - ['1.0.0', 'v0.9.9', true], - ['0.10.0', 'v0.9.0', true], - ['0.99.0', 'v0.10.0', true], - ['2.0.0', 'v1.2.3', true], - ['1.2.3', '1.2.3-asdf'], - ['1.2.3', '1.2.3-4'], - ['1.2.3', '1.2.3-4-foo'], - ['1.2.3-5-foo', '1.2.3-5'], - ['1.2.3-5', '1.2.3-4'], - ['1.2.3-5-foo', '1.2.3-5-Foo'], - ['3.0.0', '2.7.2+asdf'], - ['1.2.3-a.10', '1.2.3-a.5'], - ['1.2.3-a.b', '1.2.3-a.5'], - ['1.2.3-a.b', '1.2.3-a'], - ['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100'], - ['1.2.3-r2', '1.2.3-r100'], - ['1.2.3-r100', '1.2.3-R2'], - ].forEach((v) => { - const v0 = v[0] - const v1 = v[1] - const loose = v[2] - t.ok(gt(v0, v1, loose), `gt('${ v0 }', '${ v1 }')`) - t.ok(lt(v1, v0, loose), `lt('${ v1 }', '${ v0 }')`) - t.ok(!gt(v1, v0, loose), `!gt('${ v1 }', '${ v0 }')`) - t.ok(!lt(v0, v1, loose), `!lt('${ v0 }', '${ v1 }')`) - t.ok(eq(v0, v0, loose), `eq('${ v0 }', '${ v0 }')`) - t.ok(eq(v1, v1, loose), `eq('${ v1 }', '${ v1 }')`) - t.ok(neq(v0, v1, loose), `neq('${ v0 }', '${ v1 }')`) - t.ok(cmp(v1, '==', v1, loose), `cmp('${ v1 }' == '${ v1 }')`) - t.ok(cmp(v0, '>=', v1, loose), `cmp('${ v0 }' >= '${ v1 }')`) - t.ok(cmp(v1, '<=', v0, loose), `cmp('${ v1 }' <= '${ v0 }')`) - t.ok(cmp(v0, '!=', v1, loose), `cmp('${ v0 }' != '${ v1 }')`) - }) - t.end() -}) +t.match(Object.getOwnPropertyDescriptor(semver, 'SEMVER_SPEC_VERSION'), { + get: Function, + set: undefined, + enumerable: true, + configurable: true +}, 'properties are getters') -test('equality tests', (t) => { - // [version1, version2] - // version1 should be equivalent to version2 - [['1.2.3', 'v1.2.3', true], - ['1.2.3', '=1.2.3', true], - ['1.2.3', 'v 1.2.3', true], - ['1.2.3', '= 1.2.3', true], - ['1.2.3', ' v1.2.3', true], - ['1.2.3', ' =1.2.3', true], - ['1.2.3', ' v 1.2.3', true], - ['1.2.3', ' = 1.2.3', true], - ['1.2.3-0', 'v1.2.3-0', true], - ['1.2.3-0', '=1.2.3-0', true], - ['1.2.3-0', 'v 1.2.3-0', true], - ['1.2.3-0', '= 1.2.3-0', true], - ['1.2.3-0', ' v1.2.3-0', true], - ['1.2.3-0', ' =1.2.3-0', true], - ['1.2.3-0', ' v 1.2.3-0', true], - ['1.2.3-0', ' = 1.2.3-0', true], - ['1.2.3-1', 'v1.2.3-1', true], - ['1.2.3-1', '=1.2.3-1', true], - ['1.2.3-1', 'v 1.2.3-1', true], - ['1.2.3-1', '= 1.2.3-1', true], - ['1.2.3-1', ' v1.2.3-1', true], - ['1.2.3-1', ' =1.2.3-1', true], - ['1.2.3-1', ' v 1.2.3-1', true], - ['1.2.3-1', ' = 1.2.3-1', true], - ['1.2.3-beta', 'v1.2.3-beta', true], - ['1.2.3-beta', '=1.2.3-beta', true], - ['1.2.3-beta', 'v 1.2.3-beta', true], - ['1.2.3-beta', '= 1.2.3-beta', true], - ['1.2.3-beta', ' v1.2.3-beta', true], - ['1.2.3-beta', ' =1.2.3-beta', true], - ['1.2.3-beta', ' v 1.2.3-beta', true], - ['1.2.3-beta', ' = 1.2.3-beta', true], - ['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild', true], - ['1.2.3+build', ' = 1.2.3+otherbuild', true], - ['1.2.3-beta+build', '1.2.3-beta+otherbuild'], - ['1.2.3+build', '1.2.3+otherbuild'], - [' v1.2.3+build', '1.2.3+otherbuild'] - ].forEach((v) => { - const v0 = v[0] - const v1 = v[1] - const loose = v[2] - t.ok(eq(v0, v1, loose), `eq('${ v0 }', '${ v1 }')`) - t.ok(!neq(v0, v1, loose), `!neq('${ v0 }', '${ v1 }')`) - t.ok(cmp(v0, '==', v1, loose), `cmp(${ v0 }==${ v1 })`) - t.ok(!cmp(v0, '!=', v1, loose), `!cmp(${ v0 }!=${ v1 })`) - t.ok(!cmp(v0, '===', v1, loose), `!cmp(${ v0 }===${ v1 })`) +const {SEMVER_SPEC_VERSION} = require('../internal/constants') +t.match(semver.SEMVER_SPEC_VERSION, SEMVER_SPEC_VERSION, 'getter returns expected value') +t.match(Object.getOwnPropertyDescriptor(semver, 'SEMVER_SPEC_VERSION'), { + get: undefined, + set: undefined, + value: SEMVER_SPEC_VERSION, + configurable: true, + enumerable: true +}, 'replaced with value prop after initial get') - // also test with an object. they are === because obj.version matches - t.ok(cmp(new SemVer(v0, { loose: loose }), '===', - new SemVer(v1, { loose: loose })), - `!cmp(${ v0 }===${ v1 }) object`) - - t.ok(cmp(v0, '!==', v1, loose), `cmp(${ v0 }!==${ v1 })`) - - t.ok(!cmp(new SemVer(v0, loose), '!==', new SemVer(v1, loose)), - `cmp(${ v0 }!==${ v1 }) object`) - - t.ok(!gt(v0, v1, loose), `!gt('${ v0 }', '${ v1 }')`) - t.ok(gte(v0, v1, loose), `gte('${ v0 }', '${ v1 }')`) - t.ok(!lt(v0, v1, loose), `!lt('${ v0 }', '${ v1 }')`) - t.ok(lte(v0, v1, loose), `lte('${ v0 }', '${ v1 }')`) - }) - t.end() -}) +t.match(semver.parse, require('../functions/parse'), 'getter that does not have a subkey') diff --git a/test/internal/constants.js b/test/internal/constants.js new file mode 100644 index 00000000..8e5d0971 --- /dev/null +++ b/test/internal/constants.js @@ -0,0 +1,9 @@ +const t = require('tap') +const constants = require('../../internal/constants') + +t.match(constants, { + SEMVER_SPEC_VERSION: String, + MAX_LENGTH: Number, + MAX_SAFE_INTEGER: Number, + MAX_SAFE_COMPONENT_LENGTH: Number +}, 'got some numbers exported') diff --git a/test/internal/debug.js b/test/internal/debug.js new file mode 100644 index 00000000..967959f6 --- /dev/null +++ b/test/internal/debug.js @@ -0,0 +1,36 @@ +const main = () => { + const t = require('tap') + const {spawn} = require('child_process') + t.plan(2) + t.test('without env set', t => { + const c = spawn(process.execPath, [__filename, 'child'], {env: { + ...process.env, + NODE_DEBUG: '' + }}) + const err = [] + c.stderr.on('data', chunk => err.push(chunk)) + c.on('close', (code, signal) => { + t.equal(code, 0, 'success exit status') + t.equal(signal, null, 'no signal') + t.equal(Buffer.concat(err).toString('utf8'), '', 'got no output') + t.end() + }) + }) + t.test('with env set', t => { + const c = spawn(process.execPath, [__filename, 'child'], {env: { + ...process.env, + NODE_DEBUG: 'semver' + }}) + const err = [] + c.stderr.on('data', chunk => err.push(chunk)) + c.on('close', (code, signal) => { + t.equal(code, 0, 'success exit status') + t.equal(signal, null, 'no signal') + t.equal(Buffer.concat(err).toString('utf8'), 'SEMVER hello, world\n', 'got expected output') + t.end() + }) + }) + t.end() +} + +if (process.argv[2] === 'child') { require('../../internal/debug')('hello, world') } else { main() } diff --git a/test/internal/identifiers.js b/test/internal/identifiers.js index a7a833b7..1c331bfc 100644 --- a/test/internal/identifiers.js +++ b/test/internal/identifiers.js @@ -1,19 +1,19 @@ const { test } = require('tap') -const { compareIdentifiers, rcompareIdentifiers } = require('../../internal/identifiers'); +const { compareIdentifiers, rcompareIdentifiers } = require('../../internal/identifiers') test('rcompareIdentifiers and compareIdentifiers', (t) => { - const set = [ - ['1', '2'], - ['alpha', 'beta'], - ['0', 'beta'], - ] - set.forEach((ab) => { - const a = ab[0] - const b = ab[1] - t.equal(compareIdentifiers(a, b), -1) - t.equal(rcompareIdentifiers(a, b), 1) - }) - t.equal(compareIdentifiers('0', '0'), 0) - t.equal(rcompareIdentifiers('0', '0'), 0) - t.end() - }) \ No newline at end of file + const set = [ + ['1', '2'], + ['alpha', 'beta'], + ['0', 'beta'] + ] + set.forEach((ab) => { + const a = ab[0] + const b = ab[1] + t.equal(compareIdentifiers(a, b), -1) + t.equal(rcompareIdentifiers(a, b), 1) + }) + t.equal(compareIdentifiers('0', '0'), 0) + t.equal(rcompareIdentifiers('0', '0'), 0) + t.end() +}) diff --git a/test/internal/re.js b/test/internal/re.js index dc26ec56..0a85d5a3 100644 --- a/test/internal/re.js +++ b/test/internal/re.js @@ -3,15 +3,15 @@ const { src, re } = require('../../internal/re') const semver = require('../../') test('has a list of src, re, and tokens', (t) => { - t.match(Object.assign({}, semver), { - src: Array, - re: Array, - tokens: Object - }) - re.forEach(r => t.match(r, RegExp, 'regexps are regexps')) - src.forEach(s => t.match(s, String, 'src is strings')) - for (const i in semver.tokens) { - t.match(semver.tokens[i], Number, 'tokens are numbers') - } - t.end() - }) \ No newline at end of file + t.match(Object.assign({}, semver), { + src: Array, + re: Array, + tokens: Object + }) + re.forEach(r => t.match(r, RegExp, 'regexps are regexps')) + src.forEach(s => t.match(s, String, 'src is strings')) + for (const i in semver.tokens) { + t.match(semver.tokens[i], Number, 'tokens are numbers') + } + t.end() +}) diff --git a/test/ranges/gtr.js b/test/ranges/gtr.js index c0c3bcc6..aad2a056 100644 --- a/test/ranges/gtr.js +++ b/test/ranges/gtr.js @@ -1,75 +1,16 @@ const { test } = require('tap') const gtr = require('../../ranges/gtr') +const versionGtr = require('../fixtures/version-gt-range') +const versionNotGtr = require('../fixtures/version-not-gt-range') test('gtr tests', (t) => { // [range, version, loose] // Version should be greater than range - [ - ['~1.2.2', '1.3.0'], - ['~0.6.1-1', '0.7.1-1'], - ['1.0.0 - 2.0.0', '2.0.1'], - ['1.0.0', '1.0.1-beta1'], - ['1.0.0', '2.0.0'], - ['<=2.0.0', '2.1.1'], - ['<=2.0.0', '3.2.9'], - ['<2.0.0', '2.0.0'], - ['0.1.20 || 1.2.4', '1.2.5'], - ['2.x.x', '3.0.0'], - ['1.2.x', '1.3.0'], - ['1.2.x || 2.x', '3.0.0'], - ['2.*.*', '5.0.1'], - ['1.2.*', '1.3.3'], - ['1.2.* || 2.*', '4.0.0'], - ['2', '3.0.0'], - ['2.3', '2.4.2'], - ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.5.5'], - ['~>3.2.1', '3.3.0'], // >=3.2.1 <3.3.0 - ['~1', '2.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '2.2.4'], - ['~> 1', '3.2.3'], - ['~1.0', '1.1.2'], // >=1.0.0 <1.1.0 - ['~ 1.0', '1.1.0'], - ['<1.2', '1.2.0'], - ['< 1.2', '1.2.1'], - ['1', '2.0.0beta', true], - ['~v0.5.4-pre', '0.6.0'], - ['~v0.5.4-pre', '0.6.1-pre'], - ['=0.7.x', '0.8.0'], - ['=0.7.x', '0.8.0-asdf'], - ['<0.7.x', '0.7.0'], - ['~1.2.2', '1.3.0'], - ['1.0.0 - 2.0.0', '2.2.3'], - ['1.0.0', '1.0.1'], - ['<=2.0.0', '3.0.0'], - ['<=2.0.0', '2.9999.9999'], - ['<=2.0.0', '2.2.9'], - ['<2.0.0', '2.9999.9999'], - ['<2.0.0', '2.2.9'], - ['2.x.x', '3.1.3'], - ['1.2.x', '1.3.3'], - ['1.2.x || 2.x', '3.1.3'], - ['2.*.*', '3.1.3'], - ['1.2.*', '1.3.3'], - ['1.2.* || 2.*', '3.1.3'], - ['2', '3.1.2'], - ['2.3', '2.4.1'], - ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 - ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 - ['~1', '2.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '2.2.3'], - ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 - ['<1', '1.0.0'], - ['1', '2.0.0beta', true], - ['<1', '1.0.0beta', true], - ['< 1', '1.0.0beta', true], - ['=0.7.x', '0.8.2'], - ['<0.7.x', '0.7.2'] - ].forEach((tuple) => { + versionGtr.forEach((tuple) => { const range = tuple[0] const version = tuple[1] const loose = tuple[2] || false - const msg = `gtr(${ version }, ${ range }, ${ loose })` + const msg = `gtr(${version}, ${range}, ${loose})` t.ok(gtr(version, range, loose), msg) }) t.end() @@ -78,93 +19,11 @@ test('gtr tests', (t) => { test('negative gtr tests', (t) => { // [range, version, loose] // Version should NOT be greater than range - [ - ['~0.6.1-1', '0.6.1-1'], - ['1.0.0 - 2.0.0', '1.2.3'], - ['1.0.0 - 2.0.0', '0.9.9'], - ['1.0.0', '1.0.0'], - ['>=*', '0.2.4'], - ['', '1.0.0', true], - ['*', '1.2.3'], - ['*', 'v1.2.3-foo'], - ['>=1.0.0', '1.0.0'], - ['>=1.0.0', '1.0.1'], - ['>=1.0.0', '1.1.0'], - ['>1.0.0', '1.0.1'], - ['>1.0.0', '1.1.0'], - ['<=2.0.0', '2.0.0'], - ['<=2.0.0', '1.9999.9999'], - ['<=2.0.0', '0.2.9'], - ['<2.0.0', '1.9999.9999'], - ['<2.0.0', '0.2.9'], - ['>= 1.0.0', '1.0.0'], - ['>= 1.0.0', '1.0.1'], - ['>= 1.0.0', '1.1.0'], - ['> 1.0.0', '1.0.1'], - ['> 1.0.0', '1.1.0'], - ['<= 2.0.0', '2.0.0'], - ['<= 2.0.0', '1.9999.9999'], - ['<= 2.0.0', '0.2.9'], - ['< 2.0.0', '1.9999.9999'], - ['<\t2.0.0', '0.2.9'], - ['>=0.1.97', 'v0.1.97'], - ['>=0.1.97', '0.1.97'], - ['0.1.20 || 1.2.4', '1.2.4'], - ['0.1.20 || >1.2.4', '1.2.4'], - ['0.1.20 || 1.2.4', '1.2.3'], - ['0.1.20 || 1.2.4', '0.1.20'], - ['>=0.2.3 || <0.0.1', '0.0.0'], - ['>=0.2.3 || <0.0.1', '0.2.3'], - ['>=0.2.3 || <0.0.1', '0.2.4'], - ['||', '1.3.4'], - ['2.x.x', '2.1.3'], - ['1.2.x', '1.2.3'], - ['1.2.x || 2.x', '2.1.3'], - ['1.2.x || 2.x', '1.2.3'], - ['x', '1.2.3'], - ['2.*.*', '2.1.3'], - ['1.2.*', '1.2.3'], - ['1.2.* || 2.*', '2.1.3'], - ['1.2.* || 2.*', '1.2.3'], - ['1.2.* || 2.*', '1.2.3'], - ['*', '1.2.3'], - ['2', '2.1.2'], - ['2.3', '2.3.1'], - ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.5'], - ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0 - ['~1', '1.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '1.2.3'], - ['~> 1', '1.2.3'], - ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0 - ['~ 1.0', '1.0.2'], - ['>=1', '1.0.0'], - ['>= 1', '1.0.0'], - ['<1.2', '1.1.1'], - ['< 1.2', '1.1.1'], - ['1', '1.0.0beta', true], - ['~v0.5.4-pre', '0.5.5'], - ['~v0.5.4-pre', '0.5.4'], - ['=0.7.x', '0.7.2'], - ['>=0.7.x', '0.7.2'], - ['=0.7.x', '0.7.0-asdf'], - ['>=0.7.x', '0.7.0-asdf'], - ['<=0.7.x', '0.6.2'], - ['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'], - ['>=0.2.3 <=0.2.4', '0.2.4'], - ['1.0.0 - 2.0.0', '2.0.0'], - ['^1', '0.0.0-0'], - ['^3.0.0', '2.0.0'], - ['^1.0.0 || ~2.0.1', '2.0.0'], - ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], - ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], - ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], - ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'] - ].forEach((tuple) => { + versionNotGtr.forEach((tuple) => { const range = tuple[0] const version = tuple[1] const loose = tuple[2] || false - const msg = `!gtr(${ version }, ${ range }, ${ loose })` + const msg = `!gtr(${version}, ${range}, ${loose})` t.notOk(gtr(version, range, loose), msg) }) t.end() diff --git a/test/ranges/intersects.js b/test/ranges/intersects.js index 86db46d5..a6b1e53b 100644 --- a/test/ranges/intersects.js +++ b/test/ranges/intersects.js @@ -1,6 +1,7 @@ const { test } = require('tap') const intersects = require('../../ranges/intersects') -const { Comparator, Range } = require('../../classes/range') +const Range = require('../../classes/range') +const Comparator = require('../../classes/comparator') test('intersect comparators', (t) => { [ @@ -118,9 +119,9 @@ test('ranges intersect', (t) => { ['1.3.0 || <1.0.0 >2.0.0', 'x', true], ['1.x', '1.3.0 || <1.0.0 >2.0.0', true], ['*', '*', true], - ['x', '', true], + ['x', '', true] ].forEach((v) => { - t.test(`${v[0] } <~> ${ v[1]}`, t => { + t.test(`${v[0]} <~> ${v[1]}`, t => { const range1 = new Range(v[0]) const range2 = new Range(v[1]) const expect = v[2] @@ -158,11 +159,10 @@ test('missing comparator parameter in intersect comparators', (t) => { t.end() }) - test('missing range parameter in range intersect', (t) => { t.throws(() => { new Range('1.0.0').intersects() }, new TypeError('a Range is required'), 'throws type error') t.end() -}) \ No newline at end of file +}) diff --git a/test/ranges/ltr.js b/test/ranges/ltr.js index 35578d71..a12abbfa 100644 --- a/test/ranges/ltr.js +++ b/test/ranges/ltr.js @@ -1,80 +1,13 @@ const { test } = require('tap') const ltr = require('../../ranges/ltr') +const versionLtr = require('../fixtures/version-lt-range') +const versionNotLtr = require('../fixtures/version-not-lt-range') test('ltr tests', (t) => { // [range, version, loose] // Version should be less than range - [ - ['~1.2.2', '1.2.1'], - ['~0.6.1-1', '0.6.1-0'], - ['1.0.0 - 2.0.0', '0.0.1'], - ['1.0.0-beta.2', '1.0.0-beta.1'], - ['1.0.0', '0.0.0'], - ['>=2.0.0', '1.1.1'], - ['>=2.0.0', '1.2.9'], - ['>2.0.0', '2.0.0'], - ['0.1.20 || 1.2.4', '0.1.5'], - ['2.x.x', '1.0.0'], - ['1.2.x', '1.1.0'], - ['1.2.x || 2.x', '1.0.0'], - ['2.*.*', '1.0.1'], - ['1.2.*', '1.1.3'], - ['1.2.* || 2.*', '1.1.9999'], - ['2', '1.0.0'], - ['2.3', '2.2.2'], - ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.3.5'], - ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 - ['~1', '0.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '0.2.4'], - ['~> 1', '0.2.3'], - ['~1.0', '0.1.2'], // >=1.0.0 <1.1.0 - ['~ 1.0', '0.1.0'], - ['>1.2', '1.2.0'], - ['> 1.2', '1.2.1'], - ['1', '0.0.0beta', true], - ['~v0.5.4-pre', '0.5.4-alpha'], - ['~v0.5.4-pre', '0.5.4-alpha'], - ['=0.7.x', '0.6.0'], - ['=0.7.x', '0.6.0-asdf'], - ['>=0.7.x', '0.6.0'], - ['~1.2.2', '1.2.1'], - ['1.0.0 - 2.0.0', '0.2.3'], - ['1.0.0', '0.0.1'], - ['>=2.0.0', '1.0.0'], - ['>=2.0.0', '1.9999.9999'], - ['>=2.0.0', '1.2.9'], - ['>2.0.0', '2.0.0'], - ['>2.0.0', '1.2.9'], - ['2.x.x', '1.1.3'], - ['1.2.x', '1.1.3'], - ['1.2.x || 2.x', '1.1.3'], - ['2.*.*', '1.1.3'], - ['1.2.*', '1.1.3'], - ['1.2.* || 2.*', '1.1.3'], - ['2', '1.9999.9999'], - ['2.3', '2.2.1'], - ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0 - ['~>3.2.1', '2.3.2'], // >=3.2.1 <3.3.0 - ['~1', '0.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '0.2.3'], - ['~1.0', '0.0.0'], // >=1.0.0 <1.1.0 - ['>1', '1.0.0'], - ['2', '1.0.0beta', true], - ['>1', '1.0.0beta', true], - ['> 1', '1.0.0beta', true], - ['=0.7.x', '0.6.2'], - ['=0.7.x', '0.7.0-asdf'], - ['^1', '1.0.0-0'], - ['>=0.7.x', '0.7.0-asdf'], - ['1', '1.0.0beta', true], - ['>=0.7.x', '0.6.2'], - ['>1.2.3', '1.3.0-alpha'] - ].forEach((tuple) => { - const range = tuple[0] - const version = tuple[1] - const loose = tuple[2] || false - const msg = `ltr(${ version }, ${ range }, ${ loose })` + versionLtr.forEach(([range, version, loose = false]) => { + const msg = `ltr(${version}, ${range}, ${loose})` t.ok(ltr(version, range, loose), msg) }) t.end() @@ -83,96 +16,8 @@ test('ltr tests', (t) => { test('negative ltr tests', (t) => { // [range, version, loose] // Version should NOT be less than range - [ - ['~ 1.0', '1.1.0'], - ['~0.6.1-1', '0.6.1-1'], - ['1.0.0 - 2.0.0', '1.2.3'], - ['1.0.0 - 2.0.0', '2.9.9'], - ['1.0.0', '1.0.0'], - ['>=*', '0.2.4'], - ['', '1.0.0', true], - ['*', '1.2.3'], - ['>=1.0.0', '1.0.0'], - ['>=1.0.0', '1.0.1'], - ['>=1.0.0', '1.1.0'], - ['>1.0.0', '1.0.1'], - ['>1.0.0', '1.1.0'], - ['<=2.0.0', '2.0.0'], - ['<=2.0.0', '1.9999.9999'], - ['<=2.0.0', '0.2.9'], - ['<2.0.0', '1.9999.9999'], - ['<2.0.0', '0.2.9'], - ['>= 1.0.0', '1.0.0'], - ['>= 1.0.0', '1.0.1'], - ['>= 1.0.0', '1.1.0'], - ['> 1.0.0', '1.0.1'], - ['> 1.0.0', '1.1.0'], - ['<= 2.0.0', '2.0.0'], - ['<= 2.0.0', '1.9999.9999'], - ['<= 2.0.0', '0.2.9'], - ['< 2.0.0', '1.9999.9999'], - ['<\t2.0.0', '0.2.9'], - ['>=0.1.97', 'v0.1.97'], - ['>=0.1.97', '0.1.97'], - ['0.1.20 || 1.2.4', '1.2.4'], - ['0.1.20 || >1.2.4', '1.2.4'], - ['0.1.20 || 1.2.4', '1.2.3'], - ['0.1.20 || 1.2.4', '0.1.20'], - ['>=0.2.3 || <0.0.1', '0.0.0'], - ['>=0.2.3 || <0.0.1', '0.2.3'], - ['>=0.2.3 || <0.0.1', '0.2.4'], - ['||', '1.3.4'], - ['2.x.x', '2.1.3'], - ['1.2.x', '1.2.3'], - ['1.2.x || 2.x', '2.1.3'], - ['1.2.x || 2.x', '1.2.3'], - ['x', '1.2.3'], - ['2.*.*', '2.1.3'], - ['1.2.*', '1.2.3'], - ['1.2.* || 2.*', '2.1.3'], - ['1.2.* || 2.*', '1.2.3'], - ['1.2.* || 2.*', '1.2.3'], - ['*', '1.2.3'], - ['2', '2.1.2'], - ['2.3', '2.3.1'], - ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.5'], - ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0 - ['~1', '1.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '1.2.3'], - ['~> 1', '1.2.3'], - ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0 - ['~ 1.0', '1.0.2'], - ['>=1', '1.0.0'], - ['>= 1', '1.0.0'], - ['<1.2', '1.1.1'], - ['< 1.2', '1.1.1'], - ['~v0.5.4-pre', '0.5.5'], - ['~v0.5.4-pre', '0.5.4'], - ['=0.7.x', '0.7.2'], - ['>=0.7.x', '0.7.2'], - ['<=0.7.x', '0.6.2'], - ['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'], - ['>=0.2.3 <=0.2.4', '0.2.4'], - ['1.0.0 - 2.0.0', '2.0.0'], - ['^3.0.0', '4.0.0'], - ['^1.0.0 || ~2.0.1', '2.0.0'], - ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], - ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], - ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], - ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'], - ['^1.0.0alpha', '1.0.0beta', true], - ['~1.0.0alpha', '1.0.0beta', true], - ['^1.0.0-alpha', '1.0.0beta', true], - ['~1.0.0-alpha', '1.0.0beta', true], - ['^1.0.0-alpha', '1.0.0-beta'], - ['~1.0.0-alpha', '1.0.0-beta'], - ['=0.1.0', '1.0.0'] - ].forEach((tuple) => { - const range = tuple[0] - const version = tuple[1] - const loose = tuple[2] || false - const msg = `!ltr(${ version }, ${ range }, ${ loose })` + versionNotLtr.forEach(([range, version, loose = false]) => { + const msg = `!ltr(${version}, ${range}, ${loose})` t.notOk(ltr(version, range, loose), msg) }) t.end() diff --git a/test/ranges/max-satisfying.js b/test/ranges/max-satisfying.js index a811e251..498ef88d 100644 --- a/test/ranges/max-satisfying.js +++ b/test/ranges/max-satisfying.js @@ -2,24 +2,23 @@ const { test } = require('tap') const maxSatisfying = require('../../ranges/max-satisfying') test('max satisfying', (t) => { - [[['1.2.3', '1.2.4'], '1.2', '1.2.4'], - [['1.2.4', '1.2.3'], '1.2', '1.2.4'], - [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'], - [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] - ].forEach((v) => { - const versions = v[0] - const range = v[1] - const expect = v[2] - const loose = v[3] - const actual = maxSatisfying(versions, range, loose) - t.equal(actual, expect) - }) - t.end() + [[['1.2.3', '1.2.4'], '1.2', '1.2.4'], + [['1.2.4', '1.2.3'], '1.2', '1.2.4'], + [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'], + [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] + ].forEach((v) => { + const versions = v[0] + const range = v[1] + const expect = v[2] + const loose = v[3] + const actual = maxSatisfying(versions, range, loose) + t.equal(actual, expect) }) - + t.end() +}) test('bad ranges in max satisfying', (t) => { - const r = 'some frogs and sneks-v2.5.6' - t.equal(maxSatisfying([], r), null) - t.end() - }) + const r = 'some frogs and sneks-v2.5.6' + t.equal(maxSatisfying([], r), null) + t.end() +}) diff --git a/test/ranges/min-satisfying.js b/test/ranges/min-satisfying.js index ebda0765..bbda0668 100644 --- a/test/ranges/min-satisfying.js +++ b/test/ranges/min-satisfying.js @@ -2,24 +2,23 @@ const { test } = require('tap') const minSatisfying = require('../../ranges/min-satisfying') test('min satisfying', (t) => { - [[['1.2.3', '1.2.4'], '1.2', '1.2.3'], - [['1.2.4', '1.2.3'], '1.2', '1.2.3'], - [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.3'], - [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] - ].forEach((v) => { - const versions = v[0] - const range = v[1] - const expect = v[2] - const loose = v[3] - const actual = minSatisfying(versions, range, loose) - t.equal(actual, expect) - }) - t.end() + [[['1.2.3', '1.2.4'], '1.2', '1.2.3'], + [['1.2.4', '1.2.3'], '1.2', '1.2.3'], + [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.3'], + [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] + ].forEach((v) => { + const versions = v[0] + const range = v[1] + const expect = v[2] + const loose = v[3] + const actual = minSatisfying(versions, range, loose) + t.equal(actual, expect) }) + t.end() +}) - - test('bad ranges in min satisfying', (t) => { - const r = 'some frogs and sneks-v2.5.6' - t.equal(minSatisfying([], r), null) - t.end() - }) \ No newline at end of file +test('bad ranges in min satisfying', (t) => { + const r = 'some frogs and sneks-v2.5.6' + t.equal(minSatisfying([], r), null) + t.end() +}) diff --git a/test/ranges/min-version.js b/test/ranges/min-version.js index 8577144b..31dd93a7 100644 --- a/test/ranges/min-version.js +++ b/test/ranges/min-version.js @@ -67,7 +67,7 @@ test('minimum version in range tests', (t) => { const range = tuple[0] const version = tuple[1] const loose = tuple[2] || false - const msg = `minVersion(${ range }, ${ loose }) = ${ version}` + const msg = `minVersion(${range}, ${loose}) = ${version}` const min = minVersion(range, loose) t.ok(min === version || (min && min.version === version), msg) }) diff --git a/test/ranges/outside.js b/test/ranges/outside.js index 54b7f95c..358734e9 100644 --- a/test/ranges/outside.js +++ b/test/ranges/outside.js @@ -1,10 +1,53 @@ const { test } = require('tap') const outside = require('../../ranges/outside') +const versionGtr = require('../fixtures/version-gt-range') +const versionNotGtr = require('../fixtures/version-not-gt-range') +const versionLtr = require('../fixtures/version-lt-range') +const versionNotLtr = require('../fixtures/version-not-lt-range') -test('outside with bad hilo throws', (t) => { - t.throws(() => { - outside('1.2.3', '>1.5.0', 'blerg', true) - }, new TypeError('Must provide a hilo val of "<" or ">"')) - t.end() +test('gtr tests', (t) => { + // [range, version, loose] + // Version should be greater than range + versionGtr.forEach(([range, version, loose = false]) => { + const msg = `outside(${version}, ${range}, > ${loose})` + t.ok(outside(version, range, '>', loose), msg) + }) + t.end() +}) + +test('ltr tests', (t) => { + // [range, version, loose] + // Version should be less than range + versionLtr.forEach(([range, version, loose = false]) => { + const msg = `outside(${version}, ${range}, <, ${loose})` + t.ok(outside(version, range, '<', loose), msg) + }) + t.end() +}) + +test('negative gtr tests', (t) => { + // [range, version, loose] + // Version should NOT be greater than range + versionNotGtr.forEach(([range, version, loose = false]) => { + const msg = `!outside(${version}, ${range}, > ${loose})` + t.notOk(outside(version, range, '>', loose), msg) }) - \ No newline at end of file + t.end() +}) + +test('negative ltr tests', (t) => { + // [range, version, loose] + // Version should NOT be less than range + versionNotLtr.forEach(([range, version, loose = false]) => { + const msg = `!outside(${version}, ${range}, < ${loose})` + t.notOk(outside(version, range, '<', loose), msg) + }) + t.end() +}) + +test('outside with bad hilo throws', (t) => { + t.throws(() => { + outside('1.2.3', '>1.5.0', 'blerg', true) + }, new TypeError('Must provide a hilo val of "<" or ">"')) + t.end() +}) diff --git a/test/ranges/satisfies.js b/test/ranges/satisfies.js deleted file mode 100644 index 51cf8946..00000000 --- a/test/ranges/satisfies.js +++ /dev/null @@ -1,247 +0,0 @@ -const { test } = require('tap') -const { satisfies } = require('../../classes/range') - -test('range tests', (t) => { - // [range, version] - // version should be included by range - [['1.0.0 - 2.0.0', '1.2.3'], - ['^1.2.3+build', '1.2.3'], - ['^1.2.3+build', '1.3.0'], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'], - ['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true], - ['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true], - ['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'], - ['1.2.3+asdf - 2.4.3+asdf', '1.2.3'], - ['1.0.0', '1.0.0'], - ['>=*', '0.2.4'], - ['', '1.0.0'], - ['*', '1.2.3', {}], - ['*', 'v1.2.3', { loose: 123 }], - ['>=1.0.0', '1.0.0', /asdf/], - ['>=1.0.0', '1.0.1', { loose: null }], - ['>=1.0.0', '1.1.0', { loose: 0 }], - ['>1.0.0', '1.0.1', { loose: undefined }], - ['>1.0.0', '1.1.0'], - ['<=2.0.0', '2.0.0'], - ['<=2.0.0', '1.9999.9999'], - ['<=2.0.0', '0.2.9'], - ['<2.0.0', '1.9999.9999'], - ['<2.0.0', '0.2.9'], - ['>= 1.0.0', '1.0.0'], - ['>= 1.0.0', '1.0.1'], - ['>= 1.0.0', '1.1.0'], - ['> 1.0.0', '1.0.1'], - ['> 1.0.0', '1.1.0'], - ['<= 2.0.0', '2.0.0'], - ['<= 2.0.0', '1.9999.9999'], - ['<= 2.0.0', '0.2.9'], - ['< 2.0.0', '1.9999.9999'], - ['<\t2.0.0', '0.2.9'], - ['>=0.1.97', 'v0.1.97', true], - ['>=0.1.97', '0.1.97'], - ['0.1.20 || 1.2.4', '1.2.4'], - ['>=0.2.3 || <0.0.1', '0.0.0'], - ['>=0.2.3 || <0.0.1', '0.2.3'], - ['>=0.2.3 || <0.0.1', '0.2.4'], - ['||', '1.3.4'], - ['2.x.x', '2.1.3'], - ['1.2.x', '1.2.3'], - ['1.2.x || 2.x', '2.1.3'], - ['1.2.x || 2.x', '1.2.3'], - ['x', '1.2.3'], - ['2.*.*', '2.1.3'], - ['1.2.*', '1.2.3'], - ['1.2.* || 2.*', '2.1.3'], - ['1.2.* || 2.*', '1.2.3'], - ['*', '1.2.3'], - ['2', '2.1.2'], - ['2.3', '2.3.1'], - ['~0.0.1', '0.0.1'], - ['~0.0.1', '0.0.2'], - ['~x', '0.0.9'], // >=2.4.0 <2.5.0 - ['~2', '2.0.9'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.5'], - ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0, - ['~1', '1.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '1.2.3'], - ['~> 1', '1.2.3'], - ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0, - ['~ 1.0', '1.0.2'], - ['~ 1.0.3', '1.0.12'], - ['~ 1.0.3alpha', '1.0.12', { loose: true }], - ['>=1', '1.0.0'], - ['>= 1', '1.0.0'], - ['<1.2', '1.1.1'], - ['< 1.2', '1.1.1'], - ['~v0.5.4-pre', '0.5.5'], - ['~v0.5.4-pre', '0.5.4'], - ['=0.7.x', '0.7.2'], - ['<=0.7.x', '0.7.2'], - ['>=0.7.x', '0.7.2'], - ['<=0.7.x', '0.6.2'], - ['~1.2.1 >=1.2.3', '1.2.3'], - ['~1.2.1 =1.2.3', '1.2.3'], - ['~1.2.1 1.2.3', '1.2.3'], - ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'], - ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'], - ['~1.2.1 1.2.3', '1.2.3'], - ['>=1.2.1 1.2.3', '1.2.3'], - ['1.2.3 >=1.2.1', '1.2.3'], - ['>=1.2.3 >=1.2.1', '1.2.3'], - ['>=1.2.1 >=1.2.3', '1.2.3'], - ['>=1.2', '1.2.8'], - ['^1.2.3', '1.8.1'], - ['^0.1.2', '0.1.2'], - ['^0.1', '0.1.2'], - ['^0.0.1', '0.0.1'], - ['^1.2', '1.4.2'], - ['^1.2 ^1', '1.4.2'], - ['^1.2.3-alpha', '1.2.3-pre'], - ['^1.2.0-alpha', '1.2.0-pre'], - ['^0.0.1-alpha', '0.0.1-beta'], - ['^0.0.1-alpha', '0.0.1'], - ['^0.1.1-alpha', '0.1.1-beta'], - ['^x', '1.2.3'], - ['x - 1.0.0', '0.9.7'], - ['x - 1.x', '0.9.7'], - ['1.0.0 - x', '1.9.7'], - ['1.x - x', '1.9.7'], - ['<=7.x', '7.9.9'], - ['2.x', '2.0.0-pre.0', { includePrerelease: true }], - ['2.x', '2.1.0-pre.0', { includePrerelease: true }], - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = v[2] - t.ok(satisfies(ver, range, options), `${range } satisfied by ${ ver}`) - }) - t.end() - }) - - test('negative range tests', (t) => { - // [range, version] - // version should not be included by range - [['1.0.0 - 2.0.0', '2.2.3'], - ['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'], - ['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'], - ['^1.2.3+build', '2.0.0'], - ['^1.2.3+build', '1.2.0'], - ['^1.2.3', '1.2.3-pre'], - ['^1.2', '1.2.0-pre'], - ['>1.2', '1.3.0-beta'], - ['<=1.2.3', '1.2.3-beta'], - ['^1.2.3', '1.2.3-beta'], - ['=0.7.x', '0.7.0-asdf'], - ['>=0.7.x', '0.7.0-asdf'], - ['1', '1.0.0beta', { loose: 420 }], - ['<1', '1.0.0beta', true], - ['< 1', '1.0.0beta', true], - ['1.0.0', '1.0.1'], - ['>=1.0.0', '0.0.0'], - ['>=1.0.0', '0.0.1'], - ['>=1.0.0', '0.1.0'], - ['>1.0.0', '0.0.1'], - ['>1.0.0', '0.1.0'], - ['<=2.0.0', '3.0.0'], - ['<=2.0.0', '2.9999.9999'], - ['<=2.0.0', '2.2.9'], - ['<2.0.0', '2.9999.9999'], - ['<2.0.0', '2.2.9'], - ['>=0.1.97', 'v0.1.93', true], - ['>=0.1.97', '0.1.93'], - ['0.1.20 || 1.2.4', '1.2.3'], - ['>=0.2.3 || <0.0.1', '0.0.3'], - ['>=0.2.3 || <0.0.1', '0.2.2'], - ['2.x.x', '1.1.3', { loose: NaN }], - ['2.x.x', '3.1.3'], - ['1.2.x', '1.3.3'], - ['1.2.x || 2.x', '3.1.3'], - ['1.2.x || 2.x', '1.1.3'], - ['2.*.*', '1.1.3'], - ['2.*.*', '3.1.3'], - ['1.2.*', '1.3.3'], - ['1.2.* || 2.*', '3.1.3'], - ['1.2.* || 2.*', '1.1.3'], - ['2', '1.1.2'], - ['2.3', '2.4.1'], - ['~0.0.1', '0.1.0-alpha'], - ['~0.0.1', '0.1.0'], - ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.3.9'], - ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 - ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 - ['~1', '0.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '2.2.3'], - ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 - ['<1', '1.0.0'], - ['>=1.2', '1.1.1'], - ['1', '2.0.0beta', true], - ['~v0.5.4-beta', '0.5.4-alpha'], - ['=0.7.x', '0.8.2'], - ['>=0.7.x', '0.6.2'], - ['<0.7.x', '0.7.2'], - ['<1.2.3', '1.2.3-beta'], - ['=1.2.3', '1.2.3-beta'], - ['>1.2', '1.2.8'], - ['^0.0.1', '0.0.2-alpha'], - ['^0.0.1', '0.0.2'], - ['^1.2.3', '2.0.0-alpha'], - ['^1.2.3', '1.2.2'], - ['^1.2', '1.1.9'], - ['*', 'v1.2.3-foo', true], - // invalid ranges never satisfied! - ['blerg', '1.2.3'], - ['git+https://user:password0123@github.com/foo', '123.0.0', true], - ['^1.2.3', '2.0.0-pre'], - ['0.x', undefined], - ['*', undefined], - // invalid versions never satisfy, but shouldn't throw - ['*', 'not a version'], - ['>=2', 'glorp'], - ['2.x', '3.0.0-pre.0', { includePrerelease: true }], - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = v[2] - const found = satisfies(ver, range, options) - t.ok(!found, `${ver } not satisfied by ${ range}`) - }) - t.end() - }) - - test('unlocked prerelease range tests', (t) => { - // [range, version] - // version should be included by range - [['*', '1.0.0-rc1'], - ['^1.0.0', '2.0.0-rc1'], - ['^1.0.0-0', '1.0.1-rc1'], - ['^1.0.0-rc2', '1.0.1-rc1'], - ['^1.0.0', '1.0.1-rc1'], - ['^1.0.0', '1.1.0-rc1'] - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = { includePrerelease: true } - t.ok(satisfies(ver, range, options), `${range } satisfied by ${ ver}`) - }) - t.end() - }) - - test('negative unlocked prerelease range tests', (t) => { - // [range, version] - // version should not be included by range - [['^1.0.0', '1.0.0-rc1'], - ['^1.2.3-rc2', '2.0.0'] - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = { includePrerelease: true } - const found = satisfies(ver, range, options) - t.ok(!found, `${ver } not satisfied by ${ range}`) - }) - t.end() - }) - \ No newline at end of file diff --git a/test/ranges/to-comparators.js b/test/ranges/to-comparators.js index da8f99e2..661d5389 100644 --- a/test/ranges/to-comparators.js +++ b/test/ranges/to-comparators.js @@ -73,13 +73,11 @@ test('comparators test', (t) => { ['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]], ['>*', [['<0.0.0-0']]], ['<*', [['<0.0.0-0']]] - ].forEach((v) => { - const pre = v[0] - const wanted = v[1] - const found = toComparators(v[0]) + ].forEach(([pre, wanted]) => { + const found = toComparators(pre) const jw = JSON.stringify(wanted) - t.equivalent(found, wanted, `toComparators(${ pre }) === ${ jw}`) + t.equivalent(found, wanted, `toComparators(${pre}) === ${jw}`) }) t.end() -}) \ No newline at end of file +}) diff --git a/test/ranges/valid-range.js b/test/ranges/valid-range.js index f7689332..238164c8 100644 --- a/test/ranges/valid-range.js +++ b/test/ranges/valid-range.js @@ -83,8 +83,8 @@ test('valid range test', (t) => { const loose = v[2] const found = validRange(pre, loose) - t.equal(found, wanted, `validRange(${ pre }) === ${ wanted}`) + t.equal(found, wanted, `validRange(${pre}) === ${wanted}`) }) t.end() -}) \ No newline at end of file +}) From 18c21b242d0b4e54c4bdd677fbadbade18187d95 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 22 Nov 2019 10:01:24 -0800 Subject: [PATCH 05/44] comparator test coverage to 100% --- test/classes/comparator.js | 42 ++++++ test/classes/range.js | 25 ++++ test/fixtures/comparator-intersection.js | 36 +++++ test/fixtures/range-intersection.js | 57 +++++++ test/ranges/intersects.js | 182 +++++------------------ 5 files changed, 196 insertions(+), 146 deletions(-) create mode 100644 test/fixtures/comparator-intersection.js create mode 100644 test/fixtures/range-intersection.js diff --git a/test/classes/comparator.js b/test/classes/comparator.js index 1faaaa49..84f1e566 100644 --- a/test/classes/comparator.js +++ b/test/classes/comparator.js @@ -1,5 +1,6 @@ const { test } = require('tap') const Comparator = require('../../classes/comparator') +const comparatorIntersection = require('../fixtures/comparator-intersection.js') test('comparator testing', t => { const c = new Comparator('>=1.2.3') @@ -18,3 +19,44 @@ test('tostrings', (t) => { t.equal(new Comparator('>= v1.2.3').toString(), '>=1.2.3') t.end() }) + +test('intersect comparators', (t) => { + t.plan(comparatorIntersection.length) + comparatorIntersection.forEach(([c0, c1, expect]) => t.test(`${c0} ${c1} ${expect}`, t => { + const comp0 = new Comparator(c0) + const comp1 = new Comparator(c1) + + t.equal(comp0.intersects(comp1, false), expect, + `${c0} intersects ${c1}`) + + t.equal(comp1.intersects(comp0, { loose: false }), expect, + `${c1} intersects ${c0}`) + t.end() + })) +}) + +test('intersect demands another comparator', t => { + const c = new Comparator('>=1.2.3') + t.throws(() => c.intersects(), new TypeError('a Comparator is required')) + t.end() +}) + +test('ANY matches anything', t => { + const c = new Comparator('') + t.ok(c.test('1.2.3'), 'ANY matches anything') + const c1 = new Comparator('>=1.2.3') + const ANY = Comparator.ANY + t.ok(c.test(ANY), 'anything matches ANY') + t.end() +}) + +test('invalid comparator parse throws', t => { + t.throws(() => new Comparator('foo bar baz'), + new TypeError('Invalid comparator: foo bar baz')) + t.end() +}) + +test('= is ignored', t => { + t.match(new Comparator('=1.2.3'), new Comparator('1.2.3')) + t.end() +}) diff --git a/test/classes/range.js b/test/classes/range.js index 5c70fb58..91979d3b 100644 --- a/test/classes/range.js +++ b/test/classes/range.js @@ -1,5 +1,6 @@ const { test } = require('tap') const Range = require('../../classes/range') +const rangeIntersection = require('../fixtures/range-intersection.js') test('strict vs loose ranges', (t) => { [ @@ -16,3 +17,27 @@ test('tostrings', (t) => { t.equal(new Range('>= v1.2.3').toString(), '>=1.2.3') t.end() }) + +test('ranges intersect', (t) => { + rangeIntersection.forEach(([r0, r1, expect]) => { + t.test(`${r0} <~> ${r1}`, t => { + const range0 = new Range(r0) + const range1 = new Range(r1) + + t.equal(range0.intersects(range1), expect, + `${r0} <~> ${r1} objects`) + t.equal(range1.intersects(range0), expect, + `${r1} <~> ${r0} objects`) + t.end() + }) + }) + t.end() +}) + +test('missing range parameter in range intersect', (t) => { + t.throws(() => { + new Range('1.0.0').intersects() + }, new TypeError('a Range is required'), + 'throws type error') + t.end() +}) diff --git a/test/fixtures/comparator-intersection.js b/test/fixtures/comparator-intersection.js new file mode 100644 index 00000000..e95cb205 --- /dev/null +++ b/test/fixtures/comparator-intersection.js @@ -0,0 +1,36 @@ +// c0, c1, expected interesection +module.exports = [ + // One is a Version + ['1.3.0', '>=1.3.0', true], + ['1.3.0', '>1.3.0', false], + ['>=1.3.0', '1.3.0', true], + ['>1.3.0', '1.3.0', false], + // Same direction increasing + ['>1.3.0', '>1.2.0', true], + ['>1.2.0', '>1.3.0', true], + ['>=1.2.0', '>1.3.0', true], + ['>1.2.0', '>=1.3.0', true], + // Same direction decreasing + ['<1.3.0', '<1.2.0', true], + ['<1.2.0', '<1.3.0', true], + ['<=1.2.0', '<1.3.0', true], + ['<1.2.0', '<=1.3.0', true], + // Different directions, same semver and inclusive operator + ['>=1.3.0', '<=1.3.0', true], + ['>=v1.3.0', '<=1.3.0', true], + ['>=1.3.0', '>=1.3.0', true], + ['<=1.3.0', '<=1.3.0', true], + ['<=1.3.0', '<=v1.3.0', true], + ['>1.3.0', '<=1.3.0', false], + ['>=1.3.0', '<1.3.0', false], + // Opposite matching directions + ['>1.0.0', '<2.0.0', true], + ['>=1.0.0', '<2.0.0', true], + ['>=1.0.0', '<=2.0.0', true], + ['>1.0.0', '<=2.0.0', true], + ['<=2.0.0', '>1.0.0', true], + ['<=1.0.0', '>=2.0.0', false], + ['', '', true], + ['', '>1.0.0', true], + ['<=2.0.0', '', true], +] diff --git a/test/fixtures/range-intersection.js b/test/fixtures/range-intersection.js new file mode 100644 index 00000000..e46c82ac --- /dev/null +++ b/test/fixtures/range-intersection.js @@ -0,0 +1,57 @@ +// r0, r1, expected intersection +module.exports = [ + ['1.3.0 || <1.0.0 >2.0.0', '1.3.0 || <1.0.0 >2.0.0', true], + ['<1.0.0 >2.0.0', '>0.0.0', false], + ['>0.0.0', '<1.0.0 >2.0.0', false], + ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0', false], + ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], + ['>1.0.0 <=2.0.0', '2.0.0', true], + ['<1.0.0 >=2.0.0', '2.1.0', false], + ['<1.0.0 >=2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], + ['1.5.x', '<1.5.0 || >=1.6.0', false], + ['<1.5.0 || >=1.6.0', '1.5.x', false], + ['<1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', false], + ['<=1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', true], + ['>=1.0.0', '<=1.0.0', true], + ['>1.0.0 <1.0.0', '<=0.0.0', false], + ['*', '0.0.1', true], + ['*', '>=1.0.0', true], + ['*', '>1.0.0', true], + ['*', '~1.0.0', true], + ['*', '<1.6.0', true], + ['*', '<=1.6.0', true], + ['1.*', '0.0.1', false], + ['1.*', '2.0.0', false], + ['1.*', '1.0.0', true], + ['1.*', '<2.0.0', true], + ['1.*', '>1.0.0', true], + ['1.*', '<=1.0.0', true], + ['1.*', '^1.0.0', true], + ['1.0.*', '0.0.1', false], + ['1.0.*', '<0.0.1', false], + ['1.0.*', '>0.0.1', true], + ['*', '1.3.0 || <1.0.0 >2.0.0', true], + ['1.3.0 || <1.0.0 >2.0.0', '*', true], + ['1.*', '1.3.0 || <1.0.0 >2.0.0', true], + ['x', '0.0.1', true], + ['x', '>=1.0.0', true], + ['x', '>1.0.0', true], + ['x', '~1.0.0', true], + ['x', '<1.6.0', true], + ['x', '<=1.6.0', true], + ['1.x', '0.0.1', false], + ['1.x', '2.0.0', false], + ['1.x', '1.0.0', true], + ['1.x', '<2.0.0', true], + ['1.x', '>1.0.0', true], + ['1.x', '<=1.0.0', true], + ['1.x', '^1.0.0', true], + ['1.0.x', '0.0.1', false], + ['1.0.x', '<0.0.1', false], + ['1.0.x', '>0.0.1', true], + ['x', '1.3.0 || <1.0.0 >2.0.0', true], + ['1.3.0 || <1.0.0 >2.0.0', 'x', true], + ['1.x', '1.3.0 || <1.0.0 >2.0.0', true], + ['*', '*', true], + ['x', '', true] +] diff --git a/test/ranges/intersects.js b/test/ranges/intersects.js index a6b1e53b..e93492b7 100644 --- a/test/ranges/intersects.js +++ b/test/ranges/intersects.js @@ -2,149 +2,47 @@ const { test } = require('tap') const intersects = require('../../ranges/intersects') const Range = require('../../classes/range') const Comparator = require('../../classes/comparator') +const comparatorIntersection = require('../fixtures/comparator-intersection.js') +const rangeIntersection = require('../fixtures/range-intersection.js') -test('intersect comparators', (t) => { - [ - // One is a Version - ['1.3.0', '>=1.3.0', true], - ['1.3.0', '>1.3.0', false], - ['>=1.3.0', '1.3.0', true], - ['>1.3.0', '1.3.0', false], - // Same direction increasing - ['>1.3.0', '>1.2.0', true], - ['>1.2.0', '>1.3.0', true], - ['>=1.2.0', '>1.3.0', true], - ['>1.2.0', '>=1.3.0', true], - // Same direction decreasing - ['<1.3.0', '<1.2.0', true], - ['<1.2.0', '<1.3.0', true], - ['<=1.2.0', '<1.3.0', true], - ['<1.2.0', '<=1.3.0', true], - // Different directions, same semver and inclusive operator - ['>=1.3.0', '<=1.3.0', true], - ['>=v1.3.0', '<=1.3.0', true], - ['>=1.3.0', '>=1.3.0', true], - ['<=1.3.0', '<=1.3.0', true], - ['<=1.3.0', '<=v1.3.0', true], - ['>1.3.0', '<=1.3.0', false], - ['>=1.3.0', '<1.3.0', false], - // Opposite matching directions - ['>1.0.0', '<2.0.0', true], - ['>=1.0.0', '<2.0.0', true], - ['>=1.0.0', '<=2.0.0', true], - ['>1.0.0', '<=2.0.0', true], - ['<=2.0.0', '>1.0.0', true], - ['<=1.0.0', '>=2.0.0', false] - ].forEach((v) => { - const comparator1 = new Comparator(v[0]) - const comparator2 = new Comparator(v[1]) - const expect = v[2] +test('intersect comparators', t => { + t.plan(comparatorIntersection.length) + comparatorIntersection.forEach(([c0, c1, expect]) => t.test(`${c0} ${c1} ${expect}`, t => { + const comp0 = new Comparator(c0) + const comp1 = new Comparator(c1) - const actual1 = comparator1.intersects(comparator2, false) - const actual2 = comparator2.intersects(comparator1, { loose: false }) - const actual3 = intersects(comparator1, comparator2) - const actual4 = intersects(comparator2, comparator1) - const actual5 = intersects(comparator1, comparator2, true) - const actual6 = intersects(comparator2, comparator1, true) - const actual7 = intersects(v[0], v[1]) - const actual8 = intersects(v[1], v[0]) - const actual9 = intersects(v[0], v[1], true) - const actual10 = intersects(v[1], v[0], true) - t.equal(actual1, expect) - t.equal(actual2, expect) - t.equal(actual3, expect) - t.equal(actual4, expect) - t.equal(actual5, expect) - t.equal(actual6, expect) - t.equal(actual7, expect) - t.equal(actual8, expect) - t.equal(actual9, expect) - t.equal(actual10, expect) - }) - t.end() + t.equal(intersects(comp0, comp1), expect, `${c0} intersects ${c1} objects`) + t.equal(intersects(comp1, comp0), expect, `${c1} intersects ${c0} objects`) + t.equal(intersects(comp0, comp1, true), expect, + `${c0} intersects ${c1} loose, objects`) + t.equal(intersects(comp1, comp0, true), expect, + `${c1} intersects ${c0} loose, objects`) + t.equal(intersects(c0, c1), expect, `${c0} intersects ${c1}`) + t.equal(intersects(c1, c0), expect, `${c1} intersects ${c0}`) + t.equal(intersects(c0, c1, true), expect, + `${c0} intersects ${c1} loose`) + t.equal(intersects(c1, c0, true), expect, + `${c1} intersects ${c0} loose`) + t.end() + })) }) test('ranges intersect', (t) => { - [ - ['1.3.0 || <1.0.0 >2.0.0', '1.3.0 || <1.0.0 >2.0.0', true], - ['<1.0.0 >2.0.0', '>0.0.0', false], - ['>0.0.0', '<1.0.0 >2.0.0', false], - ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0', false], - ['<1.0.0 >2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], - ['>1.0.0 <=2.0.0', '2.0.0', true], - ['<1.0.0 >=2.0.0', '2.1.0', false], - ['<1.0.0 >=2.0.0', '>1.4.0 <1.6.0 || 2.0.0', false], - ['1.5.x', '<1.5.0 || >=1.6.0', false], - ['<1.5.0 || >=1.6.0', '1.5.x', false], - ['<1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', false], - ['<=1.6.16 || >=1.7.0 <1.7.11 || >=1.8.0 <1.8.2', '>=1.6.16 <1.7.0 || >=1.7.11 <1.8.0 || >=1.8.2', true], - ['>=1.0.0', '<=1.0.0', true], - ['>1.0.0 <1.0.0', '<=0.0.0', false], - ['*', '0.0.1', true], - ['*', '>=1.0.0', true], - ['*', '>1.0.0', true], - ['*', '~1.0.0', true], - ['*', '<1.6.0', true], - ['*', '<=1.6.0', true], - ['1.*', '0.0.1', false], - ['1.*', '2.0.0', false], - ['1.*', '1.0.0', true], - ['1.*', '<2.0.0', true], - ['1.*', '>1.0.0', true], - ['1.*', '<=1.0.0', true], - ['1.*', '^1.0.0', true], - ['1.0.*', '0.0.1', false], - ['1.0.*', '<0.0.1', false], - ['1.0.*', '>0.0.1', true], - ['*', '1.3.0 || <1.0.0 >2.0.0', true], - ['1.3.0 || <1.0.0 >2.0.0', '*', true], - ['1.*', '1.3.0 || <1.0.0 >2.0.0', true], - ['x', '0.0.1', true], - ['x', '>=1.0.0', true], - ['x', '>1.0.0', true], - ['x', '~1.0.0', true], - ['x', '<1.6.0', true], - ['x', '<=1.6.0', true], - ['1.x', '0.0.1', false], - ['1.x', '2.0.0', false], - ['1.x', '1.0.0', true], - ['1.x', '<2.0.0', true], - ['1.x', '>1.0.0', true], - ['1.x', '<=1.0.0', true], - ['1.x', '^1.0.0', true], - ['1.0.x', '0.0.1', false], - ['1.0.x', '<0.0.1', false], - ['1.0.x', '>0.0.1', true], - ['x', '1.3.0 || <1.0.0 >2.0.0', true], - ['1.3.0 || <1.0.0 >2.0.0', 'x', true], - ['1.x', '1.3.0 || <1.0.0 >2.0.0', true], - ['*', '*', true], - ['x', '', true] - ].forEach((v) => { - t.test(`${v[0]} <~> ${v[1]}`, t => { - const range1 = new Range(v[0]) - const range2 = new Range(v[1]) - const expect = v[2] - const actual1 = range1.intersects(range2) - const actual2 = range2.intersects(range1) - const actual3 = intersects(v[1], v[0]) - const actual4 = intersects(v[0], v[1]) - const actual5 = intersects(v[1], v[0], true) - const actual6 = intersects(v[0], v[1], true) - const actual7 = intersects(range1, range2) - const actual8 = intersects(range2, range1) - const actual9 = intersects(range1, range2, true) - const actual0 = intersects(range2, range1, true) - t.equal(actual1, expect) - t.equal(actual2, expect) - t.equal(actual3, expect) - t.equal(actual4, expect) - t.equal(actual5, expect) - t.equal(actual6, expect) - t.equal(actual7, expect) - t.equal(actual8, expect) - t.equal(actual9, expect) - t.equal(actual0, expect) + rangeIntersection.forEach(([r0, r1, expect]) => { + t.test(`${r0} <~> ${r1}`, t => { + const range0 = new Range(r0) + const range1 = new Range(r1) + + t.equal(intersects(r1, r0), expect, `${r0} <~> ${r1}`) + t.equal(intersects(r0, r1), expect, `${r1} <~> ${r0}`) + t.equal(intersects(r1, r0, true), expect, `${r0} <~> ${r1} loose`) + t.equal(intersects(r0, r1, true), expect, `${r1} <~> ${r0} loose`) + t.equal(intersects(range0, range1), expect, `${r0} <~> ${r1} objects`) + t.equal(intersects(range1, range0), expect, `${r1} <~> ${r0} objects`) + t.equal(intersects(range0, range1, true), expect, + `${r0} <~> ${r1} objects loose`) + t.equal(intersects(range1, range0, true), expect, + `${r1} <~> ${r0} objects loose`) t.end() }) }) @@ -158,11 +56,3 @@ test('missing comparator parameter in intersect comparators', (t) => { 'throws type error') t.end() }) - -test('missing range parameter in range intersect', (t) => { - t.throws(() => { - new Range('1.0.0').intersects() - }, new TypeError('a Range is required'), - 'throws type error') - t.end() -}) From d31381d4e227e63542977b995d1e35be1d2bd81f Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 22 Nov 2019 10:54:26 -0800 Subject: [PATCH 06/44] range class test coverage to 100 --- classes/range.js | 16 ++- test/classes/range.js | 64 +++++++++ test/fixtures/range-exclude.js | 81 +++++++++++ test/fixtures/range-include.js | 118 +++++++++++++++ test/fixtures/range-parse.js | 85 +++++++++++ test/functions/satisfies.js | 252 +++------------------------------ test/ranges/valid-range.js | 88 +----------- 7 files changed, 380 insertions(+), 324 deletions(-) create mode 100644 test/fixtures/range-exclude.js create mode 100644 test/fixtures/range-include.js create mode 100644 test/fixtures/range-parse.js diff --git a/classes/range.js b/classes/range.js index b05b8537..90876c38 100644 --- a/classes/range.js +++ b/classes/range.js @@ -20,7 +20,11 @@ class Range { } if (range instanceof Comparator) { - return new Range(range.value, options) + // just put it in the set and return + this.raw = range.value + this.set = [[range]] + this.format() + return this } this.options = options @@ -31,11 +35,12 @@ class Range { this.raw = range this.set = range .split(/\s*\|\|\s*/) + // map the range to a 2d array of comparators .map(range => this.parseRange(range.trim())) - .filter((c) => { - // throw out any that are not relevant for whatever reason - return c.length - }) + // 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}`) @@ -331,7 +336,6 @@ const replaceXRange = (comp, options) => { if (gtlt === '>') { // >1 => >=2.0.0 // >1.2 => >=1.3.0 - // >1.2.3 => >= 1.2.4 gtlt = '>=' if (xm) { M = +M + 1 diff --git a/test/classes/range.js b/test/classes/range.js index 91979d3b..267fa80b 100644 --- a/test/classes/range.js +++ b/test/classes/range.js @@ -1,7 +1,71 @@ const { test } = require('tap') const Range = require('../../classes/range') +const Comparator = require('../../classes/comparator') const rangeIntersection = require('../fixtures/range-intersection.js') +const rangeInclude = require('../fixtures/range-include.js') +const rangeExclude = require('../fixtures/range-exclude.js') +const rangeParse = require('../fixtures/range-parse.js') + +test('range tests', t => { + t.plan(rangeInclude.length) + rangeInclude.forEach(([range, ver, options]) => { + const r = new Range(range, options) + t.ok(r.test(ver), `${range} satisfied by ${ver}`) + }) +}) + +test('range parsing', t => { + t.plan(rangeParse.length) + rangeParse.forEach(([range, expect, options]) => t.test(`${range} ${expect}`, t => { + if (expect === null) + t.throws(() => new Range(range), TypeError, `invalid range: ${range}`) + else { + t.equal(new Range(range, options).range || '*', expect, + `${range} => ${expect}`) + t.equal(new Range(range, options).range, new Range(expect).range, + 'parsing both yields same result') + } + t.end() + })) +}) + +test('throw for empty comparator set, even in loose mode', t => { + t.throws(() => new Range('sadf||asdf', { loose: true }), + TypeError('Invalid SemVer Range: sadf||asdf')) + t.end() +}) + +test('convert comparator to range', t => { + const c = new Comparator('>=1.2.3') + const r = new Range(c) + t.equal(r.raw, c.value, 'created range from comparator') + t.end() +}) + +test('range as argument to range ctor', t => { + const loose = new Range('1.2.3', { loose: true }) + t.equal(new Range(loose, { loose: true }), loose, 'loose option') + t.equal(new Range(loose, true), loose, 'loose boolean') + t.notEqual(new Range(loose), loose, 'created new range if not matched') + + const incPre = new Range('1.2.3', {includePrerelease: true}) + t.equal(new Range(incPre, {includePrerelease: true}), incPre, + 'include prerelease, option match returns argument') + t.notEqual(new Range(incPre), incPre, + 'include prerelease, option mismatch does not return argument') + + t.end() +}) + +test('negative range tests', t => { + t.plan(rangeExclude.length) + rangeExclude.forEach(([range, ver, options]) => { + const r = new Range(range, options) + t.notOk(r.test(ver), `${range} not satisfied by ${ver}`) + }) +}) + test('strict vs loose ranges', (t) => { [ ['>=01.02.03', '>=1.2.3'], diff --git a/test/fixtures/range-exclude.js b/test/fixtures/range-exclude.js new file mode 100644 index 00000000..2d764bd4 --- /dev/null +++ b/test/fixtures/range-exclude.js @@ -0,0 +1,81 @@ +// [range, version, options] +// version should not be included by range +module.exports = [ + ['1.0.0 - 2.0.0', '2.2.3'], + ['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'], + ['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'], + ['^1.2.3+build', '2.0.0'], + ['^1.2.3+build', '1.2.0'], + ['^1.2.3', '1.2.3-pre'], + ['^1.2', '1.2.0-pre'], + ['>1.2', '1.3.0-beta'], + ['<=1.2.3', '1.2.3-beta'], + ['^1.2.3', '1.2.3-beta'], + ['=0.7.x', '0.7.0-asdf'], + ['>=0.7.x', '0.7.0-asdf'], + ['1', '1.0.0beta', { loose: 420 }], + ['<1', '1.0.0beta', true], + ['< 1', '1.0.0beta', true], + ['1.0.0', '1.0.1'], + ['>=1.0.0', '0.0.0'], + ['>=1.0.0', '0.0.1'], + ['>=1.0.0', '0.1.0'], + ['>1.0.0', '0.0.1'], + ['>1.0.0', '0.1.0'], + ['<=2.0.0', '3.0.0'], + ['<=2.0.0', '2.9999.9999'], + ['<=2.0.0', '2.2.9'], + ['<2.0.0', '2.9999.9999'], + ['<2.0.0', '2.2.9'], + ['>=0.1.97', 'v0.1.93', true], + ['>=0.1.97', '0.1.93'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['>=0.2.3 || <0.0.1', '0.0.3'], + ['>=0.2.3 || <0.0.1', '0.2.2'], + ['2.x.x', '1.1.3', { loose: NaN }], + ['2.x.x', '3.1.3'], + ['1.2.x', '1.3.3'], + ['1.2.x || 2.x', '3.1.3'], + ['1.2.x || 2.x', '1.1.3'], + ['2.*.*', '1.1.3'], + ['2.*.*', '3.1.3'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '3.1.3'], + ['1.2.* || 2.*', '1.1.3'], + ['2', '1.1.2'], + ['2.3', '2.4.1'], + ['~0.0.1', '0.1.0-alpha'], + ['~0.0.1', '0.1.0'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.3.9'], + ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 + ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.3'], + ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 + ['<1', '1.0.0'], + ['>=1.2', '1.1.1'], + ['1', '2.0.0beta', true], + ['~v0.5.4-beta', '0.5.4-alpha'], + ['=0.7.x', '0.8.2'], + ['>=0.7.x', '0.6.2'], + ['<0.7.x', '0.7.2'], + ['<1.2.3', '1.2.3-beta'], + ['=1.2.3', '1.2.3-beta'], + ['>1.2', '1.2.8'], + ['^0.0.1', '0.0.2-alpha'], + ['^0.0.1', '0.0.2'], + ['^1.2.3', '2.0.0-alpha'], + ['^1.2.3', '1.2.2'], + ['^1.2', '1.1.9'], + ['*', 'v1.2.3-foo', true], + + // invalid versions never satisfy, but shouldn't throw + ['*', 'not a version'], + ['>=2', 'glorp'], + ['>=2', false], + + ['2.x', '3.0.0-pre.0', { includePrerelease: true }], + ['^1.0.0', '1.0.0-rc1', { includePrerelease: true }], + ['^1.2.3-rc2', '2.0.0', { includePrerelease: true }], +] diff --git a/test/fixtures/range-include.js b/test/fixtures/range-include.js new file mode 100644 index 00000000..d523b2c7 --- /dev/null +++ b/test/fixtures/range-include.js @@ -0,0 +1,118 @@ +// [range, version, options] +// version should be included by range +module.exports = [ + ['1.0.0 - 2.0.0', '1.2.3'], + ['^1.2.3+build', '1.2.3'], + ['^1.2.3+build', '1.3.0'], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'], + ['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true], + ['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true], + ['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'], + ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'], + ['1.2.3+asdf - 2.4.3+asdf', '1.2.3'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0'], + ['*', '1.2.3', {}], + ['*', 'v1.2.3', { loose: 123 }], + ['>=1.0.0', '1.0.0', /asdf/], + ['>=1.0.0', '1.0.1', { loose: null }], + ['>=1.0.0', '1.1.0', { loose: 0 }], + ['>1.0.0', '1.0.1', { loose: undefined }], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97', true], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~0.0.1', '0.0.1'], + ['~0.0.1', '0.0.2'], + ['~x', '0.0.9'], // >=2.4.0 <2.5.0 + ['~2', '2.0.9'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0, + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0, + ['~ 1.0', '1.0.2'], + ['~ 1.0.3', '1.0.12'], + ['~ 1.0.3alpha', '1.0.12', { loose: true }], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['<=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['<=0.7.x', '0.6.2'], + ['~1.2.1 >=1.2.3', '1.2.3'], + ['~1.2.1 =1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'], + ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['>=1.2.1 1.2.3', '1.2.3'], + ['1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.1 >=1.2.3', '1.2.3'], + ['>=1.2', '1.2.8'], + ['^1.2.3', '1.8.1'], + ['^0.1.2', '0.1.2'], + ['^0.1', '0.1.2'], + ['^0.0.1', '0.0.1'], + ['^1.2', '1.4.2'], + ['^1.2 ^1', '1.4.2'], + ['^1.2.3-alpha', '1.2.3-pre'], + ['^1.2.0-alpha', '1.2.0-pre'], + ['^0.0.1-alpha', '0.0.1-beta'], + ['^0.0.1-alpha', '0.0.1'], + ['^0.1.1-alpha', '0.1.1-beta'], + ['^x', '1.2.3'], + ['x - 1.0.0', '0.9.7'], + ['x - 1.x', '0.9.7'], + ['1.0.0 - x', '1.9.7'], + ['1.x - x', '1.9.7'], + ['<=7.x', '7.9.9'], + ['2.x', '2.0.0-pre.0', { includePrerelease: true }], + ['2.x', '2.1.0-pre.0', { includePrerelease: true }], + ['*', '1.0.0-rc1', { includePrerelease: true }], + ['^1.0.0', '2.0.0-rc1', { includePrerelease: true }], + ['^1.0.0-0', '1.0.1-rc1', { includePrerelease: true }], + ['^1.0.0-rc2', '1.0.1-rc1', { includePrerelease: true }], + ['^1.0.0', '1.0.1-rc1', { includePrerelease: true }], + ['^1.0.0', '1.1.0-rc1', { includePrerelease: true }], +] diff --git a/test/fixtures/range-parse.js b/test/fixtures/range-parse.js new file mode 100644 index 00000000..a09c1f7d --- /dev/null +++ b/test/fixtures/range-parse.js @@ -0,0 +1,85 @@ +// [range, canonical result, options] +// null result means it's not a valid range +// '*' is the return value from functions.validRange(), but +// new Range().range will be '' in those cases +module.exports = [ + ['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], + ['1.0.0', '1.0.0', { loose: false }], + ['>=*', '*'], + ['', '*'], + ['*', '*'], + ['*', '*'], + ['>=1.0.0', '>=1.0.0'], + ['>1.0.0', '>1.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['1', '>=1.0.0 <2.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['<2.0.0', '<2.0.0'], + ['<2.0.0', '<2.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['> 1.0.0', '>1.0.0'], + ['> 1.0.0', '>1.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['< 2.0.0', '<2.0.0'], + ['<\t2.0.0', '<2.0.0'], + ['>=0.1.97', '>=0.1.97'], + ['>=0.1.97', '>=0.1.97'], + ['0.1.20 || 1.2.4', '0.1.20||1.2.4'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], + ['||', '||'], + ['2.x.x', '>=2.0.0 <3.0.0'], + ['1.2.x', '>=1.2.0 <1.3.0'], + ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['x', '*'], + ['2.*.*', '>=2.0.0 <3.0.0'], + ['1.2.*', '>=1.2.0 <1.3.0'], + ['1.2.* || 2.*', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['*', '*'], + ['2', '>=2.0.0 <3.0.0'], + ['2.3', '>=2.3.0 <2.4.0'], + ['~2.4', '>=2.4.0 <2.5.0'], + ['~2.4', '>=2.4.0 <2.5.0'], + ['~>3.2.1', '>=3.2.1 <3.3.0'], + ['~1', '>=1.0.0 <2.0.0'], + ['~>1', '>=1.0.0 <2.0.0'], + ['~> 1', '>=1.0.0 <2.0.0'], + ['~1.0', '>=1.0.0 <1.1.0'], + ['~ 1.0', '>=1.0.0 <1.1.0'], + ['^0', '>=0.0.0 <1.0.0'], + ['^ 1', '>=1.0.0 <2.0.0'], + ['^0.1', '>=0.1.0 <0.2.0'], + ['^1.0', '>=1.0.0 <2.0.0'], + ['^1.2', '>=1.2.0 <2.0.0'], + ['^0.0.1', '>=0.0.1 <0.0.2'], + ['^0.0.1-beta', '>=0.0.1-beta <0.0.2'], + ['^0.1.2', '>=0.1.2 <0.2.0'], + ['^1.2.3', '>=1.2.3 <2.0.0'], + ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0'], + ['<1', '<1.0.0'], + ['< 1', '<1.0.0'], + ['>=1', '>=1.0.0'], + ['>= 1', '>=1.0.0'], + ['<1.2', '<1.2.0'], + ['< 1.2', '<1.2.0'], + ['1', '>=1.0.0 <2.0.0'], + ['>01.02.03', '>1.2.3', true], + ['>01.02.03', null], + ['~1.2.3beta', '>=1.2.3-beta <1.3.0', { loose: true }], + ['~1.2.3beta', null], + ['^ 1.2 ^ 1', '>=1.2.0 <2.0.0 >=1.0.0 <2.0.0'], + ['1.2 - 3.4.5', '>=1.2.0 <=3.4.5'], + ['1.2.3 - 3.4', '>=1.2.3 <3.5.0'], + ['1.2 - 3.4', '>=1.2.0 <3.5.0'], + ['>1', '>=2.0.0'], + ['>1.2', '>=1.3.0'], + ['>X', '<0.0.0-0'], + [' { + t.plan(rangeInclude.length) + rangeInclude.forEach(([range, ver, options]) => + t.ok(satisfies(ver, range, options), `${range} satisfied by ${ver}`)) +}) -test('range tests', (t) => { - // [range, version] - // version should be included by range - [['1.0.0 - 2.0.0', '1.2.3'], - ['^1.2.3+build', '1.2.3'], - ['^1.2.3+build', '1.3.0'], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'], - ['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true], - ['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true], - ['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'], - ['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'], - ['1.2.3+asdf - 2.4.3+asdf', '1.2.3'], - ['1.0.0', '1.0.0'], - ['>=*', '0.2.4'], - ['', '1.0.0'], - ['*', '1.2.3', {}], - ['*', 'v1.2.3', { loose: 123 }], - ['>=1.0.0', '1.0.0', /asdf/], - ['>=1.0.0', '1.0.1', { loose: null }], - ['>=1.0.0', '1.1.0', { loose: 0 }], - ['>1.0.0', '1.0.1', { loose: undefined }], - ['>1.0.0', '1.1.0'], - ['<=2.0.0', '2.0.0'], - ['<=2.0.0', '1.9999.9999'], - ['<=2.0.0', '0.2.9'], - ['<2.0.0', '1.9999.9999'], - ['<2.0.0', '0.2.9'], - ['>= 1.0.0', '1.0.0'], - ['>= 1.0.0', '1.0.1'], - ['>= 1.0.0', '1.1.0'], - ['> 1.0.0', '1.0.1'], - ['> 1.0.0', '1.1.0'], - ['<= 2.0.0', '2.0.0'], - ['<= 2.0.0', '1.9999.9999'], - ['<= 2.0.0', '0.2.9'], - ['< 2.0.0', '1.9999.9999'], - ['<\t2.0.0', '0.2.9'], - ['>=0.1.97', 'v0.1.97', true], - ['>=0.1.97', '0.1.97'], - ['0.1.20 || 1.2.4', '1.2.4'], - ['>=0.2.3 || <0.0.1', '0.0.0'], - ['>=0.2.3 || <0.0.1', '0.2.3'], - ['>=0.2.3 || <0.0.1', '0.2.4'], - ['||', '1.3.4'], - ['2.x.x', '2.1.3'], - ['1.2.x', '1.2.3'], - ['1.2.x || 2.x', '2.1.3'], - ['1.2.x || 2.x', '1.2.3'], - ['x', '1.2.3'], - ['2.*.*', '2.1.3'], - ['1.2.*', '1.2.3'], - ['1.2.* || 2.*', '2.1.3'], - ['1.2.* || 2.*', '1.2.3'], - ['*', '1.2.3'], - ['2', '2.1.2'], - ['2.3', '2.3.1'], - ['~0.0.1', '0.0.1'], - ['~0.0.1', '0.0.2'], - ['~x', '0.0.9'], // >=2.4.0 <2.5.0 - ['~2', '2.0.9'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.4.5'], - ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0, - ['~1', '1.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '1.2.3'], - ['~> 1', '1.2.3'], - ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0, - ['~ 1.0', '1.0.2'], - ['~ 1.0.3', '1.0.12'], - ['~ 1.0.3alpha', '1.0.12', { loose: true }], - ['>=1', '1.0.0'], - ['>= 1', '1.0.0'], - ['<1.2', '1.1.1'], - ['< 1.2', '1.1.1'], - ['~v0.5.4-pre', '0.5.5'], - ['~v0.5.4-pre', '0.5.4'], - ['=0.7.x', '0.7.2'], - ['<=0.7.x', '0.7.2'], - ['>=0.7.x', '0.7.2'], - ['<=0.7.x', '0.6.2'], - ['~1.2.1 >=1.2.3', '1.2.3'], - ['~1.2.1 =1.2.3', '1.2.3'], - ['~1.2.1 1.2.3', '1.2.3'], - ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'], - ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'], - ['~1.2.1 1.2.3', '1.2.3'], - ['>=1.2.1 1.2.3', '1.2.3'], - ['1.2.3 >=1.2.1', '1.2.3'], - ['>=1.2.3 >=1.2.1', '1.2.3'], - ['>=1.2.1 >=1.2.3', '1.2.3'], - ['>=1.2', '1.2.8'], - ['^1.2.3', '1.8.1'], - ['^0.1.2', '0.1.2'], - ['^0.1', '0.1.2'], - ['^0.0.1', '0.0.1'], - ['^1.2', '1.4.2'], - ['^1.2 ^1', '1.4.2'], - ['^1.2.3-alpha', '1.2.3-pre'], - ['^1.2.0-alpha', '1.2.0-pre'], - ['^0.0.1-alpha', '0.0.1-beta'], - ['^0.0.1-alpha', '0.0.1'], - ['^0.1.1-alpha', '0.1.1-beta'], - ['^x', '1.2.3'], - ['x - 1.0.0', '0.9.7'], - ['x - 1.x', '0.9.7'], - ['1.0.0 - x', '1.9.7'], - ['1.x - x', '1.9.7'], - ['<=7.x', '7.9.9'], - ['2.x', '2.0.0-pre.0', { includePrerelease: true }], - ['2.x', '2.1.0-pre.0', { includePrerelease: true }] - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = v[2] - t.ok(satisfies(ver, range, options), `${range} satisfied by ${ver}`) - }) - t.end() +test('negative range tests', t => { + t.plan(rangeExclude.length) + rangeExclude.forEach(([range, ver, options]) => + t.notOk(satisfies(ver, range, options), `${range} not satisfied by ${ver}`)) }) -test('negative range tests', (t) => { - // [range, version] - // version should not be included by range - [['1.0.0 - 2.0.0', '2.2.3'], - ['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'], - ['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'], - ['^1.2.3+build', '2.0.0'], - ['^1.2.3+build', '1.2.0'], - ['^1.2.3', '1.2.3-pre'], - ['^1.2', '1.2.0-pre'], - ['>1.2', '1.3.0-beta'], - ['<=1.2.3', '1.2.3-beta'], - ['^1.2.3', '1.2.3-beta'], - ['=0.7.x', '0.7.0-asdf'], - ['>=0.7.x', '0.7.0-asdf'], - ['1', '1.0.0beta', { loose: 420 }], - ['<1', '1.0.0beta', true], - ['< 1', '1.0.0beta', true], - ['1.0.0', '1.0.1'], - ['>=1.0.0', '0.0.0'], - ['>=1.0.0', '0.0.1'], - ['>=1.0.0', '0.1.0'], - ['>1.0.0', '0.0.1'], - ['>1.0.0', '0.1.0'], - ['<=2.0.0', '3.0.0'], - ['<=2.0.0', '2.9999.9999'], - ['<=2.0.0', '2.2.9'], - ['<2.0.0', '2.9999.9999'], - ['<2.0.0', '2.2.9'], - ['>=0.1.97', 'v0.1.93', true], - ['>=0.1.97', '0.1.93'], - ['0.1.20 || 1.2.4', '1.2.3'], - ['>=0.2.3 || <0.0.1', '0.0.3'], - ['>=0.2.3 || <0.0.1', '0.2.2'], - ['2.x.x', '1.1.3', { loose: NaN }], - ['2.x.x', '3.1.3'], - ['1.2.x', '1.3.3'], - ['1.2.x || 2.x', '3.1.3'], - ['1.2.x || 2.x', '1.1.3'], - ['2.*.*', '1.1.3'], - ['2.*.*', '3.1.3'], - ['1.2.*', '1.3.3'], - ['1.2.* || 2.*', '3.1.3'], - ['1.2.* || 2.*', '1.1.3'], - ['2', '1.1.2'], - ['2.3', '2.4.1'], - ['~0.0.1', '0.1.0-alpha'], - ['~0.0.1', '0.1.0'], - ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 - ['~2.4', '2.3.9'], - ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 - ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 - ['~1', '0.2.3'], // >=1.0.0 <2.0.0 - ['~>1', '2.2.3'], - ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 - ['<1', '1.0.0'], - ['>=1.2', '1.1.1'], - ['1', '2.0.0beta', true], - ['~v0.5.4-beta', '0.5.4-alpha'], - ['=0.7.x', '0.8.2'], - ['>=0.7.x', '0.6.2'], - ['<0.7.x', '0.7.2'], - ['<1.2.3', '1.2.3-beta'], - ['=1.2.3', '1.2.3-beta'], - ['>1.2', '1.2.8'], - ['^0.0.1', '0.0.2-alpha'], - ['^0.0.1', '0.0.2'], - ['^1.2.3', '2.0.0-alpha'], - ['^1.2.3', '1.2.2'], - ['^1.2', '1.1.9'], - ['*', 'v1.2.3-foo', true], - // invalid ranges never satisfied! +test('invalid ranges never satisfied (but do not throw)', t => { + const cases = [ ['blerg', '1.2.3'], ['git+https://user:password0123@github.com/foo', '123.0.0', true], ['^1.2.3', '2.0.0-pre'], ['0.x', undefined], ['*', undefined], - // invalid versions never satisfy, but shouldn't throw - ['*', 'not a version'], - ['>=2', 'glorp'], - ['2.x', '3.0.0-pre.0', { includePrerelease: true }] - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = v[2] - const found = satisfies(ver, range, options) - t.ok(!found, `${ver} not satisfied by ${range}`) - }) - t.end() -}) - -test('unlocked prerelease range tests', (t) => { - // [range, version] - // version should be included by range - [['*', '1.0.0-rc1'], - ['^1.0.0', '2.0.0-rc1'], - ['^1.0.0-0', '1.0.1-rc1'], - ['^1.0.0-rc2', '1.0.1-rc1'], - ['^1.0.0', '1.0.1-rc1'], - ['^1.0.0', '1.1.0-rc1'] - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = { includePrerelease: true } - t.ok(satisfies(ver, range, options), `${range} satisfied by ${ver}`) - }) - t.end() -}) - -test('negative unlocked prerelease range tests', (t) => { - // [range, version] - // version should not be included by range - [['^1.0.0', '1.0.0-rc1'], - ['^1.2.3-rc2', '2.0.0'] - ].forEach((v) => { - const range = v[0] - const ver = v[1] - const options = { includePrerelease: true } - const found = satisfies(ver, range, options) - t.ok(!found, `${ver} not satisfied by ${range}`) - }) - t.end() + ] + t.plan(cases.length) + cases.forEach(([range, ver]) => + t.notOk(satisfies(ver, range), `${range} not satisfied because invalid`)) }) diff --git a/test/ranges/valid-range.js b/test/ranges/valid-range.js index 238164c8..515b4c19 100644 --- a/test/ranges/valid-range.js +++ b/test/ranges/valid-range.js @@ -1,90 +1,12 @@ const { test } = require('tap') const validRange = require('../../ranges/valid-range') +const rangeParse = require('../fixtures/range-parse.js') test('valid range test', (t) => { - // [range, result] // validRange(range) -> result // translate ranges into their canonical form - [['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], - ['1.0.0', '1.0.0'], - ['>=*', '*'], - ['', '*'], - ['*', '*'], - ['*', '*'], - ['>=1.0.0', '>=1.0.0'], - ['>1.0.0', '>1.0.0'], - ['<=2.0.0', '<=2.0.0'], - ['1', '>=1.0.0 <2.0.0'], - ['<=2.0.0', '<=2.0.0'], - ['<=2.0.0', '<=2.0.0'], - ['<2.0.0', '<2.0.0'], - ['<2.0.0', '<2.0.0'], - ['>= 1.0.0', '>=1.0.0'], - ['>= 1.0.0', '>=1.0.0'], - ['>= 1.0.0', '>=1.0.0'], - ['> 1.0.0', '>1.0.0'], - ['> 1.0.0', '>1.0.0'], - ['<= 2.0.0', '<=2.0.0'], - ['<= 2.0.0', '<=2.0.0'], - ['<= 2.0.0', '<=2.0.0'], - ['< 2.0.0', '<2.0.0'], - ['<\t2.0.0', '<2.0.0'], - ['>=0.1.97', '>=0.1.97'], - ['>=0.1.97', '>=0.1.97'], - ['0.1.20 || 1.2.4', '0.1.20||1.2.4'], - ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], - ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], - ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], - ['||', '||'], - ['2.x.x', '>=2.0.0 <3.0.0'], - ['1.2.x', '>=1.2.0 <1.3.0'], - ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], - ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], - ['x', '*'], - ['2.*.*', '>=2.0.0 <3.0.0'], - ['1.2.*', '>=1.2.0 <1.3.0'], - ['1.2.* || 2.*', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], - ['*', '*'], - ['2', '>=2.0.0 <3.0.0'], - ['2.3', '>=2.3.0 <2.4.0'], - ['~2.4', '>=2.4.0 <2.5.0'], - ['~2.4', '>=2.4.0 <2.5.0'], - ['~>3.2.1', '>=3.2.1 <3.3.0'], - ['~1', '>=1.0.0 <2.0.0'], - ['~>1', '>=1.0.0 <2.0.0'], - ['~> 1', '>=1.0.0 <2.0.0'], - ['~1.0', '>=1.0.0 <1.1.0'], - ['~ 1.0', '>=1.0.0 <1.1.0'], - ['^0', '>=0.0.0 <1.0.0'], - ['^ 1', '>=1.0.0 <2.0.0'], - ['^0.1', '>=0.1.0 <0.2.0'], - ['^1.0', '>=1.0.0 <2.0.0'], - ['^1.2', '>=1.2.0 <2.0.0'], - ['^0.0.1', '>=0.0.1 <0.0.2'], - ['^0.0.1-beta', '>=0.0.1-beta <0.0.2'], - ['^0.1.2', '>=0.1.2 <0.2.0'], - ['^1.2.3', '>=1.2.3 <2.0.0'], - ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0'], - ['<1', '<1.0.0'], - ['< 1', '<1.0.0'], - ['>=1', '>=1.0.0'], - ['>= 1', '>=1.0.0'], - ['<1.2', '<1.2.0'], - ['< 1.2', '<1.2.0'], - ['1', '>=1.0.0 <2.0.0'], - ['>01.02.03', '>1.2.3', true], - ['>01.02.03', null], - ['~1.2.3beta', '>=1.2.3-beta <1.3.0', true], - ['~1.2.3beta', null], - ['^ 1.2 ^ 1', '>=1.2.0 <2.0.0 >=1.0.0 <2.0.0'] - ].forEach((v) => { - const pre = v[0] - const wanted = v[1] - const loose = v[2] - const found = validRange(pre, loose) - - t.equal(found, wanted, `validRange(${pre}) === ${wanted}`) - }) - - t.end() + t.plan(rangeParse.length) + rangeParse.forEach(([pre, wanted, options]) => + t.equal(validRange(pre, options), wanted, + `validRange(${pre}) === ${wanted}`)) }) From d19d51eea1687981648af026b8605beb5478ba93 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 22 Nov 2019 10:57:28 -0800 Subject: [PATCH 07/44] remove duplicative naming. ranges/valid-range -> ranges/valid --- index.js | 2 +- ranges/{valid-range.js => valid.js} | 0 test/ranges/{valid-range.js => valid.js} | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename ranges/{valid-range.js => valid.js} (100%) rename test/ranges/{valid-range.js => valid.js} (87%) diff --git a/index.js b/index.js index 9be4fac8..068f8b4e 100644 --- a/index.js +++ b/index.js @@ -57,7 +57,7 @@ lazyExport('toComparators', './ranges/to-comparators') lazyExport('maxSatisfying', './ranges/max-satisfying') lazyExport('minSatisfying', './ranges/min-satisfying') lazyExport('minVersion', './ranges/min-version') -lazyExport('validRange', './ranges/valid-range') +lazyExport('validRange', './ranges/valid') lazyExport('outside', './ranges/outside') lazyExport('gtr', './ranges/gtr') lazyExport('ltr', './ranges/ltr') diff --git a/ranges/valid-range.js b/ranges/valid.js similarity index 100% rename from ranges/valid-range.js rename to ranges/valid.js diff --git a/test/ranges/valid-range.js b/test/ranges/valid.js similarity index 87% rename from test/ranges/valid-range.js rename to test/ranges/valid.js index 515b4c19..beee98d4 100644 --- a/test/ranges/valid-range.js +++ b/test/ranges/valid.js @@ -1,5 +1,5 @@ const { test } = require('tap') -const validRange = require('../../ranges/valid-range') +const validRange = require('../../ranges/valid') const rangeParse = require('../fixtures/range-parse.js') test('valid range test', (t) => { From b4b40cd3de836dddb168122944d494d929efed0f Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 22 Nov 2019 11:39:23 -0800 Subject: [PATCH 08/44] include sliced up files in package --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b095984..a1afaa6c 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,11 @@ "files": [ "bin", "range.bnf", - "semver.js" + "classes", + "functions", + "internal", + "ranges", + "index.js" ], "tap": { "check-coverage": true, From 166acc81b2488bf55d8e3c2a7b0e39c5971b36b8 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 22 Nov 2019 11:40:02 -0800 Subject: [PATCH 09/44] semver class test coverage to 100 --- classes/semver.js | 13 ++++- functions/inc.js | 10 ++-- test/classes/semver.js | 88 ++++++++++++++++++++++++++++ test/fixtures/increments.js | 85 +++++++++++++++++++++++++++ test/fixtures/invalid-versions.js | 15 +++++ test/functions/compare-build.js | 23 ++++---- test/functions/inc.js | 96 ++----------------------------- test/functions/parse.js | 14 ++--- test/functions/valid.js | 14 ++--- 9 files changed, 229 insertions(+), 129 deletions(-) create mode 100644 test/fixtures/increments.js create mode 100644 test/fixtures/invalid-versions.js diff --git a/classes/semver.js b/classes/semver.js index 3ab5b5bb..73247ad2 100644 --- a/classes/semver.js +++ b/classes/semver.js @@ -12,7 +12,8 @@ class SemVer { } } if (version instanceof SemVer) { - if (version.loose === options.loose) { + if (version.loose === !!options.loose && + version.includePrerelease === !!options.includePrerelease) { return version } else { version = version.version @@ -30,6 +31,9 @@ class SemVer { debug('SemVer', version, options) this.options = options this.loose = !!options.loose + // this isn't actually relevant for versions, but keep it so that we + // don't run into trouble passing this.options around. + this.includePrerelease = !!options.includePrerelease const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) @@ -90,9 +94,16 @@ class SemVer { compare (other) { debug('SemVer.compare', this.version, this.options, other) if (!(other instanceof SemVer)) { + if (typeof other === 'string' && other === this.version) { + return 0 + } other = new SemVer(other, this.options) } + if (other.version === this.version) { + return 0 + } + return this.compareMain(other) || this.comparePre(other) } diff --git a/functions/inc.js b/functions/inc.js index fc0fd92b..aa4d83ab 100644 --- a/functions/inc.js +++ b/functions/inc.js @@ -1,13 +1,13 @@ const SemVer = require('../classes/semver') -const inc = (version, release, loose, identifier) => { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined +const inc = (version, release, options, identifier) => { + if (typeof (options) === 'string') { + identifier = options + options = undefined } try { - return new SemVer(version, loose).inc(release, identifier).version + return new SemVer(version, options).inc(release, identifier).version } catch (er) { return null } diff --git a/test/classes/semver.js b/test/classes/semver.js index 775e87d4..2c2d1bae 100644 --- a/test/classes/semver.js +++ b/test/classes/semver.js @@ -1,5 +1,59 @@ const { test } = require('tap') const SemVer = require('../../classes/semver') +const increments = require('../fixtures/increments.js') +const comparisons = require('../fixtures/comparisons.js') +const equality = require('../fixtures/equality.js') +const invalidVersions = require('../fixtures/invalid-versions') + +test('comparisons', t => { + t.plan(comparisons.length) + comparisons.forEach(([v0, v1, opt]) => t.test(`${v0} ${v1}`, t => { + const s0 = new SemVer(v0, opt) + const s1 = new SemVer(v1, opt) + t.equal(s0.compare(s1), 1) + t.equal(s0.compare(v1), 1) + t.equal(s1.compare(s0), -1) + t.equal(s1.compare(v0), -1) + t.equal(s0.compare(v0), 0) + t.equal(s1.compare(v1), 0) + t.end() + })) +}) + +test('equality', t => { + t.plan(equality.length) + equality.forEach(([v0, v1, loose]) => t.test(`${v0} ${v1} ${loose}`, t => { + const s0 = new SemVer(v0, loose) + const s1 = new SemVer(v1, loose) + t.equal(s0.compare(s1), 0) + t.equal(s1.compare(s0), 0) + t.equal(s0.compare(v1), 0) + t.equal(s1.compare(v0), 0) + t.equal(s0.compare(s0), 0) + t.equal(s1.compare(s1), 0) + t.equal(s0.comparePre(s1), 0, 'comparePre just to hit that code path') + t.end() + })) +}) + +test('toString equals parsed version', t => { + t.equal(String(new SemVer('v1.2.3')), '1.2.3') + t.end() +}) + +test('throws when presented with garbage', t => { + t.plan(invalidVersions.length) + invalidVersions.forEach(([v, msg, opts]) => + t.throws(() => new SemVer(v, opts), msg)) +}) + +test('return SemVer arg to ctor if options match', t => { + const s = new SemVer('1.2.3', { loose: true, includePrerelease: true }) + t.equal(new SemVer(s, {loose: true, includePrerelease: true}), s, + 'get same object when options match') + t.notEqual(new SemVer(s), s, 'get new object when options match') + t.end() +}) test('really big numeric prerelease value', (t) => { const r = new SemVer(`1.2.3-beta.${Number.MAX_SAFE_INTEGER}0`) @@ -22,6 +76,23 @@ test('invalid version numbers', (t) => { t.end() }) +test('incrementing', t => { + t.plan(increments.length) + increments.forEach(([ + version, + inc, + expect, + options, + id, + ]) => t.test(`${version} ${inc} ${id || ''}`.trim(), t => { + t.plan(1) + if (expect === null) + t.throws(() => new SemVer(version, options).inc(inc, id)) + else + t.equal(new SemVer(version, options).inc(inc, id).version, expect) + })) +}) + test('compare main vs pre', (t) => { const s = new SemVer('1.2.3') t.equal(s.compareMain('2.3.4'), -1) @@ -53,3 +124,20 @@ test('invalid version numbers', (t) => { t.end() }) + +test('compareBuild', (t) => { + const noBuild = new SemVer('1.0.0') + const build0 = new SemVer('1.0.0+0') + const build1 = new SemVer('1.0.0+1') + const build10 = new SemVer('1.0.0+1.0') + t.equal(noBuild.compareBuild(build0), -1) + t.equal(build0.compareBuild(build0), 0) + t.equal(build0.compareBuild(noBuild), 1) + + t.equal(build0.compareBuild('1.0.0+0.0'), -1) + t.equal(build0.compareBuild(build1), -1) + t.equal(build1.compareBuild(build0), 1) + t.equal(build10.compareBuild(build1), 1) + + t.end() +}) diff --git a/test/fixtures/increments.js b/test/fixtures/increments.js new file mode 100644 index 00000000..e214f2ed --- /dev/null +++ b/test/fixtures/increments.js @@ -0,0 +1,85 @@ +// [version, inc, result, options, identifier] +// inc(version, inc) -> result +module.exports = [ + ['1.2.3', 'major', '2.0.0'], + ['1.2.3', 'minor', '1.3.0'], + ['1.2.3', 'patch', '1.2.4'], + ['1.2.3tag', 'major', '2.0.0', true], + ['1.2.3-tag', 'major', '2.0.0'], + ['1.2.3', 'fake', null], + ['1.2.0-0', 'patch', '1.2.0'], + ['fake', 'major', null], + ['1.2.3-4', 'major', '2.0.0'], + ['1.2.3-4', 'minor', '1.3.0'], + ['1.2.3-4', 'patch', '1.2.3'], + ['1.2.3-alpha.0.beta', 'major', '2.0.0'], + ['1.2.3-alpha.0.beta', 'minor', '1.3.0'], + ['1.2.3-alpha.0.beta', 'patch', '1.2.3'], + ['1.2.4', 'prerelease', '1.2.5-0'], + ['1.2.3-0', 'prerelease', '1.2.3-1'], + ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'], + ['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'], + ['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'], + ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'], + ['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'], + ['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'], + ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'], + ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'], + ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'], + ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'], + ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'], + ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'], + ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'], + ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'], + ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'], + ['1.2.0', 'prepatch', '1.2.1-0'], + ['1.2.0-1', 'prepatch', '1.2.1-0'], + ['1.2.0', 'preminor', '1.3.0-0'], + ['1.2.3-1', 'preminor', '1.3.0-0'], + ['1.2.0', 'premajor', '2.0.0-0'], + ['1.2.3-1', 'premajor', '2.0.0-0'], + ['1.2.0-1', 'minor', '1.2.0'], + ['1.0.0-1', 'major', '1.0.0'], + + ['1.2.3', 'major', '2.0.0', false, 'dev'], + ['1.2.3', 'minor', '1.3.0', false, 'dev'], + ['1.2.3', 'patch', '1.2.4', false, 'dev'], + ['1.2.3tag', 'major', '2.0.0', true, 'dev'], + ['1.2.3-tag', 'major', '2.0.0', false, 'dev'], + ['1.2.3', 'fake', null, false, 'dev'], + ['1.2.0-0', 'patch', '1.2.0', false, 'dev'], + ['fake', 'major', null, false, 'dev'], + ['1.2.3-4', 'major', '2.0.0', false, 'dev'], + ['1.2.3-4', 'minor', '1.3.0', false, 'dev'], + ['1.2.3-4', 'patch', '1.2.3', false, 'dev'], + ['1.2.3-alpha.0.beta', 'major', '2.0.0', false, 'dev'], + ['1.2.3-alpha.0.beta', 'minor', '1.3.0', false, 'dev'], + ['1.2.3-alpha.0.beta', 'patch', '1.2.3', false, 'dev'], + ['1.2.4', 'prerelease', '1.2.5-dev.0', false, 'dev'], + ['1.2.3-0', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1', false, 'alpha'], + ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta', false, 'alpha'], + ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta', false, 'alpha'], + ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta', false, 'alpha'], + ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta', false, 'alpha'], + ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1', false, 'alpha'], + ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2', false, 'alpha'], + ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3', false, 'alpha'], + ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], + ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'], + ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'], + ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'], + ['1.2.0', 'prepatch', '1.2.1-dev.0', false, 'dev'], + ['1.2.0-1', 'prepatch', '1.2.1-dev.0', false, 'dev'], + ['1.2.0', 'preminor', '1.3.0-dev.0', false, 'dev'], + ['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'], + ['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev'], + ['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev'], + ['1.2.0-1', 'minor', '1.2.0', false, 'dev'], + ['1.0.0-1', 'major', '1.0.0', 'dev'], + ['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev'], +] diff --git a/test/fixtures/invalid-versions.js b/test/fixtures/invalid-versions.js new file mode 100644 index 00000000..01ec10ce --- /dev/null +++ b/test/fixtures/invalid-versions.js @@ -0,0 +1,15 @@ +// none of these are semvers +// [value, reason, opt] +const {MAX_LENGTH, MAX_SAFE_INTEGER} = require('../../internal/constants') +module.exports = [ + [ new Array(MAX_LENGTH).join('1') + '.0.0', 'too long'], + [ `${MAX_SAFE_INTEGER}0.0.0`, 'too big'], + [ `0.${MAX_SAFE_INTEGER}0.0`, 'too big'], + [ `0.0.${MAX_SAFE_INTEGER}0`, 'too big'], + [ 'hello, world', 'not a version'], + [ 'hello, world', true, 'even loose, its still junk'], + [ 'xyz', 'even loose as an opt, same', , { loose: true }], + [ /a regexp/, 'regexp is not a string'], + [ /1.2.3/, 'semver-ish regexp is not a string'], + [ {toString: () => '1.2.3'}, 'obj with a tostring is not a string'], +] diff --git a/test/functions/compare-build.js b/test/functions/compare-build.js index bfb7782c..774acd12 100644 --- a/test/functions/compare-build.js +++ b/test/functions/compare-build.js @@ -1,19 +1,20 @@ const { test } = require('tap') const SemVer = require('../../classes/semver') +const compareBuild = require('../../functions/compare-build') test('compareBuild', (t) => { - const noBuild = new SemVer('1.0.0') - const build0 = new SemVer('1.0.0+0') - const build1 = new SemVer('1.0.0+1') - const build10 = new SemVer('1.0.0+1.0') - t.equal(noBuild.compareBuild(build0), -1) - t.equal(build0.compareBuild(build0), 0) - t.equal(build0.compareBuild(noBuild), 1) + const noBuild = '1.0.0' + const build0 = '1.0.0+0' + const build1 = '1.0.0+1' + const build10 = '1.0.0+1.0' + t.equal(compareBuild(noBuild, build0), -1) + t.equal(compareBuild(build0, build0), 0) + t.equal(compareBuild(build0, noBuild), 1) - t.equal(build0.compareBuild('1.0.0+0.0'), -1) - t.equal(build0.compareBuild(build1), -1) - t.equal(build1.compareBuild(build0), 1) - t.equal(build10.compareBuild(build1), 1) + t.equal(compareBuild(build0, '1.0.0+0.0'), -1) + t.equal(compareBuild(build0, build1), -1) + t.equal(compareBuild(build1, build0), 1) + t.equal(compareBuild(build10, build1), 1) t.end() }) diff --git a/test/functions/inc.js b/test/functions/inc.js index 711027a6..c91f6ebc 100644 --- a/test/functions/inc.js +++ b/test/functions/inc.js @@ -1,103 +1,15 @@ const { test } = require('tap') const inc = require('../../functions/inc') const parse = require('../../functions/parse') +const increments = require('../fixtures/increments.js') test('increment versions test', (t) => { -// [version, inc, result, identifier] -// inc(version, inc) -> result - [['1.2.3', 'major', '2.0.0'], - ['1.2.3', 'minor', '1.3.0'], - ['1.2.3', 'patch', '1.2.4'], - ['1.2.3tag', 'major', '2.0.0', true], - ['1.2.3-tag', 'major', '2.0.0'], - ['1.2.3', 'fake', null], - ['1.2.0-0', 'patch', '1.2.0'], - ['fake', 'major', null], - ['1.2.3-4', 'major', '2.0.0'], - ['1.2.3-4', 'minor', '1.3.0'], - ['1.2.3-4', 'patch', '1.2.3'], - ['1.2.3-alpha.0.beta', 'major', '2.0.0'], - ['1.2.3-alpha.0.beta', 'minor', '1.3.0'], - ['1.2.3-alpha.0.beta', 'patch', '1.2.3'], - ['1.2.4', 'prerelease', '1.2.5-0'], - ['1.2.3-0', 'prerelease', '1.2.3-1'], - ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'], - ['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'], - ['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'], - ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'], - ['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'], - ['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'], - ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'], - ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'], - ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'], - ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'], - ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'], - ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'], - ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'], - ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'], - ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'], - ['1.2.0', 'prepatch', '1.2.1-0'], - ['1.2.0-1', 'prepatch', '1.2.1-0'], - ['1.2.0', 'preminor', '1.3.0-0'], - ['1.2.3-1', 'preminor', '1.3.0-0'], - ['1.2.0', 'premajor', '2.0.0-0'], - ['1.2.3-1', 'premajor', '2.0.0-0'], - ['1.2.0-1', 'minor', '1.2.0'], - ['1.0.0-1', 'major', '1.0.0'], - - ['1.2.3', 'major', '2.0.0', false, 'dev'], - ['1.2.3', 'minor', '1.3.0', false, 'dev'], - ['1.2.3', 'patch', '1.2.4', false, 'dev'], - ['1.2.3tag', 'major', '2.0.0', true, 'dev'], - ['1.2.3-tag', 'major', '2.0.0', false, 'dev'], - ['1.2.3', 'fake', null, false, 'dev'], - ['1.2.0-0', 'patch', '1.2.0', false, 'dev'], - ['fake', 'major', null, false, 'dev'], - ['1.2.3-4', 'major', '2.0.0', false, 'dev'], - ['1.2.3-4', 'minor', '1.3.0', false, 'dev'], - ['1.2.3-4', 'patch', '1.2.3', false, 'dev'], - ['1.2.3-alpha.0.beta', 'major', '2.0.0', false, 'dev'], - ['1.2.3-alpha.0.beta', 'minor', '1.3.0', false, 'dev'], - ['1.2.3-alpha.0.beta', 'patch', '1.2.3', false, 'dev'], - ['1.2.4', 'prerelease', '1.2.5-dev.0', false, 'dev'], - ['1.2.3-0', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1', false, 'alpha'], - ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta', false, 'alpha'], - ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta', false, 'alpha'], - ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta', false, 'alpha'], - ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta', false, 'alpha'], - ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1', false, 'alpha'], - ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2', false, 'alpha'], - ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3', false, 'alpha'], - ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'], - ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'], - ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'], - ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'], - ['1.2.0', 'prepatch', '1.2.1-dev.0', false, 'dev'], - ['1.2.0-1', 'prepatch', '1.2.1-dev.0', false, 'dev'], - ['1.2.0', 'preminor', '1.3.0-dev.0', false, 'dev'], - ['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'], - ['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev'], - ['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev'], - ['1.2.0-1', 'minor', '1.2.0', false, 'dev'], - ['1.0.0-1', 'major', '1.0.0', 'dev'], - ['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev'] - - ].forEach((v) => { - const pre = v[0] - const what = v[1] - const wanted = v[2] - const loose = v[3] - const id = v[4] - const found = inc(pre, what, loose, id) + increments.forEach(([pre, what, wanted, options, id]) => { + const found = inc(pre, what, options, id) const cmd = `inc(${pre}, ${what}, ${id})` t.equal(found, wanted, `${cmd} === ${wanted}`) - const parsed = parse(pre, loose) + const parsed = parse(pre, options) if (wanted) { parsed.inc(what, id) t.equal(parsed.version, wanted, `${cmd} object version updated`) diff --git a/test/functions/parse.js b/test/functions/parse.js index 190e40af..16183dc0 100644 --- a/test/functions/parse.js +++ b/test/functions/parse.js @@ -1,18 +1,12 @@ const t = require('tap') const parse = require('../../functions/parse') const SemVer = require('../../classes/semver') -const {MAX_LENGTH, MAX_SAFE_INTEGER} = require('../../internal/constants') +const invalidVersions = require('../fixtures/invalid-versions') t.test('returns null instead of throwing when presented with garbage', t => { - t.equal(parse(new Array(MAX_LENGTH).join('1') + '.0.0'), null, 'too long') - t.equal(parse(`${MAX_SAFE_INTEGER}0.0.0`), null, 'too big') - t.equal(parse('hello, world'), null, 'not a version') - t.equal(parse('hello, world', true), null, 'even loose, its still junk') - t.equal(parse('xyz', { loose: true }), null, 'even loose as an opt, same') - t.equal(parse(/a regexp/), null, 'regexp is not a string') - t.equal(parse(/1.2.3/), null, 'semver-ish regexp is not a string') - t.equal(parse({toString: () => '1.2.3'}), null, 'obj with a tostring is not a string') - t.end() + t.plan(invalidVersions.length) + invalidVersions.forEach(([v, msg, opts]) => + t.equal(parse(v, opts), null, msg)) }) t.test('parse a version into a SemVer object', t => { diff --git a/test/functions/valid.js b/test/functions/valid.js index 2b3c7053..ab51fed3 100644 --- a/test/functions/valid.js +++ b/test/functions/valid.js @@ -1,18 +1,12 @@ const t = require('tap') const valid = require('../../functions/valid') const SemVer = require('../../classes/semver') -const {MAX_LENGTH, MAX_SAFE_INTEGER} = require('../../internal/constants') +const invalidVersions = require('../fixtures/invalid-versions') t.test('returns null instead of throwing when presented with garbage', t => { - t.equal(valid(new Array(MAX_LENGTH).join('1') + '.0.0'), null, 'too long') - t.equal(valid(`${MAX_SAFE_INTEGER}0.0.0`), null, 'too big') - t.equal(valid('hello, world'), null, 'not a version') - t.equal(valid('hello, world', true), null, 'even loose, its still junk') - t.equal(valid('xyz', { loose: true }), null, 'even loose as an opt, same') - t.equal(valid(/a regexp/), null, 'regexp is not a string') - t.equal(valid(/1.2.3/), null, 'semver-ish regexp is not a string') - t.equal(valid({toString: () => '1.2.3'}), null, 'obj with a tostring is not a string') - t.end() + t.plan(invalidVersions.length) + invalidVersions.forEach(([v, msg, opts]) => + t.equal(valid(v, opts), null, msg)) }) t.test('validate a version into a SemVer object', t => { From 6ca09494c96d1febd543e5d0e6dd9ddc738bb1f4 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 22 Nov 2019 13:24:58 -0800 Subject: [PATCH 10/44] remove test that isn't covering anything --- test/big-numbers.js | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 test/big-numbers.js diff --git a/test/big-numbers.js b/test/big-numbers.js deleted file mode 100644 index 5d49a7b1..00000000 --- a/test/big-numbers.js +++ /dev/null @@ -1,31 +0,0 @@ -const { test } = require('tap') -const semver = require('../') - -test('long version is too long', (t) => { - const v = `1.2.${new Array(256).join('1')}` - t.throws(() => { - new semver.SemVer(v) // eslint-disable-line no-new - }) - t.equal(semver.valid(v, false), null) - t.equal(semver.valid(v, true), null) - t.equal(semver.inc(v, 'patch'), null) - t.end() -}) - -test('big number is like too long version', (t) => { - const v = `1.2.${new Array(100).join('1')}` - t.throws(() => { - new semver.SemVer(v) // eslint-disable-line no-new - }) - t.equal(semver.valid(v, false), null) - t.equal(semver.valid(v, true), null) - t.equal(semver.inc(v, 'patch'), null) - t.end() -}) - -test('parsing null does not throw', (t) => { - t.equal(semver.parse(null), null) - t.equal(semver.parse({}), null) - t.equal(semver.parse(new semver.SemVer('1.2.3')).version, '1.2.3') - t.end() -}) From bbb1d02260dbbb99c8599f43c16ef837f102c249 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 23 Nov 2019 23:27:37 -0800 Subject: [PATCH 11/44] Add default npm OSS GitHub settings PR-URL: https://github.com/npm/node-semver/pull/296 Credit: @isaacs Close: #296 Reviewed-by: @isaacs --- .github/settings.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/settings.yml diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 00000000..4aaa0dd5 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,2 @@ +--- +_extends: 'open-source-project-boilerplate' From 7d834ed5dcd3ded832f8cd4e51f64261cb3cbb24 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 14 Dec 2019 11:35:43 -0800 Subject: [PATCH 12/44] document exported modules --- README.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ac5c4e90..15464585 100644 --- a/README.md +++ b/README.md @@ -430,7 +430,9 @@ any other overlapping SemVer tuple. * `clean(version)`: Clean a string to be a valid semver if possible -This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges. +This will return a cleaned and trimmed semver version. If the provided +version is not valid a null will be returned. This does not work for +ranges. ex. * `s.clean(' = v 2.1.5foo')`: `null` @@ -441,3 +443,57 @@ ex. * `s.clean(' =v2.1.5')`: `2.1.5` * `s.clean(' 2.1.5 ')`: `'2.1.5'` * `s.clean('~1.0.0')`: `null` + +## Exported Modules + + + +You may pull in just the part of this semver utility that you need, if you +are sensitive to packing and tree-shaking concerns. The main +`require('semver')` export uses getter functions to lazily load the parts +of the API that are used. + +The following modules are available: + +* `require('semver')` +* `require('semver/classes')` +* `require('semver/classes/comparator')` +* `require('semver/classes/range')` +* `require('semver/classes/semver')` +* `require('semver/functions/clean')` +* `require('semver/functions/cmp')` +* `require('semver/functions/coerce')` +* `require('semver/functions/compare')` +* `require('semver/functions/compare-build')` +* `require('semver/functions/compare-loose')` +* `require('semver/functions/diff')` +* `require('semver/functions/eq')` +* `require('semver/functions/gt')` +* `require('semver/functions/gte')` +* `require('semver/functions/inc')` +* `require('semver/functions/lt')` +* `require('semver/functions/lte')` +* `require('semver/functions/major')` +* `require('semver/functions/minor')` +* `require('semver/functions/neq')` +* `require('semver/functions/parse')` +* `require('semver/functions/patch')` +* `require('semver/functions/prerelease')` +* `require('semver/functions/rcompare')` +* `require('semver/functions/rsort')` +* `require('semver/functions/satisfies')` +* `require('semver/functions/sort')` +* `require('semver/functions/valid')` +* `require('semver/ranges/gtr')` +* `require('semver/ranges/intersects')` +* `require('semver/ranges/ltr')` +* `require('semver/ranges/max-satisfying')` +* `require('semver/ranges/min-satisfying')` +* `require('semver/ranges/min-version')` +* `require('semver/ranges/outside')` +* `require('semver/ranges/to-comparators')` +* `require('semver/ranges/valid')` From f56505b1c08856a7e6139f6ee5d4580f5f2feed8 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 14 Dec 2019 11:36:37 -0800 Subject: [PATCH 13/44] 7.0.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e412a4ee..27f6adc1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "6.3.0", + "version": "7.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a1afaa6c..88574c09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "6.3.0", + "version": "7.0.0", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 533ed1266b44d7672ad5015202c0e571da15b8c1 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 14 Dec 2019 11:37:32 -0800 Subject: [PATCH 14/44] update tap --- package-lock.json | 1350 +++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 641 insertions(+), 711 deletions(-) diff --git a/package-lock.json b/package-lock.json index 27f6adc1..b5a9b905 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,12 +14,12 @@ } }, "@babel/generator": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.2.tgz", - "integrity": "sha512-WthSArvAjYLz4TcbKOi88me+KmDJdKSlfwwN8CnUYn9jBkzhq0ZEPuBfkAWIvjJ3AdEV1Cf/+eSQTnp3IDJKlQ==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.4.tgz", + "integrity": "sha512-m5qo2WgdOJeyYngKImbkyQrnUN1mPceaG5BV+G0E3gWsa4l/jCSryWJdM2x8OuGAOyh+3d5pVYfZWCiNFtynxg==", "dev": true, "requires": { - "@babel/types": "^7.7.2", + "@babel/types": "^7.7.4", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" @@ -34,32 +34,32 @@ } }, "@babel/helper-function-name": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz", - "integrity": "sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.4.tgz", + "integrity": "sha512-AnkGIdiBhEuiwdoMnKm7jfPfqItZhgRaZfMg1XX3bS25INOnLPjPG1Ppnajh8eqgt5kPJnfqrRHqFqmjKDZLzQ==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.7.0", - "@babel/template": "^7.7.0", - "@babel/types": "^7.7.0" + "@babel/helper-get-function-arity": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/types": "^7.7.4" } }, "@babel/helper-get-function-arity": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz", - "integrity": "sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.4.tgz", + "integrity": "sha512-QTGKEdCkjgzgfJ3bAyRwF4yyT3pg+vDgan8DSivq1eS0gwi+KGKE5x8kRcbeFTb/673mkO5SN1IZfmCfA5o+EA==", "dev": true, "requires": { - "@babel/types": "^7.7.0" + "@babel/types": "^7.7.4" } }, "@babel/helper-split-export-declaration": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz", - "integrity": "sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.4.tgz", + "integrity": "sha512-guAg1SXFcVr04Guk9eq0S4/rWS++sbmyqosJzVs8+1fH5NI+ZcmkaSkc7dmtAFbHFva6yRJnjW3yAcGxjueDug==", "dev": true, "requires": { - "@babel/types": "^7.7.0" + "@babel/types": "^7.7.4" } }, "@babel/highlight": { @@ -74,69 +74,52 @@ } }, "@babel/parser": { - "version": "7.7.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.3.tgz", - "integrity": "sha512-bqv+iCo9i+uLVbI0ILzKkvMorqxouI+GbV13ivcARXn9NNEabi2IEz912IgNpT/60BNXac5dgcfjb94NjsF33A==", + "version": "7.7.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.5.tgz", + "integrity": "sha512-KNlOe9+/nk4i29g0VXgl8PEXIRms5xKLJeuZ6UptN0fHv+jDiriG+y94X6qAgWTR0h3KaoM1wK5G5h7MHFRSig==", "dev": true }, "@babel/runtime": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.2.tgz", - "integrity": "sha512-JONRbXbTXc9WQE2mAZd1p0Z3DZ/6vaQIkgYMSTP3KjRCyd7rCZCcfhCyX+YjwcKxcZ82UrxbRD358bpExNgrjw==", + "version": "7.7.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.6.tgz", + "integrity": "sha512-BWAJxpNVa0QlE5gZdWjSxXtemZyZ9RmrmVozxt3NUXeZhVIJ5ANyqmMc0JDrivBZyxUuQvFxlvH4OWWOogGfUw==", "dev": true, "requires": { "regenerator-runtime": "^0.13.2" } }, "@babel/template": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.0.tgz", - "integrity": "sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.4.tgz", + "integrity": "sha512-qUzihgVPguAzXCK7WXw8pqs6cEwi54s3E+HrejlkuWO6ivMKx9hZl3Y2fSXp9i5HgyWmj7RKP+ulaYnKM4yYxw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.0", - "@babel/types": "^7.7.0" + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4" } }, "@babel/traverse": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.2.tgz", - "integrity": "sha512-TM01cXib2+rgIZrGJOLaHV/iZUAxf4A0dt5auY6KNZ+cm6aschuJGqKJM3ROTt3raPUdIDk9siAufIFEleRwtw==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.4.tgz", + "integrity": "sha512-P1L58hQyupn8+ezVA2z5KBm4/Zr4lCC8dwKCMYzsa5jFMDMQAzaBNy9W5VjB+KAmBjb40U7a/H6ao+Xo+9saIw==", "dev": true, "requires": { "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.7.2", - "@babel/helper-function-name": "^7.7.0", - "@babel/helper-split-export-declaration": "^7.7.0", - "@babel/parser": "^7.7.2", - "@babel/types": "^7.7.2", + "@babel/generator": "^7.7.4", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" - }, - "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } } }, "@babel/types": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.2.tgz", - "integrity": "sha512-YTf6PXoh3+eZgRCBzzP25Bugd2ngmpQVrk7kXX0i5N9BO7TFBtIgZYs7WtxtOGs8e6A4ZI7ECkbBCEHeXocvOA==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.4.tgz", + "integrity": "sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -197,9 +180,9 @@ "dev": true }, "arg": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.1.tgz", - "integrity": "sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz", + "integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==", "dev": true }, "argparse": { @@ -248,9 +231,9 @@ "dev": true }, "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz", + "integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A==", "dev": true }, "balanced-match": { @@ -305,12 +288,6 @@ "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", "dev": true }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", @@ -363,23 +340,6 @@ "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" - }, - "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } } }, "chokidar": { @@ -409,16 +369,6 @@ "wrap-ansi": "^2.0.0" } }, - "cobertura-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/cobertura-parse/-/cobertura-parse-1.0.5.tgz", - "integrity": "sha512-uYJfkGhzw1wibe/8jqqHmSaPNWFguzq/IlSj83u3cSnZho/lUnfj0mLTmZGmB3AiKCOTYr22TYwpR1sXy2JEkg==", - "dev": true, - "requires": { - "mocha": "5.0.5", - "xml2js": "0.4.19" - } - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -456,10 +406,11 @@ } }, "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "optional": true }, "commondir": { "version": "1.0.1", @@ -497,12 +448,11 @@ "dev": true }, "coveralls": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.8.tgz", - "integrity": "sha512-lkQlg29RhV9zwB0gDaEAWoap8xPgFxtPsVIpTNiDDtWNrvtP1/RmGJRRAV/Loz2gihmppObkSL0wnptEGUXaOQ==", + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.9.tgz", + "integrity": "sha512-nNBg3B1+4iDox5A5zqHKzUTiwl2ey4k2o0NEcVZYvl+GOSJdKBj4AJGKLv6h3SvWch7tABHePAQOSZWM9E2hMg==", "dev": true, "requires": { - "cobertura-parse": "^1.0.5", "js-yaml": "^3.13.1", "lcov-parse": "^1.0.0", "log-driver": "^1.2.7", @@ -554,12 +504,12 @@ } }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "decamelize": { @@ -675,9 +625,9 @@ "dev": true }, "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, "fill-range": { @@ -716,18 +666,18 @@ "dev": true }, "flow-parser": { - "version": "0.112.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.112.0.tgz", - "integrity": "sha512-sxjnwhR76B/fUN6n/XerYzn8R1HvtVo3SM8Il3WiZ4nkAlb2BBzKe1TSVKGSyZgD6FW9Bsxom/57ktkqrqmXGA==", + "version": "0.114.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.114.0.tgz", + "integrity": "sha512-Qt9HT3v507bCerJfp4FX4N5E7ysinBzxjpK1rL7bJ/Bw12puF6lva2MAIXYS1d83bV7BT/F7EDk+faJQY5MpRA==", "dev": true }, "flow-remove-types": { - "version": "2.112.0", - "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.112.0.tgz", - "integrity": "sha512-h3bwcfh41nR9kvlhZFr5ySGmzzOyG4VUsnN4OBl9R6anbWAiX4H5lPhKTwZ7AelWF8Rtqmw/Vnq+VLEMg7PdAw==", + "version": "2.114.0", + "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.114.0.tgz", + "integrity": "sha512-ckon8RO7tFcVGW3Ll0jAWgULVrNa/cEN0JXp2I7XmzWT/GCQghSb+0312NjtAb+y3W9iXpPxkVMI86+SDU0E0Q==", "dev": true, "requires": { - "flow-parser": "^0.112.0", + "flow-parser": "^0.114.0", "pirates": "^3.0.2", "vlq": "^0.2.1" } @@ -834,12 +784,6 @@ "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", "dev": true }, - "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", - "dev": true - }, "handlebars": { "version": "4.5.3", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", @@ -869,9 +813,9 @@ } }, "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, "hasha": { @@ -883,12 +827,6 @@ "is-stream": "^1.0.1" } }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, "hosted-git-info": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", @@ -1087,12 +1025,6 @@ "supports-color": "^6.1.0" }, "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, "supports-color": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", @@ -1115,23 +1047,6 @@ "make-dir": "^2.1.0", "rimraf": "^2.6.3", "source-map": "^0.6.1" - }, - "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } } }, "istanbul-reports": { @@ -1270,6 +1185,15 @@ "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", "dev": true }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "lru-cache": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", @@ -1369,50 +1293,10 @@ } } }, - "mocha": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.5.tgz", - "integrity": "sha512-3MM3UjZ5p8EJrYpG7s+29HAI9G7sTzKEe4+w37Dg0QP7qL4XGsV+Q2xet2cE37AqdgN1OtYQB6Vl98YiPV3PgA==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.11.0", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.3", - "he": "1.1.1", - "mkdirp": "0.5.1", - "supports-color": "4.4.0" - }, - "dependencies": { - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } - } - }, "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "neo-async": { @@ -1502,6 +1386,12 @@ "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", "dev": true }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1686,6 +1576,17 @@ "dev": true, "optional": true }, + "prop-types": { + "version": "15.7.2", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", + "integrity": "sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==", + "dev": true, + "requires": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.8.1" + } + }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", @@ -1693,9 +1594,9 @@ "dev": true }, "psl": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz", - "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.6.0.tgz", + "integrity": "sha512-SYKKmVel98NCOYXpkwUqZqh0ahZeeKfmisiLIcEZdsb+WbLv02g/dI5BUmZnIyOe7RzZtLax81nnb2HbvC2tzA==", "dev": true }, "punycode": { @@ -1710,6 +1611,23 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, + "react": { + "version": "16.12.0", + "resolved": "https://registry.npmjs.org/react/-/react-16.12.0.tgz", + "integrity": "sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==", + "dev": true, + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "prop-types": "^15.6.2" + } + }, + "react-is": { + "version": "16.12.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz", + "integrity": "sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==", + "dev": true + }, "read-pkg": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", @@ -1821,9 +1739,9 @@ "dev": true }, "resolve": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", - "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz", + "integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1856,12 +1774,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true - }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -2042,46 +1954,46 @@ "dev": true }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "requires": { - "has-flag": "^2.0.0" + "has-flag": "^3.0.0" } }, "tap": { - "version": "14.10.1", - "resolved": "https://registry.npmjs.org/tap/-/tap-14.10.1.tgz", - "integrity": "sha512-GsjAtKf9WKe2Cj5/5OckVdwyz4kv4pjlidDPpNY32ikR6rkBnicU/gxwckXvV/pQ5uTDx+od6XqmVAB7ityXWg==", + "version": "14.10.2", + "resolved": "https://registry.npmjs.org/tap/-/tap-14.10.2.tgz", + "integrity": "sha512-JeUDsVrMFmR6b3p9hO9yIT/jibrK6LI7nFza5cqDGsxJyCp7yU3enRgS5nekuoAOzewbrU7P+9QDRDT01urROA==", "dev": true, "requires": { - "async-hook-domain": "^1.1.2", + "async-hook-domain": "^1.1.3", "bind-obj-methods": "^2.0.0", "browser-process-hrtime": "^1.0.0", - "chokidar": "^3.0.2", + "chokidar": "^3.3.0", "color-support": "^1.1.0", - "coveralls": "^3.0.6", + "coveralls": "^3.0.8", "diff": "^4.0.1", "esm": "^3.2.25", "findit": "^2.0.0", - "flow-remove-types": "^2.107.0", + "flow-remove-types": "^2.112.0", "foreground-child": "^1.3.3", "fs-exists-cached": "^1.0.0", "function-loop": "^1.0.2", - "glob": "^7.1.4", - "import-jsx": "^2.0.0", - "ink": "^2.3.0", + "glob": "^7.1.6", + "import-jsx": "^3.0.0", + "ink": "^2.5.0", "isexe": "^2.0.0", "istanbul-lib-processinfo": "^1.0.0", "jackspeak": "^1.4.0", - "minipass": "^3.0.0", + "minipass": "^3.1.1", "mkdirp": "^0.5.1", "nyc": "^14.1.1", "opener": "^1.5.1", "own-or": "^1.0.0", "own-or-env": "^1.0.1", - "react": "^16.9.0", + "react": "^16.12.0", "rimraf": "^2.7.1", "signal-exit": "^3.0.0", "source-map-support": "^0.5.16", @@ -2090,122 +2002,148 @@ "tap-parser": "^10.0.1", "tap-yaml": "^1.0.0", "tcompare": "^3.0.0", - "treport": "^0.5.0", + "treport": "^1.0.0", "trivial-deferred": "^1.0.1", - "ts-node": "^8.3.0", - "typescript": "^3.6.3", - "which": "^2.0.1", - "write-file-atomic": "^3.0.0", - "yaml": "^1.6.0", + "ts-node": "^8.5.2", + "typescript": "^3.7.2", + "which": "^2.0.2", + "write-file-atomic": "^3.0.1", + "yaml": "^1.7.2", "yapool": "^1.0.0" }, "dependencies": { - "@babel/runtime": { - "version": "7.6.3", - "bundled": true, - "dev": true, - "requires": { - "regenerator-runtime": "^0.13.2" - }, - "dependencies": { - "regenerator-runtime": { - "version": "0.13.3", - "bundled": true, - "dev": true - } - } - }, - "@types/prop-types": { - "version": "15.7.3", - "bundled": true, - "dev": true - }, - "@types/react": { - "version": "16.9.5", - "bundled": true, - "dev": true, - "requires": { - "@types/prop-types": "*", - "csstype": "^2.2.0" - } - }, - "ansi-escapes": { - "version": "4.2.1", - "bundled": true, - "dev": true, - "requires": { - "type-fest": "^0.5.2" - } - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "bundled": true, - "dev": true - }, - "ansicolors": { - "version": "0.3.2", - "bundled": true, - "dev": true - }, - "arrify": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "astral-regex": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "auto-bind": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "requires": { - "@types/react": "^16.8.12" - } - }, - "babel-code-frame": { - "version": "6.26.0", + "@babel/code-frame": { + "version": "7.5.5", "bundled": true, - "dev": true, "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" + "@babel/highlight": "^7.0.0" } }, - "babel-core": { - "version": "6.26.3", + "@babel/core": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "babel-code-frame": "^6.26.0", - "babel-generator": "^6.26.0", - "babel-helpers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-register": "^6.26.0", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "convert-source-map": "^1.5.1", - "debug": "^2.6.9", - "json5": "^0.5.1", - "lodash": "^4.17.4", - "minimatch": "^3.0.4", - "path-is-absolute": "^1.0.1", - "private": "^0.1.8", - "slash": "^1.0.0", - "source-map": "^0.5.7" + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helpers": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/traverse": "^7.7.4", + "@babel/types": "^7.7.4", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "json5": "^2.1.0", + "lodash": "^4.17.13", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" }, "dependencies": { + "@babel/generator": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/parser": { + "version": "7.7.4", + "bundled": true, + "dev": true + }, + "@babel/template": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/traverse": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "convert-source-map": { + "version": "1.7.0", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "bundled": true, + "dev": true + }, + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true + }, "source-map": { "version": "0.5.7", "bundled": true, @@ -2213,186 +2151,303 @@ } } }, - "babel-generator": { - "version": "6.26.1", + "@babel/generator": { + "version": "7.7.2", "bundled": true, - "dev": true, "requires": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" + "@babel/types": "^7.7.2", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" }, "dependencies": { "source-map": { "version": "0.5.7", - "bundled": true, - "dev": true + "bundled": true } } }, - "babel-helper-builder-react-jsx": { - "version": "6.26.0", - "bundled": true, - "dev": true, - "requires": { - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "esutils": "^2.0.2" - } - }, - "babel-helpers": { - "version": "6.24.1", - "bundled": true, - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-messages": { - "version": "6.23.0", + "@babel/helper-builder-react-jsx": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "babel-runtime": "^6.22.0" + "@babel/types": "^7.7.4", + "esutils": "^2.0.0" + }, + "dependencies": { + "@babel/types": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + } } }, - "babel-plugin-syntax-jsx": { - "version": "6.18.0", - "bundled": true, - "dev": true - }, - "babel-plugin-syntax-object-rest-spread": { - "version": "6.13.0", + "@babel/helper-plugin-utils": { + "version": "7.0.0", "bundled": true, "dev": true }, - "babel-plugin-transform-es2015-destructuring": { - "version": "6.23.0", - "bundled": true, - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-object-rest-spread": { - "version": "6.26.0", - "bundled": true, - "dev": true, - "requires": { - "babel-plugin-syntax-object-rest-spread": "^6.8.0", - "babel-runtime": "^6.26.0" - } - }, - "babel-plugin-transform-react-jsx": { - "version": "6.24.1", + "@babel/helpers": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "babel-helper-builder-react-jsx": "^6.24.1", - "babel-plugin-syntax-jsx": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-register": { - "version": "6.26.0", - "bundled": true, - "dev": true, - "requires": { - "babel-core": "^6.26.0", - "babel-runtime": "^6.26.0", - "core-js": "^2.5.0", - "home-or-tmp": "^2.0.0", - "lodash": "^4.17.4", - "mkdirp": "^0.5.1", - "source-map-support": "^0.4.15" + "@babel/template": "^7.7.4", + "@babel/traverse": "^7.7.4", + "@babel/types": "^7.7.4" }, "dependencies": { - "source-map": { - "version": "0.5.7", + "@babel/generator": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/parser": { + "version": "7.7.4", "bundled": true, "dev": true }, - "source-map-support": { - "version": "0.4.18", + "@babel/template": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "source-map": "^0.5.6" + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4" } + }, + "@babel/traverse": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "bundled": true, + "dev": true + }, + "source-map": { + "version": "0.5.7", + "bundled": true, + "dev": true } } }, - "babel-runtime": { - "version": "6.26.0", + "@babel/highlight": { + "version": "7.5.0", + "bundled": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "js-tokens": { + "version": "4.0.0", + "bundled": true + } + } + }, + "@babel/parser": { + "version": "7.7.3", + "bundled": true + }, + "@babel/plugin-proposal-object-rest-spread": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-object-rest-spread": "^7.7.4" + } + }, + "@babel/plugin-syntax-jsx": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" + "@babel/helper-plugin-utils": "^7.0.0" } }, - "babel-template": { - "version": "6.26.0", + "@babel/plugin-syntax-object-rest-spread": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "babel-runtime": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "lodash": "^4.17.4" + "@babel/helper-plugin-utils": "^7.0.0" } }, - "babel-traverse": { - "version": "6.26.0", + "@babel/plugin-transform-destructuring": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "babel-code-frame": "^6.26.0", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "debug": "^2.6.8", - "globals": "^9.18.0", - "invariant": "^2.2.2", - "lodash": "^4.17.4" + "@babel/helper-plugin-utils": "^7.0.0" } }, - "babel-types": { - "version": "6.26.0", + "@babel/plugin-transform-react-jsx": { + "version": "7.7.4", "bundled": true, "dev": true, "requires": { - "babel-runtime": "^6.26.0", + "@babel/helper-builder-react-jsx": "^7.7.4", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-jsx": "^7.7.4" + } + }, + "@babel/runtime": { + "version": "7.7.4", + "bundled": true, + "dev": true, + "requires": { + "regenerator-runtime": "^0.13.2" + } + }, + "@babel/template": { + "version": "7.7.0", + "bundled": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.0", + "@babel/types": "^7.7.0" + } + }, + "@babel/types": { + "version": "7.7.2", + "bundled": true, + "requires": { "esutils": "^2.0.2", - "lodash": "^4.17.4", - "to-fast-properties": "^1.0.3" + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "@types/color-name": { + "version": "1.1.1", + "bundled": true, + "dev": true + }, + "@types/prop-types": { + "version": "15.7.3", + "bundled": true, + "dev": true + }, + "@types/react": { + "version": "16.9.13", + "bundled": true, + "dev": true, + "requires": { + "@types/prop-types": "*", + "csstype": "^2.2.0" } }, - "babylon": { - "version": "6.18.0", + "ansi-escapes": { + "version": "4.3.0", + "bundled": true, + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "ansi-styles": { + "version": "3.2.1", + "bundled": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "ansicolors": { + "version": "0.3.2", + "bundled": true, + "dev": true + }, + "arrify": { + "version": "1.0.1", "bundled": true, "dev": true }, - "balanced-match": { + "astral-regex": { "version": "1.0.0", "bundled": true, "dev": true }, - "brace-expansion": { - "version": "1.1.11", + "auto-bind": { + "version": "2.1.1", "bundled": true, "dev": true, "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "@types/react": "^16.8.12" } }, "caller-callsite": { @@ -2426,15 +2481,12 @@ } }, "chalk": { - "version": "1.1.3", + "version": "2.4.2", "bundled": true, - "dev": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, "ci-info": { @@ -2462,40 +2514,13 @@ "color-convert": { "version": "1.9.3", "bundled": true, - "dev": true, "requires": { "color-name": "1.1.3" } }, "color-name": { "version": "1.1.3", - "bundled": true, - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true - }, - "convert-source-map": { - "version": "1.6.0", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "~5.1.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "dev": true - } - } - }, - "core-js": { - "version": "2.6.10", - "bundled": true, - "dev": true + "bundled": true }, "csstype": { "version": "2.6.7", @@ -2505,19 +2530,10 @@ "debug": { "version": "2.6.9", "bundled": true, - "dev": true, "requires": { "ms": "2.0.0" } }, - "detect-indent": { - "version": "4.0.0", - "bundled": true, - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, "emoji-regex": { "version": "7.0.3", "bundled": true, @@ -2525,8 +2541,7 @@ }, "escape-string-regexp": { "version": "1.0.5", - "bundled": true, - "dev": true + "bundled": true }, "esprima": { "version": "4.0.1", @@ -2535,8 +2550,7 @@ }, "esutils": { "version": "2.0.3", - "bundled": true, - "dev": true + "bundled": true }, "events-to-array": { "version": "1.1.2", @@ -2544,41 +2558,23 @@ "dev": true }, "globals": { - "version": "9.18.0", + "version": "11.12.0", "bundled": true, "dev": true }, - "has-ansi": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, "has-flag": { "version": "3.0.0", - "bundled": true, - "dev": true - }, - "home-or-tmp": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.1" - } + "bundled": true }, "import-jsx": { - "version": "2.0.0", + "version": "3.0.0", "bundled": true, "dev": true, "requires": { - "babel-core": "^6.25.0", - "babel-plugin-transform-es2015-destructuring": "^6.23.0", - "babel-plugin-transform-object-rest-spread": "^6.23.0", - "babel-plugin-transform-react-jsx": "^6.24.1", + "@babel/core": "^7.5.5", + "@babel/plugin-proposal-object-rest-spread": "^7.5.5", + "@babel/plugin-transform-destructuring": "^7.5.0", + "@babel/plugin-transform-react-jsx": "^7.3.0", "caller-path": "^2.0.0", "resolve-from": "^3.0.0" } @@ -2607,42 +2603,6 @@ "widest-line": "^2.0.0", "wrap-ansi": "^5.0.0", "yoga-layout-prebuilt": "^1.9.3" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "bundled": true, - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "bundled": true, - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "supports-color": { - "version": "5.5.0", - "bundled": true, - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "invariant": { - "version": "2.2.4", - "bundled": true, - "dev": true, - "requires": { - "loose-envify": "^1.0.0" } }, "is-ci": { @@ -2653,14 +2613,6 @@ "ci-info": "^2.0.0" } }, - "is-finite": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, "is-fullwidth-code-point": { "version": "2.0.0", "bundled": true, @@ -2672,19 +2624,20 @@ "dev": true }, "jsesc": { - "version": "1.3.0", - "bundled": true, - "dev": true + "version": "2.5.2", + "bundled": true }, "json5": { - "version": "0.5.1", + "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "requires": { + "minimist": "^1.2.0" + } }, "lodash": { "version": "4.17.15", - "bundled": true, - "dev": true + "bundled": true }, "lodash.throttle": { "version": "4.1.1", @@ -2721,16 +2674,13 @@ "bundled": true, "dev": true }, - "minimatch": { - "version": "3.0.4", + "minimist": { + "version": "1.2.0", "bundled": true, - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } + "dev": true }, "minipass": { - "version": "3.0.1", + "version": "3.1.1", "bundled": true, "dev": true, "requires": { @@ -2744,30 +2694,9 @@ } } }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true - } - } - }, "ms": { "version": "2.0.0", - "bundled": true, - "dev": true - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -2782,23 +2711,8 @@ "mimic-fn": "^1.0.0" } }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "private": { - "version": "0.1.8", + "path-parse": { + "version": "1.0.6", "bundled": true, "dev": true }, @@ -2817,16 +2731,6 @@ "bundled": true, "dev": true }, - "react": { - "version": "16.10.2", - "bundled": true, - "dev": true, - "requires": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1", - "prop-types": "^15.6.2" - } - }, "react-is": { "version": "16.10.2", "bundled": true, @@ -2852,16 +2756,16 @@ } }, "regenerator-runtime": { - "version": "0.11.1", + "version": "0.13.3", "bundled": true, "dev": true }, - "repeating": { - "version": "2.0.1", + "resolve": { + "version": "1.12.0", "bundled": true, "dev": true, "requires": { - "is-finite": "^1.0.0" + "path-parse": "^1.0.6" } }, "resolve-from": { @@ -2887,13 +2791,13 @@ "object-assign": "^4.1.1" } }, - "signal-exit": { - "version": "3.0.2", + "semver": { + "version": "5.7.1", "bundled": true, "dev": true }, - "slash": { - "version": "1.0.0", + "signal-exit": { + "version": "3.0.2", "bundled": true, "dev": true }, @@ -2905,6 +2809,10 @@ "is-fullwidth-code-point": "^2.0.0" } }, + "source-map": { + "version": "0.6.1", + "bundled": true + }, "string-length": { "version": "2.0.0", "bundled": true, @@ -2956,15 +2864,16 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "dev": true, "requires": { "ansi-regex": "^2.0.0" } }, "supports-color": { - "version": "2.0.0", + "version": "5.5.0", "bundled": true, - "dev": true + "requires": { + "has-flag": "^3.0.0" + } }, "tap-parser": { "version": "10.0.1", @@ -2985,55 +2894,93 @@ } }, "to-fast-properties": { - "version": "1.0.3", - "bundled": true, - "dev": true + "version": "2.0.0", + "bundled": true }, "treport": { - "version": "0.5.0", + "version": "1.0.0", "bundled": true, "dev": true, "requires": { "cardinal": "^2.1.1", - "chalk": "^2.4.2", - "import-jsx": "^2.0.0", - "ink": "^2.1.1", - "ms": "^2.1.1", - "react": "^16.8.6", - "string-length": "^2.0.0", + "chalk": "^3.0.0", + "import-jsx": "^3.0.0", + "ink": "^2.5.0", + "ms": "^2.1.2", + "string-length": "^3.1.0", "tap-parser": "^10.0.1", - "unicode-length": "^2.0.1" + "unicode-length": "^2.0.2" }, "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "bundled": true, + "dev": true + }, "ansi-styles": { - "version": "3.2.1", + "version": "4.2.0", "bundled": true, "dev": true, "requires": { - "color-convert": "^1.9.0" + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" } }, "chalk": { - "version": "2.4.2", + "version": "3.0.0", "bundled": true, "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" } }, + "color-convert": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "bundled": true, + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "bundled": true, + "dev": true + }, "ms": { "version": "2.1.2", "bundled": true, "dev": true }, + "string-length": { + "version": "3.1.0", + "bundled": true, + "dev": true, + "requires": { + "astral-regex": "^1.0.0", + "strip-ansi": "^5.2.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, "supports-color": { - "version": "5.5.0", + "version": "7.1.0", "bundled": true, "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "^4.0.0" } }, "unicode-length": { @@ -3043,17 +2990,27 @@ "requires": { "punycode": "^2.0.0", "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } } } } }, - "trim-right": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, "type-fest": { - "version": "0.5.2", + "version": "0.8.1", "bundled": true, "dev": true }, @@ -3080,14 +3037,6 @@ "bundled": true, "dev": true }, - "ansi-styles": { - "version": "3.2.1", - "bundled": true, - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, "string-width": { "version": "3.1.0", "bundled": true, @@ -3109,11 +3058,11 @@ } }, "yaml": { - "version": "1.7.1", + "version": "1.7.2", "bundled": true, "dev": true, "requires": { - "@babel/runtime": "^7.5.5" + "@babel/runtime": "^7.6.3" } }, "yoga-layout-prebuilt": { @@ -3154,6 +3103,12 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true } } }, @@ -3178,9 +3133,9 @@ } }, "tcompare": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/tcompare/-/tcompare-3.0.0.tgz", - "integrity": "sha512-lRD40wHaBoVvmcCT0L7qJmR+jBl1nVP0WxbMYyOtsFza+SXD9aiRVir9aWogdQwNzY6ZwOvwDp5vg3XWQGOIVQ==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/tcompare/-/tcompare-3.0.4.tgz", + "integrity": "sha512-Q3TitMVK59NyKgQyFh+857wTAUE329IzLDehuPgU4nF5e8g+EUQ+yUbjUy1/6ugiNnXztphT+NnqlCXolv9P3A==", "dev": true, "requires": { "diff-frag": "^1.0.1" @@ -3238,9 +3193,9 @@ "dev": true }, "ts-node": { - "version": "8.5.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.2.tgz", - "integrity": "sha512-W1DK/a6BGoV/D4x/SXXm6TSQx6q3blECUzd5TN+j56YEMX3yPVMpHsICLedUw3DvGF3aTQ8hfdR9AKMaHjIi+A==", + "version": "8.5.4", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.4.tgz", + "integrity": "sha512-izbVCRV68EasEPQ8MSIGBNK9dc/4sYJJKYA+IarMQct1RtEot6Xp0bXuClsbUSnKpg50ho+aOAx8en5c+y4OFw==", "dev": true, "requires": { "arg": "^4.1.0", @@ -3275,29 +3230,20 @@ } }, "typescript": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", - "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==", "dev": true }, "uglify-js": { - "version": "3.6.9", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.9.tgz", - "integrity": "sha512-pcnnhaoG6RtrvHJ1dFncAe8Od6Nuy30oaJ82ts6//sGSXOP5UjBMEthiProjXmMNHOfd93sqlkztifFMcb+4yw==", + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.2.tgz", + "integrity": "sha512-uhRwZcANNWVLrxLfNFEdltoPNhECUR3lc+UdJoG9CBpMcSnKyWA94tc3eAujB1GcMY5Uwq8ZMp4qWpxWYDQmaA==", "dev": true, "optional": true, "requires": { "commander": "~2.20.3", "source-map": "~0.6.1" - }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "optional": true - } } }, "unicode-length": { @@ -3468,22 +3414,6 @@ "typedarray-to-buffer": "^3.1.5" } }, - "xml2js": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", - "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", - "dev": true, - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~9.0.1" - } - }, - "xmlbuilder": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", - "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", - "dev": true - }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", diff --git a/package.json b/package.json index 88574c09..3c26ee39 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "postpublish": "git push origin --follow-tags" }, "devDependencies": { - "tap": "^14.10.1" + "tap": "^14.10.2" }, "license": "ISC", "repository": "https://github.com/npm/node-semver", From d61f828e64260a0a097f26210f5500e91a621828 Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 14 Dec 2019 15:08:36 -0800 Subject: [PATCH 15/44] update changelog, travis, and engines versions --- .travis.yml | 4 ++-- CHANGELOG.md | 6 ++++++ package.json | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90b879c1..1db41fec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: node_js node_js: - - 11 + - node + - 12 - 10 - - 8 os: - linux diff --git a/CHANGELOG.md b/CHANGELOG.md index d366696b..e710528e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # changes log +## 7.0.0 + +* Refactor module into separate files for better tree-shaking +* Drop support for very old node versions, use const/let, `=>` functions, + and classes. + ## 6.3.0 * Expose the token enum on the exports diff --git a/package.json b/package.json index 3c26ee39..aab12238 100644 --- a/package.json +++ b/package.json @@ -30,5 +30,8 @@ "tap": { "check-coverage": true, "coverage-map": "map.js" + }, + "engines": { + "node": ">=10" } } From 945d53c0979d9894343d07ffb615f7ce66cc1cbe Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 16 Dec 2019 17:28:09 -0800 Subject: [PATCH 16/44] Add semver/preload module to just load the whole thing like it used to be --- preload.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/preload.js | 4 ++++ 2 files changed, 50 insertions(+) create mode 100644 preload.js create mode 100644 test/preload.js diff --git a/preload.js b/preload.js new file mode 100644 index 00000000..3a0b4e52 --- /dev/null +++ b/preload.js @@ -0,0 +1,46 @@ +// just pre-load all the stuff that index.js lazily exports +const internalRe = require('./internal/re') +module.exports = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: require('./internal/constants').SEMVER_SPEC_VERSION, + SemVer: require('./classes/semver'), + compareIdentifiers: require('./internal/identifiers').compareIdentifiers, + rcompareIdentifiers: require('./internal/identifiers').rcompareIdentifiers, + parse: require('./functions/parse'), + valid: require('./functions/valid'), + clean: require('./functions/clean'), + inc: require('./functions/inc'), + diff: require('./functions/diff'), + major: require('./functions/major'), + minor: require('./functions/minor'), + patch: require('./functions/patch'), + prerelease: require('./functions/prerelease'), + compare: require('./functions/compare'), + rcompare: require('./functions/rcompare'), + compareLoose: require('./functions/compare-loose'), + compareBuild: require('./functions/compare-build'), + sort: require('./functions/sort'), + rsort: require('./functions/rsort'), + gt: require('./functions/gt'), + lt: require('./functions/lt'), + eq: require('./functions/eq'), + neq: require('./functions/neq'), + gte: require('./functions/gte'), + lte: require('./functions/lte'), + cmp: require('./functions/cmp'), + coerce: require('./functions/coerce'), + Comparator: require('./classes/comparator'), + Range: require('./classes/range'), + satisfies: require('./functions/satisfies'), + toComparators: require('./ranges/to-comparators'), + maxSatisfying: require('./ranges/max-satisfying'), + minSatisfying: require('./ranges/min-satisfying'), + minVersion: require('./ranges/min-version'), + validRange: require('./ranges/valid'), + outside: require('./ranges/outside'), + gtr: require('./ranges/gtr'), + ltr: require('./ranges/ltr'), + intersects: require('./ranges/intersects'), +} diff --git a/test/preload.js b/test/preload.js new file mode 100644 index 00000000..0225306f --- /dev/null +++ b/test/preload.js @@ -0,0 +1,4 @@ +const t = require('tap') +const preload = require('../preload.js') +const index = require('../index.js') +t.strictSame(preload, index, 'preload and index match') From e663d38c2d3f77bfe8c9cae9770c409aa434c713 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 16 Dec 2019 17:28:43 -0800 Subject: [PATCH 17/44] 7.1.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b5a9b905..1349a5af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.0.0", + "version": "7.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index aab12238..a48e1384 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.0.0", + "version": "7.1.0", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 5a4ce3df0c9d71900313ae165b3d31abb38dc85f Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 16 Dec 2019 17:29:55 -0800 Subject: [PATCH 18/44] changelog for 7.1 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e710528e..db6b6d4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # changes log +## 7.1.0 + +* Add `require('semver/preload')` to load the entire module without using + lazy getter methods. + ## 7.0.0 * Refactor module into separate files for better tree-shaking From 6648df16df5920f78af16a8af0711a4994996043 Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Tue, 17 Dec 2019 17:28:53 +0100 Subject: [PATCH 19/44] Add preload.js into npm package PR-URL: https://github.com/npm/node-semver/pull/301 Credit: @Flarna Close: #301 Reviewed-by: @isaacs --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a48e1384..79d7f218 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "functions", "internal", "ranges", - "index.js" + "index.js", + "preload.js" ], "tap": { "check-coverage": true, From bb36c98d71d5760d730abba71c68bc324035dd36 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 17 Dec 2019 08:56:17 -0800 Subject: [PATCH 20/44] 7.1.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1349a5af..8197d28f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.0", + "version": "7.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 79d7f218..1c8338db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.0", + "version": "7.1.1", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 70d9fb3f1c128227a3cd911867edb07a54260cad Mon Sep 17 00:00:00 2001 From: isaacs Date: Sat, 28 Dec 2019 16:17:13 -0800 Subject: [PATCH 21/44] document preload and exported modules --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/README.md b/README.md index 15464585..648c72bc 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,62 @@ semver.valid(semver.coerce('v2')) // '2.0.0' semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7' ``` +This module uses getters to lazily load only the parts of the package that +are used. To use it with Webpack and other projects that need string +literals as the argument to `require()`, load it this way: + +```js +// load the whole API at once in a single object +const semver = require('semver/preload') + +// or just load the bits you need +// all of them listed here, just pick and choose what you want + +// classes +const SemVer = require('semver/classes/semver') +const Comparator = require('semver/classes/comparator') +const Range = require('semver/classes/range') + +// functions for working with versions +const semverParse = require('semver/functions/parse') +const semverValid = require('semver/functions/valid') +const semverClean = require('semver/functions/clean') +const semverInc = require('semver/functions/inc') +const semverDiff = require('semver/functions/diff') +const semverMajor = require('semver/functions/major') +const semverMinor = require('semver/functions/minor') +const semverPatch = require('semver/functions/patch') +const semverPrerelease = require('semver/functions/prerelease') +const semverCompare = require('semver/functions/compare') +const semverRcompare = require('semver/functions/rcompare') +const semverCompareLoose = require('semver/functions/compare-loose') +const semverCompareBuild = require('semver/functions/compare-build') +const semverSort = require('semver/functions/sort') +const semverRsort = require('semver/functions/rsort') + +// low-level comparators between versions +const semverGt = require('semver/functions/gt') +const semverLt = require('semver/functions/lt') +const semverEq = require('semver/functions/eq') +const semverNeq = require('semver/functions/neq') +const semverGte = require('semver/functions/gte') +const semverLte = require('semver/functions/lte') +const semverCmp = require('semver/functions/cmp') +const semverCoerce = require('semver/functions/coerce') + +// working with ranges +const semverSatisfies = require('semver/functions/satisfies') +const semverMaxSatisfying = require('semver/ranges/max-satisfying') +const semverMinSatisfying = require('semver/ranges/min-satisfying') +const semverToComparators = require('semver/ranges/to-comparators') +const semverMinVersion = require('semver/ranges/min-version') +const semverValidRange = require('semver/ranges/valid') +const semverOutside = require('semver/ranges/outside') +const semverGtr = require('semver/ranges/gtr') +const semverLtr = require('semver/ranges/ltr') +const semverIntersects = require('semver/ranges/intersects') +``` + As a command-line utility: ``` From 70593f743620b01fdf9391a85c3dedce83dfa589 Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 22 Jan 2020 15:52:00 -0800 Subject: [PATCH 22/44] Remove the fancy preload logic in index.js This is causing some friction for webpack users, and doesn't seem to be worth the trouble from a performance point of view in npm/cli. Ditch it. Fix #306 --- README.md | 7 ++-- index.js | 108 ++++++++++++++++++++---------------------------- preload.js | 48 +-------------------- test/index.js | 14 +------ test/preload.js | 2 +- 5 files changed, 53 insertions(+), 126 deletions(-) diff --git a/README.md b/README.md index 648c72bc..9ba40454 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,12 @@ semver.valid(semver.coerce('v2')) // '2.0.0' semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7' ``` -This module uses getters to lazily load only the parts of the package that -are used. To use it with Webpack and other projects that need string -literals as the argument to `require()`, load it this way: +You can also just load the module for the function that you care about, if +you'd like to minimize your footprint. ```js // load the whole API at once in a single object -const semver = require('semver/preload') +const semver = require('semver') // or just load the bits you need // all of them listed here, just pick and choose what you want diff --git a/index.js b/index.js index 068f8b4e..3a0b4e52 100644 --- a/index.js +++ b/index.js @@ -1,64 +1,46 @@ -const lrCache = {} -const lazyRequire = (path, subkey) => { - const module = lrCache[path] || (lrCache[path] = require(path)) - return subkey ? module[subkey] : module +// just pre-load all the stuff that index.js lazily exports +const internalRe = require('./internal/re') +module.exports = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: require('./internal/constants').SEMVER_SPEC_VERSION, + SemVer: require('./classes/semver'), + compareIdentifiers: require('./internal/identifiers').compareIdentifiers, + rcompareIdentifiers: require('./internal/identifiers').rcompareIdentifiers, + parse: require('./functions/parse'), + valid: require('./functions/valid'), + clean: require('./functions/clean'), + inc: require('./functions/inc'), + diff: require('./functions/diff'), + major: require('./functions/major'), + minor: require('./functions/minor'), + patch: require('./functions/patch'), + prerelease: require('./functions/prerelease'), + compare: require('./functions/compare'), + rcompare: require('./functions/rcompare'), + compareLoose: require('./functions/compare-loose'), + compareBuild: require('./functions/compare-build'), + sort: require('./functions/sort'), + rsort: require('./functions/rsort'), + gt: require('./functions/gt'), + lt: require('./functions/lt'), + eq: require('./functions/eq'), + neq: require('./functions/neq'), + gte: require('./functions/gte'), + lte: require('./functions/lte'), + cmp: require('./functions/cmp'), + coerce: require('./functions/coerce'), + Comparator: require('./classes/comparator'), + Range: require('./classes/range'), + satisfies: require('./functions/satisfies'), + toComparators: require('./ranges/to-comparators'), + maxSatisfying: require('./ranges/max-satisfying'), + minSatisfying: require('./ranges/min-satisfying'), + minVersion: require('./ranges/min-version'), + validRange: require('./ranges/valid'), + outside: require('./ranges/outside'), + gtr: require('./ranges/gtr'), + ltr: require('./ranges/ltr'), + intersects: require('./ranges/intersects'), } - -const lazyExport = (key, path, subkey) => { - Object.defineProperty(exports, key, { - get: () => { - const res = lazyRequire(path, subkey) - Object.defineProperty(exports, key, { - value: res, - enumerable: true, - configurable: true - }) - return res - }, - configurable: true, - enumerable: true - }) -} - -lazyExport('re', './internal/re', 're') -lazyExport('src', './internal/re', 'src') -lazyExport('tokens', './internal/re', 't') -lazyExport('SEMVER_SPEC_VERSION', './internal/constants', 'SEMVER_SPEC_VERSION') -lazyExport('SemVer', './classes/semver') -lazyExport('compareIdentifiers', './internal/identifiers', 'compareIdentifiers') -lazyExport('rcompareIdentifiers', './internal/identifiers', 'rcompareIdentifiers') -lazyExport('parse', './functions/parse') -lazyExport('valid', './functions/valid') -lazyExport('clean', './functions/clean') -lazyExport('inc', './functions/inc') -lazyExport('diff', './functions/diff') -lazyExport('major', './functions/major') -lazyExport('minor', './functions/minor') -lazyExport('patch', './functions/patch') -lazyExport('prerelease', './functions/prerelease') -lazyExport('compare', './functions/compare') -lazyExport('rcompare', './functions/rcompare') -lazyExport('compareLoose', './functions/compare-loose') -lazyExport('compareBuild', './functions/compare-build') -lazyExport('sort', './functions/sort') -lazyExport('rsort', './functions/rsort') -lazyExport('gt', './functions/gt') -lazyExport('lt', './functions/lt') -lazyExport('eq', './functions/eq') -lazyExport('neq', './functions/neq') -lazyExport('gte', './functions/gte') -lazyExport('lte', './functions/lte') -lazyExport('cmp', './functions/cmp') -lazyExport('coerce', './functions/coerce') -lazyExport('Comparator', './classes/comparator') -lazyExport('Range', './classes/range') -lazyExport('satisfies', './functions/satisfies') -lazyExport('toComparators', './ranges/to-comparators') -lazyExport('maxSatisfying', './ranges/max-satisfying') -lazyExport('minSatisfying', './ranges/min-satisfying') -lazyExport('minVersion', './ranges/min-version') -lazyExport('validRange', './ranges/valid') -lazyExport('outside', './ranges/outside') -lazyExport('gtr', './ranges/gtr') -lazyExport('ltr', './ranges/ltr') -lazyExport('intersects', './ranges/intersects') diff --git a/preload.js b/preload.js index 3a0b4e52..947cd4f7 100644 --- a/preload.js +++ b/preload.js @@ -1,46 +1,2 @@ -// just pre-load all the stuff that index.js lazily exports -const internalRe = require('./internal/re') -module.exports = { - re: internalRe.re, - src: internalRe.src, - tokens: internalRe.t, - SEMVER_SPEC_VERSION: require('./internal/constants').SEMVER_SPEC_VERSION, - SemVer: require('./classes/semver'), - compareIdentifiers: require('./internal/identifiers').compareIdentifiers, - rcompareIdentifiers: require('./internal/identifiers').rcompareIdentifiers, - parse: require('./functions/parse'), - valid: require('./functions/valid'), - clean: require('./functions/clean'), - inc: require('./functions/inc'), - diff: require('./functions/diff'), - major: require('./functions/major'), - minor: require('./functions/minor'), - patch: require('./functions/patch'), - prerelease: require('./functions/prerelease'), - compare: require('./functions/compare'), - rcompare: require('./functions/rcompare'), - compareLoose: require('./functions/compare-loose'), - compareBuild: require('./functions/compare-build'), - sort: require('./functions/sort'), - rsort: require('./functions/rsort'), - gt: require('./functions/gt'), - lt: require('./functions/lt'), - eq: require('./functions/eq'), - neq: require('./functions/neq'), - gte: require('./functions/gte'), - lte: require('./functions/lte'), - cmp: require('./functions/cmp'), - coerce: require('./functions/coerce'), - Comparator: require('./classes/comparator'), - Range: require('./classes/range'), - satisfies: require('./functions/satisfies'), - toComparators: require('./ranges/to-comparators'), - maxSatisfying: require('./ranges/max-satisfying'), - minSatisfying: require('./ranges/min-satisfying'), - minVersion: require('./ranges/min-version'), - validRange: require('./ranges/valid'), - outside: require('./ranges/outside'), - gtr: require('./ranges/gtr'), - ltr: require('./ranges/ltr'), - intersects: require('./ranges/intersects'), -} +// XXX remove in v8 or beyond +module.exports = require('./index.js') diff --git a/test/index.js b/test/index.js index 7a25fe6c..f22d86eb 100644 --- a/test/index.js +++ b/test/index.js @@ -1,21 +1,11 @@ const t = require('tap') const semver = require('../') - -t.match(Object.getOwnPropertyDescriptor(semver, 'SEMVER_SPEC_VERSION'), { - get: Function, - set: undefined, - enumerable: true, - configurable: true -}, 'properties are getters') - const {SEMVER_SPEC_VERSION} = require('../internal/constants') -t.match(semver.SEMVER_SPEC_VERSION, SEMVER_SPEC_VERSION, 'getter returns expected value') + t.match(Object.getOwnPropertyDescriptor(semver, 'SEMVER_SPEC_VERSION'), { get: undefined, set: undefined, value: SEMVER_SPEC_VERSION, configurable: true, enumerable: true -}, 'replaced with value prop after initial get') - -t.match(semver.parse, require('../functions/parse'), 'getter that does not have a subkey') +}, 'just a normal value property') diff --git a/test/preload.js b/test/preload.js index 0225306f..2f56aa5f 100644 --- a/test/preload.js +++ b/test/preload.js @@ -1,4 +1,4 @@ const t = require('tap') const preload = require('../preload.js') const index = require('../index.js') -t.strictSame(preload, index, 'preload and index match') +t.equal(preload, index, 'preload and index match') From 8f4d96d7816c296d311eef101588a3809170ea2b Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 30 Jan 2020 17:29:38 -0800 Subject: [PATCH 23/44] 7.1.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8197d28f..2f5a55f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.1", + "version": "7.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1c8338db..aa9e3011 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.1", + "version": "7.1.2", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 7c2ec1c2517a63351eb8cdec68810697bba2b855 Mon Sep 17 00:00:00 2001 From: James George Date: Sun, 22 Dec 2019 23:44:37 +0530 Subject: [PATCH 24/44] refactor: replace var with let PR-URL: https://github.com/npm/node-semver/pull/302 Credit: @jamesgeorge007 Close: #302 Reviewed-by: @isaacs --- functions/diff.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/diff.js b/functions/diff.js index 1493666e..7838961a 100644 --- a/functions/diff.js +++ b/functions/diff.js @@ -8,9 +8,10 @@ const diff = (version1, version2) => { const v1 = parse(version1) const v2 = parse(version2) let prefix = '' + let defaultResult if (v1.prerelease.length || v2.prerelease.length) { prefix = 'pre' - var defaultResult = 'prerelease' + defaultResult = 'prerelease' } for (const key in v1) { if (key === 'major' || key === 'minor' || key === 'patch') { From ebcf4df7533e48a47eb60341066cf53d676de908 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 11 Feb 2020 13:51:33 -0800 Subject: [PATCH 25/44] prefer const over let --- functions/diff.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/functions/diff.js b/functions/diff.js index 7838961a..87200ef3 100644 --- a/functions/diff.js +++ b/functions/diff.js @@ -7,12 +7,9 @@ const diff = (version1, version2) => { } else { const v1 = parse(version1) const v2 = parse(version2) - let prefix = '' - let defaultResult - if (v1.prerelease.length || v2.prerelease.length) { - prefix = 'pre' - defaultResult = 'prerelease' - } + 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]) { From 6e7982f23a0f2a378dad80de6a9acb435154e652 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 11 Feb 2020 13:53:07 -0800 Subject: [PATCH 26/44] 7.1.3 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2f5a55f7..2dafdf94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.2", + "version": "7.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index aa9e3011..0e70b071 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.2", + "version": "7.1.3", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 2b5ad50b09d408d27682581c4d2ec1d580e7e681 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 6 Apr 2020 16:31:35 -0700 Subject: [PATCH 27/44] Add method for simplifying ranges Need this for a case where we programmatically generate a list of all the versions subject to a security vulnerability by virtue of depending exclusively on vulnerable versions of a given dependency. While it's not a perfect heuristic, with this method on semver, instead of printing out something long and confusing like this: 8.0.1 || 8.0.2 || 9.0.0 || 9.0.1 || 10.0.0-alpha.0 || 10.0.0-alpha.1 || 10.0.0-alpha.2 || 10.0.0-alpha.3 || 10.0.0-alpha.4 || 10.0.0 || 10.0.1 || 10.0.2 || 10.0.3 || 10.1.0 || 10.1.1 || 10.1.2 || 11.0.0 || 11.1.0 || 12.0.0-candidate.0 || 12.0.0 || 12.0.1 we can show this: 8.0.1 - 11.1.0 || 12.0.0-candidate.0 - 12.0.1 --- README.md | 9 +++++++++ index.js | 1 + ranges/simplify.js | 44 +++++++++++++++++++++++++++++++++++++++++ test/ranges/simplify.js | 42 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 ranges/simplify.js create mode 100644 test/ranges/simplify.js diff --git a/README.md b/README.md index 9ba40454..ab408d3d 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ const semverOutside = require('semver/ranges/outside') const semverGtr = require('semver/ranges/gtr') const semverLtr = require('semver/ranges/ltr') const semverIntersects = require('semver/ranges/intersects') +const simplifyRange = require('semver/ranges/simplify') ``` As a command-line utility: @@ -446,6 +447,14 @@ strings that they parse. `hilo` argument must be either the string `'>'` or `'<'`. (This is the function called by `gtr` and `ltr`.) * `intersects(range)`: Return true if any of the ranges comparators intersect +* `simplifyRange(versions, range)`: Return a "simplified" range that + matches the same items in `versions` list as the range specified. Note + that it does *not* guarantee that it would match the same versions in all + cases, only for the set of versions provided. This is useful when + generating ranges by joining together multiple versions with `||` + programmatically, to provide the user with something a bit more + ergonomic. If the provided range is shorter in string-length than the + generated range, then that is returned. Note that, since ranges may be non-contiguous, a version might not be greater than a range, less than a range, *or* satisfy a range! For diff --git a/index.js b/index.js index 3a0b4e52..54a714a3 100644 --- a/index.js +++ b/index.js @@ -43,4 +43,5 @@ module.exports = { gtr: require('./ranges/gtr'), ltr: require('./ranges/ltr'), intersects: require('./ranges/intersects'), + simplifyRange: require('./ranges/simplify'), } diff --git a/ranges/simplify.js b/ranges/simplify.js new file mode 100644 index 00000000..b792f972 --- /dev/null +++ b/ranges/simplify.js @@ -0,0 +1,44 @@ +// given a set of versions and a range, create a "simplified" range +// that includes the same versions that the original range does +// If the original range is shorter than the simplified one, return that. +const satisfies = require('../functions/satisfies.js') +const compare = require('../functions/compare.js') +module.exports = (versions, range, options) => { + const set = [] + let min = 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 + } else { + if (prev) { + set.push([min, prev]) + } + prev = null + min = null + } + } + if (min) + set.push([min, null]) + + const ranges = [] + for (const [min, max] of set) { + if (min === max) + ranges.push(min) + else if (!max && min === v[0]) + ranges.push('*') + else if (!max) + ranges.push(`>=${min}`) + else if (min === v[0]) + ranges.push(`<=${max}`) + else + ranges.push(`${min} - ${max}`) + } + const simplified = ranges.join(' || ') + const original = typeof range.raw === 'string' ? range.raw : String(range) + return simplified.length < original.length ? simplified : range +} diff --git a/test/ranges/simplify.js b/test/ranges/simplify.js new file mode 100644 index 00000000..e8e794b6 --- /dev/null +++ b/test/ranges/simplify.js @@ -0,0 +1,42 @@ +const simplify = require('../../ranges/simplify.js') +const Range = require('../../classes/range.js') +const t = require('tap') +const versions = [ + '1.0.0', + '1.0.1', + '1.0.2', + '1.0.3', + '1.0.4', + '1.1.0', + '1.1.1', + '1.1.2', + '1.2.0', + '1.2.1', + '1.2.2', + '1.2.3', + '1.2.4', + '1.2.5', + '2.0.0', + '2.0.1', + '2.1.0', + '2.1.1', + '2.1.2', + '2.2.0', + '2.2.1', + '2.2.2', + '2.3.0', + '2.3.1', + '2.4.0', + '3.0.0', + '3.1.0', + '3.2.0', + '3.3.0', +] + +t.equal(simplify(versions, '1.x'), '1.x') +t.equal(simplify(versions, '1.0.0 || 1.0.1 || 1.0.2 || 1.0.3 || 1.0.4'), '<=1.0.4') +t.equal(simplify(versions, new Range('1.0.0 || 1.0.1 || 1.0.2 || 1.0.3 || 1.0.4')), '<=1.0.4') +t.equal(simplify(versions, '>=3.0.0 <3.1.0'), '3.0.0') +t.equal(simplify(versions, '3.0.0 || 3.1 || 3.2 || 3.3'), '>=3.0.0') +t.equal(simplify(versions, '1 || 2 || 3'), '*') +t.equal(simplify(versions, '2.1 || 2.2 || 2.3'), '2.1.0 - 2.3.1') From c6581a8b6bf6dac430a30eb6be60ed0e06c22f74 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 6 Apr 2020 16:36:04 -0700 Subject: [PATCH 28/44] 7.2.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2dafdf94..a4543d55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.3", + "version": "7.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0e70b071..edbdcadf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.1.3", + "version": "7.2.0", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 6eab8c2e7d24dfb59c9c20e5f176ba9cd1bcf8bd Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 6 Apr 2020 16:37:04 -0700 Subject: [PATCH 29/44] do not include vim swap files in package --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index edbdcadf..9b7ad3dd 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,12 @@ "semver": "./bin/semver.js" }, "files": [ - "bin", + "bin/**/*.js", "range.bnf", - "classes", - "functions", - "internal", - "ranges", + "classes/**/*.js", + "functions/**/*.js", + "internal/**/*.js", + "ranges/**/*.js", "index.js", "preload.js" ], From dfe658fd611ccbf6703b1c9315f9ad8cb29db1bb Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 6 Apr 2020 16:37:39 -0700 Subject: [PATCH 30/44] 7.2.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a4543d55..dbe766ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.0", + "version": "7.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9b7ad3dd..05e6d7ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.0", + "version": "7.2.1", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 77c95e3dcfafad310c03285586c1ee883007717d Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 10 Apr 2020 01:02:46 -0700 Subject: [PATCH 31/44] update changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db6b6d4d..a544237d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # changes log +## 7.2.0 + +* Add `simplifyRange` method to attempt to generate a more human-readable + range expression that is equivalent to a supplied range, for a given set + of versions. + +## 7.1.2 + +* Remove fancy lazy-loading logic, as it was causing problems for webpack + users. + ## 7.1.0 * Add `require('semver/preload')` to load the entire module without using From 044c54cc7c10cacc2c87a7e0fd57c0166c6c6c62 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 10 Apr 2020 08:54:20 -0700 Subject: [PATCH 32/44] fix: 2.0.0-rc1 should never be included in ^1.0.0 --- CHANGELOG.md | 5 +++++ classes/range.js | 19 ++++++++++--------- test/fixtures/range-exclude.js | 2 ++ test/fixtures/range-include.js | 1 - 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a544237d..07bf4184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # changes log +## 7.2.2 + +* Fix bug where `2.0.0-pre` would be included in `^1.0.0` if + `includePrerelease` was set to true. + ## 7.2.0 * Add `simplifyRange` method to attempt to generate a more human-readable diff --git a/classes/range.js b/classes/range.js index 90876c38..76d5e67b 100644 --- a/classes/range.js +++ b/classes/range.js @@ -243,6 +243,7 @@ const replaceCarets = (comp, options) => const replaceCaret = (comp, options) => { debug('caret', comp, options) const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + const z = options.includePrerelease ? '-0' : '' return comp.replace(r, (_, M, m, p, pr) => { debug('caret', comp, _, M, m, p, pr) let ret @@ -250,40 +251,40 @@ const replaceCaret = (comp, options) => { if (isX(M)) { ret = '' } else if (isX(m)) { - ret = `>=${M}.0.0 <${+M + 1}.0.0` + ret = `>=${M}.0.0${z} <${+M + 1}.0.0${z}` } else if (isX(p)) { if (M === '0') { - ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0` + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0${z}` } else { - ret = `>=${M}.${m}.0 <${+M + 1}.0.0` + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0${z}` } } else if (pr) { debug('replaceCaret pr', pr) if (M === '0') { if (m === '0') { ret = `>=${M}.${m}.${p}-${pr - } <${M}.${m}.${+p + 1}` + } <${M}.${m}.${+p + 1}${z}` } else { ret = `>=${M}.${m}.${p}-${pr - } <${M}.${+m + 1}.0` + } <${M}.${+m + 1}.0${z}` } } else { ret = `>=${M}.${m}.${p}-${pr - } <${+M + 1}.0.0` + } <${+M + 1}.0.0${z}` } } else { debug('no pr') if (M === '0') { if (m === '0') { ret = `>=${M}.${m}.${p - } <${M}.${m}.${+p + 1}` + }${z} <${M}.${m}.${+p + 1}${z}` } else { ret = `>=${M}.${m}.${p - } <${M}.${+m + 1}.0` + }${z} <${M}.${+m + 1}.0${z}` } } else { ret = `>=${M}.${m}.${p - } <${+M + 1}.0.0` + } <${+M + 1}.0.0${z}` } } diff --git a/test/fixtures/range-exclude.js b/test/fixtures/range-exclude.js index 2d764bd4..47c36406 100644 --- a/test/fixtures/range-exclude.js +++ b/test/fixtures/range-exclude.js @@ -78,4 +78,6 @@ module.exports = [ ['2.x', '3.0.0-pre.0', { includePrerelease: true }], ['^1.0.0', '1.0.0-rc1', { includePrerelease: true }], ['^1.2.3-rc2', '2.0.0', { includePrerelease: true }], + ['^1.0.0', '2.0.0-rc1', { includePrerelease: true }], + ['^1.0.0', '2.0.0-rc1'], ] diff --git a/test/fixtures/range-include.js b/test/fixtures/range-include.js index d523b2c7..1319c001 100644 --- a/test/fixtures/range-include.js +++ b/test/fixtures/range-include.js @@ -110,7 +110,6 @@ module.exports = [ ['2.x', '2.0.0-pre.0', { includePrerelease: true }], ['2.x', '2.1.0-pre.0', { includePrerelease: true }], ['*', '1.0.0-rc1', { includePrerelease: true }], - ['^1.0.0', '2.0.0-rc1', { includePrerelease: true }], ['^1.0.0-0', '1.0.1-rc1', { includePrerelease: true }], ['^1.0.0-rc2', '1.0.1-rc1', { includePrerelease: true }], ['^1.0.0', '1.0.1-rc1', { includePrerelease: true }], From 5d0dcdac5daeef368b73b9b67d1aa6f554315e2b Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 10 Apr 2020 09:00:51 -0700 Subject: [PATCH 33/44] 7.2.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index dbe766ec..9d8ff8dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.1", + "version": "7.2.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 05e6d7ea..86517d6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.1", + "version": "7.2.2", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 1bd5bdd9aba7be6e1aa90728faf135b4ed425880 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 13 Apr 2020 11:11:33 -0700 Subject: [PATCH 34/44] fix: Handle prereleases properly in 'X - Y' ranges If includePrerelease is set, then you'd expect 1.0.0-pre and 2.0.0-pre to be included in the range '1.0.0 - 2.0.0'. You would NOT expect that 3.0.0-pre would be included in that range. To accomplish this, the bounds of the range have to be set differently, using the '-0' minimum prerelease version identifier, to include and exclude prereleases appropriately when includePrerelease is set. --- classes/range.js | 18 +++++++++++------- test/fixtures/range-exclude.js | 5 +++++ test/fixtures/range-include.js | 3 +++ test/fixtures/range-parse.js | 5 +++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/classes/range.js b/classes/range.js index 76d5e67b..51125a01 100644 --- a/classes/range.js +++ b/classes/range.js @@ -68,7 +68,7 @@ class Range { range = range.trim() // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] - range = range.replace(hr, hyphenReplace) + range = range.replace(hr, hyphenReplace(this.options.includePrerelease)) debug('hyphen replace', range) // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) @@ -384,27 +384,31 @@ const replaceStars = (comp, options) => { // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do // 1.2 - 3.4 => >=1.2.0 <3.5.0 -const hyphenReplace = ($0, +const hyphenReplace = incPr => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => { if (isX(fM)) { from = '' } else if (isX(fm)) { - from = `>=${fM}.0.0` + from = `>=${fM}.0.0${incPr ? '-0' : ''}` } else if (isX(fp)) { - from = `>=${fM}.${fm}.0` - } else { + from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}` + } else if (fpr) { from = `>=${from}` + } else { + from = `>=${from}${incPr ? '-0' : ''}` } if (isX(tM)) { to = '' } else if (isX(tm)) { - to = `<${+tM + 1}.0.0` + to = `<${+tM + 1}.0.0${incPr ? '-0' : ''}` } else if (isX(tp)) { - to = `<${tM}.${+tm + 1}.0` + to = `<${tM}.${+tm + 1}.0${incPr ? '-0' : ''}` } else if (tpr) { to = `<=${tM}.${tm}.${tp}-${tpr}` + } else if (incPr) { + to = `<${tM}.${tm}.${+tp + 1}-0` } else { to = `<=${to}` } diff --git a/test/fixtures/range-exclude.js b/test/fixtures/range-exclude.js index 47c36406..209f93a0 100644 --- a/test/fixtures/range-exclude.js +++ b/test/fixtures/range-exclude.js @@ -80,4 +80,9 @@ module.exports = [ ['^1.2.3-rc2', '2.0.0', { includePrerelease: true }], ['^1.0.0', '2.0.0-rc1', { includePrerelease: true }], ['^1.0.0', '2.0.0-rc1'], + + ['1 - 2', '3.0.0-pre', { includePrerelease: true }], + ['1 - 2', '2.0.0-pre'], + ['1 - 2', '1.0.0-pre'], + ['1.0 - 2', '1.0.0-pre'], ] diff --git a/test/fixtures/range-include.js b/test/fixtures/range-include.js index 1319c001..07be3657 100644 --- a/test/fixtures/range-include.js +++ b/test/fixtures/range-include.js @@ -114,4 +114,7 @@ module.exports = [ ['^1.0.0-rc2', '1.0.1-rc1', { includePrerelease: true }], ['^1.0.0', '1.0.1-rc1', { includePrerelease: true }], ['^1.0.0', '1.1.0-rc1', { includePrerelease: true }], + ['1 - 2', '2.0.0-pre', { includePrerelease: true }], + ['1 - 2', '1.0.0-pre', { includePrerelease: true }], + ['1.0 - 2', '1.0.0-pre', { includePrerelease: true }], ] diff --git a/test/fixtures/range-parse.js b/test/fixtures/range-parse.js index a09c1f7d..65744c4b 100644 --- a/test/fixtures/range-parse.js +++ b/test/fixtures/range-parse.js @@ -4,6 +4,11 @@ // new Range().range will be '' in those cases module.exports = [ ['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], + ['1.0.0 - 2.0.0', '>=1.0.0-0 <2.0.1-0', { includePrerelease: true }], + ['1 - 2', '>=1.0.0 <3.0.0'], + ['1 - 2', '>=1.0.0-0 <3.0.0-0', { includePrerelease: true }], + ['1.0 - 2.0', '>=1.0.0 <2.1.0'], + ['1.0 - 2.0', '>=1.0.0-0 <2.1.0-0', { includePrerelease: true }], ['1.0.0', '1.0.0', { loose: false }], ['>=*', '*'], ['', '*'], From 0365d6f6363b14aadba747c51e589de53b2fd54d Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 10 Apr 2020 09:52:18 -0700 Subject: [PATCH 35/44] update tap to make npm audit happy --- package-lock.json | 1421 ++++++++++++++++++++------------------------- package.json | 2 +- 2 files changed, 620 insertions(+), 803 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9d8ff8dd..21ca9487 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,21 +5,21 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", - "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", + "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", "dev": true, "requires": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.8.3" } }, "@babel/generator": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.4.tgz", - "integrity": "sha512-m5qo2WgdOJeyYngKImbkyQrnUN1mPceaG5BV+G0E3gWsa4l/jCSryWJdM2x8OuGAOyh+3d5pVYfZWCiNFtynxg==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.5.tgz", + "integrity": "sha512-GbNIxVB3ZJe3tLeDm1HSn2AhuD/mVcyLDpgtLXa5tplmWrJdF/elxB56XNqCuD6szyNkDi6wuoKXln3QeBmCHQ==", "dev": true, "requires": { - "@babel/types": "^7.7.4", + "@babel/types": "^7.9.5", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" @@ -34,106 +34,112 @@ } }, "@babel/helper-function-name": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.4.tgz", - "integrity": "sha512-AnkGIdiBhEuiwdoMnKm7jfPfqItZhgRaZfMg1XX3bS25INOnLPjPG1Ppnajh8eqgt5kPJnfqrRHqFqmjKDZLzQ==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz", + "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.7.4", - "@babel/template": "^7.7.4", - "@babel/types": "^7.7.4" + "@babel/helper-get-function-arity": "^7.8.3", + "@babel/template": "^7.8.3", + "@babel/types": "^7.9.5" } }, "@babel/helper-get-function-arity": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.4.tgz", - "integrity": "sha512-QTGKEdCkjgzgfJ3bAyRwF4yyT3pg+vDgan8DSivq1eS0gwi+KGKE5x8kRcbeFTb/673mkO5SN1IZfmCfA5o+EA==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", + "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", "dev": true, "requires": { - "@babel/types": "^7.7.4" + "@babel/types": "^7.8.3" } }, "@babel/helper-split-export-declaration": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.4.tgz", - "integrity": "sha512-guAg1SXFcVr04Guk9eq0S4/rWS++sbmyqosJzVs8+1fH5NI+ZcmkaSkc7dmtAFbHFva6yRJnjW3yAcGxjueDug==", + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", + "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", "dev": true, "requires": { - "@babel/types": "^7.7.4" + "@babel/types": "^7.8.3" } }, + "@babel/helper-validator-identifier": { + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", + "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==", + "dev": true + }, "@babel/highlight": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", - "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz", + "integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==", "dev": true, "requires": { + "@babel/helper-validator-identifier": "^7.9.0", "chalk": "^2.0.0", - "esutils": "^2.0.2", "js-tokens": "^4.0.0" } }, "@babel/parser": { - "version": "7.7.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.5.tgz", - "integrity": "sha512-KNlOe9+/nk4i29g0VXgl8PEXIRms5xKLJeuZ6UptN0fHv+jDiriG+y94X6qAgWTR0h3KaoM1wK5G5h7MHFRSig==", + "version": "7.9.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.4.tgz", + "integrity": "sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA==", "dev": true }, "@babel/runtime": { - "version": "7.7.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.6.tgz", - "integrity": "sha512-BWAJxpNVa0QlE5gZdWjSxXtemZyZ9RmrmVozxt3NUXeZhVIJ5ANyqmMc0JDrivBZyxUuQvFxlvH4OWWOogGfUw==", + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.9.2.tgz", + "integrity": "sha512-NE2DtOdufG7R5vnfQUTehdTfNycfUANEtCa9PssN9O/xmTzP4E08UI797ixaei6hBEVL9BI/PsdJS5x7mWoB9Q==", "dev": true, "requires": { - "regenerator-runtime": "^0.13.2" + "regenerator-runtime": "^0.13.4" } }, "@babel/template": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.4.tgz", - "integrity": "sha512-qUzihgVPguAzXCK7WXw8pqs6cEwi54s3E+HrejlkuWO6ivMKx9hZl3Y2fSXp9i5HgyWmj7RKP+ulaYnKM4yYxw==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz", + "integrity": "sha512-zbMsPMy/v0PWFZEhQJ66bqjhH+z0JgMoBWuikXybgG3Gkd/3t5oQ1Rw2WQhnSrsOmsKXnZOx15tkC4qON/+JPg==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.4", - "@babel/types": "^7.7.4" + "@babel/code-frame": "^7.8.3", + "@babel/parser": "^7.8.6", + "@babel/types": "^7.8.6" } }, "@babel/traverse": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.4.tgz", - "integrity": "sha512-P1L58hQyupn8+ezVA2z5KBm4/Zr4lCC8dwKCMYzsa5jFMDMQAzaBNy9W5VjB+KAmBjb40U7a/H6ao+Xo+9saIw==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.5.tgz", + "integrity": "sha512-c4gH3jsvSuGUezlP6rzSJ6jf8fYjLj3hsMZRx/nX0h+fmHN0w+ekubRrHPqnMec0meycA2nwCsJ7dC8IPem2FQ==", "dev": true, "requires": { - "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.7.4", - "@babel/helper-function-name": "^7.7.4", - "@babel/helper-split-export-declaration": "^7.7.4", - "@babel/parser": "^7.7.4", - "@babel/types": "^7.7.4", + "@babel/code-frame": "^7.8.3", + "@babel/generator": "^7.9.5", + "@babel/helper-function-name": "^7.9.5", + "@babel/helper-split-export-declaration": "^7.8.3", + "@babel/parser": "^7.9.0", + "@babel/types": "^7.9.5", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" } }, "@babel/types": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.4.tgz", - "integrity": "sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==", + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.5.tgz", + "integrity": "sha512-XjnvNqenk818r5zMaba+sLQjnbda31UfUURv3ei0qPQw4u+j2jMyJ5b11y8ZHYTRSI3NnInQkkkRT4fLqqPdHg==", "dev": true, "requires": { - "esutils": "^2.0.2", + "@babel/helper-validator-identifier": "^7.9.5", "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } }, "ajv": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", - "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.0.tgz", + "integrity": "sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==", "dev": true, "requires": { - "fast-deep-equal": "^2.0.1", + "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" @@ -180,9 +186,9 @@ "dev": true }, "arg": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz", - "integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", "dev": true }, "argparse": { @@ -231,9 +237,9 @@ "dev": true }, "aws4": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.0.tgz", - "integrity": "sha512-Uvq6hVe90D0B2WEnUqtdgY1bATGz3mw33nH9Y+dmA+w5DHvUmBgkr5rM/KCHpCsiFNRUfokW/szpPPgMK2hm4A==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", + "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==", "dev": true }, "balanced-match": { @@ -343,19 +349,19 @@ } }, "chokidar": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", - "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.1.tgz", + "integrity": "sha512-4QYCEWOcK3OJrxwvyyAOxFuhpvOVCYkr33LPfFNBjAD/w3sEzWsp2BUOkI4l9bHvWioAd0rc6NlHUOEaWkTeqg==", "dev": true, "requires": { "anymatch": "~3.1.1", "braces": "~3.0.2", - "fsevents": "~2.1.1", + "fsevents": "~2.1.2", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", - "readdirp": "~3.2.0" + "readdirp": "~3.3.0" } }, "cliui": { @@ -405,13 +411,6 @@ "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "optional": true - }, "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -448,15 +447,15 @@ "dev": true }, "coveralls": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.9.tgz", - "integrity": "sha512-nNBg3B1+4iDox5A5zqHKzUTiwl2ey4k2o0NEcVZYvl+GOSJdKBj4AJGKLv6h3SvWch7tABHePAQOSZWM9E2hMg==", + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.11.tgz", + "integrity": "sha512-LZPWPR2NyGKyaABnc49dR0fpeP6UqhvGq4B5nUrTQ1UBy55z96+ga7r+/ChMdMJUwBgyJDXBi88UBgz2rs9IiQ==", "dev": true, "requires": { "js-yaml": "^3.13.1", "lcov-parse": "^1.0.0", "log-driver": "^1.2.7", - "minimist": "^1.2.0", + "minimist": "^1.2.5", "request": "^2.88.0" } }, @@ -534,9 +533,9 @@ "dev": true }, "diff": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", - "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true }, "diff-frag": { @@ -594,12 +593,6 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, "events-to-array": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/events-to-array/-/events-to-array-1.1.2.tgz", @@ -619,9 +612,9 @@ "dev": true }, "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", + "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", "dev": true }, "fast-json-stable-stringify": { @@ -666,18 +659,18 @@ "dev": true }, "flow-parser": { - "version": "0.114.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.114.0.tgz", - "integrity": "sha512-Qt9HT3v507bCerJfp4FX4N5E7ysinBzxjpK1rL7bJ/Bw12puF6lva2MAIXYS1d83bV7BT/F7EDk+faJQY5MpRA==", + "version": "0.122.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.122.0.tgz", + "integrity": "sha512-rb4pLIb7JAWn4dnO+fB9YLTUOM0SvY1ZN2yeu2NOyL7f2JeXBp9Nevqf+h4OluQcdI+9CnGa/if/HUy1YOX0dA==", "dev": true }, "flow-remove-types": { - "version": "2.114.0", - "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.114.0.tgz", - "integrity": "sha512-ckon8RO7tFcVGW3Ll0jAWgULVrNa/cEN0JXp2I7XmzWT/GCQghSb+0312NjtAb+y3W9iXpPxkVMI86+SDU0E0Q==", + "version": "2.122.0", + "resolved": "https://registry.npmjs.org/flow-remove-types/-/flow-remove-types-2.122.0.tgz", + "integrity": "sha512-48cyUF9nyqwlQGRnncNWJNFSIN+sMpeHhqtATwnUZE3bDG8QXH2YS8mL68Xzxs9BVRzcUI+r9ib7d9E/rqUpuQ==", "dev": true, "requires": { - "flow-parser": "^0.114.0", + "flow-parser": "^0.122.0", "pirates": "^3.0.2", "vlq": "^0.2.1" } @@ -764,9 +757,9 @@ } }, "glob-parent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", - "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", "dev": true, "requires": { "is-glob": "^4.0.1" @@ -784,18 +777,6 @@ "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", "dev": true }, - "handlebars": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", - "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", - "dev": true, - "requires": { - "neo-async": "^2.6.0", - "optimist": "^0.6.1", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4" - } - }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -828,9 +809,15 @@ } }, "hosted-git-info": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", - "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, "http-signature": { @@ -920,13 +907,6 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true, - "optional": true - }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -1050,12 +1030,12 @@ } }, "istanbul-reports": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.6.tgz", - "integrity": "sha512-SKi4rnMyLBKe0Jy2uUdx28h8oG7ph2PPuQPvIAh31d+Ci+lSiEu4C+h3oBPuJ9+mPKhOyW0M8gY4U5NM1WLeXA==", + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.7.tgz", + "integrity": "sha512-uu1F/L1o5Y6LzPVSVZXNOoD/KXpJue9aeLRd0sM9uMXfZvzomB0WxVamWb5ue8kA2vVWEmW7EG+A5n3f1kqHKg==", "dev": true, "requires": { - "handlebars": "^4.1.2" + "html-escaper": "^2.0.0" } }, "jackspeak": { @@ -1215,9 +1195,9 @@ } }, "make-error": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", - "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, "merge-source-map": { @@ -1230,18 +1210,18 @@ } }, "mime-db": { - "version": "1.42.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", - "integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==", + "version": "1.43.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", "dev": true }, "mime-types": { - "version": "2.1.25", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz", - "integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==", + "version": "2.1.26", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", + "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", "dev": true, "requires": { - "mime-db": "1.42.0" + "mime-db": "1.43.0" } }, "minimatch": { @@ -1254,9 +1234,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, "minipass": { @@ -1277,20 +1257,12 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } + "minimist": "^1.2.5" } }, "ms": { @@ -1299,12 +1271,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "neo-async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", - "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", - "dev": true - }, "nested-error-stacks": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-2.1.0.tgz", @@ -1407,24 +1373,6 @@ "integrity": "sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==", "dev": true }, - "optimist": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", - "dev": true, - "requires": { - "minimist": "~0.0.1", - "wordwrap": "~0.0.2" - }, - "dependencies": { - "minimist": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", - "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", - "dev": true - } - } - }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", @@ -1447,9 +1395,9 @@ } }, "p-limit": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", - "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -1540,9 +1488,9 @@ "dev": true }, "picomatch": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.1.1.tgz", - "integrity": "sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "dev": true }, "pify": { @@ -1569,13 +1517,6 @@ "find-up": "^3.0.0" } }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true, - "optional": true - }, "prop-types": { "version": "15.7.2", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.2.tgz", @@ -1594,9 +1535,9 @@ "dev": true }, "psl": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.6.0.tgz", - "integrity": "sha512-SYKKmVel98NCOYXpkwUqZqh0ahZeeKfmisiLIcEZdsb+WbLv02g/dI5BUmZnIyOe7RzZtLax81nnb2HbvC2tzA==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", + "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", "dev": true }, "punycode": { @@ -1612,9 +1553,9 @@ "dev": true }, "react": { - "version": "16.12.0", - "resolved": "https://registry.npmjs.org/react/-/react-16.12.0.tgz", - "integrity": "sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==", + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz", + "integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==", "dev": true, "requires": { "loose-envify": "^1.1.0", @@ -1623,9 +1564,9 @@ } }, "react-is": { - "version": "16.12.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.12.0.tgz", - "integrity": "sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==", + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "dev": true }, "read-pkg": { @@ -1649,44 +1590,19 @@ "read-pkg": "^3.0.0" } }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "optional": true - } - } - }, "readdirp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", - "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.3.0.tgz", + "integrity": "sha512-zz0pAkSPOXXm1viEwygWIPSPkcBYjW1xU5j/JBh5t9bGCJwa6f9+BJa6VaB2g+b55yVrmXzqkyLf4xaWYM0IkQ==", "dev": true, "requires": { - "picomatch": "^2.0.4" + "picomatch": "^2.0.7" } }, "regenerator-runtime": { - "version": "0.13.3", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", - "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==", + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", + "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", "dev": true }, "release-zalgo": { @@ -1699,9 +1615,9 @@ } }, "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", "dev": true, "requires": { "aws-sign2": "~0.7.0", @@ -1711,7 +1627,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.0", + "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -1721,7 +1637,7 @@ "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", + "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" } @@ -1739,9 +1655,9 @@ "dev": true }, "resolve": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz", - "integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1802,9 +1718,9 @@ "dev": true }, "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", "dev": true }, "source-map": { @@ -1919,25 +1835,6 @@ "strip-ansi": "^4.0.0" } }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "optional": true - } - } - }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -1963,11 +1860,12 @@ } }, "tap": { - "version": "14.10.2", - "resolved": "https://registry.npmjs.org/tap/-/tap-14.10.2.tgz", - "integrity": "sha512-JeUDsVrMFmR6b3p9hO9yIT/jibrK6LI7nFza5cqDGsxJyCp7yU3enRgS5nekuoAOzewbrU7P+9QDRDT01urROA==", + "version": "14.10.7", + "resolved": "https://registry.npmjs.org/tap/-/tap-14.10.7.tgz", + "integrity": "sha512-DVx00lfiMxFhofwFDP77pitRCruVQJn8Dcj/6auIU3dErJQWsKT94oG6Yj0MQRuYANhSec8ruIPyUjH/RI9Hrw==", "dev": true, "requires": { + "@types/react": "^16.9.16", "async-hook-domain": "^1.1.3", "bind-obj-methods": "^2.0.0", "browser-process-hrtime": "^1.0.0", @@ -1982,8 +1880,8 @@ "fs-exists-cached": "^1.0.0", "function-loop": "^1.0.2", "glob": "^7.1.6", - "import-jsx": "^3.0.0", - "ink": "^2.5.0", + "import-jsx": "^3.1.0", + "ink": "^2.6.0", "isexe": "^2.0.0", "istanbul-lib-processinfo": "^1.0.0", "jackspeak": "^1.4.0", @@ -2002,7 +1900,7 @@ "tap-parser": "^10.0.1", "tap-yaml": "^1.0.0", "tcompare": "^3.0.0", - "treport": "^1.0.0", + "treport": "^1.0.2", "trivial-deferred": "^1.0.1", "ts-node": "^8.5.2", "typescript": "^3.7.2", @@ -2013,26 +1911,28 @@ }, "dependencies": { "@babel/code-frame": { - "version": "7.5.5", + "version": "7.8.3", "bundled": true, + "dev": true, "requires": { - "@babel/highlight": "^7.0.0" + "@babel/highlight": "^7.8.3" } }, "@babel/core": { - "version": "7.7.4", + "version": "7.8.7", "bundled": true, "dev": true, "requires": { - "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.7.4", - "@babel/helpers": "^7.7.4", - "@babel/parser": "^7.7.4", - "@babel/template": "^7.7.4", - "@babel/traverse": "^7.7.4", - "@babel/types": "^7.7.4", + "@babel/code-frame": "^7.8.3", + "@babel/generator": "^7.8.7", + "@babel/helpers": "^7.8.4", + "@babel/parser": "^7.8.7", + "@babel/template": "^7.8.6", + "@babel/traverse": "^7.8.6", + "@babel/types": "^7.8.7", "convert-source-map": "^1.7.0", "debug": "^4.1.0", + "gensync": "^1.0.0-beta.1", "json5": "^2.1.0", "lodash": "^4.17.13", "resolve": "^1.3.2", @@ -2040,110 +1940,6 @@ "source-map": "^0.5.0" }, "dependencies": { - "@babel/generator": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/types": "^7.7.4", - "jsesc": "^2.5.1", - "lodash": "^4.17.13", - "source-map": "^0.5.0" - } - }, - "@babel/helper-function-name": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/helper-get-function-arity": "^7.7.4", - "@babel/template": "^7.7.4", - "@babel/types": "^7.7.4" - } - }, - "@babel/helper-get-function-arity": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/types": "^7.7.4" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/types": "^7.7.4" - } - }, - "@babel/parser": { - "version": "7.7.4", - "bundled": true, - "dev": true - }, - "@babel/template": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.4", - "@babel/types": "^7.7.4" - } - }, - "@babel/traverse": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.7.4", - "@babel/helper-function-name": "^7.7.4", - "@babel/helper-split-export-declaration": "^7.7.4", - "@babel/parser": "^7.7.4", - "@babel/types": "^7.7.4", - "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.13" - } - }, - "@babel/types": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.13", - "to-fast-properties": "^2.0.0" - } - }, - "convert-source-map": { - "version": "1.7.0", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "~5.1.1" - } - }, - "debug": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "bundled": true, - "dev": true - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "dev": true - }, "source-map": { "version": "0.5.7", "bundled": true, @@ -2152,10 +1948,11 @@ } }, "@babel/generator": { - "version": "7.7.2", + "version": "7.8.8", "bundled": true, + "dev": true, "requires": { - "@babel/types": "^7.7.2", + "@babel/types": "^7.8.7", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" @@ -2163,226 +1960,157 @@ "dependencies": { "source-map": { "version": "0.5.7", - "bundled": true + "bundled": true, + "dev": true } } }, "@babel/helper-builder-react-jsx": { - "version": "7.7.4", + "version": "7.8.3", "bundled": true, "dev": true, "requires": { - "@babel/types": "^7.7.4", + "@babel/types": "^7.8.3", "esutils": "^2.0.0" - }, - "dependencies": { - "@babel/types": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.13", - "to-fast-properties": "^2.0.0" - } - } + } + }, + "@babel/helper-function-name": { + "version": "7.8.3", + "bundled": true, + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.8.3", + "@babel/template": "^7.8.3", + "@babel/types": "^7.8.3" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.8.3", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.8.3" } }, "@babel/helper-plugin-utils": { - "version": "7.0.0", + "version": "7.8.3", "bundled": true, "dev": true }, + "@babel/helper-split-export-declaration": { + "version": "7.8.3", + "bundled": true, + "dev": true, + "requires": { + "@babel/types": "^7.8.3" + } + }, "@babel/helpers": { - "version": "7.7.4", + "version": "7.8.4", "bundled": true, "dev": true, "requires": { - "@babel/template": "^7.7.4", - "@babel/traverse": "^7.7.4", - "@babel/types": "^7.7.4" - }, - "dependencies": { - "@babel/generator": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/types": "^7.7.4", - "jsesc": "^2.5.1", - "lodash": "^4.17.13", - "source-map": "^0.5.0" - } - }, - "@babel/helper-function-name": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/helper-get-function-arity": "^7.7.4", - "@babel/template": "^7.7.4", - "@babel/types": "^7.7.4" - } - }, - "@babel/helper-get-function-arity": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/types": "^7.7.4" - } - }, - "@babel/helper-split-export-declaration": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/types": "^7.7.4" - } - }, - "@babel/parser": { - "version": "7.7.4", - "bundled": true, - "dev": true - }, - "@babel/template": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.4", - "@babel/types": "^7.7.4" - } - }, - "@babel/traverse": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "@babel/code-frame": "^7.5.5", - "@babel/generator": "^7.7.4", - "@babel/helper-function-name": "^7.7.4", - "@babel/helper-split-export-declaration": "^7.7.4", - "@babel/parser": "^7.7.4", - "@babel/types": "^7.7.4", - "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.13" - } - }, - "@babel/types": { - "version": "7.7.4", - "bundled": true, - "dev": true, - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.13", - "to-fast-properties": "^2.0.0" - } - }, - "debug": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "bundled": true, - "dev": true - }, - "source-map": { - "version": "0.5.7", - "bundled": true, - "dev": true - } + "@babel/template": "^7.8.3", + "@babel/traverse": "^7.8.4", + "@babel/types": "^7.8.3" } }, "@babel/highlight": { - "version": "7.5.0", + "version": "7.8.3", "bundled": true, + "dev": true, "requires": { "chalk": "^2.0.0", "esutils": "^2.0.2", "js-tokens": "^4.0.0" - }, - "dependencies": { - "js-tokens": { - "version": "4.0.0", - "bundled": true - } } }, "@babel/parser": { - "version": "7.7.3", - "bundled": true + "version": "7.8.8", + "bundled": true, + "dev": true }, "@babel/plugin-proposal-object-rest-spread": { - "version": "7.7.4", + "version": "7.8.3", "bundled": true, "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-syntax-object-rest-spread": "^7.7.4" + "@babel/helper-plugin-utils": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.0" } }, "@babel/plugin-syntax-jsx": { - "version": "7.7.4", + "version": "7.8.3", "bundled": true, "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-plugin-utils": "^7.8.3" } }, "@babel/plugin-syntax-object-rest-spread": { - "version": "7.7.4", + "version": "7.8.3", "bundled": true, "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-plugin-utils": "^7.8.0" } }, "@babel/plugin-transform-destructuring": { - "version": "7.7.4", + "version": "7.8.8", "bundled": true, "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-plugin-utils": "^7.8.3" } }, "@babel/plugin-transform-react-jsx": { - "version": "7.7.4", + "version": "7.8.3", "bundled": true, "dev": true, "requires": { - "@babel/helper-builder-react-jsx": "^7.7.4", - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-syntax-jsx": "^7.7.4" + "@babel/helper-builder-react-jsx": "^7.8.3", + "@babel/helper-plugin-utils": "^7.8.3", + "@babel/plugin-syntax-jsx": "^7.8.3" } }, "@babel/runtime": { - "version": "7.7.4", + "version": "7.8.7", "bundled": true, "dev": true, "requires": { - "regenerator-runtime": "^0.13.2" + "regenerator-runtime": "^0.13.4" } }, "@babel/template": { - "version": "7.7.0", + "version": "7.8.6", "bundled": true, + "dev": true, + "requires": { + "@babel/code-frame": "^7.8.3", + "@babel/parser": "^7.8.6", + "@babel/types": "^7.8.6" + } + }, + "@babel/traverse": { + "version": "7.8.6", + "bundled": true, + "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.0", - "@babel/types": "^7.7.0" + "@babel/code-frame": "^7.8.3", + "@babel/generator": "^7.8.6", + "@babel/helper-function-name": "^7.8.3", + "@babel/helper-split-export-declaration": "^7.8.3", + "@babel/parser": "^7.8.6", + "@babel/types": "^7.8.6", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" } }, "@babel/types": { - "version": "7.7.2", + "version": "7.8.7", "bundled": true, + "dev": true, "requires": { "esutils": "^2.0.2", "lodash": "^4.17.13", @@ -2400,7 +2128,7 @@ "dev": true }, "@types/react": { - "version": "16.9.13", + "version": "16.9.23", "bundled": true, "dev": true, "requires": { @@ -2408,21 +2136,28 @@ "csstype": "^2.2.0" } }, + "@types/yoga-layout": { + "version": "1.9.1", + "bundled": true, + "dev": true + }, "ansi-escapes": { - "version": "4.3.0", + "version": "4.3.1", "bundled": true, "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.11.0" } }, "ansi-regex": { - "version": "2.1.1", - "bundled": true + "version": "5.0.0", + "bundled": true, + "dev": true }, "ansi-styles": { "version": "3.2.1", "bundled": true, + "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -2433,22 +2168,19 @@ "dev": true }, "arrify": { - "version": "1.0.1", + "version": "2.0.1", "bundled": true, "dev": true }, "astral-regex": { - "version": "1.0.0", + "version": "2.0.0", "bundled": true, "dev": true }, "auto-bind": { - "version": "2.1.1", + "version": "4.0.0", "bundled": true, - "dev": true, - "requires": { - "@types/react": "^16.8.12" - } + "dev": true }, "caller-callsite": { "version": "2.0.0", @@ -2483,6 +2215,7 @@ "chalk": { "version": "2.4.2", "bundled": true, + "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -2495,53 +2228,72 @@ "dev": true }, "cli-cursor": { - "version": "2.1.0", + "version": "3.1.0", "bundled": true, "dev": true, "requires": { - "restore-cursor": "^2.0.0" + "restore-cursor": "^3.1.0" } }, "cli-truncate": { - "version": "1.1.0", + "version": "2.1.0", "bundled": true, "dev": true, "requires": { - "slice-ansi": "^1.0.0", - "string-width": "^2.0.0" + "slice-ansi": "^3.0.0", + "string-width": "^4.2.0" } }, "color-convert": { "version": "1.9.3", "bundled": true, + "dev": true, "requires": { "color-name": "1.1.3" } }, "color-name": { "version": "1.1.3", - "bundled": true - }, - "csstype": { - "version": "2.6.7", "bundled": true, "dev": true }, - "debug": { - "version": "2.6.9", + "convert-source-map": { + "version": "1.7.0", "bundled": true, + "dev": true, "requires": { - "ms": "2.0.0" - } - }, - "emoji-regex": { - "version": "7.0.3", - "bundled": true, - "dev": true + "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "bundled": true, + "dev": true + } + } + }, + "csstype": { + "version": "2.6.9", + "bundled": true, + "dev": true + }, + "debug": { + "version": "4.1.1", + "bundled": true, + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "emoji-regex": { + "version": "8.0.0", + "bundled": true, + "dev": true }, "escape-string-regexp": { "version": "1.0.5", - "bundled": true + "bundled": true, + "dev": true }, "esprima": { "version": "4.0.1", @@ -2550,13 +2302,19 @@ }, "esutils": { "version": "2.0.3", - "bundled": true + "bundled": true, + "dev": true }, "events-to-array": { "version": "1.1.2", "bundled": true, "dev": true }, + "gensync": { + "version": "1.0.0-beta.1", + "bundled": true, + "dev": true + }, "globals": { "version": "11.12.0", "bundled": true, @@ -2564,10 +2322,11 @@ }, "has-flag": { "version": "3.0.0", - "bundled": true + "bundled": true, + "dev": true }, "import-jsx": { - "version": "3.0.0", + "version": "3.1.0", "bundled": true, "dev": true, "requires": { @@ -2580,29 +2339,74 @@ } }, "ink": { - "version": "2.5.0", + "version": "2.7.1", "bundled": true, "dev": true, "requires": { - "@types/react": "^16.8.6", "ansi-escapes": "^4.2.1", - "arrify": "^1.0.1", - "auto-bind": "^2.0.0", - "chalk": "^2.4.1", - "cli-cursor": "^2.1.0", - "cli-truncate": "^1.1.0", + "arrify": "^2.0.1", + "auto-bind": "^4.0.0", + "chalk": "^3.0.0", + "cli-cursor": "^3.1.0", + "cli-truncate": "^2.1.0", "is-ci": "^2.0.0", "lodash.throttle": "^4.1.1", "log-update": "^3.0.0", "prop-types": "^15.6.2", - "react-reconciler": "^0.21.0", - "scheduler": "^0.15.0", + "react-reconciler": "^0.24.0", + "scheduler": "^0.18.0", "signal-exit": "^3.0.2", - "slice-ansi": "^1.0.0", - "string-length": "^2.0.0", - "widest-line": "^2.0.0", - "wrap-ansi": "^5.0.0", + "slice-ansi": "^3.0.0", + "string-length": "^3.1.0", + "widest-line": "^3.1.0", + "wrap-ansi": "^6.2.0", "yoga-layout-prebuilt": "^1.9.3" + }, + "dependencies": { + "ansi-styles": { + "version": "4.2.1", + "bundled": true, + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "bundled": true, + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "bundled": true, + "dev": true + }, + "supports-color": { + "version": "7.1.0", + "bundled": true, + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "is-ci": { @@ -2614,30 +2418,32 @@ } }, "is-fullwidth-code-point": { - "version": "2.0.0", + "version": "3.0.0", "bundled": true, "dev": true }, "js-tokens": { - "version": "3.0.2", + "version": "4.0.0", "bundled": true, "dev": true }, "jsesc": { "version": "2.5.2", - "bundled": true + "bundled": true, + "dev": true }, "json5": { - "version": "2.1.1", + "version": "2.1.2", "bundled": true, "dev": true, "requires": { - "minimist": "^1.2.0" + "minimist": "^1.2.5" } }, "lodash": { "version": "4.17.15", - "bundled": true + "bundled": true, + "dev": true }, "lodash.throttle": { "version": "4.1.1", @@ -2645,7 +2451,7 @@ "dev": true }, "log-update": { - "version": "3.3.0", + "version": "3.4.0", "bundled": true, "dev": true, "requires": { @@ -2658,6 +2464,79 @@ "version": "3.2.0", "bundled": true, "dev": true + }, + "ansi-regex": { + "version": "4.1.0", + "bundled": true, + "dev": true + }, + "cli-cursor": { + "version": "2.1.0", + "bundled": true, + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "emoji-regex": { + "version": "7.0.3", + "bundled": true, + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "mimic-fn": { + "version": "1.2.0", + "bundled": true, + "dev": true + }, + "onetime": { + "version": "2.0.1", + "bundled": true, + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "restore-cursor": { + "version": "2.0.0", + "bundled": true, + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, + "string-width": { + "version": "3.1.0", + "bundled": true, + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, + "wrap-ansi": { + "version": "5.1.0", + "bundled": true, + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } } } }, @@ -2670,12 +2549,12 @@ } }, "mimic-fn": { - "version": "1.2.0", + "version": "2.1.0", "bundled": true, "dev": true }, "minimist": { - "version": "1.2.0", + "version": "1.2.5", "bundled": true, "dev": true }, @@ -2695,8 +2574,9 @@ } }, "ms": { - "version": "2.0.0", - "bundled": true + "version": "2.1.2", + "bundled": true, + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2704,11 +2584,11 @@ "dev": true }, "onetime": { - "version": "2.0.1", + "version": "5.1.0", "bundled": true, "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "mimic-fn": "^2.1.0" } }, "path-parse": { @@ -2732,19 +2612,19 @@ "dev": true }, "react-is": { - "version": "16.10.2", + "version": "16.13.1", "bundled": true, "dev": true }, "react-reconciler": { - "version": "0.21.0", + "version": "0.24.0", "bundled": true, "dev": true, "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", "prop-types": "^15.6.2", - "scheduler": "^0.15.0" + "scheduler": "^0.18.0" } }, "redeyed": { @@ -2756,12 +2636,12 @@ } }, "regenerator-runtime": { - "version": "0.13.3", + "version": "0.13.5", "bundled": true, "dev": true }, "resolve": { - "version": "1.12.0", + "version": "1.15.1", "bundled": true, "dev": true, "requires": { @@ -2774,16 +2654,16 @@ "dev": true }, "restore-cursor": { - "version": "2.0.0", + "version": "3.1.0", "bundled": true, "dev": true, "requires": { - "onetime": "^2.0.0", + "onetime": "^5.1.0", "signal-exit": "^3.0.2" } }, "scheduler": { - "version": "0.15.0", + "version": "0.18.0", "bundled": true, "dev": true, "requires": { @@ -2802,75 +2682,90 @@ "dev": true }, "slice-ansi": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0" - } - }, - "source-map": { - "version": "0.6.1", - "bundled": true - }, - "string-length": { - "version": "2.0.0", + "version": "3.0.0", "bundled": true, "dev": true, "requires": { - "astral-regex": "^1.0.0", - "strip-ansi": "^4.0.0" + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", + "ansi-styles": { + "version": "4.2.1", "bundled": true, - "dev": true + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } }, - "strip-ansi": { - "version": "4.0.0", + "color-convert": { + "version": "2.0.1", "bundled": true, "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "color-name": "~1.1.4" } + }, + "color-name": { + "version": "1.1.4", + "bundled": true, + "dev": true } } }, - "string-width": { - "version": "2.1.1", + "string-length": { + "version": "3.1.0", "bundled": true, "dev": true, "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "astral-regex": "^1.0.0", + "strip-ansi": "^5.2.0" }, "dependencies": { "ansi-regex": { - "version": "3.0.0", + "version": "4.1.0", + "bundled": true, + "dev": true + }, + "astral-regex": { + "version": "1.0.0", "bundled": true, "dev": true }, "strip-ansi": { - "version": "4.0.0", + "version": "5.2.0", "bundled": true, "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "ansi-regex": "^4.1.0" } } } }, + "string-width": { + "version": "4.2.0", + "bundled": true, + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, "strip-ansi": { - "version": "3.0.1", + "version": "6.0.0", "bundled": true, + "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "^5.0.0" } }, "supports-color": { "version": "5.5.0", "bundled": true, + "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -2895,30 +2790,26 @@ }, "to-fast-properties": { "version": "2.0.0", - "bundled": true + "bundled": true, + "dev": true }, "treport": { - "version": "1.0.0", + "version": "1.0.2", "bundled": true, "dev": true, "requires": { "cardinal": "^2.1.1", "chalk": "^3.0.0", - "import-jsx": "^3.0.0", - "ink": "^2.5.0", + "import-jsx": "^3.1.0", + "ink": "^2.6.0", "ms": "^2.1.2", "string-length": "^3.1.0", "tap-parser": "^10.0.1", "unicode-length": "^2.0.2" }, "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "bundled": true, - "dev": true - }, "ansi-styles": { - "version": "4.2.0", + "version": "4.2.1", "bundled": true, "dev": true, "requires": { @@ -2953,28 +2844,6 @@ "bundled": true, "dev": true }, - "ms": { - "version": "2.1.2", - "bundled": true, - "dev": true - }, - "string-length": { - "version": "3.1.0", - "bundled": true, - "dev": true, - "requires": { - "astral-regex": "^1.0.0", - "strip-ansi": "^5.2.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - }, "supports-color": { "version": "7.1.0", "bundled": true, @@ -2982,132 +2851,118 @@ "requires": { "has-flag": "^4.0.0" } + } + } + }, + "type-fest": { + "version": "0.11.0", + "bundled": true, + "dev": true + }, + "unicode-length": { + "version": "2.0.2", + "bundled": true, + "dev": true, + "requires": { + "punycode": "^2.0.0", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true }, - "unicode-length": { - "version": "2.0.2", + "strip-ansi": { + "version": "3.0.1", "bundled": true, "dev": true, "requires": { - "punycode": "^2.0.0", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } + "ansi-regex": "^2.0.0" } } } }, - "type-fest": { - "version": "0.8.1", - "bundled": true, - "dev": true - }, "widest-line": { - "version": "2.0.1", + "version": "3.1.0", "bundled": true, "dev": true, "requires": { - "string-width": "^2.1.1" + "string-width": "^4.0.0" } }, "wrap-ansi": { - "version": "5.1.0", + "version": "6.2.0", "bundled": true, "dev": true, "requires": { - "ansi-styles": "^3.2.0", - "string-width": "^3.0.0", - "strip-ansi": "^5.0.0" + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" }, "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "bundled": true, - "dev": true - }, - "string-width": { - "version": "3.1.0", + "ansi-styles": { + "version": "4.2.1", "bundled": true, "dev": true, "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" } }, - "strip-ansi": { - "version": "5.2.0", + "color-convert": { + "version": "2.0.1", "bundled": true, "dev": true, "requires": { - "ansi-regex": "^4.1.0" + "color-name": "~1.1.4" } + }, + "color-name": { + "version": "1.1.4", + "bundled": true, + "dev": true } } }, "yaml": { - "version": "1.7.2", + "version": "1.8.2", "bundled": true, "dev": true, "requires": { - "@babel/runtime": "^7.6.3" + "@babel/runtime": "^7.8.7" } }, "yoga-layout-prebuilt": { - "version": "1.9.3", + "version": "1.9.5", "bundled": true, - "dev": true + "dev": true, + "requires": { + "@types/yoga-layout": "1.9.1" + } } } }, "tap-mocha-reporter": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/tap-mocha-reporter/-/tap-mocha-reporter-5.0.0.tgz", - "integrity": "sha512-8HlAtdmYGlDZuW83QbF/dc46L7cN+AGhLZcanX3I9ILvxUAl+G2/mtucNPSXecTlG/4iP1hv6oMo0tMhkn3Tsw==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/tap-mocha-reporter/-/tap-mocha-reporter-5.0.1.tgz", + "integrity": "sha512-1knFWOwd4khx/7uSEnUeaP9IPW3w+sqTgJMhrwah6t46nZ8P25atOKAjSvVDsT67lOPu0nfdOqUwoyKn+3E5pA==", "dev": true, "requires": { "color-support": "^1.1.0", - "debug": "^2.1.3", - "diff": "^1.3.2", - "escape-string-regexp": "^1.0.3", + "debug": "^4.1.1", + "diff": "^4.0.1", + "escape-string-regexp": "^2.0.0", "glob": "^7.0.5", - "readable-stream": "^2.1.5", "tap-parser": "^10.0.0", "tap-yaml": "^1.0.0", - "unicode-length": "^1.0.0" + "unicode-length": "^2.0.2" }, "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "diff": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", - "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", - "dev": true - }, - "ms": { + "escape-string-regexp": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", "dev": true } } @@ -3169,21 +3024,13 @@ } }, "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "dev": true, "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - }, - "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - } + "psl": "^1.1.28", + "punycode": "^2.1.1" } }, "trivial-deferred": { @@ -3193,16 +3040,16 @@ "dev": true }, "ts-node": { - "version": "8.5.4", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.4.tgz", - "integrity": "sha512-izbVCRV68EasEPQ8MSIGBNK9dc/4sYJJKYA+IarMQct1RtEot6Xp0bXuClsbUSnKpg50ho+aOAx8en5c+y4OFw==", + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.8.2.tgz", + "integrity": "sha512-duVj6BpSpUpD/oM4MfhO98ozgkp3Gt9qIp3jGxwU2DFvl/3IRaEAvbLa8G60uS7C77457e/m5TMowjedeRxI1Q==", "dev": true, "requires": { "arg": "^4.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", "source-map-support": "^0.5.6", - "yn": "^3.0.0" + "yn": "3.1.1" } }, "tunnel-agent": { @@ -3230,29 +3077,18 @@ } }, "typescript": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", - "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", "dev": true }, - "uglify-js": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.2.tgz", - "integrity": "sha512-uhRwZcANNWVLrxLfNFEdltoPNhECUR3lc+UdJoG9CBpMcSnKyWA94tc3eAujB1GcMY5Uwq8ZMp4qWpxWYDQmaA==", - "dev": true, - "optional": true, - "requires": { - "commander": "~2.20.3", - "source-map": "~0.6.1" - } - }, "unicode-length": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/unicode-length/-/unicode-length-1.0.3.tgz", - "integrity": "sha1-Wtp6f+1RhBpBijKM8UlHisg1irs=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/unicode-length/-/unicode-length-2.0.2.tgz", + "integrity": "sha512-Ph/j1VbS3/r77nhoY2WU0GWGjVYOHL3xpKp0y/Eq2e5r0mT/6b649vm7KFO6RdAdrZkYLdxphYVgvODxPB+Ebg==", "dev": true, "requires": { - "punycode": "^1.3.2", + "punycode": "^2.0.0", "strip-ansi": "^3.0.1" }, "dependencies": { @@ -3262,12 +3098,6 @@ "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -3288,17 +3118,10 @@ "punycode": "^2.1.0" } }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true, - "optional": true - }, "uuid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", - "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true }, "validate-npm-package-license": { @@ -3343,12 +3166,6 @@ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, - "wordwrap": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", - "dev": true - }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", @@ -3403,9 +3220,9 @@ "dev": true }, "write-file-atomic": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.1.tgz", - "integrity": "sha512-JPStrIyyVJ6oCSz/691fAjFtefZ6q+fP6tm+OS4Qw6o+TGQxNp1ziY2PgS+X/m0V8OWhZiO/m4xSj+Pr4RrZvw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", "dev": true, "requires": { "imurmurhash": "^0.1.4", @@ -3427,12 +3244,12 @@ "dev": true }, "yaml": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz", - "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==", + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.8.3.tgz", + "integrity": "sha512-X/v7VDnK+sxbQ2Imq4Jt2PRUsRsP7UcpSl3Llg6+NRRqWLIvxkMFYtH1FmvwNGYRKKPa+EPA4qDBlI9WVG1UKw==", "dev": true, "requires": { - "@babel/runtime": "^7.6.3" + "@babel/runtime": "^7.8.7" } }, "yapool": { @@ -3442,9 +3259,9 @@ "dev": true }, "yargs": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", - "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", "dev": true, "requires": { "cliui": "^5.0.0", @@ -3456,7 +3273,7 @@ "string-width": "^3.0.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^13.1.1" + "yargs-parser": "^13.1.2" }, "dependencies": { "ansi-regex": { @@ -3510,9 +3327,9 @@ } }, "yargs-parser": { - "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "dev": true, "requires": { "camelcase": "^5.0.0", diff --git a/package.json b/package.json index 86517d6a..5d8cc0ee 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "postpublish": "git push origin --follow-tags" }, "devDependencies": { - "tap": "^14.10.2" + "tap": "^14.10.7" }, "license": "ISC", "repository": "https://github.com/npm/node-semver", From 45b14954eac049a1d2824fb5543753e53192216a Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 13 Apr 2020 11:31:19 -0700 Subject: [PATCH 36/44] 7.2.3 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21ca9487..311656e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.2", + "version": "7.2.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5d8cc0ee..f0f7df5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.2", + "version": "7.2.3", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 33daffef8139c675a361aac8cc242175772f79d2 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 13 Apr 2020 11:34:07 -0700 Subject: [PATCH 37/44] changelog 7.2.3 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07bf4184..c6c3da03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # changes log +## 7.2.3 + +* Fix handling of `includePrelease` mode where version ranges like `1.0.0 - + 2.0.0` would include `3.0.0-pre` and not `1.0.0-pre`. + ## 7.2.2 * Fix bug where `2.0.0-pre` would be included in `^1.0.0` if From 100f07aa7137b774180f983ea7968361d26c17b6 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 10 Apr 2020 08:56:43 -0700 Subject: [PATCH 38/44] subset(): test if one range is a subset of another This also removes `>=0.0.0` (or `>=0.0.0-0` in `includePrerelease` mode) from the comparators in a range set, because that is equivalent to a `*`. --- CHANGELOG.md | 5 ++ README.md | 3 + classes/range.js | 7 ++ index.js | 1 + internal/re.js | 3 + ranges/subset.js | 155 +++++++++++++++++++++++++++++++++++ test/fixtures/range-parse.js | 2 +- test/ranges/subset.js | 75 +++++++++++++++++ 8 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 ranges/subset.js create mode 100644 test/ranges/subset.js diff --git a/CHANGELOG.md b/CHANGELOG.md index c6c3da03..220af176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # changes log +## 7.3.0 + +* Add `subset(r1, r2)` method to determine if `r1` range is entirely + contained by `r2` range. + ## 7.2.3 * Fix handling of `includePrelease` mode where version ranges like `1.0.0 - diff --git a/README.md b/README.md index ab408d3d..659201e2 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ const semverGtr = require('semver/ranges/gtr') const semverLtr = require('semver/ranges/ltr') const semverIntersects = require('semver/ranges/intersects') const simplifyRange = require('semver/ranges/simplify') +const rangeSubset = require('semver/ranges/subset') ``` As a command-line utility: @@ -455,6 +456,8 @@ strings that they parse. programmatically, to provide the user with something a bit more ergonomic. If the provided range is shorter in string-length than the generated range, then that is returned. +* `subset(subRange, superRange)`: Return `true` if the `subRange` range is + entirely contained by the `superRange` range. Note that, since ranges may be non-contiguous, a version might not be greater than a range, less than a range, *or* satisfy a range! For diff --git a/classes/range.js b/classes/range.js index 51125a01..cd87fb4d 100644 --- a/classes/range.js +++ b/classes/range.js @@ -92,6 +92,7 @@ class Range { .map(comp => parseComparator(comp, this.options)) .join(' ') .split(/\s+/) + .map(comp => replaceGTE0(comp, this.options)) // 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)) @@ -379,6 +380,12 @@ const replaceStars = (comp, options) => { return comp.trim().replace(re[t.STAR], '') } +const replaceGTE0 = (comp, options) => { + debug('replaceGTE0', comp, options) + return comp.trim() + .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') +} + // This function is passed to string.replace(re[t.HYPHENRANGE]) // M, m, patch, prerelease, build // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 diff --git a/index.js b/index.js index 54a714a3..57e2ae64 100644 --- a/index.js +++ b/index.js @@ -44,4 +44,5 @@ module.exports = { ltr: require('./ranges/ltr'), intersects: require('./ranges/intersects'), simplifyRange: require('./ranges/simplify'), + subset: require('./ranges/subset'), } diff --git a/internal/re.js b/internal/re.js index 0e8fb528..54d4176d 100644 --- a/internal/re.js +++ b/internal/re.js @@ -177,3 +177,6 @@ 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*$') diff --git a/ranges/subset.js b/ranges/subset.js new file mode 100644 index 00000000..6ae29a3c --- /dev/null +++ b/ranges/subset.js @@ -0,0 +1,155 @@ +const Range = require('../classes/range.js') +const { ANY } = require('../classes/comparator.js') +const satisfies = require('../functions/satisfies.js') +const compare = require('../functions/compare.js') + +// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: +// - Every simple range `r1, r2, ...` is a subset of some `R1, R2, ...` +// +// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: +// - If c is only the ANY comparator +// - If C is only the ANY comparator, return true +// - Else return false +// - Let EQ be the set of = comparators in c +// - If EQ is more than one, return true (null set) +// - Let GT be the highest > or >= comparator in c +// - Let LT be the lowest < or <= comparator in c +// - If GT and LT, and GT.semver > LT.semver, return true (null set) +// - If EQ +// - If GT, and EQ does not satisfy GT, return true (null set) +// - If LT, and EQ does not satisfy LT, return true (null set) +// - If EQ satisfies every C, return true +// - Else return false +// - If GT +// - If GT is lower than any > or >= comp in C, return false +// - If GT is >=, and GT.semver does not satisfy every C, return false +// - If LT +// - If LT.semver is greater than that of any > comp in C, return false +// - If LT is <=, and LT.semver does not satisfy every C, return false +// - If any C is a = range, and GT or LT are set, return false +// - Else return true + +const subset = (sub, dom, options) => { + sub = new Range(sub, options) + dom = new Range(dom, options) + let sawNonNull = false + + OUTER: for (const simpleSub of sub.set) { + for (const simpleDom of dom.set) { + const isSub = simpleSubset(simpleSub, simpleDom, options) + sawNonNull = sawNonNull || isSub !== null + 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) + return false + } + return true +} + +const simpleSubset = (sub, dom, options) => { + if (sub.length === 1 && sub[0].semver === ANY) + return dom.length === 1 && dom[0].semver === ANY + + const eqSet = new Set() + let gt, lt + for (const c of sub) { + if (c.operator === '>' || c.operator === '>=') + gt = higherGT(gt, c, options) + else if (c.operator === '<' || c.operator === '<=') + lt = lowerLT(lt, c, options) + else + eqSet.add(c.semver) + } + + if (eqSet.size > 1) + return null + + let gtltComp + if (gt && lt) { + gtltComp = compare(gt.semver, lt.semver, options) + if (gtltComp > 0) + return null + 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)) + return null + + if (lt && !satisfies(eq, String(lt), options)) + return null + + for (const c of dom) { + if (!satisfies(eq, String(c), options)) + return false + } + return true + } + + let higher, lower + let hasDomLT, hasDomGT + for (const c of dom) { + hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' + hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' + if (gt) { + if (c.operator === '>' || c.operator === '>=') { + higher = higherGT(gt, c, options) + if (higher === c) + return false + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + return false + } + if (lt) { + if (c.operator === '<' || c.operator === '<=') { + lower = lowerLT(lt, c, options) + if (lower === c) + return false + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + return false + } + 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) + return false + + if (lt && hasDomGT && !gt && gtltComp !== 0) + return false + + return true +} + +// >=1.2.3 is lower than >1.2.3 +const higherGT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp > 0 ? a + : comp < 0 ? b + : b.operator === '>' && a.operator === '>=' ? b + : a +} + +// <=1.2.3 is higher than <1.2.3 +const lowerLT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp < 0 ? a + : comp > 0 ? b + : b.operator === '<' && a.operator === '<=' ? b + : a +} + +module.exports = subset diff --git a/test/fixtures/range-parse.js b/test/fixtures/range-parse.js index 65744c4b..be7feffd 100644 --- a/test/fixtures/range-parse.js +++ b/test/fixtures/range-parse.js @@ -58,7 +58,7 @@ module.exports = [ ['~> 1', '>=1.0.0 <2.0.0'], ['~1.0', '>=1.0.0 <1.1.0'], ['~ 1.0', '>=1.0.0 <1.1.0'], - ['^0', '>=0.0.0 <1.0.0'], + ['^0', '<1.0.0'], ['^ 1', '>=1.0.0 <2.0.0'], ['^0.1', '>=0.1.0 <0.2.0'], ['^1.0', '>=1.0.0 <2.0.0'], diff --git a/test/ranges/subset.js b/test/ranges/subset.js new file mode 100644 index 00000000..586723fe --- /dev/null +++ b/test/ranges/subset.js @@ -0,0 +1,75 @@ +const t = require('tap') +const subset = require('../../ranges/subset.js') + +// sub, dom, expect, [options] +const cases = [ + ['1.2.3', '1.2.3', true], + ['1.2.3 1.2.4', '1.2.3', true], + ['1.2.3 2.3.4 || 2.3.4', '3', false], + ['^1.2.3-pre.0', '1.x', false], + ['^1.2.3-pre.0', '1.x', true, { includePrerelease: true }], + ['>2 <1', '3', true], + ['1 || 2 || 3', '>=1.0.0', true], + + ['*', '*', true], + ['', '*', true], + ['*', '', true], + ['', '', true], + + // >=0.0.0 is like * in non-prerelease mode + // >=0.0.0-0 is like * in prerelease mode + ['*', '>=0.0.0-0', true, { includePrerelease: true }], + ['*', '>=0.0.0', true], + ['*', '>=0.0.0', false, { includePrerelease: true }], + ['*', '>=0.0.0-0', false], + ['^2 || ^3 || ^4', '>=1', true], + ['^2 || ^3 || ^4', '>1', true], + ['^2 || ^3 || ^4', '>=2', true], + ['^2 || ^3 || ^4', '>=3', false], + ['>=1', '^2 || ^3 || ^4', false], + ['>1', '^2 || ^3 || ^4', false], + ['>=2', '^2 || ^3 || ^4', false], + ['>=3', '^2 || ^3 || ^4', false], + ['^1', '^2 || ^3 || ^4', false], + ['^2', '^2 || ^3 || ^4', true], + ['^3', '^2 || ^3 || ^4', true], + ['^4', '^2 || ^3 || ^4', true], + ['1.x', '^2 || ^3 || ^4', false], + ['2.x', '^2 || ^3 || ^4', true], + ['3.x', '^2 || ^3 || ^4', true], + ['4.x', '^2 || ^3 || ^4', true], + + ['>=1.0.0 <=1.0.0 || 2.0.0', '1.0.0 || 2.0.0', true], + ['<=1.0.0 >=1.0.0 || 2.0.0', '1.0.0 || 2.0.0', true], + ['>=1.0.0', '1.0.0', false], + ['>=1.0.0 <2.0.0', '<2.0.0', true], + ['>=1.0.0 <2.0.0', '>0.0.0', true], + ['>=1.0.0 <=1.0.0', '1.0.0', true], + ['>=1.0.0 <=1.0.0', '2.0.0', false], + ['<2.0.0', '>=1.0.0 <2.0.0', false], + ['>=1.0.0', '>=1.0.0 <2.0.0', false], + ['>=1.0.0 <2.0.0', '<2.0.0', true], + ['>=1.0.0 <2.0.0', '>=1.0.0', true], + ['>=1.0.0 <2.0.0', '>1.0.0', false], + ['>=1.0.0 <=2.0.0', '<2.0.0', false], + ['>=1.0.0', '<1.0.0', false], + ['<=1.0.0', '>1.0.0', false], + ['<=1.0.0 >1.0.0', '>1.0.0', true], + ['1.0.0 >1.0.0', '>1.0.0', true], + ['1.0.0 <1.0.0', '>1.0.0', true], + ['<1 <2 <3', '<4', true], + ['<3 <2 <1', '<4', true], + ['>1 >2 >3', '>0', true], + ['>3 >2 >1', '>0', true], + ['<=1 <=2 <=3', '<4', true], + ['<=3 <=2 <=1', '<4', true], + ['>=1 >=2 >=3', '>0', true], + ['>=3 >=2 >=1', '>0', true], +] + +t.plan(cases.length) +cases.forEach(([sub, dom, expect, options = {}]) => { + const msg = `${sub || "''"} ⊂ ${dom || "''"} = ${expect}` + + (options ? ' ' + Object.keys(options).join(',') : '') + t.equal(subset(sub, dom, options), expect, msg) +}) From 92bccf1d0950c9bd136f58886036e8c1921cd9a1 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 13 Apr 2020 18:08:32 -0700 Subject: [PATCH 39/44] 7.3.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 311656e5..88c79c31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.3", + "version": "7.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f0f7df5c..413d00ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.2.3", + "version": "7.3.0", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From f27dcf5bbc9a80f7981c3026ff5de243f5c13356 Mon Sep 17 00:00:00 2001 From: Raphael Zulliger Date: Mon, 2 Mar 2020 17:33:26 +0100 Subject: [PATCH 40/44] Adding several tests for various 'pre-release' situations. PR-URL: https://github.com/npm/node-semver/pull/316 Credit: @raphaelzulliger Close: #316 Reviewed-by: @isaacs --- test/fixtures/range-exclude.js | 17 +++++++++++++++++ test/fixtures/range-include.js | 8 ++++++++ test/fixtures/version-gt-range.js | 3 ++- test/fixtures/version-not-gt-range.js | 3 ++- test/fixtures/version-not-lt-range.js | 3 ++- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/test/fixtures/range-exclude.js b/test/fixtures/range-exclude.js index 209f93a0..6b703d46 100644 --- a/test/fixtures/range-exclude.js +++ b/test/fixtures/range-exclude.js @@ -13,6 +13,7 @@ module.exports = [ ['^1.2.3', '1.2.3-beta'], ['=0.7.x', '0.7.0-asdf'], ['>=0.7.x', '0.7.0-asdf'], + ['<=0.7.x', '0.7.0-asdf'], ['1', '1.0.0beta', { loose: 420 }], ['<1', '1.0.0beta', true], ['< 1', '1.0.0beta', true], @@ -85,4 +86,20 @@ module.exports = [ ['1 - 2', '2.0.0-pre'], ['1 - 2', '1.0.0-pre'], ['1.0 - 2', '1.0.0-pre'], + + ['1.1.x', '1.0.0-a'], + ['1.1.x', '1.1.0-a'], + ['1.1.x', '1.2.0-a'], + ['1.1.x', '1.2.0-a', { includePrerelease: true }], + ['1.1.x', '1.0.0-a', { includePrerelease: true }], + ['1.x', '1.0.0-a'], + ['1.x', '1.1.0-a'], + ['1.x', '1.2.0-a'], + ['1.x', '0.0.0-a', { includePrerelease: true }], + ['1.x', '2.0.0-a', { includePrerelease: true }], + + ['>=1.0.0 <1.1.0', '1.1.0'], + ['>=1.0.0 <1.1.0', '1.1.0', { includePrerelease: true }], + ['>=1.0.0 <1.1.0', '1.1.0-pre'], + ['>=1.0.0 <1.1.0-pre', '1.1.0-pre'], ] diff --git a/test/fixtures/range-include.js b/test/fixtures/range-include.js index 07be3657..da20f6ce 100644 --- a/test/fixtures/range-include.js +++ b/test/fixtures/range-include.js @@ -109,6 +109,8 @@ module.exports = [ ['<=7.x', '7.9.9'], ['2.x', '2.0.0-pre.0', { includePrerelease: true }], ['2.x', '2.1.0-pre.0', { includePrerelease: true }], + ['1.1.x', '1.1.0-a', { includePrerelease: true }], + ['1.1.x', '1.1.1-a', { includePrerelease: true }], ['*', '1.0.0-rc1', { includePrerelease: true }], ['^1.0.0-0', '1.0.1-rc1', { includePrerelease: true }], ['^1.0.0-rc2', '1.0.1-rc1', { includePrerelease: true }], @@ -117,4 +119,10 @@ module.exports = [ ['1 - 2', '2.0.0-pre', { includePrerelease: true }], ['1 - 2', '1.0.0-pre', { includePrerelease: true }], ['1.0 - 2', '1.0.0-pre', { includePrerelease: true }], + + ['=0.7.x', '0.7.0-asdf', { includePrerelease: true }], + ['>=0.7.x', '0.7.0-asdf', { includePrerelease: true }], + ['<=0.7.x', '0.7.0-asdf', { includePrerelease: true }], + + ['>=1.0.0 <=1.1.0', '1.1.0-pre', { includePrerelease: true }], ] diff --git a/test/fixtures/version-gt-range.js b/test/fixtures/version-gt-range.js index 24afa025..5887dae9 100644 --- a/test/fixtures/version-gt-range.js +++ b/test/fixtures/version-gt-range.js @@ -60,5 +60,6 @@ module.exports = [ ['<1', '1.0.0beta', true], ['< 1', '1.0.0beta', true], ['=0.7.x', '0.8.2'], - ['<0.7.x', '0.7.2'] + ['<0.7.x', '0.7.2'], + ['0.7.x', '0.7.2-beta'] ] diff --git a/test/fixtures/version-not-gt-range.js b/test/fixtures/version-not-gt-range.js index 926123ab..af6d6e8d 100644 --- a/test/fixtures/version-not-gt-range.js +++ b/test/fixtures/version-not-gt-range.js @@ -81,5 +81,6 @@ module.exports = [ ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], - ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'] + ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'], + ['0.7.x', '0.7.2-beta', { includePrerelease: true }] ] diff --git a/test/fixtures/version-not-lt-range.js b/test/fixtures/version-not-lt-range.js index a9558b84..b98a57a0 100644 --- a/test/fixtures/version-not-lt-range.js +++ b/test/fixtures/version-not-lt-range.js @@ -84,5 +84,6 @@ module.exports = [ ['~1.0.0-alpha', '1.0.0beta', true], ['^1.0.0-alpha', '1.0.0-beta'], ['~1.0.0-alpha', '1.0.0-beta'], - ['=0.1.0', '1.0.0'] + ['=0.1.0', '1.0.0'], + ['>1.2.3', '1.3.0-alpha', { includePrerelease: true }] ] From 059a5adec5aefaa764bf4fdb717ae8b42cbbefcd Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Tue, 7 Apr 2020 13:57:26 +0300 Subject: [PATCH 41/44] Always exclude prereleases from range maximums In semver v4, the ranges were simplified in 2331a9e "to remove -0 everywhere". This had the unintended side effect of including the endpoint version's prerelease versions in the resulting range, as lt('1.0.0-0', '1.0.0') === true. Tests are updated, adding -0 to the maximal endpoints. One test is moved from range-include to range-exclude, comparing 2.0.0-rc1 against ^1.0.0 Fixes #223 Fixes #254 EDIT(isaacs): Updated to resolve conflicts on master branch. PR-URL: https://github.com/npm/node-semver/pull/320 Credit: @eemeli Close: #320 Reviewed-by: @isaacs --- README.md | 46 +++++++++++----------- classes/range.js | 62 +++++++++++++++--------------- test/classes/range.js | 2 +- test/fixtures/range-exclude.js | 1 + test/fixtures/range-parse.js | 70 +++++++++++++++++----------------- test/ranges/to-comparators.js | 50 ++++++++++++------------ 6 files changed, 116 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index 659201e2..9bef045a 100644 --- a/README.md +++ b/README.md @@ -256,8 +256,8 @@ inclusive range, then all versions that start with the supplied parts of the tuple are accepted, but nothing that would be greater than the provided tuple parts. -* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0` -* `1.2.3 - 2` := `>=1.2.3 <3.0.0` +* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0` +* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0` #### X-Ranges `1.2.x` `1.X` `1.2.*` `*` @@ -265,28 +265,28 @@ Any of `X`, `x`, or `*` may be used to "stand in" for one of the numeric values in the `[major, minor, patch]` tuple. * `*` := `>=0.0.0` (Any version satisfies) -* `1.x` := `>=1.0.0 <2.0.0` (Matching major version) -* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions) +* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version) +* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions) A partial version range is treated as an X-Range, so the special character is in fact optional. * `""` (empty string) := `*` := `>=0.0.0` -* `1` := `1.x.x` := `>=1.0.0 <2.0.0` -* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0` +* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0` +* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0` #### Tilde Ranges `~1.2.3` `~1.2` `~1` Allows patch-level changes if a minor version is specified on the comparator. Allows minor-level changes if not. -* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0` -* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`) -* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`) -* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0` -* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`) -* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`) -* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in +* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0-0` +* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0-0` (Same as `1.2.x`) +* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0-0` (Same as `1.x`) +* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0-0` +* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0-0` (Same as `0.2.x`) +* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0-0` (Same as `0.x`) +* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0-0` Note that prereleases in the `1.2.3` version will be allowed, if they are greater than or equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but `1.2.4-beta.2` would not, because it is a prerelease of a @@ -308,15 +308,15 @@ However, it presumes that there will *not* be breaking changes between `0.2.4` and `0.2.5`. It allows for changes that are presumed to be additive (but non-breaking), according to commonly observed practices. -* `^1.2.3` := `>=1.2.3 <2.0.0` -* `^0.2.3` := `>=0.2.3 <0.3.0` -* `^0.0.3` := `>=0.0.3 <0.0.4` -* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in +* `^1.2.3` := `>=1.2.3 <2.0.0-0` +* `^0.2.3` := `>=0.2.3 <0.3.0-0` +* `^0.0.3` := `>=0.0.3 <0.0.4-0` +* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0-0` Note that prereleases in the `1.2.3` version will be allowed, if they are greater than or equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but `1.2.4-beta.2` would not, because it is a prerelease of a different `[major, minor, patch]` tuple. -* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the +* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4-0` Note that prereleases in the `0.0.3` version *only* will be allowed, if they are greater than or equal to `beta`. So, `0.0.3-pr.2` would be allowed. @@ -324,16 +324,16 @@ When parsing caret ranges, a missing `patch` value desugars to the number `0`, but will allow flexibility within that value, even if the major and minor versions are both `0`. -* `^1.2.x` := `>=1.2.0 <2.0.0` -* `^0.0.x` := `>=0.0.0 <0.1.0` -* `^0.0` := `>=0.0.0 <0.1.0` +* `^1.2.x` := `>=1.2.0 <2.0.0-0` +* `^0.0.x` := `>=0.0.0 <0.1.0-0` +* `^0.0` := `>=0.0.0 <0.1.0-0` A missing `minor` and `patch` values will desugar to zero, but also allow flexibility within those values, even if the major version is zero. -* `^1.x` := `>=1.0.0 <2.0.0` -* `^0.x` := `>=0.0.0 <1.0.0` +* `^1.x` := `>=1.0.0 <2.0.0-0` +* `^0.x` := `>=0.0.0 <1.0.0-0` ### Range Grammar diff --git a/classes/range.js b/classes/range.js index cd87fb4d..e7b6af3b 100644 --- a/classes/range.js +++ b/classes/range.js @@ -192,11 +192,11 @@ const parseComparator = (comp, options) => { const isX = id => !id || id.toLowerCase() === 'x' || id === '*' // ~, ~> --> * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 +// ~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) @@ -211,18 +211,18 @@ const replaceTilde = (comp, options) => { if (isX(M)) { ret = '' } else if (isX(m)) { - ret = `>=${M}.0.0 <${+M + 1}.0.0` + ret = `>=${M}.0.0 <${+M + 1}.0.0-0` } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0 - ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0` + // ~1.2 == >=1.2.0 <1.3.0-0 + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0` } else if (pr) { debug('replaceTilde pr', pr) ret = `>=${M}.${m}.${p}-${pr - } <${M}.${+m + 1}.0` + } <${M}.${+m + 1}.0-0` } else { - // ~1.2.3 == >=1.2.3 <1.3.0 + // ~1.2.3 == >=1.2.3 <1.3.0-0 ret = `>=${M}.${m}.${p - } <${M}.${+m + 1}.0` + } <${M}.${+m + 1}.0-0` } debug('tilde return', ret) @@ -231,11 +231,11 @@ const replaceTilde = (comp, options) => { } // ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 -// ^1.2.3 --> >=1.2.3 <2.0.0 -// ^1.2.0 --> >=1.2.0 <2.0.0 +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 +// ^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) @@ -252,40 +252,40 @@ const replaceCaret = (comp, options) => { if (isX(M)) { ret = '' } else if (isX(m)) { - ret = `>=${M}.0.0${z} <${+M + 1}.0.0${z}` + ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` } else if (isX(p)) { if (M === '0') { - ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0${z}` + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` } else { - ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0${z}` + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` } } else if (pr) { debug('replaceCaret pr', pr) if (M === '0') { if (m === '0') { ret = `>=${M}.${m}.${p}-${pr - } <${M}.${m}.${+p + 1}${z}` + } <${M}.${m}.${+p + 1}-0` } else { ret = `>=${M}.${m}.${p}-${pr - } <${M}.${+m + 1}.0${z}` + } <${M}.${+m + 1}.0-0` } } else { ret = `>=${M}.${m}.${p}-${pr - } <${+M + 1}.0.0${z}` + } <${+M + 1}.0.0-0` } } else { debug('no pr') if (M === '0') { if (m === '0') { ret = `>=${M}.${m}.${p - }${z} <${M}.${m}.${+p + 1}${z}` + }${z} <${M}.${m}.${+p + 1}-0` } else { ret = `>=${M}.${m}.${p - }${z} <${M}.${+m + 1}.0${z}` + }${z} <${M}.${+m + 1}.0-0` } } else { ret = `>=${M}.${m}.${p - } <${+M + 1}.0.0${z}` + } <${+M + 1}.0.0-0` } } @@ -360,10 +360,10 @@ const replaceXRange = (comp, options) => { ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { - ret = `>=${M}.0.0${pr} <${+M + 1}.0.0${pr}` + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` } else if (xp) { ret = `>=${M}.${m}.0${pr - } <${M}.${+m + 1}.0${pr}` + } <${M}.${+m + 1}.0-0` } debug('xRange return', ret) @@ -389,8 +389,8 @@ const replaceGTE0 = (comp, options) => { // This function is passed to string.replace(re[t.HYPHENRANGE]) // M, m, patch, prerelease, build // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 -// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 const hyphenReplace = incPr => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => { @@ -409,9 +409,9 @@ const hyphenReplace = incPr => ($0, if (isX(tM)) { to = '' } else if (isX(tm)) { - to = `<${+tM + 1}.0.0${incPr ? '-0' : ''}` + to = `<${+tM + 1}.0.0-0` } else if (isX(tp)) { - to = `<${tM}.${+tm + 1}.0${incPr ? '-0' : ''}` + to = `<${tM}.${+tm + 1}.0-0` } else if (tpr) { to = `<=${tM}.${tm}.${tp}-${tpr}` } else if (incPr) { diff --git a/test/classes/range.js b/test/classes/range.js index 267fa80b..e3867a9a 100644 --- a/test/classes/range.js +++ b/test/classes/range.js @@ -69,7 +69,7 @@ test('negative range tests', t => { test('strict vs loose ranges', (t) => { [ ['>=01.02.03', '>=1.2.3'], - ['~1.02.03beta', '>=1.2.3-beta <1.3.0'] + ['~1.02.03beta', '>=1.2.3-beta <1.3.0-0'] ].forEach(([loose, comps]) => { t.throws(() => new Range(loose)) t.equal(new Range(loose, true).range, comps) diff --git a/test/fixtures/range-exclude.js b/test/fixtures/range-exclude.js index 6b703d46..9e829445 100644 --- a/test/fixtures/range-exclude.js +++ b/test/fixtures/range-exclude.js @@ -78,6 +78,7 @@ module.exports = [ ['2.x', '3.0.0-pre.0', { includePrerelease: true }], ['^1.0.0', '1.0.0-rc1', { includePrerelease: true }], + ['^1.0.0', '2.0.0-rc1', { includePrerelease: true }], ['^1.2.3-rc2', '2.0.0', { includePrerelease: true }], ['^1.0.0', '2.0.0-rc1', { includePrerelease: true }], ['^1.0.0', '2.0.0-rc1'], diff --git a/test/fixtures/range-parse.js b/test/fixtures/range-parse.js index be7feffd..422e32c6 100644 --- a/test/fixtures/range-parse.js +++ b/test/fixtures/range-parse.js @@ -5,9 +5,9 @@ module.exports = [ ['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], ['1.0.0 - 2.0.0', '>=1.0.0-0 <2.0.1-0', { includePrerelease: true }], - ['1 - 2', '>=1.0.0 <3.0.0'], + ['1 - 2', '>=1.0.0 <3.0.0-0'], ['1 - 2', '>=1.0.0-0 <3.0.0-0', { includePrerelease: true }], - ['1.0 - 2.0', '>=1.0.0 <2.1.0'], + ['1.0 - 2.0', '>=1.0.0 <2.1.0-0'], ['1.0 - 2.0', '>=1.0.0-0 <2.1.0-0', { includePrerelease: true }], ['1.0.0', '1.0.0', { loose: false }], ['>=*', '*'], @@ -17,7 +17,7 @@ module.exports = [ ['>=1.0.0', '>=1.0.0'], ['>1.0.0', '>1.0.0'], ['<=2.0.0', '<=2.0.0'], - ['1', '>=1.0.0 <2.0.0'], + ['1', '>=1.0.0 <2.0.0-0'], ['<=2.0.0', '<=2.0.0'], ['<=2.0.0', '<=2.0.0'], ['<2.0.0', '<2.0.0'], @@ -39,50 +39,50 @@ module.exports = [ ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'], ['||', '||'], - ['2.x.x', '>=2.0.0 <3.0.0'], - ['1.2.x', '>=1.2.0 <1.3.0'], - ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], - ['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['2.x.x', '>=2.0.0 <3.0.0-0'], + ['1.2.x', '>=1.2.0 <1.3.0-0'], + ['1.2.x || 2.x', '>=1.2.0 <1.3.0-0||>=2.0.0 <3.0.0-0'], + ['1.2.x || 2.x', '>=1.2.0 <1.3.0-0||>=2.0.0 <3.0.0-0'], ['x', '*'], - ['2.*.*', '>=2.0.0 <3.0.0'], - ['1.2.*', '>=1.2.0 <1.3.0'], - ['1.2.* || 2.*', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'], + ['2.*.*', '>=2.0.0 <3.0.0-0'], + ['1.2.*', '>=1.2.0 <1.3.0-0'], + ['1.2.* || 2.*', '>=1.2.0 <1.3.0-0||>=2.0.0 <3.0.0-0'], ['*', '*'], - ['2', '>=2.0.0 <3.0.0'], - ['2.3', '>=2.3.0 <2.4.0'], - ['~2.4', '>=2.4.0 <2.5.0'], - ['~2.4', '>=2.4.0 <2.5.0'], - ['~>3.2.1', '>=3.2.1 <3.3.0'], - ['~1', '>=1.0.0 <2.0.0'], - ['~>1', '>=1.0.0 <2.0.0'], - ['~> 1', '>=1.0.0 <2.0.0'], - ['~1.0', '>=1.0.0 <1.1.0'], - ['~ 1.0', '>=1.0.0 <1.1.0'], - ['^0', '<1.0.0'], - ['^ 1', '>=1.0.0 <2.0.0'], - ['^0.1', '>=0.1.0 <0.2.0'], - ['^1.0', '>=1.0.0 <2.0.0'], - ['^1.2', '>=1.2.0 <2.0.0'], - ['^0.0.1', '>=0.0.1 <0.0.2'], - ['^0.0.1-beta', '>=0.0.1-beta <0.0.2'], - ['^0.1.2', '>=0.1.2 <0.2.0'], - ['^1.2.3', '>=1.2.3 <2.0.0'], - ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0'], + ['2', '>=2.0.0 <3.0.0-0'], + ['2.3', '>=2.3.0 <2.4.0-0'], + ['~2.4', '>=2.4.0 <2.5.0-0'], + ['~2.4', '>=2.4.0 <2.5.0-0'], + ['~>3.2.1', '>=3.2.1 <3.3.0-0'], + ['~1', '>=1.0.0 <2.0.0-0'], + ['~>1', '>=1.0.0 <2.0.0-0'], + ['~> 1', '>=1.0.0 <2.0.0-0'], + ['~1.0', '>=1.0.0 <1.1.0-0'], + ['~ 1.0', '>=1.0.0 <1.1.0-0'], + ['^0', '<1.0.0-0'], + ['^ 1', '>=1.0.0 <2.0.0-0'], + ['^0.1', '>=0.1.0 <0.2.0-0'], + ['^1.0', '>=1.0.0 <2.0.0-0'], + ['^1.2', '>=1.2.0 <2.0.0-0'], + ['^0.0.1', '>=0.0.1 <0.0.2-0'], + ['^0.0.1-beta', '>=0.0.1-beta <0.0.2-0'], + ['^0.1.2', '>=0.1.2 <0.2.0-0'], + ['^1.2.3', '>=1.2.3 <2.0.0-0'], + ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'], ['<1', '<1.0.0'], ['< 1', '<1.0.0'], ['>=1', '>=1.0.0'], ['>= 1', '>=1.0.0'], ['<1.2', '<1.2.0'], ['< 1.2', '<1.2.0'], - ['1', '>=1.0.0 <2.0.0'], + ['1', '>=1.0.0 <2.0.0-0'], ['>01.02.03', '>1.2.3', true], ['>01.02.03', null], - ['~1.2.3beta', '>=1.2.3-beta <1.3.0', { loose: true }], + ['~1.2.3beta', '>=1.2.3-beta <1.3.0-0', { loose: true }], ['~1.2.3beta', null], - ['^ 1.2 ^ 1', '>=1.2.0 <2.0.0 >=1.0.0 <2.0.0'], + ['^ 1.2 ^ 1', '>=1.2.0 <2.0.0-0 >=1.0.0 <2.0.0-0'], ['1.2 - 3.4.5', '>=1.2.0 <=3.4.5'], - ['1.2.3 - 3.4', '>=1.2.3 <3.5.0'], - ['1.2 - 3.4', '>=1.2.0 <3.5.0'], + ['1.2.3 - 3.4', '>=1.2.3 <3.5.0-0'], + ['1.2 - 3.4', '>=1.2.0 <3.5.0-0'], ['>1', '>=2.0.0'], ['>1.2', '>=1.3.0'], ['>X', '<0.0.0-0'], diff --git a/test/ranges/to-comparators.js b/test/ranges/to-comparators.js index 661d5389..4472484f 100644 --- a/test/ranges/to-comparators.js +++ b/test/ranges/to-comparators.js @@ -16,7 +16,7 @@ test('comparators test', (t) => { ['>1.0.0', [['>1.0.0']]], ['>1.0.0', [['>1.0.0']]], ['<=2.0.0', [['<=2.0.0']]], - ['1', [['>=1.0.0', '<2.0.0']]], + ['1', [['>=1.0.0', '<2.0.0-0']]], ['<=2.0.0', [['<=2.0.0']]], ['<=2.0.0', [['<=2.0.0']]], ['<2.0.0', [['<2.0.0']]], @@ -38,39 +38,39 @@ test('comparators test', (t) => { ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]], ['||', [[''], ['']]], - ['2.x.x', [['>=2.0.0', '<3.0.0']]], - ['1.2.x', [['>=1.2.0', '<1.3.0']]], - ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], - ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], + ['2.x.x', [['>=2.0.0', '<3.0.0-0']]], + ['1.2.x', [['>=1.2.0', '<1.3.0-0']]], + ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]], + ['1.2.x || 2.x', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]], ['x', [['']]], - ['2.*.*', [['>=2.0.0', '<3.0.0']]], - ['1.2.*', [['>=1.2.0', '<1.3.0']]], - ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], - ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]], + ['2.*.*', [['>=2.0.0', '<3.0.0-0']]], + ['1.2.*', [['>=1.2.0', '<1.3.0-0']]], + ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]], + ['1.2.* || 2.*', [['>=1.2.0', '<1.3.0-0'], ['>=2.0.0', '<3.0.0-0']]], ['*', [['']]], - ['2', [['>=2.0.0', '<3.0.0']]], - ['2.3', [['>=2.3.0', '<2.4.0']]], - ['~2.4', [['>=2.4.0', '<2.5.0']]], - ['~2.4', [['>=2.4.0', '<2.5.0']]], - ['~>3.2.1', [['>=3.2.1', '<3.3.0']]], - ['~1', [['>=1.0.0', '<2.0.0']]], - ['~>1', [['>=1.0.0', '<2.0.0']]], - ['~> 1', [['>=1.0.0', '<2.0.0']]], - ['~1.0', [['>=1.0.0', '<1.1.0']]], - ['~ 1.0', [['>=1.0.0', '<1.1.0']]], - ['~ 1.0.3', [['>=1.0.3', '<1.1.0']]], - ['~> 1.0.3', [['>=1.0.3', '<1.1.0']]], + ['2', [['>=2.0.0', '<3.0.0-0']]], + ['2.3', [['>=2.3.0', '<2.4.0-0']]], + ['~2.4', [['>=2.4.0', '<2.5.0-0']]], + ['~2.4', [['>=2.4.0', '<2.5.0-0']]], + ['~>3.2.1', [['>=3.2.1', '<3.3.0-0']]], + ['~1', [['>=1.0.0', '<2.0.0-0']]], + ['~>1', [['>=1.0.0', '<2.0.0-0']]], + ['~> 1', [['>=1.0.0', '<2.0.0-0']]], + ['~1.0', [['>=1.0.0', '<1.1.0-0']]], + ['~ 1.0', [['>=1.0.0', '<1.1.0-0']]], + ['~ 1.0.3', [['>=1.0.3', '<1.1.0-0']]], + ['~> 1.0.3', [['>=1.0.3', '<1.1.0-0']]], ['<1', [['<1.0.0']]], ['< 1', [['<1.0.0']]], ['>=1', [['>=1.0.0']]], ['>= 1', [['>=1.0.0']]], ['<1.2', [['<1.2.0']]], ['< 1.2', [['<1.2.0']]], - ['1', [['>=1.0.0', '<2.0.0']]], - ['1 2', [['>=1.0.0', '<2.0.0', '>=2.0.0', '<3.0.0']]], + ['1', [['>=1.0.0', '<2.0.0-0']]], + ['1 2', [['>=1.0.0', '<2.0.0-0', '>=2.0.0', '<3.0.0-0']]], ['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]], - ['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0']]], - ['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]], + ['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0-0']]], + ['1.2.3 - 3', [['>=1.2.3', '<4.0.0-0']]], ['>*', [['<0.0.0-0']]], ['<*', [['<0.0.0-0']]] ].forEach(([pre, wanted]) => { From b97044b0de1a771bff151c40695fd7e340b3a09c Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 14 Apr 2020 09:55:54 -0700 Subject: [PATCH 42/44] 7.3.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 88c79c31..586fb396 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.3.0", + "version": "7.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 413d00ae..3b59a8c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.3.0", + "version": "7.3.1", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": { From 9fb2c19b159602b5544944b610fca69fd6ad5c77 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 14 Apr 2020 10:40:39 -0700 Subject: [PATCH 43/44] Exclude prereleases in X-ranges with < comparators This one didn't cause any bugs, but it's more for consistency and future-proofing. When a range like '<=1' is translated to 'anything less than 2.0.0', it should be expressed as '<2.0.0-0' to prevent prerelease 2.0.0 versions as well. It didn't cause any problems with intersection or range satisfying because it would only treat 2.0.0-pre as satisfying <2.0.0 when includePrerelease was set, and if includePrerelease was set, then it would add the -0 to the less-than comparator. Nevertheless, all other areas where we use a { } } + if (gtlt === '<') + pr = '-0' + ret = `${gtlt + M}.${m}.${p}${pr}` } else if (xm) { ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` diff --git a/test/fixtures/range-parse.js b/test/fixtures/range-parse.js index 422e32c6..42414903 100644 --- a/test/fixtures/range-parse.js +++ b/test/fixtures/range-parse.js @@ -68,12 +68,12 @@ module.exports = [ ['^0.1.2', '>=0.1.2 <0.2.0-0'], ['^1.2.3', '>=1.2.3 <2.0.0-0'], ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'], - ['<1', '<1.0.0'], - ['< 1', '<1.0.0'], + ['<1', '<1.0.0-0'], + ['< 1', '<1.0.0-0'], ['>=1', '>=1.0.0'], ['>= 1', '>=1.0.0'], - ['<1.2', '<1.2.0'], - ['< 1.2', '<1.2.0'], + ['<1.2', '<1.2.0-0'], + ['< 1.2', '<1.2.0-0'], ['1', '>=1.0.0 <2.0.0-0'], ['>01.02.03', '>1.2.3', true], ['>01.02.03', null], diff --git a/test/ranges/to-comparators.js b/test/ranges/to-comparators.js index 4472484f..bc9c52a6 100644 --- a/test/ranges/to-comparators.js +++ b/test/ranges/to-comparators.js @@ -60,12 +60,12 @@ test('comparators test', (t) => { ['~ 1.0', [['>=1.0.0', '<1.1.0-0']]], ['~ 1.0.3', [['>=1.0.3', '<1.1.0-0']]], ['~> 1.0.3', [['>=1.0.3', '<1.1.0-0']]], - ['<1', [['<1.0.0']]], - ['< 1', [['<1.0.0']]], + ['<1', [['<1.0.0-0']]], + ['< 1', [['<1.0.0-0']]], ['>=1', [['>=1.0.0']]], ['>= 1', [['>=1.0.0']]], - ['<1.2', [['<1.2.0']]], - ['< 1.2', [['<1.2.0']]], + ['<1.2', [['<1.2.0-0']]], + ['< 1.2', [['<1.2.0-0']]], ['1', [['>=1.0.0', '<2.0.0-0']]], ['1 2', [['>=1.0.0', '<2.0.0-0', '>=2.0.0', '<3.0.0-0']]], ['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]], From ce978f9a58b71d22a7c303432c9a5135510e01be Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 14 Apr 2020 10:43:09 -0700 Subject: [PATCH 44/44] 7.3.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 586fb396..07cc92b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.3.1", + "version": "7.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3b59a8c4..07867975 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.3.1", + "version": "7.3.2", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": {