keep-a-changelog 2.1.0 → 2.3.0
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 +23 -6
- package/esm/_dnt.test_shims.d.ts +5 -0
- package/esm/bin.js +11 -2
- package/esm/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
- package/esm/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
- package/esm/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
- package/esm/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +227 -334
- package/esm/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
- package/esm/deps/deno.land/std@0.189.0/_util/asserts.js +21 -0
- package/esm/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/_util/os.js +3 -2
- package/esm/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/flags/mod.js +146 -36
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_constants.js +1 -0
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_interface.d.ts +1 -1
- package/esm/deps/deno.land/std@0.189.0/path/_interface.js +3 -0
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_util.d.ts +3 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_util.js +47 -0
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/common.js +1 -1
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/glob.d.ts +10 -5
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/glob.js +1 -1
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/mod.d.ts +3 -1
- package/esm/deps/deno.land/std@0.189.0/path/mod.js +35 -0
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/posix.d.ts +15 -9
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/posix.js +58 -112
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/separator.js +1 -1
- package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/win32.d.ts +13 -9
- package/esm/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/win32.js +30 -87
- package/esm/src/Change.js +15 -15
- package/{types → esm}/src/Changelog.d.ts +1 -0
- package/esm/src/Changelog.js +9 -1
- package/{types → esm}/src/Release.d.ts +1 -0
- package/esm/src/Release.js +10 -0
- package/esm/src/deps.d.ts +1 -0
- package/esm/src/deps.js +1 -1
- package/esm/src/parser.js +19 -3
- package/esm/test/Change.test.d.ts +1 -0
- package/esm/test/changelog.custom.type.md +0 -1
- package/esm/test/changelog.expected.linted.md +208 -0
- package/esm/test/changelog.expected.md +3 -1
- package/esm/test/changelog.md +4 -0
- package/esm/test/deps.d.ts +1 -0
- package/esm/test/empty.expected.md +0 -1
- package/esm/test/fixture/CustomRelease.d.ts +8 -0
- package/esm/test/parser.test.d.ts +1 -0
- package/esm/test/test.d.ts +1 -0
- package/package.json +6 -8
- package/script/_dnt.polyfills.d.ts +11 -0
- package/script/_dnt.shims.d.ts +5 -0
- package/script/_dnt.test_shims.d.ts +5 -0
- package/script/bin.d.ts +2 -0
- package/script/bin.js +11 -2
- package/script/deps/deno.land/std@0.133.0/fmt/colors.d.ts +270 -0
- package/script/deps/deno.land/std@0.133.0/testing/_diff.d.ts +23 -0
- package/script/deps/deno.land/std@0.133.0/testing/asserts.d.ts +167 -0
- package/script/deps/deno.land/std@0.173.0/semver/mod.d.ts +398 -0
- package/script/deps/deno.land/{x/semver@v1.4.0 → std@0.173.0/semver}/mod.js +232 -342
- package/script/deps/deno.land/std@0.189.0/_util/asserts.d.ts +10 -0
- package/script/deps/deno.land/std@0.189.0/_util/asserts.js +27 -0
- package/script/deps/deno.land/std@0.189.0/_util/os.d.ts +4 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/_util/os.js +4 -3
- package/script/deps/deno.land/std@0.189.0/flags/mod.d.ts +166 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/flags/mod.js +150 -40
- package/script/deps/deno.land/std@0.189.0/path/_constants.d.ts +39 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_constants.js +1 -0
- package/script/deps/deno.land/std@0.189.0/path/_interface.d.ts +26 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_interface.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/_util.d.ts +11 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/_util.js +51 -1
- package/script/deps/deno.land/std@0.189.0/path/common.d.ts +13 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/common.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/glob.d.ts +83 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/glob.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/mod.d.ts +11 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/mod.js +23 -2
- package/script/deps/deno.land/std@0.189.0/path/posix.d.ts +86 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/posix.js +56 -110
- package/script/deps/deno.land/std@0.189.0/path/separator.d.ts +2 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/separator.js +1 -1
- package/script/deps/deno.land/std@0.189.0/path/win32.d.ts +91 -0
- package/script/deps/deno.land/{std@0.120.0 → std@0.189.0}/path/win32.js +30 -87
- package/script/deps/deno.land/std@0.51.0/fs/eol.d.ts +12 -0
- package/script/deps/deno.land/x/ini@v2.1.0/ini.d.ts +53 -0
- package/script/deps/deno.land/x/ini@v2.1.0/mod.d.ts +1 -0
- package/script/mod.d.ts +6 -0
- package/script/src/Change.d.ts +8 -0
- package/script/src/Change.js +15 -15
- package/script/src/Changelog.d.ts +19 -0
- package/script/src/Changelog.js +9 -1
- package/script/src/Release.d.ts +27 -0
- package/script/src/Release.js +10 -0
- package/script/src/deps.d.ts +1 -0
- package/script/src/deps.js +1 -1
- package/script/src/parser.d.ts +11 -0
- package/script/src/parser.js +19 -3
- package/script/test/Change.test.d.ts +1 -0
- package/script/test/changelog.custom.type.md +0 -1
- package/script/test/changelog.expected.linted.md +208 -0
- package/script/test/changelog.expected.md +3 -1
- package/script/test/changelog.md +4 -0
- package/script/test/deps.d.ts +1 -0
- package/script/test/empty.expected.md +0 -1
- package/script/test/fixture/CustomRelease.d.ts +8 -0
- package/script/test/parser.test.d.ts +1 -0
- package/script/test/test.d.ts +1 -0
- 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/script/deps/deno.land/std@0.120.0/_util/assert.js +0 -18
- 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/types/src/deps.d.ts +0 -1
- /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
- /package/{types → esm}/_dnt.shims.d.ts +0 -0
- /package/{types → esm}/bin.d.ts +0 -0
- /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/_constants.d.ts +0 -0
- /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/common.d.ts +0 -0
- /package/{types/deps/deno.land/std@0.120.0 → esm/deps/deno.land/std@0.189.0}/path/separator.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/std@0.51.0/fs/eol.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/ini.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/x/ini@v2.1.0/mod.d.ts +0 -0
- /package/{types → esm}/mod.d.ts +0 -0
- /package/{types → esm}/src/Change.d.ts +0 -0
- /package/{types → esm}/src/parser.d.ts +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright Isaac Z. Schlueter and Contributors. All rights reserved. ISC license.
|
|
3
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
5
|
+
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.compare = exports.patch = exports.minor = exports.major = exports.rcompareIdentifiers = exports.compareIdentifiers = exports.difference = exports.increment = exports.SemVer = exports.valid = exports.parse = exports.SEMVER_SPEC_VERSION = void 0;
|
|
4
6
|
// Note: this is the semver.org version of the spec that it implements
|
|
5
7
|
// Not necessarily the package version of this code.
|
|
6
8
|
exports.SEMVER_SPEC_VERSION = "2.0.0";
|
|
7
9
|
const MAX_LENGTH = 256;
|
|
8
|
-
// Max safe segment length for coercion.
|
|
9
|
-
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
10
10
|
// The actual regexps
|
|
11
11
|
const re = [];
|
|
12
12
|
const src = [];
|
|
@@ -17,8 +17,6 @@ let R = 0;
|
|
|
17
17
|
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
18
18
|
const NUMERICIDENTIFIER = R++;
|
|
19
19
|
src[NUMERICIDENTIFIER] = "0|[1-9]\\d*";
|
|
20
|
-
const NUMERICIDENTIFIERLOOSE = R++;
|
|
21
|
-
src[NUMERICIDENTIFIERLOOSE] = "[0-9]+";
|
|
22
20
|
// ## Non-numeric Identifier
|
|
23
21
|
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
24
22
|
// more letters, digits, or hyphens.
|
|
@@ -29,17 +27,11 @@ src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
|
|
|
29
27
|
const MAINVERSION = R++;
|
|
30
28
|
const nid = src[NUMERICIDENTIFIER];
|
|
31
29
|
src[MAINVERSION] = `(${nid})\\.(${nid})\\.(${nid})`;
|
|
32
|
-
const MAINVERSIONLOOSE = R++;
|
|
33
|
-
const nidl = src[NUMERICIDENTIFIERLOOSE];
|
|
34
|
-
src[MAINVERSIONLOOSE] = `(${nidl})\\.(${nidl})\\.(${nidl})`;
|
|
35
30
|
// ## Pre-release Version Identifier
|
|
36
31
|
// A numeric identifier, or a non-numeric identifier.
|
|
37
32
|
const PRERELEASEIDENTIFIER = R++;
|
|
38
33
|
src[PRERELEASEIDENTIFIER] = "(?:" + src[NUMERICIDENTIFIER] + "|" +
|
|
39
34
|
src[NONNUMERICIDENTIFIER] + ")";
|
|
40
|
-
const PRERELEASEIDENTIFIERLOOSE = R++;
|
|
41
|
-
src[PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[NUMERICIDENTIFIERLOOSE] + "|" +
|
|
42
|
-
src[NONNUMERICIDENTIFIER] + ")";
|
|
43
35
|
// ## Pre-release Version
|
|
44
36
|
// Hyphen, followed by one or more dot-separated pre-release version
|
|
45
37
|
// identifiers.
|
|
@@ -49,12 +41,6 @@ src[PRERELEASE] = "(?:-(" +
|
|
|
49
41
|
"(?:\\." +
|
|
50
42
|
src[PRERELEASEIDENTIFIER] +
|
|
51
43
|
")*))";
|
|
52
|
-
const PRERELEASELOOSE = R++;
|
|
53
|
-
src[PRERELEASELOOSE] = "(?:-?(" +
|
|
54
|
-
src[PRERELEASEIDENTIFIERLOOSE] +
|
|
55
|
-
"(?:\\." +
|
|
56
|
-
src[PRERELEASEIDENTIFIERLOOSE] +
|
|
57
|
-
")*))";
|
|
58
44
|
// ## Build Metadata Identifier
|
|
59
45
|
// Any combination of digits, letters, or hyphens.
|
|
60
46
|
const BUILDIDENTIFIER = R++;
|
|
@@ -76,24 +62,11 @@ const FULL = R++;
|
|
|
76
62
|
const FULLPLAIN = "v?" + src[MAINVERSION] + src[PRERELEASE] + "?" + src[BUILD] +
|
|
77
63
|
"?";
|
|
78
64
|
src[FULL] = "^" + FULLPLAIN + "$";
|
|
79
|
-
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
80
|
-
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
81
|
-
// common in the npm registry.
|
|
82
|
-
const LOOSEPLAIN = "[v=\\s]*" +
|
|
83
|
-
src[MAINVERSIONLOOSE] +
|
|
84
|
-
src[PRERELEASELOOSE] +
|
|
85
|
-
"?" +
|
|
86
|
-
src[BUILD] +
|
|
87
|
-
"?";
|
|
88
|
-
const LOOSE = R++;
|
|
89
|
-
src[LOOSE] = "^" + LOOSEPLAIN + "$";
|
|
90
65
|
const GTLT = R++;
|
|
91
66
|
src[GTLT] = "((?:<|>)?=?)";
|
|
92
67
|
// Something like "2.*" or "1.2.x".
|
|
93
68
|
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
94
69
|
// Only the first item is strictly required.
|
|
95
|
-
const XRANGEIDENTIFIERLOOSE = R++;
|
|
96
|
-
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
|
|
97
70
|
const XRANGEIDENTIFIER = R++;
|
|
98
71
|
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + "|x|X|\\*";
|
|
99
72
|
const XRANGEPLAIN = R++;
|
|
@@ -112,81 +85,24 @@ src[XRANGEPLAIN] = "[v=\\s]*(" +
|
|
|
112
85
|
src[BUILD] +
|
|
113
86
|
"?" +
|
|
114
87
|
")?)?";
|
|
115
|
-
const XRANGEPLAINLOOSE = R++;
|
|
116
|
-
src[XRANGEPLAINLOOSE] = "[v=\\s]*(" +
|
|
117
|
-
src[XRANGEIDENTIFIERLOOSE] +
|
|
118
|
-
")" +
|
|
119
|
-
"(?:\\.(" +
|
|
120
|
-
src[XRANGEIDENTIFIERLOOSE] +
|
|
121
|
-
")" +
|
|
122
|
-
"(?:\\.(" +
|
|
123
|
-
src[XRANGEIDENTIFIERLOOSE] +
|
|
124
|
-
")" +
|
|
125
|
-
"(?:" +
|
|
126
|
-
src[PRERELEASELOOSE] +
|
|
127
|
-
")?" +
|
|
128
|
-
src[BUILD] +
|
|
129
|
-
"?" +
|
|
130
|
-
")?)?";
|
|
131
88
|
const XRANGE = R++;
|
|
132
89
|
src[XRANGE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAIN] + "$";
|
|
133
|
-
const XRANGELOOSE = R++;
|
|
134
|
-
src[XRANGELOOSE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAINLOOSE] + "$";
|
|
135
|
-
// Coercion.
|
|
136
|
-
// Extract anything that could conceivably be a part of a valid semver
|
|
137
|
-
const COERCE = R++;
|
|
138
|
-
src[COERCE] = "(?:^|[^\\d])" +
|
|
139
|
-
"(\\d{1," +
|
|
140
|
-
MAX_SAFE_COMPONENT_LENGTH +
|
|
141
|
-
"})" +
|
|
142
|
-
"(?:\\.(\\d{1," +
|
|
143
|
-
MAX_SAFE_COMPONENT_LENGTH +
|
|
144
|
-
"}))?" +
|
|
145
|
-
"(?:\\.(\\d{1," +
|
|
146
|
-
MAX_SAFE_COMPONENT_LENGTH +
|
|
147
|
-
"}))?" +
|
|
148
|
-
"(?:$|[^\\d])";
|
|
149
90
|
// Tilde ranges.
|
|
150
91
|
// Meaning is "reasonably at or greater than"
|
|
151
92
|
const LONETILDE = R++;
|
|
152
93
|
src[LONETILDE] = "(?:~>?)";
|
|
153
|
-
const TILDETRIM = R++;
|
|
154
|
-
src[TILDETRIM] = "(\\s*)" + src[LONETILDE] + "\\s+";
|
|
155
|
-
re[TILDETRIM] = new RegExp(src[TILDETRIM], "g");
|
|
156
|
-
const tildeTrimReplace = "$1~";
|
|
157
94
|
const TILDE = R++;
|
|
158
95
|
src[TILDE] = "^" + src[LONETILDE] + src[XRANGEPLAIN] + "$";
|
|
159
|
-
const TILDELOOSE = R++;
|
|
160
|
-
src[TILDELOOSE] = "^" + src[LONETILDE] + src[XRANGEPLAINLOOSE] + "$";
|
|
161
96
|
// Caret ranges.
|
|
162
97
|
// Meaning is "at least and backwards compatible with"
|
|
163
98
|
const LONECARET = R++;
|
|
164
99
|
src[LONECARET] = "(?:\\^)";
|
|
165
|
-
const CARETTRIM = R++;
|
|
166
|
-
src[CARETTRIM] = "(\\s*)" + src[LONECARET] + "\\s+";
|
|
167
|
-
re[CARETTRIM] = new RegExp(src[CARETTRIM], "g");
|
|
168
|
-
const caretTrimReplace = "$1^";
|
|
169
100
|
const CARET = R++;
|
|
170
101
|
src[CARET] = "^" + src[LONECARET] + src[XRANGEPLAIN] + "$";
|
|
171
|
-
const CARETLOOSE = R++;
|
|
172
|
-
src[CARETLOOSE] = "^" + src[LONECARET] + src[XRANGEPLAINLOOSE] + "$";
|
|
173
102
|
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
174
|
-
const COMPARATORLOOSE = R++;
|
|
175
|
-
src[COMPARATORLOOSE] = "^" + src[GTLT] + "\\s*(" + LOOSEPLAIN + ")$|^$";
|
|
176
103
|
const COMPARATOR = R++;
|
|
177
104
|
src[COMPARATOR] = "^" + src[GTLT] + "\\s*(" + FULLPLAIN + ")$|^$";
|
|
178
|
-
// An expression to strip any whitespace between the gtlt and the thing
|
|
179
|
-
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
180
|
-
const COMPARATORTRIM = R++;
|
|
181
|
-
src[COMPARATORTRIM] = "(\\s*)" + src[GTLT] + "\\s*(" + LOOSEPLAIN + "|" +
|
|
182
|
-
src[XRANGEPLAIN] + ")";
|
|
183
|
-
// this one has to use the /g flag
|
|
184
|
-
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g");
|
|
185
|
-
const comparatorTrimReplace = "$1$2$3";
|
|
186
105
|
// Something like `1.2.3 - 1.2.4`
|
|
187
|
-
// Note that these all use the loose form, because they'll be
|
|
188
|
-
// checked against either the strict or loose comparator form
|
|
189
|
-
// later.
|
|
190
106
|
const HYPHENRANGE = R++;
|
|
191
107
|
src[HYPHENRANGE] = "^\\s*(" +
|
|
192
108
|
src[XRANGEPLAIN] +
|
|
@@ -196,15 +112,6 @@ src[HYPHENRANGE] = "^\\s*(" +
|
|
|
196
112
|
src[XRANGEPLAIN] +
|
|
197
113
|
")" +
|
|
198
114
|
"\\s*$";
|
|
199
|
-
const HYPHENRANGELOOSE = R++;
|
|
200
|
-
src[HYPHENRANGELOOSE] = "^\\s*(" +
|
|
201
|
-
src[XRANGEPLAINLOOSE] +
|
|
202
|
-
")" +
|
|
203
|
-
"\\s+-\\s+" +
|
|
204
|
-
"(" +
|
|
205
|
-
src[XRANGEPLAINLOOSE] +
|
|
206
|
-
")" +
|
|
207
|
-
"\\s*$";
|
|
208
115
|
// Star ranges basically just allow anything at all.
|
|
209
116
|
const STAR = R++;
|
|
210
117
|
src[STAR] = "(<|>)?=?\\s*\\*";
|
|
@@ -215,10 +122,13 @@ for (let i = 0; i < R; i++) {
|
|
|
215
122
|
re[i] = new RegExp(src[i]);
|
|
216
123
|
}
|
|
217
124
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Attempt to parse a string as a semantic version, returning either a `SemVer`
|
|
127
|
+
* object or `null`.
|
|
128
|
+
*/
|
|
129
|
+
function parse(version, options) {
|
|
130
|
+
if (typeof options !== "object") {
|
|
131
|
+
options = {
|
|
222
132
|
includePrerelease: false,
|
|
223
133
|
};
|
|
224
134
|
}
|
|
@@ -231,44 +141,34 @@ function parse(version, optionsOrLoose) {
|
|
|
231
141
|
if (version.length > MAX_LENGTH) {
|
|
232
142
|
return null;
|
|
233
143
|
}
|
|
234
|
-
const r =
|
|
144
|
+
const r = re[FULL];
|
|
235
145
|
if (!r.test(version)) {
|
|
236
146
|
return null;
|
|
237
147
|
}
|
|
238
148
|
try {
|
|
239
|
-
return new SemVer(version,
|
|
149
|
+
return new SemVer(version, options);
|
|
240
150
|
}
|
|
241
|
-
catch
|
|
151
|
+
catch {
|
|
242
152
|
return null;
|
|
243
153
|
}
|
|
244
154
|
}
|
|
245
155
|
exports.parse = parse;
|
|
246
|
-
|
|
156
|
+
/** Returns the parsed version, or null if it's not valid. */
|
|
157
|
+
function valid(version, options) {
|
|
247
158
|
if (version === null)
|
|
248
159
|
return null;
|
|
249
|
-
const v = parse(version,
|
|
160
|
+
const v = parse(version, options);
|
|
250
161
|
return v ? v.version : null;
|
|
251
162
|
}
|
|
252
163
|
exports.valid = valid;
|
|
253
|
-
function clean(version, optionsOrLoose) {
|
|
254
|
-
const s = parse(version.trim().replace(/^[=v]+/, ""), optionsOrLoose);
|
|
255
|
-
return s ? s.version : null;
|
|
256
|
-
}
|
|
257
|
-
exports.clean = clean;
|
|
258
164
|
class SemVer {
|
|
259
|
-
constructor(version,
|
|
165
|
+
constructor(version, options) {
|
|
260
166
|
Object.defineProperty(this, "raw", {
|
|
261
167
|
enumerable: true,
|
|
262
168
|
configurable: true,
|
|
263
169
|
writable: true,
|
|
264
170
|
value: void 0
|
|
265
171
|
});
|
|
266
|
-
Object.defineProperty(this, "loose", {
|
|
267
|
-
enumerable: true,
|
|
268
|
-
configurable: true,
|
|
269
|
-
writable: true,
|
|
270
|
-
value: void 0
|
|
271
|
-
});
|
|
272
172
|
Object.defineProperty(this, "options", {
|
|
273
173
|
enumerable: true,
|
|
274
174
|
configurable: true,
|
|
@@ -311,19 +211,13 @@ class SemVer {
|
|
|
311
211
|
writable: true,
|
|
312
212
|
value: void 0
|
|
313
213
|
});
|
|
314
|
-
if (
|
|
315
|
-
|
|
316
|
-
loose: !!optionsOrLoose,
|
|
214
|
+
if (typeof options !== "object") {
|
|
215
|
+
options = {
|
|
317
216
|
includePrerelease: false,
|
|
318
217
|
};
|
|
319
218
|
}
|
|
320
219
|
if (version instanceof SemVer) {
|
|
321
|
-
|
|
322
|
-
return version;
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
version = version.version;
|
|
326
|
-
}
|
|
220
|
+
version = version.version;
|
|
327
221
|
}
|
|
328
222
|
else if (typeof version !== "string") {
|
|
329
223
|
throw new TypeError("Invalid Version: " + version);
|
|
@@ -332,11 +226,10 @@ class SemVer {
|
|
|
332
226
|
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
|
|
333
227
|
}
|
|
334
228
|
if (!(this instanceof SemVer)) {
|
|
335
|
-
return new SemVer(version,
|
|
229
|
+
return new SemVer(version, options);
|
|
336
230
|
}
|
|
337
|
-
this.options =
|
|
338
|
-
|
|
339
|
-
const m = version.trim().match(optionsOrLoose.loose ? re[LOOSE] : re[FULL]);
|
|
231
|
+
this.options = options;
|
|
232
|
+
const m = version.trim().match(re[FULL]);
|
|
340
233
|
if (!m) {
|
|
341
234
|
throw new TypeError("Invalid Version: " + version);
|
|
342
235
|
}
|
|
@@ -455,36 +348,36 @@ class SemVer {
|
|
|
455
348
|
} while (++i);
|
|
456
349
|
return 1;
|
|
457
350
|
}
|
|
458
|
-
|
|
351
|
+
increment(release, identifier) {
|
|
459
352
|
switch (release) {
|
|
460
353
|
case "premajor":
|
|
461
354
|
this.prerelease.length = 0;
|
|
462
355
|
this.patch = 0;
|
|
463
356
|
this.minor = 0;
|
|
464
357
|
this.major++;
|
|
465
|
-
this.
|
|
358
|
+
this.increment("pre", identifier);
|
|
466
359
|
break;
|
|
467
360
|
case "preminor":
|
|
468
361
|
this.prerelease.length = 0;
|
|
469
362
|
this.patch = 0;
|
|
470
363
|
this.minor++;
|
|
471
|
-
this.
|
|
364
|
+
this.increment("pre", identifier);
|
|
472
365
|
break;
|
|
473
366
|
case "prepatch":
|
|
474
367
|
// If this is already a prerelease, it will bump to the next version
|
|
475
368
|
// drop any prereleases that might already exist, since they are not
|
|
476
369
|
// relevant at this point.
|
|
477
370
|
this.prerelease.length = 0;
|
|
478
|
-
this.
|
|
479
|
-
this.
|
|
371
|
+
this.increment("patch", identifier);
|
|
372
|
+
this.increment("pre", identifier);
|
|
480
373
|
break;
|
|
481
374
|
// If the input is a non-prerelease version, this acts the same as
|
|
482
375
|
// prepatch.
|
|
483
376
|
case "prerelease":
|
|
484
377
|
if (this.prerelease.length === 0) {
|
|
485
|
-
this.
|
|
378
|
+
this.increment("patch", identifier);
|
|
486
379
|
}
|
|
487
|
-
this.
|
|
380
|
+
this.increment("pre", identifier);
|
|
488
381
|
break;
|
|
489
382
|
case "major":
|
|
490
383
|
// If this is a pre-major version, bump up to the same major version.
|
|
@@ -531,6 +424,7 @@ class SemVer {
|
|
|
531
424
|
let i = this.prerelease.length;
|
|
532
425
|
while (--i >= 0) {
|
|
533
426
|
if (typeof this.prerelease[i] === "number") {
|
|
427
|
+
// deno-fmt-ignore
|
|
534
428
|
this.prerelease[i]++;
|
|
535
429
|
i = -2;
|
|
536
430
|
}
|
|
@@ -566,23 +460,37 @@ class SemVer {
|
|
|
566
460
|
}
|
|
567
461
|
exports.SemVer = SemVer;
|
|
568
462
|
/**
|
|
569
|
-
*
|
|
463
|
+
* Returns the version incremented by the release type
|
|
464
|
+
* (major, minor, patch, or prerelease), or null if it's not valid.
|
|
465
|
+
*
|
|
466
|
+
* `premajor` in one call will bump the version up to the next major version and
|
|
467
|
+
* down to a prerelease of that major version. `preminor`, and `prepatch` work
|
|
468
|
+
* the same way.
|
|
469
|
+
*
|
|
470
|
+
* If called from a non-prerelease version, the `prerelease` will work the same
|
|
471
|
+
* as `prepatch`. It increments the patch version, then makes a prerelease. If
|
|
472
|
+
* the input version is already a prerelease it simply increments it.
|
|
570
473
|
*/
|
|
571
|
-
function
|
|
572
|
-
if (typeof
|
|
573
|
-
identifier =
|
|
574
|
-
|
|
474
|
+
function increment(version, release, options, identifier) {
|
|
475
|
+
if (typeof options === "string") {
|
|
476
|
+
identifier = options;
|
|
477
|
+
options = undefined;
|
|
575
478
|
}
|
|
576
479
|
try {
|
|
577
|
-
return new SemVer(version,
|
|
480
|
+
return new SemVer(version, options).increment(release, identifier).version;
|
|
578
481
|
}
|
|
579
|
-
catch
|
|
482
|
+
catch {
|
|
580
483
|
return null;
|
|
581
484
|
}
|
|
582
485
|
}
|
|
583
|
-
exports.
|
|
584
|
-
|
|
585
|
-
|
|
486
|
+
exports.increment = increment;
|
|
487
|
+
/**
|
|
488
|
+
* Returns difference between two versions by the release type (`major`,
|
|
489
|
+
* `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`), or
|
|
490
|
+
* null if the versions are the same.
|
|
491
|
+
*/
|
|
492
|
+
function difference(version1, version2, options) {
|
|
493
|
+
if (eq(version1, version2, options)) {
|
|
586
494
|
return null;
|
|
587
495
|
}
|
|
588
496
|
else {
|
|
@@ -606,7 +514,7 @@ function diff(version1, version2, optionsOrLoose) {
|
|
|
606
514
|
return defaultResult; // may be undefined
|
|
607
515
|
}
|
|
608
516
|
}
|
|
609
|
-
exports.
|
|
517
|
+
exports.difference = difference;
|
|
610
518
|
const numeric = /^[0-9]+$/;
|
|
611
519
|
function compareIdentifiers(a, b) {
|
|
612
520
|
const anum = numeric.test(a);
|
|
@@ -624,82 +532,101 @@ function rcompareIdentifiers(a, b) {
|
|
|
624
532
|
return compareIdentifiers(b, a);
|
|
625
533
|
}
|
|
626
534
|
exports.rcompareIdentifiers = rcompareIdentifiers;
|
|
627
|
-
/**
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
function major(v, optionsOrLoose) {
|
|
631
|
-
return new SemVer(v, optionsOrLoose).major;
|
|
535
|
+
/** Returns the major version number. */
|
|
536
|
+
function major(v, options) {
|
|
537
|
+
return new SemVer(v, options).major;
|
|
632
538
|
}
|
|
633
539
|
exports.major = major;
|
|
634
|
-
/**
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
function minor(v, optionsOrLoose) {
|
|
638
|
-
return new SemVer(v, optionsOrLoose).minor;
|
|
540
|
+
/** Returns the minor version number. */
|
|
541
|
+
function minor(v, options) {
|
|
542
|
+
return new SemVer(v, options).minor;
|
|
639
543
|
}
|
|
640
544
|
exports.minor = minor;
|
|
641
|
-
/**
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
function patch(v, optionsOrLoose) {
|
|
645
|
-
return new SemVer(v, optionsOrLoose).patch;
|
|
545
|
+
/** Returns the patch version number. */
|
|
546
|
+
function patch(v, options) {
|
|
547
|
+
return new SemVer(v, options).patch;
|
|
646
548
|
}
|
|
647
549
|
exports.patch = patch;
|
|
648
|
-
|
|
649
|
-
|
|
550
|
+
/**
|
|
551
|
+
* Returns `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if `v2` is
|
|
552
|
+
* greater. Sorts in ascending order if passed to `Array.sort()`,
|
|
553
|
+
*/
|
|
554
|
+
function compare(v1, v2, options) {
|
|
555
|
+
return new SemVer(v1, options).compare(new SemVer(v2, options));
|
|
650
556
|
}
|
|
651
557
|
exports.compare = compare;
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
function compareBuild(a, b,
|
|
657
|
-
|
|
658
|
-
|
|
558
|
+
/**
|
|
559
|
+
* The same as {@linkcode compare} but considers `build` when two versions are
|
|
560
|
+
* equal. Sorts in ascending order if passed to `Array.sort()`.
|
|
561
|
+
*/
|
|
562
|
+
function compareBuild(a, b, options) {
|
|
563
|
+
const versionA = new SemVer(a, options);
|
|
564
|
+
const versionB = new SemVer(b, options);
|
|
659
565
|
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
660
566
|
}
|
|
661
567
|
exports.compareBuild = compareBuild;
|
|
662
|
-
|
|
663
|
-
|
|
568
|
+
/**
|
|
569
|
+
* Returns `0` if `v1 == v2`, or `-1` if `v1` is greater, or `1` if `v2` is
|
|
570
|
+
* greater. Sorts in descending order if passed to `Array.sort()`,
|
|
571
|
+
*/
|
|
572
|
+
function rcompare(v1, v2, options) {
|
|
573
|
+
return compare(v2, v1, options);
|
|
664
574
|
}
|
|
665
575
|
exports.rcompare = rcompare;
|
|
666
|
-
function sort(list,
|
|
576
|
+
function sort(list, options) {
|
|
667
577
|
return list.sort((a, b) => {
|
|
668
|
-
return compareBuild(a, b,
|
|
578
|
+
return compareBuild(a, b, options);
|
|
669
579
|
});
|
|
670
580
|
}
|
|
671
581
|
exports.sort = sort;
|
|
672
|
-
function rsort(list,
|
|
582
|
+
function rsort(list, options) {
|
|
673
583
|
return list.sort((a, b) => {
|
|
674
|
-
return compareBuild(b, a,
|
|
584
|
+
return compareBuild(b, a, options);
|
|
675
585
|
});
|
|
676
586
|
}
|
|
677
587
|
exports.rsort = rsort;
|
|
678
|
-
|
|
679
|
-
|
|
588
|
+
/** Greater than comparison */
|
|
589
|
+
function gt(v1, v2, options) {
|
|
590
|
+
return compare(v1, v2, options) > 0;
|
|
680
591
|
}
|
|
681
592
|
exports.gt = gt;
|
|
682
|
-
|
|
683
|
-
|
|
593
|
+
/** Less than comparison */
|
|
594
|
+
function lt(v1, v2, options) {
|
|
595
|
+
return compare(v1, v2, options) < 0;
|
|
684
596
|
}
|
|
685
597
|
exports.lt = lt;
|
|
686
|
-
|
|
687
|
-
|
|
598
|
+
/**
|
|
599
|
+
* This is true if they're logically equivalent, even if they're not the exact
|
|
600
|
+
* same string.
|
|
601
|
+
*/
|
|
602
|
+
function eq(v1, v2, options) {
|
|
603
|
+
return compare(v1, v2, options) === 0;
|
|
688
604
|
}
|
|
689
605
|
exports.eq = eq;
|
|
690
|
-
|
|
691
|
-
|
|
606
|
+
/**
|
|
607
|
+
* This is true if they're not logically equivalent, even if they're the exact
|
|
608
|
+
* same string.
|
|
609
|
+
*/
|
|
610
|
+
function neq(v1, v2, options) {
|
|
611
|
+
return compare(v1, v2, options) !== 0;
|
|
692
612
|
}
|
|
693
613
|
exports.neq = neq;
|
|
694
|
-
|
|
695
|
-
|
|
614
|
+
/** Greater than or equal comparison */
|
|
615
|
+
function gte(v1, v2, options) {
|
|
616
|
+
return compare(v1, v2, options) >= 0;
|
|
696
617
|
}
|
|
697
618
|
exports.gte = gte;
|
|
698
|
-
|
|
699
|
-
|
|
619
|
+
/** Less than or equal comparison */
|
|
620
|
+
function lte(v1, v2, options) {
|
|
621
|
+
return compare(v1, v2, options) <= 0;
|
|
700
622
|
}
|
|
701
623
|
exports.lte = lte;
|
|
702
|
-
|
|
624
|
+
/**
|
|
625
|
+
* Pass in a comparison string, and it'll call the corresponding comparison
|
|
626
|
+
* function. `"==="` and `"!=="` do simple string comparison, but are included
|
|
627
|
+
* for completeness. Throws if an invalid comparison string is provided.
|
|
628
|
+
*/
|
|
629
|
+
function cmp(v1, operator, v2, options) {
|
|
703
630
|
switch (operator) {
|
|
704
631
|
case "===":
|
|
705
632
|
if (typeof v1 === "object")
|
|
@@ -716,17 +643,17 @@ function cmp(v1, operator, v2, optionsOrLoose) {
|
|
|
716
643
|
case "":
|
|
717
644
|
case "=":
|
|
718
645
|
case "==":
|
|
719
|
-
return eq(v1, v2,
|
|
646
|
+
return eq(v1, v2, options);
|
|
720
647
|
case "!=":
|
|
721
|
-
return neq(v1, v2,
|
|
648
|
+
return neq(v1, v2, options);
|
|
722
649
|
case ">":
|
|
723
|
-
return gt(v1, v2,
|
|
650
|
+
return gt(v1, v2, options);
|
|
724
651
|
case ">=":
|
|
725
|
-
return gte(v1, v2,
|
|
652
|
+
return gte(v1, v2, options);
|
|
726
653
|
case "<":
|
|
727
|
-
return lt(v1, v2,
|
|
654
|
+
return lt(v1, v2, options);
|
|
728
655
|
case "<=":
|
|
729
|
-
return lte(v1, v2,
|
|
656
|
+
return lte(v1, v2, options);
|
|
730
657
|
default:
|
|
731
658
|
throw new TypeError("Invalid operator: " + operator);
|
|
732
659
|
}
|
|
@@ -734,7 +661,7 @@ function cmp(v1, operator, v2, optionsOrLoose) {
|
|
|
734
661
|
exports.cmp = cmp;
|
|
735
662
|
const ANY = {};
|
|
736
663
|
class Comparator {
|
|
737
|
-
constructor(comp,
|
|
664
|
+
constructor(comp, options) {
|
|
738
665
|
Object.defineProperty(this, "semver", {
|
|
739
666
|
enumerable: true,
|
|
740
667
|
configurable: true,
|
|
@@ -753,37 +680,24 @@ class Comparator {
|
|
|
753
680
|
writable: true,
|
|
754
681
|
value: void 0
|
|
755
682
|
});
|
|
756
|
-
Object.defineProperty(this, "loose", {
|
|
757
|
-
enumerable: true,
|
|
758
|
-
configurable: true,
|
|
759
|
-
writable: true,
|
|
760
|
-
value: void 0
|
|
761
|
-
});
|
|
762
683
|
Object.defineProperty(this, "options", {
|
|
763
684
|
enumerable: true,
|
|
764
685
|
configurable: true,
|
|
765
686
|
writable: true,
|
|
766
687
|
value: void 0
|
|
767
688
|
});
|
|
768
|
-
if (
|
|
769
|
-
|
|
770
|
-
loose: !!optionsOrLoose,
|
|
689
|
+
if (typeof options !== "object") {
|
|
690
|
+
options = {
|
|
771
691
|
includePrerelease: false,
|
|
772
692
|
};
|
|
773
693
|
}
|
|
774
694
|
if (comp instanceof Comparator) {
|
|
775
|
-
|
|
776
|
-
return comp;
|
|
777
|
-
}
|
|
778
|
-
else {
|
|
779
|
-
comp = comp.value;
|
|
780
|
-
}
|
|
695
|
+
return comp;
|
|
781
696
|
}
|
|
782
697
|
if (!(this instanceof Comparator)) {
|
|
783
|
-
return new Comparator(comp,
|
|
698
|
+
return new Comparator(comp, options);
|
|
784
699
|
}
|
|
785
|
-
this.options =
|
|
786
|
-
this.loose = !!optionsOrLoose.loose;
|
|
700
|
+
this.options = options;
|
|
787
701
|
this.parse(comp);
|
|
788
702
|
if (this.semver === ANY) {
|
|
789
703
|
this.value = "";
|
|
@@ -793,7 +707,7 @@ class Comparator {
|
|
|
793
707
|
}
|
|
794
708
|
}
|
|
795
709
|
parse(comp) {
|
|
796
|
-
const r =
|
|
710
|
+
const r = re[COMPARATOR];
|
|
797
711
|
const m = comp.match(r);
|
|
798
712
|
if (!m) {
|
|
799
713
|
throw new TypeError("Invalid comparator: " + comp);
|
|
@@ -808,7 +722,7 @@ class Comparator {
|
|
|
808
722
|
this.semver = ANY;
|
|
809
723
|
}
|
|
810
724
|
else {
|
|
811
|
-
this.semver = new SemVer(m[2], this.options
|
|
725
|
+
this.semver = new SemVer(m[2], this.options);
|
|
812
726
|
}
|
|
813
727
|
}
|
|
814
728
|
test(version) {
|
|
@@ -820,13 +734,12 @@ class Comparator {
|
|
|
820
734
|
}
|
|
821
735
|
return cmp(version, this.operator, this.semver, this.options);
|
|
822
736
|
}
|
|
823
|
-
intersects(comp,
|
|
737
|
+
intersects(comp, options) {
|
|
824
738
|
if (!(comp instanceof Comparator)) {
|
|
825
739
|
throw new TypeError("a Comparator is required");
|
|
826
740
|
}
|
|
827
|
-
if (
|
|
828
|
-
|
|
829
|
-
loose: !!optionsOrLoose,
|
|
741
|
+
if (typeof options !== "object") {
|
|
742
|
+
options = {
|
|
830
743
|
includePrerelease: false,
|
|
831
744
|
};
|
|
832
745
|
}
|
|
@@ -835,15 +748,15 @@ class Comparator {
|
|
|
835
748
|
if (this.value === "") {
|
|
836
749
|
return true;
|
|
837
750
|
}
|
|
838
|
-
rangeTmp = new Range(comp.value,
|
|
839
|
-
return satisfies(this.value, rangeTmp,
|
|
751
|
+
rangeTmp = new Range(comp.value, options);
|
|
752
|
+
return satisfies(this.value, rangeTmp, options);
|
|
840
753
|
}
|
|
841
754
|
else if (comp.operator === "") {
|
|
842
755
|
if (comp.value === "") {
|
|
843
756
|
return true;
|
|
844
757
|
}
|
|
845
|
-
rangeTmp = new Range(this.value,
|
|
846
|
-
return satisfies(comp.semver, rangeTmp,
|
|
758
|
+
rangeTmp = new Range(this.value, options);
|
|
759
|
+
return satisfies(comp.semver, rangeTmp, options);
|
|
847
760
|
}
|
|
848
761
|
const sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") &&
|
|
849
762
|
(comp.operator === ">=" || comp.operator === ">");
|
|
@@ -852,10 +765,10 @@ class Comparator {
|
|
|
852
765
|
const sameSemVer = this.semver.version === comp.semver.version;
|
|
853
766
|
const differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") &&
|
|
854
767
|
(comp.operator === ">=" || comp.operator === "<=");
|
|
855
|
-
const oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver,
|
|
768
|
+
const oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) &&
|
|
856
769
|
(this.operator === ">=" || this.operator === ">") &&
|
|
857
770
|
(comp.operator === "<=" || comp.operator === "<");
|
|
858
|
-
const oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver,
|
|
771
|
+
const oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) &&
|
|
859
772
|
(this.operator === "<=" || this.operator === "<") &&
|
|
860
773
|
(comp.operator === ">=" || comp.operator === ">");
|
|
861
774
|
return (sameDirectionIncreasing ||
|
|
@@ -870,7 +783,7 @@ class Comparator {
|
|
|
870
783
|
}
|
|
871
784
|
exports.Comparator = Comparator;
|
|
872
785
|
class Range {
|
|
873
|
-
constructor(range,
|
|
786
|
+
constructor(range, options) {
|
|
874
787
|
Object.defineProperty(this, "range", {
|
|
875
788
|
enumerable: true,
|
|
876
789
|
configurable: true,
|
|
@@ -883,12 +796,6 @@ class Range {
|
|
|
883
796
|
writable: true,
|
|
884
797
|
value: void 0
|
|
885
798
|
});
|
|
886
|
-
Object.defineProperty(this, "loose", {
|
|
887
|
-
enumerable: true,
|
|
888
|
-
configurable: true,
|
|
889
|
-
writable: true,
|
|
890
|
-
value: void 0
|
|
891
|
-
});
|
|
892
799
|
Object.defineProperty(this, "options", {
|
|
893
800
|
enumerable: true,
|
|
894
801
|
configurable: true,
|
|
@@ -907,30 +814,27 @@ class Range {
|
|
|
907
814
|
writable: true,
|
|
908
815
|
value: void 0
|
|
909
816
|
});
|
|
910
|
-
if (
|
|
911
|
-
|
|
912
|
-
loose: !!optionsOrLoose,
|
|
817
|
+
if (typeof options !== "object") {
|
|
818
|
+
options = {
|
|
913
819
|
includePrerelease: false,
|
|
914
820
|
};
|
|
915
821
|
}
|
|
916
822
|
if (range instanceof Range) {
|
|
917
|
-
if (range.
|
|
918
|
-
range.includePrerelease === !!optionsOrLoose.includePrerelease) {
|
|
823
|
+
if (range.includePrerelease === !!options.includePrerelease) {
|
|
919
824
|
return range;
|
|
920
825
|
}
|
|
921
826
|
else {
|
|
922
|
-
return new Range(range.raw,
|
|
827
|
+
return new Range(range.raw, options);
|
|
923
828
|
}
|
|
924
829
|
}
|
|
925
830
|
if (range instanceof Comparator) {
|
|
926
|
-
return new Range(range.value,
|
|
831
|
+
return new Range(range.value, options);
|
|
927
832
|
}
|
|
928
833
|
if (!(this instanceof Range)) {
|
|
929
|
-
return new Range(range,
|
|
834
|
+
return new Range(range, options);
|
|
930
835
|
}
|
|
931
|
-
this.options =
|
|
932
|
-
this.
|
|
933
|
-
this.includePrerelease = !!optionsOrLoose.includePrerelease;
|
|
836
|
+
this.options = options;
|
|
837
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
934
838
|
// First, split based on boolean or ||
|
|
935
839
|
this.raw = range;
|
|
936
840
|
this.set = range
|
|
@@ -953,57 +857,43 @@ class Range {
|
|
|
953
857
|
return this.range;
|
|
954
858
|
}
|
|
955
859
|
parseRange(range) {
|
|
956
|
-
const loose = this.options.loose;
|
|
957
860
|
range = range.trim();
|
|
958
861
|
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
959
|
-
const hr =
|
|
862
|
+
const hr = re[HYPHENRANGE];
|
|
960
863
|
range = range.replace(hr, hyphenReplace);
|
|
961
|
-
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
962
|
-
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace);
|
|
963
|
-
// `~ 1.2.3` => `~1.2.3`
|
|
964
|
-
range = range.replace(re[TILDETRIM], tildeTrimReplace);
|
|
965
|
-
// `^ 1.2.3` => `^1.2.3`
|
|
966
|
-
range = range.replace(re[CARETTRIM], caretTrimReplace);
|
|
967
864
|
// normalize spaces
|
|
968
865
|
range = range.split(/\s+/).join(" ");
|
|
969
866
|
// At this point, the range is completely trimmed and
|
|
970
867
|
// ready to be split into comparators.
|
|
971
|
-
const
|
|
972
|
-
let set = range
|
|
868
|
+
const set = range
|
|
973
869
|
.split(" ")
|
|
974
870
|
.map((comp) => parseComparator(comp, this.options))
|
|
975
871
|
.join(" ")
|
|
976
872
|
.split(/\s+/);
|
|
977
|
-
if (this.options.loose) {
|
|
978
|
-
// in loose mode, throw out any that are not valid comparators
|
|
979
|
-
set = set.filter((comp) => {
|
|
980
|
-
return !!comp.match(compRe);
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
873
|
return set.map((comp) => new Comparator(comp, this.options));
|
|
984
874
|
}
|
|
985
875
|
test(version) {
|
|
986
876
|
if (typeof version === "string") {
|
|
987
877
|
version = new SemVer(version, this.options);
|
|
988
878
|
}
|
|
989
|
-
for (
|
|
879
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
990
880
|
if (testSet(this.set[i], version, this.options)) {
|
|
991
881
|
return true;
|
|
992
882
|
}
|
|
993
883
|
}
|
|
994
884
|
return false;
|
|
995
885
|
}
|
|
996
|
-
intersects(range,
|
|
886
|
+
intersects(range, options) {
|
|
997
887
|
if (!(range instanceof Range)) {
|
|
998
888
|
throw new TypeError("a Range is required");
|
|
999
889
|
}
|
|
1000
890
|
return this.set.some((thisComparators) => {
|
|
1001
|
-
return (isSatisfiable(thisComparators,
|
|
891
|
+
return (isSatisfiable(thisComparators, options) &&
|
|
1002
892
|
range.set.some((rangeComparators) => {
|
|
1003
|
-
return (isSatisfiable(rangeComparators,
|
|
893
|
+
return (isSatisfiable(rangeComparators, options) &&
|
|
1004
894
|
thisComparators.every((thisComparator) => {
|
|
1005
895
|
return rangeComparators.every((rangeComparator) => {
|
|
1006
|
-
return thisComparator.intersects(rangeComparator,
|
|
896
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
1007
897
|
});
|
|
1008
898
|
}));
|
|
1009
899
|
}));
|
|
@@ -1059,8 +949,8 @@ function isSatisfiable(comparators, options) {
|
|
|
1059
949
|
return result;
|
|
1060
950
|
}
|
|
1061
951
|
// Mostly just for testing and legacy API reasons
|
|
1062
|
-
function toComparators(range,
|
|
1063
|
-
return new Range(range,
|
|
952
|
+
function toComparators(range, options) {
|
|
953
|
+
return new Range(range, options).set.map((comp) => {
|
|
1064
954
|
return comp
|
|
1065
955
|
.map((c) => c.value)
|
|
1066
956
|
.join(" ")
|
|
@@ -1095,8 +985,8 @@ function replaceTildes(comp, options) {
|
|
|
1095
985
|
.map((comp) => replaceTilde(comp, options))
|
|
1096
986
|
.join(" ");
|
|
1097
987
|
}
|
|
1098
|
-
function replaceTilde(comp,
|
|
1099
|
-
const r =
|
|
988
|
+
function replaceTilde(comp, _options) {
|
|
989
|
+
const r = re[TILDE];
|
|
1100
990
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1101
991
|
let ret;
|
|
1102
992
|
if (isX(M)) {
|
|
@@ -1144,8 +1034,8 @@ function replaceCarets(comp, options) {
|
|
|
1144
1034
|
.map((comp) => replaceCaret(comp, options))
|
|
1145
1035
|
.join(" ");
|
|
1146
1036
|
}
|
|
1147
|
-
function replaceCaret(comp,
|
|
1148
|
-
const r =
|
|
1037
|
+
function replaceCaret(comp, _options) {
|
|
1038
|
+
const r = re[CARET];
|
|
1149
1039
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1150
1040
|
let ret;
|
|
1151
1041
|
if (isX(M)) {
|
|
@@ -1224,10 +1114,10 @@ function replaceXRanges(comp, options) {
|
|
|
1224
1114
|
.map((comp) => replaceXRange(comp, options))
|
|
1225
1115
|
.join(" ");
|
|
1226
1116
|
}
|
|
1227
|
-
function replaceXRange(comp,
|
|
1117
|
+
function replaceXRange(comp, _options) {
|
|
1228
1118
|
comp = comp.trim();
|
|
1229
|
-
const r =
|
|
1230
|
-
return comp.replace(r, (ret, gtlt, M, m, p,
|
|
1119
|
+
const r = re[XRANGE];
|
|
1120
|
+
return comp.replace(r, (ret, gtlt, M, m, p, _pr) => {
|
|
1231
1121
|
const xM = isX(M);
|
|
1232
1122
|
const xm = xM || isX(m);
|
|
1233
1123
|
const xp = xm || isX(p);
|
|
@@ -1291,8 +1181,7 @@ function replaceXRange(comp, options) {
|
|
|
1291
1181
|
}
|
|
1292
1182
|
// Because * is AND-ed with everything else in the comparator,
|
|
1293
1183
|
// and '' means "any version", just remove the *s entirely.
|
|
1294
|
-
function replaceStars(comp,
|
|
1295
|
-
// Looseness is ignored here. star is always as loose as it gets!
|
|
1184
|
+
function replaceStars(comp, _options) {
|
|
1296
1185
|
return comp.trim().replace(re[STAR], "");
|
|
1297
1186
|
}
|
|
1298
1187
|
// This function is passed to string.replace(re[HYPHENRANGE])
|
|
@@ -1300,7 +1189,7 @@ function replaceStars(comp, options) {
|
|
|
1300
1189
|
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
1301
1190
|
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
|
1302
1191
|
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
|
1303
|
-
function hyphenReplace($0, from, fM, fm, fp,
|
|
1192
|
+
function hyphenReplace(_$0, from, fM, fm, fp, _fpr, _fb, to, tM, tm, tp, tpr, _tb) {
|
|
1304
1193
|
if (isX(fM)) {
|
|
1305
1194
|
from = "";
|
|
1306
1195
|
}
|
|
@@ -1330,24 +1219,30 @@ function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
|
|
|
1330
1219
|
}
|
|
1331
1220
|
return (from + " " + to).trim();
|
|
1332
1221
|
}
|
|
1333
|
-
|
|
1222
|
+
/** Returns true if the version satisfies the range. */
|
|
1223
|
+
function satisfies(version, range, options) {
|
|
1334
1224
|
try {
|
|
1335
|
-
range = new Range(range,
|
|
1225
|
+
range = new Range(range, options);
|
|
1336
1226
|
}
|
|
1337
|
-
catch
|
|
1227
|
+
catch {
|
|
1338
1228
|
return false;
|
|
1339
1229
|
}
|
|
1340
1230
|
return range.test(version);
|
|
1341
1231
|
}
|
|
1342
1232
|
exports.satisfies = satisfies;
|
|
1343
|
-
|
|
1233
|
+
/**
|
|
1234
|
+
* Returns the highest version in the list that satisfies the range, or `null`
|
|
1235
|
+
* if none of them do.
|
|
1236
|
+
*/
|
|
1237
|
+
function maxSatisfying(versions, range, options) {
|
|
1344
1238
|
//todo
|
|
1345
|
-
|
|
1346
|
-
|
|
1239
|
+
let max = null;
|
|
1240
|
+
let maxSV = null;
|
|
1241
|
+
let rangeObj;
|
|
1347
1242
|
try {
|
|
1348
|
-
|
|
1243
|
+
rangeObj = new Range(range, options);
|
|
1349
1244
|
}
|
|
1350
|
-
catch
|
|
1245
|
+
catch {
|
|
1351
1246
|
return null;
|
|
1352
1247
|
}
|
|
1353
1248
|
versions.forEach((v) => {
|
|
@@ -1356,21 +1251,26 @@ function maxSatisfying(versions, range, optionsOrLoose) {
|
|
|
1356
1251
|
if (!max || (maxSV && maxSV.compare(v) === -1)) {
|
|
1357
1252
|
// compare(max, v, true)
|
|
1358
1253
|
max = v;
|
|
1359
|
-
maxSV = new SemVer(max,
|
|
1254
|
+
maxSV = new SemVer(max, options);
|
|
1360
1255
|
}
|
|
1361
1256
|
}
|
|
1362
1257
|
});
|
|
1363
1258
|
return max;
|
|
1364
1259
|
}
|
|
1365
1260
|
exports.maxSatisfying = maxSatisfying;
|
|
1366
|
-
|
|
1261
|
+
/**
|
|
1262
|
+
* Returns the lowest version in the list that satisfies the range, or `null` if
|
|
1263
|
+
* none of them do.
|
|
1264
|
+
*/
|
|
1265
|
+
function minSatisfying(versions, range, options) {
|
|
1367
1266
|
//todo
|
|
1368
|
-
|
|
1369
|
-
|
|
1267
|
+
let min = null;
|
|
1268
|
+
let minSV = null;
|
|
1269
|
+
let rangeObj;
|
|
1370
1270
|
try {
|
|
1371
|
-
|
|
1271
|
+
rangeObj = new Range(range, options);
|
|
1372
1272
|
}
|
|
1373
|
-
catch
|
|
1273
|
+
catch {
|
|
1374
1274
|
return null;
|
|
1375
1275
|
}
|
|
1376
1276
|
versions.forEach((v) => {
|
|
@@ -1379,16 +1279,17 @@ function minSatisfying(versions, range, optionsOrLoose) {
|
|
|
1379
1279
|
if (!min || minSV.compare(v) === 1) {
|
|
1380
1280
|
// compare(min, v, true)
|
|
1381
1281
|
min = v;
|
|
1382
|
-
minSV = new SemVer(min,
|
|
1282
|
+
minSV = new SemVer(min, options);
|
|
1383
1283
|
}
|
|
1384
1284
|
}
|
|
1385
1285
|
});
|
|
1386
1286
|
return min;
|
|
1387
1287
|
}
|
|
1388
1288
|
exports.minSatisfying = minSatisfying;
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1289
|
+
/** Returns the lowest version that can possibly match the given range. */
|
|
1290
|
+
function minVersion(range, options) {
|
|
1291
|
+
range = new Range(range, options);
|
|
1292
|
+
let minver = new SemVer("0.0.0");
|
|
1392
1293
|
if (range.test(minver)) {
|
|
1393
1294
|
return minver;
|
|
1394
1295
|
}
|
|
@@ -1397,11 +1298,11 @@ function minVersion(range, optionsOrLoose) {
|
|
|
1397
1298
|
return minver;
|
|
1398
1299
|
}
|
|
1399
1300
|
minver = null;
|
|
1400
|
-
for (
|
|
1401
|
-
|
|
1301
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1302
|
+
const comparators = range.set[i];
|
|
1402
1303
|
comparators.forEach((comparator) => {
|
|
1403
1304
|
// Clone to avoid manipulating the comparator's semver object.
|
|
1404
|
-
|
|
1305
|
+
const compver = new SemVer(comparator.semver.version);
|
|
1405
1306
|
switch (comparator.operator) {
|
|
1406
1307
|
case ">":
|
|
1407
1308
|
if (compver.prerelease.length === 0) {
|
|
@@ -1434,40 +1335,42 @@ function minVersion(range, optionsOrLoose) {
|
|
|
1434
1335
|
return null;
|
|
1435
1336
|
}
|
|
1436
1337
|
exports.minVersion = minVersion;
|
|
1437
|
-
|
|
1338
|
+
/** Returns the valid range or null if it's not valid. */
|
|
1339
|
+
function validRange(range, options) {
|
|
1438
1340
|
try {
|
|
1439
1341
|
if (range === null)
|
|
1440
1342
|
return null;
|
|
1441
1343
|
// Return '*' instead of '' so that truthiness works.
|
|
1442
1344
|
// This will throw if it's invalid anyway
|
|
1443
|
-
return new Range(range,
|
|
1345
|
+
return new Range(range, options).range || "*";
|
|
1444
1346
|
}
|
|
1445
|
-
catch
|
|
1347
|
+
catch {
|
|
1446
1348
|
return null;
|
|
1447
1349
|
}
|
|
1448
1350
|
}
|
|
1449
1351
|
exports.validRange = validRange;
|
|
1450
1352
|
/**
|
|
1451
|
-
*
|
|
1353
|
+
* Returns true if version is less than all the versions possible in the range.
|
|
1452
1354
|
*/
|
|
1453
|
-
function ltr(version, range,
|
|
1454
|
-
return outside(version, range, "<",
|
|
1355
|
+
function ltr(version, range, options) {
|
|
1356
|
+
return outside(version, range, "<", options);
|
|
1455
1357
|
}
|
|
1456
1358
|
exports.ltr = ltr;
|
|
1457
1359
|
/**
|
|
1458
|
-
*
|
|
1360
|
+
* Returns true if version is greater than all the versions possible in the range.
|
|
1459
1361
|
*/
|
|
1460
|
-
function gtr(version, range,
|
|
1461
|
-
return outside(version, range, ">",
|
|
1362
|
+
function gtr(version, range, options) {
|
|
1363
|
+
return outside(version, range, ">", options);
|
|
1462
1364
|
}
|
|
1463
1365
|
exports.gtr = gtr;
|
|
1464
1366
|
/**
|
|
1465
|
-
*
|
|
1466
|
-
* The hilo argument must be either the string '>' or
|
|
1367
|
+
* Returns true if the version is outside the bounds of the range in either the
|
|
1368
|
+
* high or low direction. The hilo argument must be either the string '>' or
|
|
1369
|
+
* '<'. (This is the function called by {@linkcode gtr} and {@linkcode ltr}.)
|
|
1467
1370
|
*/
|
|
1468
|
-
function outside(version, range, hilo,
|
|
1469
|
-
version = new SemVer(version,
|
|
1470
|
-
range = new Range(range,
|
|
1371
|
+
function outside(version, range, hilo, options) {
|
|
1372
|
+
version = new SemVer(version, options);
|
|
1373
|
+
range = new Range(range, options);
|
|
1471
1374
|
let gtfn;
|
|
1472
1375
|
let ltefn;
|
|
1473
1376
|
let ltfn;
|
|
@@ -1492,7 +1395,7 @@ function outside(version, range, hilo, optionsOrLoose) {
|
|
|
1492
1395
|
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
1493
1396
|
}
|
|
1494
1397
|
// If it satisifes the range it is not outside
|
|
1495
|
-
if (satisfies(version, range,
|
|
1398
|
+
if (satisfies(version, range, options)) {
|
|
1496
1399
|
return false;
|
|
1497
1400
|
}
|
|
1498
1401
|
// From now on, variable terms are as if we're in "gtr" mode.
|
|
@@ -1507,10 +1410,10 @@ function outside(version, range, hilo, optionsOrLoose) {
|
|
|
1507
1410
|
}
|
|
1508
1411
|
high = high || comparator;
|
|
1509
1412
|
low = low || comparator;
|
|
1510
|
-
if (gtfn(comparator.semver, high.semver,
|
|
1413
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
1511
1414
|
high = comparator;
|
|
1512
1415
|
}
|
|
1513
|
-
else if (ltfn(comparator.semver, low.semver,
|
|
1416
|
+
else if (ltfn(comparator.semver, low.semver, options)) {
|
|
1514
1417
|
low = comparator;
|
|
1515
1418
|
}
|
|
1516
1419
|
}
|
|
@@ -1534,35 +1437,22 @@ function outside(version, range, hilo, optionsOrLoose) {
|
|
|
1534
1437
|
return true;
|
|
1535
1438
|
}
|
|
1536
1439
|
exports.outside = outside;
|
|
1537
|
-
|
|
1538
|
-
|
|
1440
|
+
/**
|
|
1441
|
+
* Returns an array of prerelease components, or null if none exist.
|
|
1442
|
+
*
|
|
1443
|
+
* @example
|
|
1444
|
+
* `prerelease("1.2.3-alpha.1") -> ["alpha", 1]`
|
|
1445
|
+
*/
|
|
1446
|
+
function prerelease(version, options) {
|
|
1447
|
+
const parsed = parse(version, options);
|
|
1539
1448
|
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
1540
1449
|
}
|
|
1541
1450
|
exports.prerelease = prerelease;
|
|
1542
|
-
/**
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
range1 = new Range(range1, optionsOrLoose);
|
|
1547
|
-
range2 = new Range(range2, optionsOrLoose);
|
|
1451
|
+
/** Returns true if the two supplied ranges or comparators intersect. */
|
|
1452
|
+
function intersects(range1, range2, options) {
|
|
1453
|
+
range1 = new Range(range1, options);
|
|
1454
|
+
range2 = new Range(range2, options);
|
|
1548
1455
|
return range1.intersects(range2);
|
|
1549
1456
|
}
|
|
1550
1457
|
exports.intersects = intersects;
|
|
1551
|
-
/**
|
|
1552
|
-
* Coerces a string to semver if possible
|
|
1553
|
-
*/
|
|
1554
|
-
function coerce(version, optionsOrLoose) {
|
|
1555
|
-
if (version instanceof SemVer) {
|
|
1556
|
-
return version;
|
|
1557
|
-
}
|
|
1558
|
-
if (typeof version !== "string") {
|
|
1559
|
-
return null;
|
|
1560
|
-
}
|
|
1561
|
-
const match = version.match(re[COERCE]);
|
|
1562
|
-
if (match == null) {
|
|
1563
|
-
return null;
|
|
1564
|
-
}
|
|
1565
|
-
return parse(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0"), optionsOrLoose);
|
|
1566
|
-
}
|
|
1567
|
-
exports.coerce = coerce;
|
|
1568
1458
|
exports.default = SemVer;
|