keep-a-changelog 2.0.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -2
- package/README.md +21 -6
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/bin.js +9 -4
- package/esm/deps/deno.land/std@0.173.0/_util/asserts.js +21 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/_util/os.js +4 -1
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/flags/mod.js +145 -36
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_constants.js +1 -0
- package/esm/deps/deno.land/std@0.173.0/path/_interface.js +3 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_util.js +1 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/common.js +1 -1
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/glob.js +1 -1
- package/esm/deps/deno.land/std@0.173.0/path/mod.js +32 -0
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/posix.js +23 -16
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/separator.js +1 -1
- package/esm/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/win32.js +20 -15
- package/esm/deps/{deno_land/x/semver_v1.4.0 → deno.land/std@0.173.0/semver}/mod.js +227 -334
- package/esm/deps/{deno_land/std_0.51.0 → deno.land/std@0.51.0}/fs/eol.js +0 -0
- package/esm/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/ini.js +1 -1
- package/esm/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/mod.js +0 -0
- package/esm/mod.js +1 -0
- package/esm/src/Change.js +15 -15
- package/esm/src/Changelog.js +9 -1
- package/esm/src/Release.js +21 -4
- package/esm/src/deps.js +1 -1
- package/esm/src/parser.js +24 -5
- package/esm/test/changelog.custom.type.md +0 -1
- package/esm/test/changelog.expected.linted.md +208 -0
- package/esm/test/changelog.expected.md +6 -4
- package/esm/test/changelog.md +7 -3
- package/esm/test/empty.expected.md +0 -1
- package/package.json +13 -8
- package/script/_dnt.polyfills.js +16 -0
- package/script/_dnt.shims.js +66 -0
- package/script/bin.js +144 -0
- package/script/deps/deno.land/std@0.173.0/_util/asserts.js +27 -0
- package/script/deps/deno.land/std@0.173.0/_util/os.js +44 -0
- package/script/deps/deno.land/std@0.173.0/flags/mod.js +368 -0
- package/script/deps/deno.land/std@0.173.0/path/_constants.js +49 -0
- package/script/deps/deno.land/std@0.173.0/path/_interface.js +4 -0
- package/script/deps/deno.land/std@0.173.0/path/_util.js +125 -0
- package/script/deps/deno.land/std@0.173.0/path/common.js +40 -0
- package/script/deps/deno.land/std@0.173.0/path/glob.js +391 -0
- package/script/deps/deno.land/std@0.173.0/path/mod.js +63 -0
- package/script/deps/deno.land/std@0.173.0/path/posix.js +539 -0
- package/script/deps/deno.land/std@0.173.0/path/separator.js +8 -0
- package/script/deps/deno.land/std@0.173.0/path/win32.js +1007 -0
- package/script/deps/deno.land/std@0.173.0/semver/mod.js +1458 -0
- package/script/deps/deno.land/std@0.51.0/fs/eol.js +34 -0
- package/script/deps/deno.land/x/ini@v2.1.0/ini.js +256 -0
- package/script/deps/deno.land/x/ini@v2.1.0/mod.js +17 -0
- package/script/mod.js +15 -0
- package/{umd → script}/package.json +0 -0
- package/script/src/Change.js +51 -0
- package/script/src/Changelog.js +148 -0
- package/script/src/Release.js +227 -0
- package/script/src/deps.js +9 -0
- package/script/src/parser.js +184 -0
- package/{umd → script}/test/changelog.custom.type.md +0 -1
- package/script/test/changelog.expected.linted.md +208 -0
- package/{umd → script}/test/changelog.expected.md +6 -4
- package/{umd → script}/test/changelog.md +7 -3
- package/{umd → script}/test/empty.expected.md +0 -1
- package/types/_dnt.polyfills.d.ts +11 -0
- package/types/_dnt.shims.d.ts +0 -4
- package/types/bin.d.ts +1 -1
- package/types/deps/deno.land/std@0.173.0/_util/asserts.d.ts +10 -0
- package/types/deps/deno.land/std@0.173.0/_util/os.d.ts +4 -0
- package/types/deps/deno.land/std@0.173.0/flags/mod.d.ts +166 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_constants.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_interface.d.ts +1 -1
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/_util.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/common.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/glob.d.ts +10 -5
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/mod.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/posix.d.ts +9 -5
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/separator.d.ts +0 -0
- package/types/deps/{deno_land/std_0.120.0 → deno.land/std@0.173.0}/path/win32.d.ts +7 -5
- package/types/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
- package/types/deps/{deno_land/std_0.51.0 → deno.land/std@0.51.0}/fs/eol.d.ts +0 -0
- package/types/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/ini.d.ts +0 -0
- package/types/deps/{deno_land/x/ini_v2.1.0 → deno.land/x/ini@v2.1.0}/mod.d.ts +0 -0
- package/types/mod.d.ts +1 -0
- package/types/src/Changelog.d.ts +1 -0
- package/types/src/Release.d.ts +2 -0
- package/types/src/deps.d.ts +1 -1
- package/esm/deps/deno_land/std_0.120.0/_util/assert.js +0 -13
- package/esm/deps/deno_land/std_0.120.0/path/_interface.js +0 -3
- package/esm/deps/deno_land/std_0.120.0/path/mod.js +0 -14
- package/types/deps/deno_land/std_0.120.0/_util/assert.d.ts +0 -5
- package/types/deps/deno_land/std_0.120.0/_util/os.d.ts +0 -3
- package/types/deps/deno_land/std_0.120.0/flags/mod.d.ts +0 -50
- package/types/deps/deno_land/x/semver_v1.4.0/mod.d.ts +0 -116
- package/umd/_dnt.shims.js +0 -76
- package/umd/bin.js +0 -145
- package/umd/deps/deno_land/std_0.120.0/_util/assert.js +0 -28
- package/umd/deps/deno_land/std_0.120.0/_util/os.js +0 -47
- package/umd/deps/deno_land/std_0.120.0/flags/mod.js +0 -269
- package/umd/deps/deno_land/std_0.120.0/path/_constants.js +0 -58
- package/umd/deps/deno_land/std_0.120.0/path/_interface.js +0 -14
- package/umd/deps/deno_land/std_0.120.0/path/_util.js +0 -134
- package/umd/deps/deno_land/std_0.120.0/path/common.js +0 -50
- package/umd/deps/deno_land/std_0.120.0/path/glob.js +0 -397
- package/umd/deps/deno_land/std_0.120.0/path/mod.js +0 -51
- package/umd/deps/deno_land/std_0.120.0/path/posix.js +0 -538
- package/umd/deps/deno_land/std_0.120.0/path/separator.js +0 -18
- package/umd/deps/deno_land/std_0.120.0/path/win32.js +0 -1008
- package/umd/deps/deno_land/std_0.51.0/fs/eol.js +0 -44
- package/umd/deps/deno_land/x/ini_v2.1.0/ini.js +0 -262
- package/umd/deps/deno_land/x/ini_v2.1.0/mod.js +0 -23
- package/umd/deps/deno_land/x/semver_v1.4.0/mod.js +0 -1578
- package/umd/mod.js +0 -24
- package/umd/src/Change.js +0 -61
- package/umd/src/Changelog.js +0 -150
- package/umd/src/Release.js +0 -220
- package/umd/src/deps.js +0 -19
- package/umd/src/parser.js +0 -175
|
@@ -1,1578 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.coerce = exports.intersects = exports.prerelease = exports.outside = exports.gtr = exports.ltr = exports.validRange = exports.minVersion = exports.minSatisfying = exports.maxSatisfying = exports.satisfies = exports.toComparators = exports.Range = exports.Comparator = exports.cmp = exports.lte = exports.gte = exports.neq = exports.eq = exports.lt = exports.gt = exports.rsort = exports.sort = exports.rcompare = exports.compareBuild = exports.compareLoose = exports.compare = exports.patch = exports.minor = exports.major = exports.rcompareIdentifiers = exports.compareIdentifiers = exports.diff = exports.inc = exports.SemVer = exports.clean = exports.valid = exports.parse = exports.SEMVER_SPEC_VERSION = void 0;
|
|
13
|
-
// Note: this is the semver.org version of the spec that it implements
|
|
14
|
-
// Not necessarily the package version of this code.
|
|
15
|
-
exports.SEMVER_SPEC_VERSION = "2.0.0";
|
|
16
|
-
const MAX_LENGTH = 256;
|
|
17
|
-
// Max safe segment length for coercion.
|
|
18
|
-
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
19
|
-
// The actual regexps
|
|
20
|
-
const re = [];
|
|
21
|
-
const src = [];
|
|
22
|
-
let R = 0;
|
|
23
|
-
// The following Regular Expressions can be used for tokenizing,
|
|
24
|
-
// validating, and parsing SemVer version strings.
|
|
25
|
-
// ## Numeric Identifier
|
|
26
|
-
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
27
|
-
const NUMERICIDENTIFIER = R++;
|
|
28
|
-
src[NUMERICIDENTIFIER] = "0|[1-9]\\d*";
|
|
29
|
-
const NUMERICIDENTIFIERLOOSE = R++;
|
|
30
|
-
src[NUMERICIDENTIFIERLOOSE] = "[0-9]+";
|
|
31
|
-
// ## Non-numeric Identifier
|
|
32
|
-
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
33
|
-
// more letters, digits, or hyphens.
|
|
34
|
-
const NONNUMERICIDENTIFIER = R++;
|
|
35
|
-
src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
|
|
36
|
-
// ## Main Version
|
|
37
|
-
// Three dot-separated numeric identifiers.
|
|
38
|
-
const MAINVERSION = R++;
|
|
39
|
-
const nid = src[NUMERICIDENTIFIER];
|
|
40
|
-
src[MAINVERSION] = `(${nid})\\.(${nid})\\.(${nid})`;
|
|
41
|
-
const MAINVERSIONLOOSE = R++;
|
|
42
|
-
const nidl = src[NUMERICIDENTIFIERLOOSE];
|
|
43
|
-
src[MAINVERSIONLOOSE] = `(${nidl})\\.(${nidl})\\.(${nidl})`;
|
|
44
|
-
// ## Pre-release Version Identifier
|
|
45
|
-
// A numeric identifier, or a non-numeric identifier.
|
|
46
|
-
const PRERELEASEIDENTIFIER = R++;
|
|
47
|
-
src[PRERELEASEIDENTIFIER] = "(?:" + src[NUMERICIDENTIFIER] + "|" +
|
|
48
|
-
src[NONNUMERICIDENTIFIER] + ")";
|
|
49
|
-
const PRERELEASEIDENTIFIERLOOSE = R++;
|
|
50
|
-
src[PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[NUMERICIDENTIFIERLOOSE] + "|" +
|
|
51
|
-
src[NONNUMERICIDENTIFIER] + ")";
|
|
52
|
-
// ## Pre-release Version
|
|
53
|
-
// Hyphen, followed by one or more dot-separated pre-release version
|
|
54
|
-
// identifiers.
|
|
55
|
-
const PRERELEASE = R++;
|
|
56
|
-
src[PRERELEASE] = "(?:-(" +
|
|
57
|
-
src[PRERELEASEIDENTIFIER] +
|
|
58
|
-
"(?:\\." +
|
|
59
|
-
src[PRERELEASEIDENTIFIER] +
|
|
60
|
-
")*))";
|
|
61
|
-
const PRERELEASELOOSE = R++;
|
|
62
|
-
src[PRERELEASELOOSE] = "(?:-?(" +
|
|
63
|
-
src[PRERELEASEIDENTIFIERLOOSE] +
|
|
64
|
-
"(?:\\." +
|
|
65
|
-
src[PRERELEASEIDENTIFIERLOOSE] +
|
|
66
|
-
")*))";
|
|
67
|
-
// ## Build Metadata Identifier
|
|
68
|
-
// Any combination of digits, letters, or hyphens.
|
|
69
|
-
const BUILDIDENTIFIER = R++;
|
|
70
|
-
src[BUILDIDENTIFIER] = "[0-9A-Za-z-]+";
|
|
71
|
-
// ## Build Metadata
|
|
72
|
-
// Plus sign, followed by one or more period-separated build metadata
|
|
73
|
-
// identifiers.
|
|
74
|
-
const BUILD = R++;
|
|
75
|
-
src[BUILD] = "(?:\\+(" + src[BUILDIDENTIFIER] + "(?:\\." +
|
|
76
|
-
src[BUILDIDENTIFIER] + ")*))";
|
|
77
|
-
// ## Full Version String
|
|
78
|
-
// A main version, followed optionally by a pre-release version and
|
|
79
|
-
// build metadata.
|
|
80
|
-
// Note that the only major, minor, patch, and pre-release sections of
|
|
81
|
-
// the version string are capturing groups. The build metadata is not a
|
|
82
|
-
// capturing group, because it should not ever be used in version
|
|
83
|
-
// comparison.
|
|
84
|
-
const FULL = R++;
|
|
85
|
-
const FULLPLAIN = "v?" + src[MAINVERSION] + src[PRERELEASE] + "?" + src[BUILD] +
|
|
86
|
-
"?";
|
|
87
|
-
src[FULL] = "^" + FULLPLAIN + "$";
|
|
88
|
-
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
89
|
-
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
90
|
-
// common in the npm registry.
|
|
91
|
-
const LOOSEPLAIN = "[v=\\s]*" +
|
|
92
|
-
src[MAINVERSIONLOOSE] +
|
|
93
|
-
src[PRERELEASELOOSE] +
|
|
94
|
-
"?" +
|
|
95
|
-
src[BUILD] +
|
|
96
|
-
"?";
|
|
97
|
-
const LOOSE = R++;
|
|
98
|
-
src[LOOSE] = "^" + LOOSEPLAIN + "$";
|
|
99
|
-
const GTLT = R++;
|
|
100
|
-
src[GTLT] = "((?:<|>)?=?)";
|
|
101
|
-
// Something like "2.*" or "1.2.x".
|
|
102
|
-
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
103
|
-
// Only the first item is strictly required.
|
|
104
|
-
const XRANGEIDENTIFIERLOOSE = R++;
|
|
105
|
-
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
|
|
106
|
-
const XRANGEIDENTIFIER = R++;
|
|
107
|
-
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + "|x|X|\\*";
|
|
108
|
-
const XRANGEPLAIN = R++;
|
|
109
|
-
src[XRANGEPLAIN] = "[v=\\s]*(" +
|
|
110
|
-
src[XRANGEIDENTIFIER] +
|
|
111
|
-
")" +
|
|
112
|
-
"(?:\\.(" +
|
|
113
|
-
src[XRANGEIDENTIFIER] +
|
|
114
|
-
")" +
|
|
115
|
-
"(?:\\.(" +
|
|
116
|
-
src[XRANGEIDENTIFIER] +
|
|
117
|
-
")" +
|
|
118
|
-
"(?:" +
|
|
119
|
-
src[PRERELEASE] +
|
|
120
|
-
")?" +
|
|
121
|
-
src[BUILD] +
|
|
122
|
-
"?" +
|
|
123
|
-
")?)?";
|
|
124
|
-
const XRANGEPLAINLOOSE = R++;
|
|
125
|
-
src[XRANGEPLAINLOOSE] = "[v=\\s]*(" +
|
|
126
|
-
src[XRANGEIDENTIFIERLOOSE] +
|
|
127
|
-
")" +
|
|
128
|
-
"(?:\\.(" +
|
|
129
|
-
src[XRANGEIDENTIFIERLOOSE] +
|
|
130
|
-
")" +
|
|
131
|
-
"(?:\\.(" +
|
|
132
|
-
src[XRANGEIDENTIFIERLOOSE] +
|
|
133
|
-
")" +
|
|
134
|
-
"(?:" +
|
|
135
|
-
src[PRERELEASELOOSE] +
|
|
136
|
-
")?" +
|
|
137
|
-
src[BUILD] +
|
|
138
|
-
"?" +
|
|
139
|
-
")?)?";
|
|
140
|
-
const XRANGE = R++;
|
|
141
|
-
src[XRANGE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAIN] + "$";
|
|
142
|
-
const XRANGELOOSE = R++;
|
|
143
|
-
src[XRANGELOOSE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAINLOOSE] + "$";
|
|
144
|
-
// Coercion.
|
|
145
|
-
// Extract anything that could conceivably be a part of a valid semver
|
|
146
|
-
const COERCE = R++;
|
|
147
|
-
src[COERCE] = "(?:^|[^\\d])" +
|
|
148
|
-
"(\\d{1," +
|
|
149
|
-
MAX_SAFE_COMPONENT_LENGTH +
|
|
150
|
-
"})" +
|
|
151
|
-
"(?:\\.(\\d{1," +
|
|
152
|
-
MAX_SAFE_COMPONENT_LENGTH +
|
|
153
|
-
"}))?" +
|
|
154
|
-
"(?:\\.(\\d{1," +
|
|
155
|
-
MAX_SAFE_COMPONENT_LENGTH +
|
|
156
|
-
"}))?" +
|
|
157
|
-
"(?:$|[^\\d])";
|
|
158
|
-
// Tilde ranges.
|
|
159
|
-
// Meaning is "reasonably at or greater than"
|
|
160
|
-
const LONETILDE = R++;
|
|
161
|
-
src[LONETILDE] = "(?:~>?)";
|
|
162
|
-
const TILDETRIM = R++;
|
|
163
|
-
src[TILDETRIM] = "(\\s*)" + src[LONETILDE] + "\\s+";
|
|
164
|
-
re[TILDETRIM] = new RegExp(src[TILDETRIM], "g");
|
|
165
|
-
const tildeTrimReplace = "$1~";
|
|
166
|
-
const TILDE = R++;
|
|
167
|
-
src[TILDE] = "^" + src[LONETILDE] + src[XRANGEPLAIN] + "$";
|
|
168
|
-
const TILDELOOSE = R++;
|
|
169
|
-
src[TILDELOOSE] = "^" + src[LONETILDE] + src[XRANGEPLAINLOOSE] + "$";
|
|
170
|
-
// Caret ranges.
|
|
171
|
-
// Meaning is "at least and backwards compatible with"
|
|
172
|
-
const LONECARET = R++;
|
|
173
|
-
src[LONECARET] = "(?:\\^)";
|
|
174
|
-
const CARETTRIM = R++;
|
|
175
|
-
src[CARETTRIM] = "(\\s*)" + src[LONECARET] + "\\s+";
|
|
176
|
-
re[CARETTRIM] = new RegExp(src[CARETTRIM], "g");
|
|
177
|
-
const caretTrimReplace = "$1^";
|
|
178
|
-
const CARET = R++;
|
|
179
|
-
src[CARET] = "^" + src[LONECARET] + src[XRANGEPLAIN] + "$";
|
|
180
|
-
const CARETLOOSE = R++;
|
|
181
|
-
src[CARETLOOSE] = "^" + src[LONECARET] + src[XRANGEPLAINLOOSE] + "$";
|
|
182
|
-
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
183
|
-
const COMPARATORLOOSE = R++;
|
|
184
|
-
src[COMPARATORLOOSE] = "^" + src[GTLT] + "\\s*(" + LOOSEPLAIN + ")$|^$";
|
|
185
|
-
const COMPARATOR = R++;
|
|
186
|
-
src[COMPARATOR] = "^" + src[GTLT] + "\\s*(" + FULLPLAIN + ")$|^$";
|
|
187
|
-
// An expression to strip any whitespace between the gtlt and the thing
|
|
188
|
-
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
189
|
-
const COMPARATORTRIM = R++;
|
|
190
|
-
src[COMPARATORTRIM] = "(\\s*)" + src[GTLT] + "\\s*(" + LOOSEPLAIN + "|" +
|
|
191
|
-
src[XRANGEPLAIN] + ")";
|
|
192
|
-
// this one has to use the /g flag
|
|
193
|
-
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g");
|
|
194
|
-
const comparatorTrimReplace = "$1$2$3";
|
|
195
|
-
// Something like `1.2.3 - 1.2.4`
|
|
196
|
-
// Note that these all use the loose form, because they'll be
|
|
197
|
-
// checked against either the strict or loose comparator form
|
|
198
|
-
// later.
|
|
199
|
-
const HYPHENRANGE = R++;
|
|
200
|
-
src[HYPHENRANGE] = "^\\s*(" +
|
|
201
|
-
src[XRANGEPLAIN] +
|
|
202
|
-
")" +
|
|
203
|
-
"\\s+-\\s+" +
|
|
204
|
-
"(" +
|
|
205
|
-
src[XRANGEPLAIN] +
|
|
206
|
-
")" +
|
|
207
|
-
"\\s*$";
|
|
208
|
-
const HYPHENRANGELOOSE = R++;
|
|
209
|
-
src[HYPHENRANGELOOSE] = "^\\s*(" +
|
|
210
|
-
src[XRANGEPLAINLOOSE] +
|
|
211
|
-
")" +
|
|
212
|
-
"\\s+-\\s+" +
|
|
213
|
-
"(" +
|
|
214
|
-
src[XRANGEPLAINLOOSE] +
|
|
215
|
-
")" +
|
|
216
|
-
"\\s*$";
|
|
217
|
-
// Star ranges basically just allow anything at all.
|
|
218
|
-
const STAR = R++;
|
|
219
|
-
src[STAR] = "(<|>)?=?\\s*\\*";
|
|
220
|
-
// Compile to actual regexp objects.
|
|
221
|
-
// All are flag-free, unless they were created above with a flag.
|
|
222
|
-
for (let i = 0; i < R; i++) {
|
|
223
|
-
if (!re[i]) {
|
|
224
|
-
re[i] = new RegExp(src[i]);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function parse(version, optionsOrLoose) {
|
|
228
|
-
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
|
|
229
|
-
optionsOrLoose = {
|
|
230
|
-
loose: !!optionsOrLoose,
|
|
231
|
-
includePrerelease: false,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
if (version instanceof SemVer) {
|
|
235
|
-
return version;
|
|
236
|
-
}
|
|
237
|
-
if (typeof version !== "string") {
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
if (version.length > MAX_LENGTH) {
|
|
241
|
-
return null;
|
|
242
|
-
}
|
|
243
|
-
const r = optionsOrLoose.loose ? re[LOOSE] : re[FULL];
|
|
244
|
-
if (!r.test(version)) {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
try {
|
|
248
|
-
return new SemVer(version, optionsOrLoose);
|
|
249
|
-
}
|
|
250
|
-
catch (er) {
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
exports.parse = parse;
|
|
255
|
-
function valid(version, optionsOrLoose) {
|
|
256
|
-
if (version === null)
|
|
257
|
-
return null;
|
|
258
|
-
const v = parse(version, optionsOrLoose);
|
|
259
|
-
return v ? v.version : null;
|
|
260
|
-
}
|
|
261
|
-
exports.valid = valid;
|
|
262
|
-
function clean(version, optionsOrLoose) {
|
|
263
|
-
const s = parse(version.trim().replace(/^[=v]+/, ""), optionsOrLoose);
|
|
264
|
-
return s ? s.version : null;
|
|
265
|
-
}
|
|
266
|
-
exports.clean = clean;
|
|
267
|
-
class SemVer {
|
|
268
|
-
constructor(version, optionsOrLoose) {
|
|
269
|
-
Object.defineProperty(this, "raw", {
|
|
270
|
-
enumerable: true,
|
|
271
|
-
configurable: true,
|
|
272
|
-
writable: true,
|
|
273
|
-
value: void 0
|
|
274
|
-
});
|
|
275
|
-
Object.defineProperty(this, "loose", {
|
|
276
|
-
enumerable: true,
|
|
277
|
-
configurable: true,
|
|
278
|
-
writable: true,
|
|
279
|
-
value: void 0
|
|
280
|
-
});
|
|
281
|
-
Object.defineProperty(this, "options", {
|
|
282
|
-
enumerable: true,
|
|
283
|
-
configurable: true,
|
|
284
|
-
writable: true,
|
|
285
|
-
value: void 0
|
|
286
|
-
});
|
|
287
|
-
Object.defineProperty(this, "major", {
|
|
288
|
-
enumerable: true,
|
|
289
|
-
configurable: true,
|
|
290
|
-
writable: true,
|
|
291
|
-
value: void 0
|
|
292
|
-
});
|
|
293
|
-
Object.defineProperty(this, "minor", {
|
|
294
|
-
enumerable: true,
|
|
295
|
-
configurable: true,
|
|
296
|
-
writable: true,
|
|
297
|
-
value: void 0
|
|
298
|
-
});
|
|
299
|
-
Object.defineProperty(this, "patch", {
|
|
300
|
-
enumerable: true,
|
|
301
|
-
configurable: true,
|
|
302
|
-
writable: true,
|
|
303
|
-
value: void 0
|
|
304
|
-
});
|
|
305
|
-
Object.defineProperty(this, "version", {
|
|
306
|
-
enumerable: true,
|
|
307
|
-
configurable: true,
|
|
308
|
-
writable: true,
|
|
309
|
-
value: void 0
|
|
310
|
-
});
|
|
311
|
-
Object.defineProperty(this, "build", {
|
|
312
|
-
enumerable: true,
|
|
313
|
-
configurable: true,
|
|
314
|
-
writable: true,
|
|
315
|
-
value: void 0
|
|
316
|
-
});
|
|
317
|
-
Object.defineProperty(this, "prerelease", {
|
|
318
|
-
enumerable: true,
|
|
319
|
-
configurable: true,
|
|
320
|
-
writable: true,
|
|
321
|
-
value: void 0
|
|
322
|
-
});
|
|
323
|
-
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
|
|
324
|
-
optionsOrLoose = {
|
|
325
|
-
loose: !!optionsOrLoose,
|
|
326
|
-
includePrerelease: false,
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
if (version instanceof SemVer) {
|
|
330
|
-
if (version.loose === optionsOrLoose.loose) {
|
|
331
|
-
return version;
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
version = version.version;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
else if (typeof version !== "string") {
|
|
338
|
-
throw new TypeError("Invalid Version: " + version);
|
|
339
|
-
}
|
|
340
|
-
if (version.length > MAX_LENGTH) {
|
|
341
|
-
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
|
|
342
|
-
}
|
|
343
|
-
if (!(this instanceof SemVer)) {
|
|
344
|
-
return new SemVer(version, optionsOrLoose);
|
|
345
|
-
}
|
|
346
|
-
this.options = optionsOrLoose;
|
|
347
|
-
this.loose = !!optionsOrLoose.loose;
|
|
348
|
-
const m = version.trim().match(optionsOrLoose.loose ? re[LOOSE] : re[FULL]);
|
|
349
|
-
if (!m) {
|
|
350
|
-
throw new TypeError("Invalid Version: " + version);
|
|
351
|
-
}
|
|
352
|
-
this.raw = version;
|
|
353
|
-
// these are actually numbers
|
|
354
|
-
this.major = +m[1];
|
|
355
|
-
this.minor = +m[2];
|
|
356
|
-
this.patch = +m[3];
|
|
357
|
-
if (this.major > Number.MAX_SAFE_INTEGER || this.major < 0) {
|
|
358
|
-
throw new TypeError("Invalid major version");
|
|
359
|
-
}
|
|
360
|
-
if (this.minor > Number.MAX_SAFE_INTEGER || this.minor < 0) {
|
|
361
|
-
throw new TypeError("Invalid minor version");
|
|
362
|
-
}
|
|
363
|
-
if (this.patch > Number.MAX_SAFE_INTEGER || this.patch < 0) {
|
|
364
|
-
throw new TypeError("Invalid patch version");
|
|
365
|
-
}
|
|
366
|
-
// numberify any prerelease numeric ids
|
|
367
|
-
if (!m[4]) {
|
|
368
|
-
this.prerelease = [];
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
this.prerelease = m[4].split(".").map((id) => {
|
|
372
|
-
if (/^[0-9]+$/.test(id)) {
|
|
373
|
-
const num = +id;
|
|
374
|
-
if (num >= 0 && num < Number.MAX_SAFE_INTEGER) {
|
|
375
|
-
return num;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
return id;
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
this.build = m[5] ? m[5].split(".") : [];
|
|
382
|
-
this.format();
|
|
383
|
-
}
|
|
384
|
-
format() {
|
|
385
|
-
this.version = this.major + "." + this.minor + "." + this.patch;
|
|
386
|
-
if (this.prerelease.length) {
|
|
387
|
-
this.version += "-" + this.prerelease.join(".");
|
|
388
|
-
}
|
|
389
|
-
return this.version;
|
|
390
|
-
}
|
|
391
|
-
compare(other) {
|
|
392
|
-
if (!(other instanceof SemVer)) {
|
|
393
|
-
other = new SemVer(other, this.options);
|
|
394
|
-
}
|
|
395
|
-
return this.compareMain(other) || this.comparePre(other);
|
|
396
|
-
}
|
|
397
|
-
compareMain(other) {
|
|
398
|
-
if (!(other instanceof SemVer)) {
|
|
399
|
-
other = new SemVer(other, this.options);
|
|
400
|
-
}
|
|
401
|
-
return (compareIdentifiers(this.major, other.major) ||
|
|
402
|
-
compareIdentifiers(this.minor, other.minor) ||
|
|
403
|
-
compareIdentifiers(this.patch, other.patch));
|
|
404
|
-
}
|
|
405
|
-
comparePre(other) {
|
|
406
|
-
if (!(other instanceof SemVer)) {
|
|
407
|
-
other = new SemVer(other, this.options);
|
|
408
|
-
}
|
|
409
|
-
// NOT having a prerelease is > having one
|
|
410
|
-
if (this.prerelease.length && !other.prerelease.length) {
|
|
411
|
-
return -1;
|
|
412
|
-
}
|
|
413
|
-
else if (!this.prerelease.length && other.prerelease.length) {
|
|
414
|
-
return 1;
|
|
415
|
-
}
|
|
416
|
-
else if (!this.prerelease.length && !other.prerelease.length) {
|
|
417
|
-
return 0;
|
|
418
|
-
}
|
|
419
|
-
let i = 0;
|
|
420
|
-
do {
|
|
421
|
-
const a = this.prerelease[i];
|
|
422
|
-
const b = other.prerelease[i];
|
|
423
|
-
if (a === undefined && b === undefined) {
|
|
424
|
-
return 0;
|
|
425
|
-
}
|
|
426
|
-
else if (b === undefined) {
|
|
427
|
-
return 1;
|
|
428
|
-
}
|
|
429
|
-
else if (a === undefined) {
|
|
430
|
-
return -1;
|
|
431
|
-
}
|
|
432
|
-
else if (a === b) {
|
|
433
|
-
continue;
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
return compareIdentifiers(a, b);
|
|
437
|
-
}
|
|
438
|
-
} while (++i);
|
|
439
|
-
return 1;
|
|
440
|
-
}
|
|
441
|
-
compareBuild(other) {
|
|
442
|
-
if (!(other instanceof SemVer)) {
|
|
443
|
-
other = new SemVer(other, this.options);
|
|
444
|
-
}
|
|
445
|
-
let i = 0;
|
|
446
|
-
do {
|
|
447
|
-
const a = this.build[i];
|
|
448
|
-
const b = other.build[i];
|
|
449
|
-
if (a === undefined && b === undefined) {
|
|
450
|
-
return 0;
|
|
451
|
-
}
|
|
452
|
-
else if (b === undefined) {
|
|
453
|
-
return 1;
|
|
454
|
-
}
|
|
455
|
-
else if (a === undefined) {
|
|
456
|
-
return -1;
|
|
457
|
-
}
|
|
458
|
-
else if (a === b) {
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
return compareIdentifiers(a, b);
|
|
463
|
-
}
|
|
464
|
-
} while (++i);
|
|
465
|
-
return 1;
|
|
466
|
-
}
|
|
467
|
-
inc(release, identifier) {
|
|
468
|
-
switch (release) {
|
|
469
|
-
case "premajor":
|
|
470
|
-
this.prerelease.length = 0;
|
|
471
|
-
this.patch = 0;
|
|
472
|
-
this.minor = 0;
|
|
473
|
-
this.major++;
|
|
474
|
-
this.inc("pre", identifier);
|
|
475
|
-
break;
|
|
476
|
-
case "preminor":
|
|
477
|
-
this.prerelease.length = 0;
|
|
478
|
-
this.patch = 0;
|
|
479
|
-
this.minor++;
|
|
480
|
-
this.inc("pre", identifier);
|
|
481
|
-
break;
|
|
482
|
-
case "prepatch":
|
|
483
|
-
// If this is already a prerelease, it will bump to the next version
|
|
484
|
-
// drop any prereleases that might already exist, since they are not
|
|
485
|
-
// relevant at this point.
|
|
486
|
-
this.prerelease.length = 0;
|
|
487
|
-
this.inc("patch", identifier);
|
|
488
|
-
this.inc("pre", identifier);
|
|
489
|
-
break;
|
|
490
|
-
// If the input is a non-prerelease version, this acts the same as
|
|
491
|
-
// prepatch.
|
|
492
|
-
case "prerelease":
|
|
493
|
-
if (this.prerelease.length === 0) {
|
|
494
|
-
this.inc("patch", identifier);
|
|
495
|
-
}
|
|
496
|
-
this.inc("pre", identifier);
|
|
497
|
-
break;
|
|
498
|
-
case "major":
|
|
499
|
-
// If this is a pre-major version, bump up to the same major version.
|
|
500
|
-
// Otherwise increment major.
|
|
501
|
-
// 1.0.0-5 bumps to 1.0.0
|
|
502
|
-
// 1.1.0 bumps to 2.0.0
|
|
503
|
-
if (this.minor !== 0 ||
|
|
504
|
-
this.patch !== 0 ||
|
|
505
|
-
this.prerelease.length === 0) {
|
|
506
|
-
this.major++;
|
|
507
|
-
}
|
|
508
|
-
this.minor = 0;
|
|
509
|
-
this.patch = 0;
|
|
510
|
-
this.prerelease = [];
|
|
511
|
-
break;
|
|
512
|
-
case "minor":
|
|
513
|
-
// If this is a pre-minor version, bump up to the same minor version.
|
|
514
|
-
// Otherwise increment minor.
|
|
515
|
-
// 1.2.0-5 bumps to 1.2.0
|
|
516
|
-
// 1.2.1 bumps to 1.3.0
|
|
517
|
-
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
518
|
-
this.minor++;
|
|
519
|
-
}
|
|
520
|
-
this.patch = 0;
|
|
521
|
-
this.prerelease = [];
|
|
522
|
-
break;
|
|
523
|
-
case "patch":
|
|
524
|
-
// If this is not a pre-release version, it will increment the patch.
|
|
525
|
-
// If it is a pre-release it will bump up to the same patch version.
|
|
526
|
-
// 1.2.0-5 patches to 1.2.0
|
|
527
|
-
// 1.2.0 patches to 1.2.1
|
|
528
|
-
if (this.prerelease.length === 0) {
|
|
529
|
-
this.patch++;
|
|
530
|
-
}
|
|
531
|
-
this.prerelease = [];
|
|
532
|
-
break;
|
|
533
|
-
// This probably shouldn't be used publicly.
|
|
534
|
-
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
|
535
|
-
case "pre":
|
|
536
|
-
if (this.prerelease.length === 0) {
|
|
537
|
-
this.prerelease = [0];
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
let i = this.prerelease.length;
|
|
541
|
-
while (--i >= 0) {
|
|
542
|
-
if (typeof this.prerelease[i] === "number") {
|
|
543
|
-
this.prerelease[i]++;
|
|
544
|
-
i = -2;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
if (i === -1) {
|
|
548
|
-
// didn't increment anything
|
|
549
|
-
this.prerelease.push(0);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
if (identifier) {
|
|
553
|
-
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
554
|
-
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
555
|
-
if (this.prerelease[0] === identifier) {
|
|
556
|
-
if (isNaN(this.prerelease[1])) {
|
|
557
|
-
this.prerelease = [identifier, 0];
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
this.prerelease = [identifier, 0];
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
break;
|
|
565
|
-
default:
|
|
566
|
-
throw new Error("invalid increment argument: " + release);
|
|
567
|
-
}
|
|
568
|
-
this.format();
|
|
569
|
-
this.raw = this.version;
|
|
570
|
-
return this;
|
|
571
|
-
}
|
|
572
|
-
toString() {
|
|
573
|
-
return this.version;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
exports.SemVer = SemVer;
|
|
577
|
-
/**
|
|
578
|
-
* Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
|
|
579
|
-
*/
|
|
580
|
-
function inc(version, release, optionsOrLoose, identifier) {
|
|
581
|
-
if (typeof optionsOrLoose === "string") {
|
|
582
|
-
identifier = optionsOrLoose;
|
|
583
|
-
optionsOrLoose = undefined;
|
|
584
|
-
}
|
|
585
|
-
try {
|
|
586
|
-
return new SemVer(version, optionsOrLoose).inc(release, identifier).version;
|
|
587
|
-
}
|
|
588
|
-
catch (er) {
|
|
589
|
-
return null;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
exports.inc = inc;
|
|
593
|
-
function diff(version1, version2, optionsOrLoose) {
|
|
594
|
-
if (eq(version1, version2, optionsOrLoose)) {
|
|
595
|
-
return null;
|
|
596
|
-
}
|
|
597
|
-
else {
|
|
598
|
-
const v1 = parse(version1);
|
|
599
|
-
const v2 = parse(version2);
|
|
600
|
-
let prefix = "";
|
|
601
|
-
let defaultResult = null;
|
|
602
|
-
if (v1 && v2) {
|
|
603
|
-
if (v1.prerelease.length || v2.prerelease.length) {
|
|
604
|
-
prefix = "pre";
|
|
605
|
-
defaultResult = "prerelease";
|
|
606
|
-
}
|
|
607
|
-
for (const key in v1) {
|
|
608
|
-
if (key === "major" || key === "minor" || key === "patch") {
|
|
609
|
-
if (v1[key] !== v2[key]) {
|
|
610
|
-
return (prefix + key);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
return defaultResult; // may be undefined
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
exports.diff = diff;
|
|
619
|
-
const numeric = /^[0-9]+$/;
|
|
620
|
-
function compareIdentifiers(a, b) {
|
|
621
|
-
const anum = numeric.test(a);
|
|
622
|
-
const bnum = numeric.test(b);
|
|
623
|
-
if (a === null || b === null)
|
|
624
|
-
throw "Comparison against null invalid";
|
|
625
|
-
if (anum && bnum) {
|
|
626
|
-
a = +a;
|
|
627
|
-
b = +b;
|
|
628
|
-
}
|
|
629
|
-
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
630
|
-
}
|
|
631
|
-
exports.compareIdentifiers = compareIdentifiers;
|
|
632
|
-
function rcompareIdentifiers(a, b) {
|
|
633
|
-
return compareIdentifiers(b, a);
|
|
634
|
-
}
|
|
635
|
-
exports.rcompareIdentifiers = rcompareIdentifiers;
|
|
636
|
-
/**
|
|
637
|
-
* Return the major version number.
|
|
638
|
-
*/
|
|
639
|
-
function major(v, optionsOrLoose) {
|
|
640
|
-
return new SemVer(v, optionsOrLoose).major;
|
|
641
|
-
}
|
|
642
|
-
exports.major = major;
|
|
643
|
-
/**
|
|
644
|
-
* Return the minor version number.
|
|
645
|
-
*/
|
|
646
|
-
function minor(v, optionsOrLoose) {
|
|
647
|
-
return new SemVer(v, optionsOrLoose).minor;
|
|
648
|
-
}
|
|
649
|
-
exports.minor = minor;
|
|
650
|
-
/**
|
|
651
|
-
* Return the patch version number.
|
|
652
|
-
*/
|
|
653
|
-
function patch(v, optionsOrLoose) {
|
|
654
|
-
return new SemVer(v, optionsOrLoose).patch;
|
|
655
|
-
}
|
|
656
|
-
exports.patch = patch;
|
|
657
|
-
function compare(v1, v2, optionsOrLoose) {
|
|
658
|
-
return new SemVer(v1, optionsOrLoose).compare(new SemVer(v2, optionsOrLoose));
|
|
659
|
-
}
|
|
660
|
-
exports.compare = compare;
|
|
661
|
-
function compareLoose(a, b) {
|
|
662
|
-
return compare(a, b, true);
|
|
663
|
-
}
|
|
664
|
-
exports.compareLoose = compareLoose;
|
|
665
|
-
function compareBuild(a, b, loose) {
|
|
666
|
-
var versionA = new SemVer(a, loose);
|
|
667
|
-
var versionB = new SemVer(b, loose);
|
|
668
|
-
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
669
|
-
}
|
|
670
|
-
exports.compareBuild = compareBuild;
|
|
671
|
-
function rcompare(v1, v2, optionsOrLoose) {
|
|
672
|
-
return compare(v2, v1, optionsOrLoose);
|
|
673
|
-
}
|
|
674
|
-
exports.rcompare = rcompare;
|
|
675
|
-
function sort(list, optionsOrLoose) {
|
|
676
|
-
return list.sort((a, b) => {
|
|
677
|
-
return compareBuild(a, b, optionsOrLoose);
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
exports.sort = sort;
|
|
681
|
-
function rsort(list, optionsOrLoose) {
|
|
682
|
-
return list.sort((a, b) => {
|
|
683
|
-
return compareBuild(b, a, optionsOrLoose);
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
exports.rsort = rsort;
|
|
687
|
-
function gt(v1, v2, optionsOrLoose) {
|
|
688
|
-
return compare(v1, v2, optionsOrLoose) > 0;
|
|
689
|
-
}
|
|
690
|
-
exports.gt = gt;
|
|
691
|
-
function lt(v1, v2, optionsOrLoose) {
|
|
692
|
-
return compare(v1, v2, optionsOrLoose) < 0;
|
|
693
|
-
}
|
|
694
|
-
exports.lt = lt;
|
|
695
|
-
function eq(v1, v2, optionsOrLoose) {
|
|
696
|
-
return compare(v1, v2, optionsOrLoose) === 0;
|
|
697
|
-
}
|
|
698
|
-
exports.eq = eq;
|
|
699
|
-
function neq(v1, v2, optionsOrLoose) {
|
|
700
|
-
return compare(v1, v2, optionsOrLoose) !== 0;
|
|
701
|
-
}
|
|
702
|
-
exports.neq = neq;
|
|
703
|
-
function gte(v1, v2, optionsOrLoose) {
|
|
704
|
-
return compare(v1, v2, optionsOrLoose) >= 0;
|
|
705
|
-
}
|
|
706
|
-
exports.gte = gte;
|
|
707
|
-
function lte(v1, v2, optionsOrLoose) {
|
|
708
|
-
return compare(v1, v2, optionsOrLoose) <= 0;
|
|
709
|
-
}
|
|
710
|
-
exports.lte = lte;
|
|
711
|
-
function cmp(v1, operator, v2, optionsOrLoose) {
|
|
712
|
-
switch (operator) {
|
|
713
|
-
case "===":
|
|
714
|
-
if (typeof v1 === "object")
|
|
715
|
-
v1 = v1.version;
|
|
716
|
-
if (typeof v2 === "object")
|
|
717
|
-
v2 = v2.version;
|
|
718
|
-
return v1 === v2;
|
|
719
|
-
case "!==":
|
|
720
|
-
if (typeof v1 === "object")
|
|
721
|
-
v1 = v1.version;
|
|
722
|
-
if (typeof v2 === "object")
|
|
723
|
-
v2 = v2.version;
|
|
724
|
-
return v1 !== v2;
|
|
725
|
-
case "":
|
|
726
|
-
case "=":
|
|
727
|
-
case "==":
|
|
728
|
-
return eq(v1, v2, optionsOrLoose);
|
|
729
|
-
case "!=":
|
|
730
|
-
return neq(v1, v2, optionsOrLoose);
|
|
731
|
-
case ">":
|
|
732
|
-
return gt(v1, v2, optionsOrLoose);
|
|
733
|
-
case ">=":
|
|
734
|
-
return gte(v1, v2, optionsOrLoose);
|
|
735
|
-
case "<":
|
|
736
|
-
return lt(v1, v2, optionsOrLoose);
|
|
737
|
-
case "<=":
|
|
738
|
-
return lte(v1, v2, optionsOrLoose);
|
|
739
|
-
default:
|
|
740
|
-
throw new TypeError("Invalid operator: " + operator);
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
exports.cmp = cmp;
|
|
744
|
-
const ANY = {};
|
|
745
|
-
class Comparator {
|
|
746
|
-
constructor(comp, optionsOrLoose) {
|
|
747
|
-
Object.defineProperty(this, "semver", {
|
|
748
|
-
enumerable: true,
|
|
749
|
-
configurable: true,
|
|
750
|
-
writable: true,
|
|
751
|
-
value: void 0
|
|
752
|
-
});
|
|
753
|
-
Object.defineProperty(this, "operator", {
|
|
754
|
-
enumerable: true,
|
|
755
|
-
configurable: true,
|
|
756
|
-
writable: true,
|
|
757
|
-
value: void 0
|
|
758
|
-
});
|
|
759
|
-
Object.defineProperty(this, "value", {
|
|
760
|
-
enumerable: true,
|
|
761
|
-
configurable: true,
|
|
762
|
-
writable: true,
|
|
763
|
-
value: void 0
|
|
764
|
-
});
|
|
765
|
-
Object.defineProperty(this, "loose", {
|
|
766
|
-
enumerable: true,
|
|
767
|
-
configurable: true,
|
|
768
|
-
writable: true,
|
|
769
|
-
value: void 0
|
|
770
|
-
});
|
|
771
|
-
Object.defineProperty(this, "options", {
|
|
772
|
-
enumerable: true,
|
|
773
|
-
configurable: true,
|
|
774
|
-
writable: true,
|
|
775
|
-
value: void 0
|
|
776
|
-
});
|
|
777
|
-
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
|
|
778
|
-
optionsOrLoose = {
|
|
779
|
-
loose: !!optionsOrLoose,
|
|
780
|
-
includePrerelease: false,
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
if (comp instanceof Comparator) {
|
|
784
|
-
if (comp.loose === !!optionsOrLoose.loose) {
|
|
785
|
-
return comp;
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
comp = comp.value;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
if (!(this instanceof Comparator)) {
|
|
792
|
-
return new Comparator(comp, optionsOrLoose);
|
|
793
|
-
}
|
|
794
|
-
this.options = optionsOrLoose;
|
|
795
|
-
this.loose = !!optionsOrLoose.loose;
|
|
796
|
-
this.parse(comp);
|
|
797
|
-
if (this.semver === ANY) {
|
|
798
|
-
this.value = "";
|
|
799
|
-
}
|
|
800
|
-
else {
|
|
801
|
-
this.value = this.operator + this.semver.version;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
parse(comp) {
|
|
805
|
-
const r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
|
|
806
|
-
const m = comp.match(r);
|
|
807
|
-
if (!m) {
|
|
808
|
-
throw new TypeError("Invalid comparator: " + comp);
|
|
809
|
-
}
|
|
810
|
-
const m1 = m[1];
|
|
811
|
-
this.operator = m1 !== undefined ? m1 : "";
|
|
812
|
-
if (this.operator === "=") {
|
|
813
|
-
this.operator = "";
|
|
814
|
-
}
|
|
815
|
-
// if it literally is just '>' or '' then allow anything.
|
|
816
|
-
if (!m[2]) {
|
|
817
|
-
this.semver = ANY;
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
this.semver = new SemVer(m[2], this.options.loose);
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
test(version) {
|
|
824
|
-
if (this.semver === ANY || version === ANY) {
|
|
825
|
-
return true;
|
|
826
|
-
}
|
|
827
|
-
if (typeof version === "string") {
|
|
828
|
-
version = new SemVer(version, this.options);
|
|
829
|
-
}
|
|
830
|
-
return cmp(version, this.operator, this.semver, this.options);
|
|
831
|
-
}
|
|
832
|
-
intersects(comp, optionsOrLoose) {
|
|
833
|
-
if (!(comp instanceof Comparator)) {
|
|
834
|
-
throw new TypeError("a Comparator is required");
|
|
835
|
-
}
|
|
836
|
-
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
|
|
837
|
-
optionsOrLoose = {
|
|
838
|
-
loose: !!optionsOrLoose,
|
|
839
|
-
includePrerelease: false,
|
|
840
|
-
};
|
|
841
|
-
}
|
|
842
|
-
let rangeTmp;
|
|
843
|
-
if (this.operator === "") {
|
|
844
|
-
if (this.value === "") {
|
|
845
|
-
return true;
|
|
846
|
-
}
|
|
847
|
-
rangeTmp = new Range(comp.value, optionsOrLoose);
|
|
848
|
-
return satisfies(this.value, rangeTmp, optionsOrLoose);
|
|
849
|
-
}
|
|
850
|
-
else if (comp.operator === "") {
|
|
851
|
-
if (comp.value === "") {
|
|
852
|
-
return true;
|
|
853
|
-
}
|
|
854
|
-
rangeTmp = new Range(this.value, optionsOrLoose);
|
|
855
|
-
return satisfies(comp.semver, rangeTmp, optionsOrLoose);
|
|
856
|
-
}
|
|
857
|
-
const sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") &&
|
|
858
|
-
(comp.operator === ">=" || comp.operator === ">");
|
|
859
|
-
const sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") &&
|
|
860
|
-
(comp.operator === "<=" || comp.operator === "<");
|
|
861
|
-
const sameSemVer = this.semver.version === comp.semver.version;
|
|
862
|
-
const differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") &&
|
|
863
|
-
(comp.operator === ">=" || comp.operator === "<=");
|
|
864
|
-
const oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, optionsOrLoose) &&
|
|
865
|
-
(this.operator === ">=" || this.operator === ">") &&
|
|
866
|
-
(comp.operator === "<=" || comp.operator === "<");
|
|
867
|
-
const oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, optionsOrLoose) &&
|
|
868
|
-
(this.operator === "<=" || this.operator === "<") &&
|
|
869
|
-
(comp.operator === ">=" || comp.operator === ">");
|
|
870
|
-
return (sameDirectionIncreasing ||
|
|
871
|
-
sameDirectionDecreasing ||
|
|
872
|
-
(sameSemVer && differentDirectionsInclusive) ||
|
|
873
|
-
oppositeDirectionsLessThan ||
|
|
874
|
-
oppositeDirectionsGreaterThan);
|
|
875
|
-
}
|
|
876
|
-
toString() {
|
|
877
|
-
return this.value;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
exports.Comparator = Comparator;
|
|
881
|
-
class Range {
|
|
882
|
-
constructor(range, optionsOrLoose) {
|
|
883
|
-
Object.defineProperty(this, "range", {
|
|
884
|
-
enumerable: true,
|
|
885
|
-
configurable: true,
|
|
886
|
-
writable: true,
|
|
887
|
-
value: void 0
|
|
888
|
-
});
|
|
889
|
-
Object.defineProperty(this, "raw", {
|
|
890
|
-
enumerable: true,
|
|
891
|
-
configurable: true,
|
|
892
|
-
writable: true,
|
|
893
|
-
value: void 0
|
|
894
|
-
});
|
|
895
|
-
Object.defineProperty(this, "loose", {
|
|
896
|
-
enumerable: true,
|
|
897
|
-
configurable: true,
|
|
898
|
-
writable: true,
|
|
899
|
-
value: void 0
|
|
900
|
-
});
|
|
901
|
-
Object.defineProperty(this, "options", {
|
|
902
|
-
enumerable: true,
|
|
903
|
-
configurable: true,
|
|
904
|
-
writable: true,
|
|
905
|
-
value: void 0
|
|
906
|
-
});
|
|
907
|
-
Object.defineProperty(this, "includePrerelease", {
|
|
908
|
-
enumerable: true,
|
|
909
|
-
configurable: true,
|
|
910
|
-
writable: true,
|
|
911
|
-
value: void 0
|
|
912
|
-
});
|
|
913
|
-
Object.defineProperty(this, "set", {
|
|
914
|
-
enumerable: true,
|
|
915
|
-
configurable: true,
|
|
916
|
-
writable: true,
|
|
917
|
-
value: void 0
|
|
918
|
-
});
|
|
919
|
-
if (!optionsOrLoose || typeof optionsOrLoose !== "object") {
|
|
920
|
-
optionsOrLoose = {
|
|
921
|
-
loose: !!optionsOrLoose,
|
|
922
|
-
includePrerelease: false,
|
|
923
|
-
};
|
|
924
|
-
}
|
|
925
|
-
if (range instanceof Range) {
|
|
926
|
-
if (range.loose === !!optionsOrLoose.loose &&
|
|
927
|
-
range.includePrerelease === !!optionsOrLoose.includePrerelease) {
|
|
928
|
-
return range;
|
|
929
|
-
}
|
|
930
|
-
else {
|
|
931
|
-
return new Range(range.raw, optionsOrLoose);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
if (range instanceof Comparator) {
|
|
935
|
-
return new Range(range.value, optionsOrLoose);
|
|
936
|
-
}
|
|
937
|
-
if (!(this instanceof Range)) {
|
|
938
|
-
return new Range(range, optionsOrLoose);
|
|
939
|
-
}
|
|
940
|
-
this.options = optionsOrLoose;
|
|
941
|
-
this.loose = !!optionsOrLoose.loose;
|
|
942
|
-
this.includePrerelease = !!optionsOrLoose.includePrerelease;
|
|
943
|
-
// First, split based on boolean or ||
|
|
944
|
-
this.raw = range;
|
|
945
|
-
this.set = range
|
|
946
|
-
.split(/\s*\|\|\s*/)
|
|
947
|
-
.map((range) => this.parseRange(range.trim()))
|
|
948
|
-
.filter((c) => {
|
|
949
|
-
// throw out any that are not relevant for whatever reason
|
|
950
|
-
return c.length;
|
|
951
|
-
});
|
|
952
|
-
if (!this.set.length) {
|
|
953
|
-
throw new TypeError("Invalid SemVer Range: " + range);
|
|
954
|
-
}
|
|
955
|
-
this.format();
|
|
956
|
-
}
|
|
957
|
-
format() {
|
|
958
|
-
this.range = this.set
|
|
959
|
-
.map((comps) => comps.join(" ").trim())
|
|
960
|
-
.join("||")
|
|
961
|
-
.trim();
|
|
962
|
-
return this.range;
|
|
963
|
-
}
|
|
964
|
-
parseRange(range) {
|
|
965
|
-
const loose = this.options.loose;
|
|
966
|
-
range = range.trim();
|
|
967
|
-
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
968
|
-
const hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE];
|
|
969
|
-
range = range.replace(hr, hyphenReplace);
|
|
970
|
-
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
971
|
-
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
|
|
972
|
-
// `~ 1.2.3` => `~1.2.3`
|
|
973
|
-
range = range.replace(re[TILDETRIM], tildeTrimReplace);
|
|
974
|
-
// `^ 1.2.3` => `^1.2.3`
|
|
975
|
-
range = range.replace(re[CARETTRIM], caretTrimReplace);
|
|
976
|
-
// normalize spaces
|
|
977
|
-
range = range.split(/\s+/).join(" ");
|
|
978
|
-
// At this point, the range is completely trimmed and
|
|
979
|
-
// ready to be split into comparators.
|
|
980
|
-
const compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR];
|
|
981
|
-
let set = range
|
|
982
|
-
.split(" ")
|
|
983
|
-
.map((comp) => parseComparator(comp, this.options))
|
|
984
|
-
.join(" ")
|
|
985
|
-
.split(/\s+/);
|
|
986
|
-
if (this.options.loose) {
|
|
987
|
-
// in loose mode, throw out any that are not valid comparators
|
|
988
|
-
set = set.filter((comp) => {
|
|
989
|
-
return !!comp.match(compRe);
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
return set.map((comp) => new Comparator(comp, this.options));
|
|
993
|
-
}
|
|
994
|
-
test(version) {
|
|
995
|
-
if (typeof version === "string") {
|
|
996
|
-
version = new SemVer(version, this.options);
|
|
997
|
-
}
|
|
998
|
-
for (var i = 0; i < this.set.length; i++) {
|
|
999
|
-
if (testSet(this.set[i], version, this.options)) {
|
|
1000
|
-
return true;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
return false;
|
|
1004
|
-
}
|
|
1005
|
-
intersects(range, optionsOrLoose) {
|
|
1006
|
-
if (!(range instanceof Range)) {
|
|
1007
|
-
throw new TypeError("a Range is required");
|
|
1008
|
-
}
|
|
1009
|
-
return this.set.some((thisComparators) => {
|
|
1010
|
-
return (isSatisfiable(thisComparators, optionsOrLoose) &&
|
|
1011
|
-
range.set.some((rangeComparators) => {
|
|
1012
|
-
return (isSatisfiable(rangeComparators, optionsOrLoose) &&
|
|
1013
|
-
thisComparators.every((thisComparator) => {
|
|
1014
|
-
return rangeComparators.every((rangeComparator) => {
|
|
1015
|
-
return thisComparator.intersects(rangeComparator, optionsOrLoose);
|
|
1016
|
-
});
|
|
1017
|
-
}));
|
|
1018
|
-
}));
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
toString() {
|
|
1022
|
-
return this.range;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
exports.Range = Range;
|
|
1026
|
-
function testSet(set, version, options) {
|
|
1027
|
-
for (let i = 0; i < set.length; i++) {
|
|
1028
|
-
if (!set[i].test(version)) {
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
if (version.prerelease.length && !options.includePrerelease) {
|
|
1033
|
-
// Find the set of versions that are allowed to have prereleases
|
|
1034
|
-
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
1035
|
-
// That should allow `1.2.3-pr.2` to pass.
|
|
1036
|
-
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
1037
|
-
// even though it's within the range set by the comparators.
|
|
1038
|
-
for (let i = 0; i < set.length; i++) {
|
|
1039
|
-
if (set[i].semver === ANY) {
|
|
1040
|
-
continue;
|
|
1041
|
-
}
|
|
1042
|
-
if (set[i].semver.prerelease.length > 0) {
|
|
1043
|
-
const allowed = set[i].semver;
|
|
1044
|
-
if (allowed.major === version.major &&
|
|
1045
|
-
allowed.minor === version.minor &&
|
|
1046
|
-
allowed.patch === version.patch) {
|
|
1047
|
-
return true;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
// Version has a -pre, but it's not one of the ones we like.
|
|
1052
|
-
return false;
|
|
1053
|
-
}
|
|
1054
|
-
return true;
|
|
1055
|
-
}
|
|
1056
|
-
// take a set of comparators and determine whether there
|
|
1057
|
-
// exists a version which can satisfy it
|
|
1058
|
-
function isSatisfiable(comparators, options) {
|
|
1059
|
-
let result = true;
|
|
1060
|
-
const remainingComparators = comparators.slice();
|
|
1061
|
-
let testComparator = remainingComparators.pop();
|
|
1062
|
-
while (result && remainingComparators.length) {
|
|
1063
|
-
result = remainingComparators.every((otherComparator) => {
|
|
1064
|
-
return testComparator?.intersects(otherComparator, options);
|
|
1065
|
-
});
|
|
1066
|
-
testComparator = remainingComparators.pop();
|
|
1067
|
-
}
|
|
1068
|
-
return result;
|
|
1069
|
-
}
|
|
1070
|
-
// Mostly just for testing and legacy API reasons
|
|
1071
|
-
function toComparators(range, optionsOrLoose) {
|
|
1072
|
-
return new Range(range, optionsOrLoose).set.map((comp) => {
|
|
1073
|
-
return comp
|
|
1074
|
-
.map((c) => c.value)
|
|
1075
|
-
.join(" ")
|
|
1076
|
-
.trim()
|
|
1077
|
-
.split(" ");
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
exports.toComparators = toComparators;
|
|
1081
|
-
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
1082
|
-
// already replaced the hyphen ranges
|
|
1083
|
-
// turn into a set of JUST comparators.
|
|
1084
|
-
function parseComparator(comp, options) {
|
|
1085
|
-
comp = replaceCarets(comp, options);
|
|
1086
|
-
comp = replaceTildes(comp, options);
|
|
1087
|
-
comp = replaceXRanges(comp, options);
|
|
1088
|
-
comp = replaceStars(comp, options);
|
|
1089
|
-
return comp;
|
|
1090
|
-
}
|
|
1091
|
-
function isX(id) {
|
|
1092
|
-
return !id || id.toLowerCase() === "x" || id === "*";
|
|
1093
|
-
}
|
|
1094
|
-
// ~, ~> --> * (any, kinda silly)
|
|
1095
|
-
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
|
1096
|
-
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
|
1097
|
-
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
|
1098
|
-
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
|
1099
|
-
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
|
1100
|
-
function replaceTildes(comp, options) {
|
|
1101
|
-
return comp
|
|
1102
|
-
.trim()
|
|
1103
|
-
.split(/\s+/)
|
|
1104
|
-
.map((comp) => replaceTilde(comp, options))
|
|
1105
|
-
.join(" ");
|
|
1106
|
-
}
|
|
1107
|
-
function replaceTilde(comp, options) {
|
|
1108
|
-
const r = options.loose ? re[TILDELOOSE] : re[TILDE];
|
|
1109
|
-
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1110
|
-
let ret;
|
|
1111
|
-
if (isX(M)) {
|
|
1112
|
-
ret = "";
|
|
1113
|
-
}
|
|
1114
|
-
else if (isX(m)) {
|
|
1115
|
-
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
|
|
1116
|
-
}
|
|
1117
|
-
else if (isX(p)) {
|
|
1118
|
-
// ~1.2 == >=1.2.0 <1.3.0
|
|
1119
|
-
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
1120
|
-
}
|
|
1121
|
-
else if (pr) {
|
|
1122
|
-
ret = ">=" +
|
|
1123
|
-
M +
|
|
1124
|
-
"." +
|
|
1125
|
-
m +
|
|
1126
|
-
"." +
|
|
1127
|
-
p +
|
|
1128
|
-
"-" +
|
|
1129
|
-
pr +
|
|
1130
|
-
" <" +
|
|
1131
|
-
M +
|
|
1132
|
-
"." +
|
|
1133
|
-
(+m + 1) +
|
|
1134
|
-
".0";
|
|
1135
|
-
}
|
|
1136
|
-
else {
|
|
1137
|
-
// ~1.2.3 == >=1.2.3 <1.3.0
|
|
1138
|
-
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
|
|
1139
|
-
}
|
|
1140
|
-
return ret;
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
// ^ --> * (any, kinda silly)
|
|
1144
|
-
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
|
1145
|
-
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
|
1146
|
-
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
|
1147
|
-
// ^1.2.3 --> >=1.2.3 <2.0.0
|
|
1148
|
-
// ^1.2.0 --> >=1.2.0 <2.0.0
|
|
1149
|
-
function replaceCarets(comp, options) {
|
|
1150
|
-
return comp
|
|
1151
|
-
.trim()
|
|
1152
|
-
.split(/\s+/)
|
|
1153
|
-
.map((comp) => replaceCaret(comp, options))
|
|
1154
|
-
.join(" ");
|
|
1155
|
-
}
|
|
1156
|
-
function replaceCaret(comp, options) {
|
|
1157
|
-
const r = options.loose ? re[CARETLOOSE] : re[CARET];
|
|
1158
|
-
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1159
|
-
let ret;
|
|
1160
|
-
if (isX(M)) {
|
|
1161
|
-
ret = "";
|
|
1162
|
-
}
|
|
1163
|
-
else if (isX(m)) {
|
|
1164
|
-
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
|
|
1165
|
-
}
|
|
1166
|
-
else if (isX(p)) {
|
|
1167
|
-
if (M === "0") {
|
|
1168
|
-
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
1169
|
-
}
|
|
1170
|
-
else {
|
|
1171
|
-
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
else if (pr) {
|
|
1175
|
-
if (M === "0") {
|
|
1176
|
-
if (m === "0") {
|
|
1177
|
-
ret = ">=" +
|
|
1178
|
-
M +
|
|
1179
|
-
"." +
|
|
1180
|
-
m +
|
|
1181
|
-
"." +
|
|
1182
|
-
p +
|
|
1183
|
-
"-" +
|
|
1184
|
-
pr +
|
|
1185
|
-
" <" +
|
|
1186
|
-
M +
|
|
1187
|
-
"." +
|
|
1188
|
-
m +
|
|
1189
|
-
"." +
|
|
1190
|
-
(+p + 1);
|
|
1191
|
-
}
|
|
1192
|
-
else {
|
|
1193
|
-
ret = ">=" +
|
|
1194
|
-
M +
|
|
1195
|
-
"." +
|
|
1196
|
-
m +
|
|
1197
|
-
"." +
|
|
1198
|
-
p +
|
|
1199
|
-
"-" +
|
|
1200
|
-
pr +
|
|
1201
|
-
" <" +
|
|
1202
|
-
M +
|
|
1203
|
-
"." +
|
|
1204
|
-
(+m + 1) +
|
|
1205
|
-
".0";
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
else {
|
|
1209
|
-
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) +
|
|
1210
|
-
".0.0";
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
else {
|
|
1214
|
-
if (M === "0") {
|
|
1215
|
-
if (m === "0") {
|
|
1216
|
-
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." +
|
|
1217
|
-
(+p + 1);
|
|
1218
|
-
}
|
|
1219
|
-
else {
|
|
1220
|
-
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
else {
|
|
1224
|
-
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
return ret;
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
function replaceXRanges(comp, options) {
|
|
1231
|
-
return comp
|
|
1232
|
-
.split(/\s+/)
|
|
1233
|
-
.map((comp) => replaceXRange(comp, options))
|
|
1234
|
-
.join(" ");
|
|
1235
|
-
}
|
|
1236
|
-
function replaceXRange(comp, options) {
|
|
1237
|
-
comp = comp.trim();
|
|
1238
|
-
const r = options.loose ? re[XRANGELOOSE] : re[XRANGE];
|
|
1239
|
-
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1240
|
-
const xM = isX(M);
|
|
1241
|
-
const xm = xM || isX(m);
|
|
1242
|
-
const xp = xm || isX(p);
|
|
1243
|
-
const anyX = xp;
|
|
1244
|
-
if (gtlt === "=" && anyX) {
|
|
1245
|
-
gtlt = "";
|
|
1246
|
-
}
|
|
1247
|
-
if (xM) {
|
|
1248
|
-
if (gtlt === ">" || gtlt === "<") {
|
|
1249
|
-
// nothing is allowed
|
|
1250
|
-
ret = "<0.0.0";
|
|
1251
|
-
}
|
|
1252
|
-
else {
|
|
1253
|
-
// nothing is forbidden
|
|
1254
|
-
ret = "*";
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
else if (gtlt && anyX) {
|
|
1258
|
-
// we know patch is an x, because we have any x at all.
|
|
1259
|
-
// replace X with 0
|
|
1260
|
-
if (xm) {
|
|
1261
|
-
m = 0;
|
|
1262
|
-
}
|
|
1263
|
-
p = 0;
|
|
1264
|
-
if (gtlt === ">") {
|
|
1265
|
-
// >1 => >=2.0.0
|
|
1266
|
-
// >1.2 => >=1.3.0
|
|
1267
|
-
// >1.2.3 => >= 1.2.4
|
|
1268
|
-
gtlt = ">=";
|
|
1269
|
-
if (xm) {
|
|
1270
|
-
M = +M + 1;
|
|
1271
|
-
m = 0;
|
|
1272
|
-
p = 0;
|
|
1273
|
-
}
|
|
1274
|
-
else {
|
|
1275
|
-
m = +m + 1;
|
|
1276
|
-
p = 0;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
else if (gtlt === "<=") {
|
|
1280
|
-
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
1281
|
-
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
1282
|
-
gtlt = "<";
|
|
1283
|
-
if (xm) {
|
|
1284
|
-
M = +M + 1;
|
|
1285
|
-
}
|
|
1286
|
-
else {
|
|
1287
|
-
m = +m + 1;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
ret = gtlt + M + "." + m + "." + p;
|
|
1291
|
-
}
|
|
1292
|
-
else if (xm) {
|
|
1293
|
-
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
|
|
1294
|
-
}
|
|
1295
|
-
else if (xp) {
|
|
1296
|
-
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
1297
|
-
}
|
|
1298
|
-
return ret;
|
|
1299
|
-
});
|
|
1300
|
-
}
|
|
1301
|
-
// Because * is AND-ed with everything else in the comparator,
|
|
1302
|
-
// and '' means "any version", just remove the *s entirely.
|
|
1303
|
-
function replaceStars(comp, options) {
|
|
1304
|
-
// Looseness is ignored here. star is always as loose as it gets!
|
|
1305
|
-
return comp.trim().replace(re[STAR], "");
|
|
1306
|
-
}
|
|
1307
|
-
// This function is passed to string.replace(re[HYPHENRANGE])
|
|
1308
|
-
// M, m, patch, prerelease, build
|
|
1309
|
-
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
1310
|
-
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
|
1311
|
-
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
|
1312
|
-
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
|
|
1313
|
-
if (isX(fM)) {
|
|
1314
|
-
from = "";
|
|
1315
|
-
}
|
|
1316
|
-
else if (isX(fm)) {
|
|
1317
|
-
from = ">=" + fM + ".0.0";
|
|
1318
|
-
}
|
|
1319
|
-
else if (isX(fp)) {
|
|
1320
|
-
from = ">=" + fM + "." + fm + ".0";
|
|
1321
|
-
}
|
|
1322
|
-
else {
|
|
1323
|
-
from = ">=" + from;
|
|
1324
|
-
}
|
|
1325
|
-
if (isX(tM)) {
|
|
1326
|
-
to = "";
|
|
1327
|
-
}
|
|
1328
|
-
else if (isX(tm)) {
|
|
1329
|
-
to = "<" + (+tM + 1) + ".0.0";
|
|
1330
|
-
}
|
|
1331
|
-
else if (isX(tp)) {
|
|
1332
|
-
to = "<" + tM + "." + (+tm + 1) + ".0";
|
|
1333
|
-
}
|
|
1334
|
-
else if (tpr) {
|
|
1335
|
-
to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
|
|
1336
|
-
}
|
|
1337
|
-
else {
|
|
1338
|
-
to = "<=" + to;
|
|
1339
|
-
}
|
|
1340
|
-
return (from + " " + to).trim();
|
|
1341
|
-
}
|
|
1342
|
-
function satisfies(version, range, optionsOrLoose) {
|
|
1343
|
-
try {
|
|
1344
|
-
range = new Range(range, optionsOrLoose);
|
|
1345
|
-
}
|
|
1346
|
-
catch (er) {
|
|
1347
|
-
return false;
|
|
1348
|
-
}
|
|
1349
|
-
return range.test(version);
|
|
1350
|
-
}
|
|
1351
|
-
exports.satisfies = satisfies;
|
|
1352
|
-
function maxSatisfying(versions, range, optionsOrLoose) {
|
|
1353
|
-
//todo
|
|
1354
|
-
var max = null;
|
|
1355
|
-
var maxSV = null;
|
|
1356
|
-
try {
|
|
1357
|
-
var rangeObj = new Range(range, optionsOrLoose);
|
|
1358
|
-
}
|
|
1359
|
-
catch (er) {
|
|
1360
|
-
return null;
|
|
1361
|
-
}
|
|
1362
|
-
versions.forEach((v) => {
|
|
1363
|
-
if (rangeObj.test(v)) {
|
|
1364
|
-
// satisfies(v, range, options)
|
|
1365
|
-
if (!max || (maxSV && maxSV.compare(v) === -1)) {
|
|
1366
|
-
// compare(max, v, true)
|
|
1367
|
-
max = v;
|
|
1368
|
-
maxSV = new SemVer(max, optionsOrLoose);
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
});
|
|
1372
|
-
return max;
|
|
1373
|
-
}
|
|
1374
|
-
exports.maxSatisfying = maxSatisfying;
|
|
1375
|
-
function minSatisfying(versions, range, optionsOrLoose) {
|
|
1376
|
-
//todo
|
|
1377
|
-
var min = null;
|
|
1378
|
-
var minSV = null;
|
|
1379
|
-
try {
|
|
1380
|
-
var rangeObj = new Range(range, optionsOrLoose);
|
|
1381
|
-
}
|
|
1382
|
-
catch (er) {
|
|
1383
|
-
return null;
|
|
1384
|
-
}
|
|
1385
|
-
versions.forEach((v) => {
|
|
1386
|
-
if (rangeObj.test(v)) {
|
|
1387
|
-
// satisfies(v, range, options)
|
|
1388
|
-
if (!min || minSV.compare(v) === 1) {
|
|
1389
|
-
// compare(min, v, true)
|
|
1390
|
-
min = v;
|
|
1391
|
-
minSV = new SemVer(min, optionsOrLoose);
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
});
|
|
1395
|
-
return min;
|
|
1396
|
-
}
|
|
1397
|
-
exports.minSatisfying = minSatisfying;
|
|
1398
|
-
function minVersion(range, optionsOrLoose) {
|
|
1399
|
-
range = new Range(range, optionsOrLoose);
|
|
1400
|
-
var minver = new SemVer("0.0.0");
|
|
1401
|
-
if (range.test(minver)) {
|
|
1402
|
-
return minver;
|
|
1403
|
-
}
|
|
1404
|
-
minver = new SemVer("0.0.0-0");
|
|
1405
|
-
if (range.test(minver)) {
|
|
1406
|
-
return minver;
|
|
1407
|
-
}
|
|
1408
|
-
minver = null;
|
|
1409
|
-
for (var i = 0; i < range.set.length; ++i) {
|
|
1410
|
-
var comparators = range.set[i];
|
|
1411
|
-
comparators.forEach((comparator) => {
|
|
1412
|
-
// Clone to avoid manipulating the comparator's semver object.
|
|
1413
|
-
var compver = new SemVer(comparator.semver.version);
|
|
1414
|
-
switch (comparator.operator) {
|
|
1415
|
-
case ">":
|
|
1416
|
-
if (compver.prerelease.length === 0) {
|
|
1417
|
-
compver.patch++;
|
|
1418
|
-
}
|
|
1419
|
-
else {
|
|
1420
|
-
compver.prerelease.push(0);
|
|
1421
|
-
}
|
|
1422
|
-
compver.raw = compver.format();
|
|
1423
|
-
/* fallthrough */
|
|
1424
|
-
case "":
|
|
1425
|
-
case ">=":
|
|
1426
|
-
if (!minver || gt(minver, compver)) {
|
|
1427
|
-
minver = compver;
|
|
1428
|
-
}
|
|
1429
|
-
break;
|
|
1430
|
-
case "<":
|
|
1431
|
-
case "<=":
|
|
1432
|
-
/* Ignore maximum versions */
|
|
1433
|
-
break;
|
|
1434
|
-
/* istanbul ignore next */
|
|
1435
|
-
default:
|
|
1436
|
-
throw new Error("Unexpected operation: " + comparator.operator);
|
|
1437
|
-
}
|
|
1438
|
-
});
|
|
1439
|
-
}
|
|
1440
|
-
if (minver && range.test(minver)) {
|
|
1441
|
-
return minver;
|
|
1442
|
-
}
|
|
1443
|
-
return null;
|
|
1444
|
-
}
|
|
1445
|
-
exports.minVersion = minVersion;
|
|
1446
|
-
function validRange(range, optionsOrLoose) {
|
|
1447
|
-
try {
|
|
1448
|
-
if (range === null)
|
|
1449
|
-
return null;
|
|
1450
|
-
// Return '*' instead of '' so that truthiness works.
|
|
1451
|
-
// This will throw if it's invalid anyway
|
|
1452
|
-
return new Range(range, optionsOrLoose).range || "*";
|
|
1453
|
-
}
|
|
1454
|
-
catch (er) {
|
|
1455
|
-
return null;
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
exports.validRange = validRange;
|
|
1459
|
-
/**
|
|
1460
|
-
* Return true if version is less than all the versions possible in the range.
|
|
1461
|
-
*/
|
|
1462
|
-
function ltr(version, range, optionsOrLoose) {
|
|
1463
|
-
return outside(version, range, "<", optionsOrLoose);
|
|
1464
|
-
}
|
|
1465
|
-
exports.ltr = ltr;
|
|
1466
|
-
/**
|
|
1467
|
-
* Return true if version is greater than all the versions possible in the range.
|
|
1468
|
-
*/
|
|
1469
|
-
function gtr(version, range, optionsOrLoose) {
|
|
1470
|
-
return outside(version, range, ">", optionsOrLoose);
|
|
1471
|
-
}
|
|
1472
|
-
exports.gtr = gtr;
|
|
1473
|
-
/**
|
|
1474
|
-
* Return true if the version is outside the bounds of the range in either the high or low direction.
|
|
1475
|
-
* The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
|
1476
|
-
*/
|
|
1477
|
-
function outside(version, range, hilo, optionsOrLoose) {
|
|
1478
|
-
version = new SemVer(version, optionsOrLoose);
|
|
1479
|
-
range = new Range(range, optionsOrLoose);
|
|
1480
|
-
let gtfn;
|
|
1481
|
-
let ltefn;
|
|
1482
|
-
let ltfn;
|
|
1483
|
-
let comp;
|
|
1484
|
-
let ecomp;
|
|
1485
|
-
switch (hilo) {
|
|
1486
|
-
case ">":
|
|
1487
|
-
gtfn = gt;
|
|
1488
|
-
ltefn = lte;
|
|
1489
|
-
ltfn = lt;
|
|
1490
|
-
comp = ">";
|
|
1491
|
-
ecomp = ">=";
|
|
1492
|
-
break;
|
|
1493
|
-
case "<":
|
|
1494
|
-
gtfn = lt;
|
|
1495
|
-
ltefn = gte;
|
|
1496
|
-
ltfn = gt;
|
|
1497
|
-
comp = "<";
|
|
1498
|
-
ecomp = "<=";
|
|
1499
|
-
break;
|
|
1500
|
-
default:
|
|
1501
|
-
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
1502
|
-
}
|
|
1503
|
-
// If it satisifes the range it is not outside
|
|
1504
|
-
if (satisfies(version, range, optionsOrLoose)) {
|
|
1505
|
-
return false;
|
|
1506
|
-
}
|
|
1507
|
-
// From now on, variable terms are as if we're in "gtr" mode.
|
|
1508
|
-
// but note that everything is flipped for the "ltr" function.
|
|
1509
|
-
for (let i = 0; i < range.set.length; ++i) {
|
|
1510
|
-
const comparators = range.set[i];
|
|
1511
|
-
let high = null;
|
|
1512
|
-
let low = null;
|
|
1513
|
-
for (let comparator of comparators) {
|
|
1514
|
-
if (comparator.semver === ANY) {
|
|
1515
|
-
comparator = new Comparator(">=0.0.0");
|
|
1516
|
-
}
|
|
1517
|
-
high = high || comparator;
|
|
1518
|
-
low = low || comparator;
|
|
1519
|
-
if (gtfn(comparator.semver, high.semver, optionsOrLoose)) {
|
|
1520
|
-
high = comparator;
|
|
1521
|
-
}
|
|
1522
|
-
else if (ltfn(comparator.semver, low.semver, optionsOrLoose)) {
|
|
1523
|
-
low = comparator;
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
if (high === null || low === null)
|
|
1527
|
-
return true;
|
|
1528
|
-
// If the edge version comparator has a operator then our version
|
|
1529
|
-
// isn't outside it
|
|
1530
|
-
if (high.operator === comp || high.operator === ecomp) {
|
|
1531
|
-
return false;
|
|
1532
|
-
}
|
|
1533
|
-
// If the lowest version comparator has an operator and our version
|
|
1534
|
-
// is less than it then it isn't higher than the range
|
|
1535
|
-
if ((!low.operator || low.operator === comp) &&
|
|
1536
|
-
ltefn(version, low.semver)) {
|
|
1537
|
-
return false;
|
|
1538
|
-
}
|
|
1539
|
-
else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
1540
|
-
return false;
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
return true;
|
|
1544
|
-
}
|
|
1545
|
-
exports.outside = outside;
|
|
1546
|
-
function prerelease(version, optionsOrLoose) {
|
|
1547
|
-
var parsed = parse(version, optionsOrLoose);
|
|
1548
|
-
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
1549
|
-
}
|
|
1550
|
-
exports.prerelease = prerelease;
|
|
1551
|
-
/**
|
|
1552
|
-
* Return true if any of the ranges comparators intersect
|
|
1553
|
-
*/
|
|
1554
|
-
function intersects(range1, range2, optionsOrLoose) {
|
|
1555
|
-
range1 = new Range(range1, optionsOrLoose);
|
|
1556
|
-
range2 = new Range(range2, optionsOrLoose);
|
|
1557
|
-
return range1.intersects(range2);
|
|
1558
|
-
}
|
|
1559
|
-
exports.intersects = intersects;
|
|
1560
|
-
/**
|
|
1561
|
-
* Coerces a string to semver if possible
|
|
1562
|
-
*/
|
|
1563
|
-
function coerce(version, optionsOrLoose) {
|
|
1564
|
-
if (version instanceof SemVer) {
|
|
1565
|
-
return version;
|
|
1566
|
-
}
|
|
1567
|
-
if (typeof version !== "string") {
|
|
1568
|
-
return null;
|
|
1569
|
-
}
|
|
1570
|
-
const match = version.match(re[COERCE]);
|
|
1571
|
-
if (match == null) {
|
|
1572
|
-
return null;
|
|
1573
|
-
}
|
|
1574
|
-
return parse(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0"), optionsOrLoose);
|
|
1575
|
-
}
|
|
1576
|
-
exports.coerce = coerce;
|
|
1577
|
-
exports.default = SemVer;
|
|
1578
|
-
});
|