@enke.dev/bumper 0.0.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/LICENSE +21 -0
- package/README.md +137 -0
- package/dist/cli.mjs +2924 -0
- package/package.json +60 -0
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,2924 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
|
|
34
|
+
// node_modules/semver/internal/constants.js
|
|
35
|
+
var require_constants = __commonJS((exports, module) => {
|
|
36
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
37
|
+
var MAX_LENGTH = 256;
|
|
38
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
39
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
40
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
41
|
+
var RELEASE_TYPES = [
|
|
42
|
+
"major",
|
|
43
|
+
"premajor",
|
|
44
|
+
"minor",
|
|
45
|
+
"preminor",
|
|
46
|
+
"patch",
|
|
47
|
+
"prepatch",
|
|
48
|
+
"prerelease"
|
|
49
|
+
];
|
|
50
|
+
module.exports = {
|
|
51
|
+
MAX_LENGTH,
|
|
52
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
53
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
54
|
+
MAX_SAFE_INTEGER,
|
|
55
|
+
RELEASE_TYPES,
|
|
56
|
+
SEMVER_SPEC_VERSION,
|
|
57
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
58
|
+
FLAG_LOOSE: 2
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// node_modules/semver/internal/debug.js
|
|
63
|
+
var require_debug = __commonJS((exports, module) => {
|
|
64
|
+
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
65
|
+
module.exports = debug;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// node_modules/semver/internal/re.js
|
|
69
|
+
var require_re = __commonJS((exports, module) => {
|
|
70
|
+
var {
|
|
71
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
72
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
73
|
+
MAX_LENGTH
|
|
74
|
+
} = require_constants();
|
|
75
|
+
var debug = require_debug();
|
|
76
|
+
exports = module.exports = {};
|
|
77
|
+
var re = exports.re = [];
|
|
78
|
+
var safeRe = exports.safeRe = [];
|
|
79
|
+
var src = exports.src = [];
|
|
80
|
+
var safeSrc = exports.safeSrc = [];
|
|
81
|
+
var t = exports.t = {};
|
|
82
|
+
var R = 0;
|
|
83
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
84
|
+
var safeRegexReplacements = [
|
|
85
|
+
["\\s", 1],
|
|
86
|
+
["\\d", MAX_LENGTH],
|
|
87
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
88
|
+
];
|
|
89
|
+
var makeSafeRegex = (value) => {
|
|
90
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
91
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
};
|
|
95
|
+
var createToken = (name, value, isGlobal) => {
|
|
96
|
+
const safe = makeSafeRegex(value);
|
|
97
|
+
const index = R++;
|
|
98
|
+
debug(name, index, value);
|
|
99
|
+
t[name] = index;
|
|
100
|
+
src[index] = value;
|
|
101
|
+
safeSrc[index] = safe;
|
|
102
|
+
re[index] = new RegExp(value, isGlobal ? "g" : undefined);
|
|
103
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : undefined);
|
|
104
|
+
};
|
|
105
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
106
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
107
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
108
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
|
|
109
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
110
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
111
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
112
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
113
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
114
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
115
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
116
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
117
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
118
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
119
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
120
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
121
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
122
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
123
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
124
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
125
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
126
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
127
|
+
createToken("COERCEPLAIN", `${"(^|[^\\d])" + "(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
128
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
129
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?` + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`);
|
|
130
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
131
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
132
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
133
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
134
|
+
exports.tildeTrimReplace = "$1~";
|
|
135
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
136
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
137
|
+
createToken("LONECARET", "(?:\\^)");
|
|
138
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
139
|
+
exports.caretTrimReplace = "$1^";
|
|
140
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
141
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
142
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
143
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
144
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
145
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
146
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
|
|
147
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`);
|
|
148
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
149
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
150
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// node_modules/semver/internal/parse-options.js
|
|
154
|
+
var require_parse_options = __commonJS((exports, module) => {
|
|
155
|
+
var looseOption = Object.freeze({ loose: true });
|
|
156
|
+
var emptyOpts = Object.freeze({});
|
|
157
|
+
var parseOptions = (options) => {
|
|
158
|
+
if (!options) {
|
|
159
|
+
return emptyOpts;
|
|
160
|
+
}
|
|
161
|
+
if (typeof options !== "object") {
|
|
162
|
+
return looseOption;
|
|
163
|
+
}
|
|
164
|
+
return options;
|
|
165
|
+
};
|
|
166
|
+
module.exports = parseOptions;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// node_modules/semver/internal/identifiers.js
|
|
170
|
+
var require_identifiers = __commonJS((exports, module) => {
|
|
171
|
+
var numeric = /^[0-9]+$/;
|
|
172
|
+
var compareIdentifiers = (a, b) => {
|
|
173
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
174
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
175
|
+
}
|
|
176
|
+
const anum = numeric.test(a);
|
|
177
|
+
const bnum = numeric.test(b);
|
|
178
|
+
if (anum && bnum) {
|
|
179
|
+
a = +a;
|
|
180
|
+
b = +b;
|
|
181
|
+
}
|
|
182
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
183
|
+
};
|
|
184
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
185
|
+
module.exports = {
|
|
186
|
+
compareIdentifiers,
|
|
187
|
+
rcompareIdentifiers
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// node_modules/semver/classes/semver.js
|
|
192
|
+
var require_semver = __commonJS((exports, module) => {
|
|
193
|
+
var debug = require_debug();
|
|
194
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
195
|
+
var { safeRe: re, t } = require_re();
|
|
196
|
+
var parseOptions = require_parse_options();
|
|
197
|
+
var { compareIdentifiers } = require_identifiers();
|
|
198
|
+
var isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
199
|
+
const identifiers = identifier.split(".");
|
|
200
|
+
if (identifiers.length > prerelease.length) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
for (let i = 0;i < identifiers.length; i++) {
|
|
204
|
+
if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return true;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
class SemVer {
|
|
212
|
+
constructor(version, options) {
|
|
213
|
+
options = parseOptions(options);
|
|
214
|
+
if (version instanceof SemVer) {
|
|
215
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
216
|
+
return version;
|
|
217
|
+
} else {
|
|
218
|
+
version = version.version;
|
|
219
|
+
}
|
|
220
|
+
} else if (typeof version !== "string") {
|
|
221
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
222
|
+
}
|
|
223
|
+
if (version.length > MAX_LENGTH) {
|
|
224
|
+
throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
225
|
+
}
|
|
226
|
+
debug("SemVer", version, options);
|
|
227
|
+
this.options = options;
|
|
228
|
+
this.loose = !!options.loose;
|
|
229
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
230
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
231
|
+
if (!m) {
|
|
232
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
233
|
+
}
|
|
234
|
+
this.raw = version;
|
|
235
|
+
this.major = +m[1];
|
|
236
|
+
this.minor = +m[2];
|
|
237
|
+
this.patch = +m[3];
|
|
238
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
239
|
+
throw new TypeError("Invalid major version");
|
|
240
|
+
}
|
|
241
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
242
|
+
throw new TypeError("Invalid minor version");
|
|
243
|
+
}
|
|
244
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
245
|
+
throw new TypeError("Invalid patch version");
|
|
246
|
+
}
|
|
247
|
+
if (!m[4]) {
|
|
248
|
+
this.prerelease = [];
|
|
249
|
+
} else {
|
|
250
|
+
this.prerelease = m[4].split(".").map((id) => {
|
|
251
|
+
if (/^[0-9]+$/.test(id)) {
|
|
252
|
+
const num = +id;
|
|
253
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
254
|
+
return num;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return id;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
261
|
+
this.format();
|
|
262
|
+
}
|
|
263
|
+
format() {
|
|
264
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
265
|
+
if (this.prerelease.length) {
|
|
266
|
+
this.version += `-${this.prerelease.join(".")}`;
|
|
267
|
+
}
|
|
268
|
+
return this.version;
|
|
269
|
+
}
|
|
270
|
+
toString() {
|
|
271
|
+
return this.version;
|
|
272
|
+
}
|
|
273
|
+
compare(other) {
|
|
274
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
275
|
+
if (!(other instanceof SemVer)) {
|
|
276
|
+
if (typeof other === "string" && other === this.version) {
|
|
277
|
+
return 0;
|
|
278
|
+
}
|
|
279
|
+
other = new SemVer(other, this.options);
|
|
280
|
+
}
|
|
281
|
+
if (other.version === this.version) {
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
285
|
+
}
|
|
286
|
+
compareMain(other) {
|
|
287
|
+
if (!(other instanceof SemVer)) {
|
|
288
|
+
other = new SemVer(other, this.options);
|
|
289
|
+
}
|
|
290
|
+
if (this.major < other.major) {
|
|
291
|
+
return -1;
|
|
292
|
+
}
|
|
293
|
+
if (this.major > other.major) {
|
|
294
|
+
return 1;
|
|
295
|
+
}
|
|
296
|
+
if (this.minor < other.minor) {
|
|
297
|
+
return -1;
|
|
298
|
+
}
|
|
299
|
+
if (this.minor > other.minor) {
|
|
300
|
+
return 1;
|
|
301
|
+
}
|
|
302
|
+
if (this.patch < other.patch) {
|
|
303
|
+
return -1;
|
|
304
|
+
}
|
|
305
|
+
if (this.patch > other.patch) {
|
|
306
|
+
return 1;
|
|
307
|
+
}
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
310
|
+
comparePre(other) {
|
|
311
|
+
if (!(other instanceof SemVer)) {
|
|
312
|
+
other = new SemVer(other, this.options);
|
|
313
|
+
}
|
|
314
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
315
|
+
return -1;
|
|
316
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
317
|
+
return 1;
|
|
318
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
319
|
+
return 0;
|
|
320
|
+
}
|
|
321
|
+
let i = 0;
|
|
322
|
+
do {
|
|
323
|
+
const a = this.prerelease[i];
|
|
324
|
+
const b = other.prerelease[i];
|
|
325
|
+
debug("prerelease compare", i, a, b);
|
|
326
|
+
if (a === undefined && b === undefined) {
|
|
327
|
+
return 0;
|
|
328
|
+
} else if (b === undefined) {
|
|
329
|
+
return 1;
|
|
330
|
+
} else if (a === undefined) {
|
|
331
|
+
return -1;
|
|
332
|
+
} else if (a === b) {
|
|
333
|
+
continue;
|
|
334
|
+
} else {
|
|
335
|
+
return compareIdentifiers(a, b);
|
|
336
|
+
}
|
|
337
|
+
} while (++i);
|
|
338
|
+
}
|
|
339
|
+
compareBuild(other) {
|
|
340
|
+
if (!(other instanceof SemVer)) {
|
|
341
|
+
other = new SemVer(other, this.options);
|
|
342
|
+
}
|
|
343
|
+
let i = 0;
|
|
344
|
+
do {
|
|
345
|
+
const a = this.build[i];
|
|
346
|
+
const b = other.build[i];
|
|
347
|
+
debug("build compare", i, a, b);
|
|
348
|
+
if (a === undefined && b === undefined) {
|
|
349
|
+
return 0;
|
|
350
|
+
} else if (b === undefined) {
|
|
351
|
+
return 1;
|
|
352
|
+
} else if (a === undefined) {
|
|
353
|
+
return -1;
|
|
354
|
+
} else if (a === b) {
|
|
355
|
+
continue;
|
|
356
|
+
} else {
|
|
357
|
+
return compareIdentifiers(a, b);
|
|
358
|
+
}
|
|
359
|
+
} while (++i);
|
|
360
|
+
}
|
|
361
|
+
inc(release, identifier, identifierBase) {
|
|
362
|
+
if (release.startsWith("pre")) {
|
|
363
|
+
if (!identifier && identifierBase === false) {
|
|
364
|
+
throw new Error("invalid increment argument: identifier is empty");
|
|
365
|
+
}
|
|
366
|
+
if (identifier) {
|
|
367
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
368
|
+
if (!match || match[1] !== identifier) {
|
|
369
|
+
throw new Error(`invalid identifier: ${identifier}`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
switch (release) {
|
|
374
|
+
case "premajor":
|
|
375
|
+
this.prerelease.length = 0;
|
|
376
|
+
this.patch = 0;
|
|
377
|
+
this.minor = 0;
|
|
378
|
+
this.major++;
|
|
379
|
+
this.inc("pre", identifier, identifierBase);
|
|
380
|
+
break;
|
|
381
|
+
case "preminor":
|
|
382
|
+
this.prerelease.length = 0;
|
|
383
|
+
this.patch = 0;
|
|
384
|
+
this.minor++;
|
|
385
|
+
this.inc("pre", identifier, identifierBase);
|
|
386
|
+
break;
|
|
387
|
+
case "prepatch":
|
|
388
|
+
this.prerelease.length = 0;
|
|
389
|
+
this.inc("patch", identifier, identifierBase);
|
|
390
|
+
this.inc("pre", identifier, identifierBase);
|
|
391
|
+
break;
|
|
392
|
+
case "prerelease":
|
|
393
|
+
if (this.prerelease.length === 0) {
|
|
394
|
+
this.inc("patch", identifier, identifierBase);
|
|
395
|
+
}
|
|
396
|
+
this.inc("pre", identifier, identifierBase);
|
|
397
|
+
break;
|
|
398
|
+
case "release":
|
|
399
|
+
if (this.prerelease.length === 0) {
|
|
400
|
+
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
401
|
+
}
|
|
402
|
+
this.prerelease.length = 0;
|
|
403
|
+
break;
|
|
404
|
+
case "major":
|
|
405
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
406
|
+
this.major++;
|
|
407
|
+
}
|
|
408
|
+
this.minor = 0;
|
|
409
|
+
this.patch = 0;
|
|
410
|
+
this.prerelease = [];
|
|
411
|
+
break;
|
|
412
|
+
case "minor":
|
|
413
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
414
|
+
this.minor++;
|
|
415
|
+
}
|
|
416
|
+
this.patch = 0;
|
|
417
|
+
this.prerelease = [];
|
|
418
|
+
break;
|
|
419
|
+
case "patch":
|
|
420
|
+
if (this.prerelease.length === 0) {
|
|
421
|
+
this.patch++;
|
|
422
|
+
}
|
|
423
|
+
this.prerelease = [];
|
|
424
|
+
break;
|
|
425
|
+
case "pre": {
|
|
426
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
427
|
+
if (this.prerelease.length === 0) {
|
|
428
|
+
this.prerelease = [base];
|
|
429
|
+
} else {
|
|
430
|
+
let i = this.prerelease.length;
|
|
431
|
+
while (--i >= 0) {
|
|
432
|
+
if (typeof this.prerelease[i] === "number") {
|
|
433
|
+
this.prerelease[i]++;
|
|
434
|
+
i = -2;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (i === -1) {
|
|
438
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
439
|
+
throw new Error("invalid increment argument: identifier already exists");
|
|
440
|
+
}
|
|
441
|
+
this.prerelease.push(base);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (identifier) {
|
|
445
|
+
let prerelease = [identifier, base];
|
|
446
|
+
if (identifierBase === false) {
|
|
447
|
+
prerelease = [identifier];
|
|
448
|
+
}
|
|
449
|
+
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
450
|
+
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
451
|
+
if (isNaN(prereleaseBase)) {
|
|
452
|
+
this.prerelease = prerelease;
|
|
453
|
+
}
|
|
454
|
+
} else {
|
|
455
|
+
this.prerelease = prerelease;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
default:
|
|
461
|
+
throw new Error(`invalid increment argument: ${release}`);
|
|
462
|
+
}
|
|
463
|
+
this.raw = this.format();
|
|
464
|
+
if (this.build.length) {
|
|
465
|
+
this.raw += `+${this.build.join(".")}`;
|
|
466
|
+
}
|
|
467
|
+
return this;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
module.exports = SemVer;
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
// node_modules/semver/functions/parse.js
|
|
474
|
+
var require_parse = __commonJS((exports, module) => {
|
|
475
|
+
var SemVer = require_semver();
|
|
476
|
+
var parse = (version, options, throwErrors = false) => {
|
|
477
|
+
if (version instanceof SemVer) {
|
|
478
|
+
return version;
|
|
479
|
+
}
|
|
480
|
+
try {
|
|
481
|
+
return new SemVer(version, options);
|
|
482
|
+
} catch (er) {
|
|
483
|
+
if (!throwErrors) {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
throw er;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
module.exports = parse;
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// node_modules/semver/functions/valid.js
|
|
493
|
+
var require_valid = __commonJS((exports, module) => {
|
|
494
|
+
var parse = require_parse();
|
|
495
|
+
var valid = (version, options) => {
|
|
496
|
+
const v = parse(version, options);
|
|
497
|
+
return v ? v.version : null;
|
|
498
|
+
};
|
|
499
|
+
module.exports = valid;
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
// node_modules/semver/functions/clean.js
|
|
503
|
+
var require_clean = __commonJS((exports, module) => {
|
|
504
|
+
var parse = require_parse();
|
|
505
|
+
var clean = (version, options) => {
|
|
506
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
507
|
+
return s ? s.version : null;
|
|
508
|
+
};
|
|
509
|
+
module.exports = clean;
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// node_modules/semver/functions/inc.js
|
|
513
|
+
var require_inc = __commonJS((exports, module) => {
|
|
514
|
+
var SemVer = require_semver();
|
|
515
|
+
var inc = (version, release, options, identifier, identifierBase) => {
|
|
516
|
+
if (typeof options === "string") {
|
|
517
|
+
identifierBase = identifier;
|
|
518
|
+
identifier = options;
|
|
519
|
+
options = undefined;
|
|
520
|
+
}
|
|
521
|
+
try {
|
|
522
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
523
|
+
} catch (er) {
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
module.exports = inc;
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// node_modules/semver/functions/diff.js
|
|
531
|
+
var require_diff = __commonJS((exports, module) => {
|
|
532
|
+
var parse = require_parse();
|
|
533
|
+
var diff = (version1, version2) => {
|
|
534
|
+
const v1 = parse(version1, null, true);
|
|
535
|
+
const v2 = parse(version2, null, true);
|
|
536
|
+
const comparison = v1.compare(v2);
|
|
537
|
+
if (comparison === 0) {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
const v1Higher = comparison > 0;
|
|
541
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
542
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
543
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
544
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
545
|
+
if (lowHasPre && !highHasPre) {
|
|
546
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
547
|
+
return "major";
|
|
548
|
+
}
|
|
549
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
550
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
551
|
+
return "minor";
|
|
552
|
+
}
|
|
553
|
+
return "patch";
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
const prefix = highHasPre ? "pre" : "";
|
|
557
|
+
if (v1.major !== v2.major) {
|
|
558
|
+
return prefix + "major";
|
|
559
|
+
}
|
|
560
|
+
if (v1.minor !== v2.minor) {
|
|
561
|
+
return prefix + "minor";
|
|
562
|
+
}
|
|
563
|
+
if (v1.patch !== v2.patch) {
|
|
564
|
+
return prefix + "patch";
|
|
565
|
+
}
|
|
566
|
+
return "prerelease";
|
|
567
|
+
};
|
|
568
|
+
module.exports = diff;
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// node_modules/semver/functions/major.js
|
|
572
|
+
var require_major = __commonJS((exports, module) => {
|
|
573
|
+
var SemVer = require_semver();
|
|
574
|
+
var major = (a, loose) => new SemVer(a, loose).major;
|
|
575
|
+
module.exports = major;
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
// node_modules/semver/functions/minor.js
|
|
579
|
+
var require_minor = __commonJS((exports, module) => {
|
|
580
|
+
var SemVer = require_semver();
|
|
581
|
+
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
582
|
+
module.exports = minor;
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
// node_modules/semver/functions/patch.js
|
|
586
|
+
var require_patch = __commonJS((exports, module) => {
|
|
587
|
+
var SemVer = require_semver();
|
|
588
|
+
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
589
|
+
module.exports = patch;
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
// node_modules/semver/functions/prerelease.js
|
|
593
|
+
var require_prerelease = __commonJS((exports, module) => {
|
|
594
|
+
var parse = require_parse();
|
|
595
|
+
var prerelease = (version, options) => {
|
|
596
|
+
const parsed = parse(version, options);
|
|
597
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
598
|
+
};
|
|
599
|
+
module.exports = prerelease;
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// node_modules/semver/functions/compare.js
|
|
603
|
+
var require_compare = __commonJS((exports, module) => {
|
|
604
|
+
var SemVer = require_semver();
|
|
605
|
+
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
606
|
+
module.exports = compare;
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// node_modules/semver/functions/rcompare.js
|
|
610
|
+
var require_rcompare = __commonJS((exports, module) => {
|
|
611
|
+
var compare = require_compare();
|
|
612
|
+
var rcompare = (a, b, loose) => compare(b, a, loose);
|
|
613
|
+
module.exports = rcompare;
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
// node_modules/semver/functions/compare-loose.js
|
|
617
|
+
var require_compare_loose = __commonJS((exports, module) => {
|
|
618
|
+
var compare = require_compare();
|
|
619
|
+
var compareLoose = (a, b) => compare(a, b, true);
|
|
620
|
+
module.exports = compareLoose;
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
// node_modules/semver/functions/compare-build.js
|
|
624
|
+
var require_compare_build = __commonJS((exports, module) => {
|
|
625
|
+
var SemVer = require_semver();
|
|
626
|
+
var compareBuild = (a, b, loose) => {
|
|
627
|
+
const versionA = new SemVer(a, loose);
|
|
628
|
+
const versionB = new SemVer(b, loose);
|
|
629
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
630
|
+
};
|
|
631
|
+
module.exports = compareBuild;
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
// node_modules/semver/functions/sort.js
|
|
635
|
+
var require_sort = __commonJS((exports, module) => {
|
|
636
|
+
var compareBuild = require_compare_build();
|
|
637
|
+
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
638
|
+
module.exports = sort;
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// node_modules/semver/functions/rsort.js
|
|
642
|
+
var require_rsort = __commonJS((exports, module) => {
|
|
643
|
+
var compareBuild = require_compare_build();
|
|
644
|
+
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
645
|
+
module.exports = rsort;
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
// node_modules/semver/functions/gt.js
|
|
649
|
+
var require_gt = __commonJS((exports, module) => {
|
|
650
|
+
var compare = require_compare();
|
|
651
|
+
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
652
|
+
module.exports = gt;
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
// node_modules/semver/functions/lt.js
|
|
656
|
+
var require_lt = __commonJS((exports, module) => {
|
|
657
|
+
var compare = require_compare();
|
|
658
|
+
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
659
|
+
module.exports = lt;
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
// node_modules/semver/functions/eq.js
|
|
663
|
+
var require_eq = __commonJS((exports, module) => {
|
|
664
|
+
var compare = require_compare();
|
|
665
|
+
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
666
|
+
module.exports = eq;
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
// node_modules/semver/functions/neq.js
|
|
670
|
+
var require_neq = __commonJS((exports, module) => {
|
|
671
|
+
var compare = require_compare();
|
|
672
|
+
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
673
|
+
module.exports = neq;
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
// node_modules/semver/functions/gte.js
|
|
677
|
+
var require_gte = __commonJS((exports, module) => {
|
|
678
|
+
var compare = require_compare();
|
|
679
|
+
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
680
|
+
module.exports = gte;
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
// node_modules/semver/functions/lte.js
|
|
684
|
+
var require_lte = __commonJS((exports, module) => {
|
|
685
|
+
var compare = require_compare();
|
|
686
|
+
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
687
|
+
module.exports = lte;
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
// node_modules/semver/functions/cmp.js
|
|
691
|
+
var require_cmp = __commonJS((exports, module) => {
|
|
692
|
+
var eq = require_eq();
|
|
693
|
+
var neq = require_neq();
|
|
694
|
+
var gt = require_gt();
|
|
695
|
+
var gte = require_gte();
|
|
696
|
+
var lt = require_lt();
|
|
697
|
+
var lte = require_lte();
|
|
698
|
+
var cmp = (a, op, b, loose) => {
|
|
699
|
+
switch (op) {
|
|
700
|
+
case "===":
|
|
701
|
+
if (typeof a === "object") {
|
|
702
|
+
a = a.version;
|
|
703
|
+
}
|
|
704
|
+
if (typeof b === "object") {
|
|
705
|
+
b = b.version;
|
|
706
|
+
}
|
|
707
|
+
return a === b;
|
|
708
|
+
case "!==":
|
|
709
|
+
if (typeof a === "object") {
|
|
710
|
+
a = a.version;
|
|
711
|
+
}
|
|
712
|
+
if (typeof b === "object") {
|
|
713
|
+
b = b.version;
|
|
714
|
+
}
|
|
715
|
+
return a !== b;
|
|
716
|
+
case "":
|
|
717
|
+
case "=":
|
|
718
|
+
case "==":
|
|
719
|
+
return eq(a, b, loose);
|
|
720
|
+
case "!=":
|
|
721
|
+
return neq(a, b, loose);
|
|
722
|
+
case ">":
|
|
723
|
+
return gt(a, b, loose);
|
|
724
|
+
case ">=":
|
|
725
|
+
return gte(a, b, loose);
|
|
726
|
+
case "<":
|
|
727
|
+
return lt(a, b, loose);
|
|
728
|
+
case "<=":
|
|
729
|
+
return lte(a, b, loose);
|
|
730
|
+
default:
|
|
731
|
+
throw new TypeError(`Invalid operator: ${op}`);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
module.exports = cmp;
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
// node_modules/semver/functions/coerce.js
|
|
738
|
+
var require_coerce = __commonJS((exports, module) => {
|
|
739
|
+
var SemVer = require_semver();
|
|
740
|
+
var parse = require_parse();
|
|
741
|
+
var { safeRe: re, t } = require_re();
|
|
742
|
+
var coerce = (version, options) => {
|
|
743
|
+
if (version instanceof SemVer) {
|
|
744
|
+
return version;
|
|
745
|
+
}
|
|
746
|
+
if (typeof version === "number") {
|
|
747
|
+
version = String(version);
|
|
748
|
+
}
|
|
749
|
+
if (typeof version !== "string") {
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
options = options || {};
|
|
753
|
+
let match = null;
|
|
754
|
+
if (!options.rtl) {
|
|
755
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
756
|
+
} else {
|
|
757
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
758
|
+
let next;
|
|
759
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
760
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
761
|
+
match = next;
|
|
762
|
+
}
|
|
763
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
764
|
+
}
|
|
765
|
+
coerceRtlRegex.lastIndex = -1;
|
|
766
|
+
}
|
|
767
|
+
if (match === null) {
|
|
768
|
+
return null;
|
|
769
|
+
}
|
|
770
|
+
const major = match[2];
|
|
771
|
+
const minor = match[3] || "0";
|
|
772
|
+
const patch = match[4] || "0";
|
|
773
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
|
|
774
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
|
|
775
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
776
|
+
};
|
|
777
|
+
module.exports = coerce;
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
// node_modules/semver/functions/truncate.js
|
|
781
|
+
var require_truncate = __commonJS((exports, module) => {
|
|
782
|
+
var parse = require_parse();
|
|
783
|
+
var constants2 = require_constants();
|
|
784
|
+
var SemVer = require_semver();
|
|
785
|
+
var truncate = (version, truncation, options) => {
|
|
786
|
+
if (!constants2.RELEASE_TYPES.includes(truncation)) {
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
790
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
791
|
+
};
|
|
792
|
+
var cloneInputVersion = (version, options) => {
|
|
793
|
+
const versionStringToParse = version instanceof SemVer ? version.version : version;
|
|
794
|
+
return parse(versionStringToParse, options);
|
|
795
|
+
};
|
|
796
|
+
var doTruncation = (version, truncation) => {
|
|
797
|
+
if (isPrerelease(truncation)) {
|
|
798
|
+
return version.version;
|
|
799
|
+
}
|
|
800
|
+
version.prerelease = [];
|
|
801
|
+
switch (truncation) {
|
|
802
|
+
case "major":
|
|
803
|
+
version.minor = 0;
|
|
804
|
+
version.patch = 0;
|
|
805
|
+
break;
|
|
806
|
+
case "minor":
|
|
807
|
+
version.patch = 0;
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
return version.format();
|
|
811
|
+
};
|
|
812
|
+
var isPrerelease = (type) => {
|
|
813
|
+
return type.startsWith("pre");
|
|
814
|
+
};
|
|
815
|
+
module.exports = truncate;
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
// node_modules/semver/internal/lrucache.js
|
|
819
|
+
var require_lrucache = __commonJS((exports, module) => {
|
|
820
|
+
class LRUCache {
|
|
821
|
+
constructor() {
|
|
822
|
+
this.max = 1000;
|
|
823
|
+
this.map = new Map;
|
|
824
|
+
}
|
|
825
|
+
get(key) {
|
|
826
|
+
const value = this.map.get(key);
|
|
827
|
+
if (value === undefined) {
|
|
828
|
+
return;
|
|
829
|
+
} else {
|
|
830
|
+
this.map.delete(key);
|
|
831
|
+
this.map.set(key, value);
|
|
832
|
+
return value;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
delete(key) {
|
|
836
|
+
return this.map.delete(key);
|
|
837
|
+
}
|
|
838
|
+
set(key, value) {
|
|
839
|
+
const deleted = this.delete(key);
|
|
840
|
+
if (!deleted && value !== undefined) {
|
|
841
|
+
if (this.map.size >= this.max) {
|
|
842
|
+
const firstKey = this.map.keys().next().value;
|
|
843
|
+
this.delete(firstKey);
|
|
844
|
+
}
|
|
845
|
+
this.map.set(key, value);
|
|
846
|
+
}
|
|
847
|
+
return this;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
module.exports = LRUCache;
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
// node_modules/semver/classes/range.js
|
|
854
|
+
var require_range = __commonJS((exports, module) => {
|
|
855
|
+
var SPACE_CHARACTERS = /\s+/g;
|
|
856
|
+
|
|
857
|
+
class Range {
|
|
858
|
+
constructor(range, options) {
|
|
859
|
+
options = parseOptions(options);
|
|
860
|
+
if (range instanceof Range) {
|
|
861
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
862
|
+
return range;
|
|
863
|
+
} else {
|
|
864
|
+
return new Range(range.raw, options);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (range instanceof Comparator) {
|
|
868
|
+
this.raw = range.value;
|
|
869
|
+
this.set = [[range]];
|
|
870
|
+
this.formatted = undefined;
|
|
871
|
+
return this;
|
|
872
|
+
}
|
|
873
|
+
this.options = options;
|
|
874
|
+
this.loose = !!options.loose;
|
|
875
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
876
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
877
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
878
|
+
if (!this.set.length) {
|
|
879
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
880
|
+
}
|
|
881
|
+
if (this.set.length > 1) {
|
|
882
|
+
const first = this.set[0];
|
|
883
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
884
|
+
if (this.set.length === 0) {
|
|
885
|
+
this.set = [first];
|
|
886
|
+
} else if (this.set.length > 1) {
|
|
887
|
+
for (const c of this.set) {
|
|
888
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
889
|
+
this.set = [c];
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
this.formatted = undefined;
|
|
896
|
+
}
|
|
897
|
+
get range() {
|
|
898
|
+
if (this.formatted === undefined) {
|
|
899
|
+
this.formatted = "";
|
|
900
|
+
for (let i = 0;i < this.set.length; i++) {
|
|
901
|
+
if (i > 0) {
|
|
902
|
+
this.formatted += "||";
|
|
903
|
+
}
|
|
904
|
+
const comps = this.set[i];
|
|
905
|
+
for (let k = 0;k < comps.length; k++) {
|
|
906
|
+
if (k > 0) {
|
|
907
|
+
this.formatted += " ";
|
|
908
|
+
}
|
|
909
|
+
this.formatted += comps[k].toString().trim();
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
return this.formatted;
|
|
914
|
+
}
|
|
915
|
+
format() {
|
|
916
|
+
return this.range;
|
|
917
|
+
}
|
|
918
|
+
toString() {
|
|
919
|
+
return this.range;
|
|
920
|
+
}
|
|
921
|
+
parseRange(range) {
|
|
922
|
+
range = range.replace(BUILDSTRIPRE, "");
|
|
923
|
+
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
924
|
+
const memoKey = memoOpts + ":" + range;
|
|
925
|
+
const cached = cache.get(memoKey);
|
|
926
|
+
if (cached) {
|
|
927
|
+
return cached;
|
|
928
|
+
}
|
|
929
|
+
const loose = this.options.loose;
|
|
930
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
931
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
932
|
+
debug("hyphen replace", range);
|
|
933
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
934
|
+
debug("comparator trim", range);
|
|
935
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
936
|
+
debug("tilde trim", range);
|
|
937
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
938
|
+
debug("caret trim", range);
|
|
939
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
940
|
+
if (loose) {
|
|
941
|
+
rangeList = rangeList.filter((comp) => {
|
|
942
|
+
debug("loose invalid filter", comp, this.options);
|
|
943
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
debug("range list", rangeList);
|
|
947
|
+
const rangeMap = new Map;
|
|
948
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
949
|
+
for (const comp of comparators) {
|
|
950
|
+
if (isNullSet(comp)) {
|
|
951
|
+
return [comp];
|
|
952
|
+
}
|
|
953
|
+
rangeMap.set(comp.value, comp);
|
|
954
|
+
}
|
|
955
|
+
if (rangeMap.size > 1 && rangeMap.has("")) {
|
|
956
|
+
rangeMap.delete("");
|
|
957
|
+
}
|
|
958
|
+
const result = [...rangeMap.values()];
|
|
959
|
+
cache.set(memoKey, result);
|
|
960
|
+
return result;
|
|
961
|
+
}
|
|
962
|
+
intersects(range, options) {
|
|
963
|
+
if (!(range instanceof Range)) {
|
|
964
|
+
throw new TypeError("a Range is required");
|
|
965
|
+
}
|
|
966
|
+
return this.set.some((thisComparators) => {
|
|
967
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
968
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
969
|
+
return rangeComparators.every((rangeComparator) => {
|
|
970
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
971
|
+
});
|
|
972
|
+
});
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
test(version) {
|
|
977
|
+
if (!version) {
|
|
978
|
+
return false;
|
|
979
|
+
}
|
|
980
|
+
if (typeof version === "string") {
|
|
981
|
+
try {
|
|
982
|
+
version = new SemVer(version, this.options);
|
|
983
|
+
} catch (er) {
|
|
984
|
+
return false;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
for (let i = 0;i < this.set.length; i++) {
|
|
988
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
989
|
+
return true;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
module.exports = Range;
|
|
996
|
+
var LRU = require_lrucache();
|
|
997
|
+
var cache = new LRU;
|
|
998
|
+
var parseOptions = require_parse_options();
|
|
999
|
+
var Comparator = require_comparator();
|
|
1000
|
+
var debug = require_debug();
|
|
1001
|
+
var SemVer = require_semver();
|
|
1002
|
+
var {
|
|
1003
|
+
safeRe: re,
|
|
1004
|
+
src,
|
|
1005
|
+
t,
|
|
1006
|
+
comparatorTrimReplace,
|
|
1007
|
+
tildeTrimReplace,
|
|
1008
|
+
caretTrimReplace
|
|
1009
|
+
} = require_re();
|
|
1010
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
1011
|
+
var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
1012
|
+
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
1013
|
+
var isAny = (c) => c.value === "";
|
|
1014
|
+
var isSatisfiable = (comparators, options) => {
|
|
1015
|
+
let result = true;
|
|
1016
|
+
const remainingComparators = comparators.slice();
|
|
1017
|
+
let testComparator = remainingComparators.pop();
|
|
1018
|
+
while (result && remainingComparators.length) {
|
|
1019
|
+
result = remainingComparators.every((otherComparator) => {
|
|
1020
|
+
return testComparator.intersects(otherComparator, options);
|
|
1021
|
+
});
|
|
1022
|
+
testComparator = remainingComparators.pop();
|
|
1023
|
+
}
|
|
1024
|
+
return result;
|
|
1025
|
+
};
|
|
1026
|
+
var parseComparator = (comp, options) => {
|
|
1027
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
1028
|
+
debug("comp", comp, options);
|
|
1029
|
+
comp = replaceCarets(comp, options);
|
|
1030
|
+
debug("caret", comp);
|
|
1031
|
+
comp = replaceTildes(comp, options);
|
|
1032
|
+
debug("tildes", comp);
|
|
1033
|
+
comp = replaceXRanges(comp, options);
|
|
1034
|
+
debug("xrange", comp);
|
|
1035
|
+
comp = replaceStars(comp, options);
|
|
1036
|
+
debug("stars", comp);
|
|
1037
|
+
return comp;
|
|
1038
|
+
};
|
|
1039
|
+
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
1040
|
+
var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
1041
|
+
var replaceTildes = (comp, options) => {
|
|
1042
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
1043
|
+
};
|
|
1044
|
+
var replaceTilde = (comp, options) => {
|
|
1045
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1046
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1047
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1048
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
1049
|
+
let ret;
|
|
1050
|
+
if (isX(M)) {
|
|
1051
|
+
ret = "";
|
|
1052
|
+
} else if (isX(m)) {
|
|
1053
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1054
|
+
} else if (isX(p)) {
|
|
1055
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1056
|
+
} else if (pr) {
|
|
1057
|
+
debug("replaceTilde pr", pr);
|
|
1058
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1059
|
+
} else {
|
|
1060
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1061
|
+
}
|
|
1062
|
+
debug("tilde return", ret);
|
|
1063
|
+
return ret;
|
|
1064
|
+
});
|
|
1065
|
+
};
|
|
1066
|
+
var replaceCarets = (comp, options) => {
|
|
1067
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
1068
|
+
};
|
|
1069
|
+
var replaceCaret = (comp, options) => {
|
|
1070
|
+
debug("caret", comp, options);
|
|
1071
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1072
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1073
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1074
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
1075
|
+
let ret;
|
|
1076
|
+
if (isX(M)) {
|
|
1077
|
+
ret = "";
|
|
1078
|
+
} else if (isX(m)) {
|
|
1079
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1080
|
+
} else if (isX(p)) {
|
|
1081
|
+
if (M === "0") {
|
|
1082
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1083
|
+
} else {
|
|
1084
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
1085
|
+
}
|
|
1086
|
+
} else if (pr) {
|
|
1087
|
+
debug("replaceCaret pr", pr);
|
|
1088
|
+
if (M === "0") {
|
|
1089
|
+
if (m === "0") {
|
|
1090
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1091
|
+
} else {
|
|
1092
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1093
|
+
}
|
|
1094
|
+
} else {
|
|
1095
|
+
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1096
|
+
}
|
|
1097
|
+
} else {
|
|
1098
|
+
debug("no pr");
|
|
1099
|
+
if (M === "0") {
|
|
1100
|
+
if (m === "0") {
|
|
1101
|
+
ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
1102
|
+
} else {
|
|
1103
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1104
|
+
}
|
|
1105
|
+
} else {
|
|
1106
|
+
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
debug("caret return", ret);
|
|
1110
|
+
return ret;
|
|
1111
|
+
});
|
|
1112
|
+
};
|
|
1113
|
+
var replaceXRanges = (comp, options) => {
|
|
1114
|
+
debug("replaceXRanges", comp, options);
|
|
1115
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
1116
|
+
};
|
|
1117
|
+
var replaceXRange = (comp, options) => {
|
|
1118
|
+
comp = comp.trim();
|
|
1119
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1120
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1121
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1122
|
+
if (invalidXRangeOrder(M, m, p)) {
|
|
1123
|
+
return comp;
|
|
1124
|
+
}
|
|
1125
|
+
const xM = isX(M);
|
|
1126
|
+
const xm = xM || isX(m);
|
|
1127
|
+
const xp = xm || isX(p);
|
|
1128
|
+
const anyX = xp;
|
|
1129
|
+
if (gtlt === "=" && anyX) {
|
|
1130
|
+
gtlt = "";
|
|
1131
|
+
}
|
|
1132
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
1133
|
+
if (xM) {
|
|
1134
|
+
if (gtlt === ">" || gtlt === "<") {
|
|
1135
|
+
ret = "<0.0.0-0";
|
|
1136
|
+
} else {
|
|
1137
|
+
ret = "*";
|
|
1138
|
+
}
|
|
1139
|
+
} else if (gtlt && anyX) {
|
|
1140
|
+
if (xm) {
|
|
1141
|
+
m = 0;
|
|
1142
|
+
}
|
|
1143
|
+
p = 0;
|
|
1144
|
+
if (gtlt === ">") {
|
|
1145
|
+
gtlt = ">=";
|
|
1146
|
+
if (xm) {
|
|
1147
|
+
M = +M + 1;
|
|
1148
|
+
m = 0;
|
|
1149
|
+
p = 0;
|
|
1150
|
+
} else {
|
|
1151
|
+
m = +m + 1;
|
|
1152
|
+
p = 0;
|
|
1153
|
+
}
|
|
1154
|
+
} else if (gtlt === "<=") {
|
|
1155
|
+
gtlt = "<";
|
|
1156
|
+
if (xm) {
|
|
1157
|
+
M = +M + 1;
|
|
1158
|
+
} else {
|
|
1159
|
+
m = +m + 1;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (gtlt === "<") {
|
|
1163
|
+
pr = "-0";
|
|
1164
|
+
}
|
|
1165
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
1166
|
+
} else if (xm) {
|
|
1167
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
1168
|
+
} else if (xp) {
|
|
1169
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
1170
|
+
}
|
|
1171
|
+
debug("xRange return", ret);
|
|
1172
|
+
return ret;
|
|
1173
|
+
});
|
|
1174
|
+
};
|
|
1175
|
+
var replaceStars = (comp, options) => {
|
|
1176
|
+
debug("replaceStars", comp, options);
|
|
1177
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
1178
|
+
};
|
|
1179
|
+
var replaceGTE0 = (comp, options) => {
|
|
1180
|
+
debug("replaceGTE0", comp, options);
|
|
1181
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
1182
|
+
};
|
|
1183
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
1184
|
+
if (isX(fM)) {
|
|
1185
|
+
from = "";
|
|
1186
|
+
} else if (isX(fm)) {
|
|
1187
|
+
from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
1188
|
+
} else if (isX(fp)) {
|
|
1189
|
+
from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
1190
|
+
} else if (fpr) {
|
|
1191
|
+
from = `>=${from}`;
|
|
1192
|
+
} else {
|
|
1193
|
+
from = `>=${from}${incPr ? "-0" : ""}`;
|
|
1194
|
+
}
|
|
1195
|
+
if (isX(tM)) {
|
|
1196
|
+
to = "";
|
|
1197
|
+
} else if (isX(tm)) {
|
|
1198
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
1199
|
+
} else if (isX(tp)) {
|
|
1200
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
1201
|
+
} else if (tpr) {
|
|
1202
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
1203
|
+
} else if (incPr) {
|
|
1204
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
1205
|
+
} else {
|
|
1206
|
+
to = `<=${to}`;
|
|
1207
|
+
}
|
|
1208
|
+
return `${from} ${to}`.trim();
|
|
1209
|
+
};
|
|
1210
|
+
var testSet = (set, version, options) => {
|
|
1211
|
+
for (let i = 0;i < set.length; i++) {
|
|
1212
|
+
if (!set[i].test(version)) {
|
|
1213
|
+
return false;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
1217
|
+
for (let i = 0;i < set.length; i++) {
|
|
1218
|
+
debug(set[i].semver);
|
|
1219
|
+
if (set[i].semver === Comparator.ANY) {
|
|
1220
|
+
continue;
|
|
1221
|
+
}
|
|
1222
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
1223
|
+
const allowed = set[i].semver;
|
|
1224
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
1225
|
+
return true;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
return false;
|
|
1230
|
+
}
|
|
1231
|
+
return true;
|
|
1232
|
+
};
|
|
1233
|
+
});
|
|
1234
|
+
|
|
1235
|
+
// node_modules/semver/classes/comparator.js
|
|
1236
|
+
var require_comparator = __commonJS((exports, module) => {
|
|
1237
|
+
var ANY = Symbol("SemVer ANY");
|
|
1238
|
+
|
|
1239
|
+
class Comparator {
|
|
1240
|
+
static get ANY() {
|
|
1241
|
+
return ANY;
|
|
1242
|
+
}
|
|
1243
|
+
constructor(comp, options) {
|
|
1244
|
+
options = parseOptions(options);
|
|
1245
|
+
if (comp instanceof Comparator) {
|
|
1246
|
+
if (comp.loose === !!options.loose) {
|
|
1247
|
+
return comp;
|
|
1248
|
+
} else {
|
|
1249
|
+
comp = comp.value;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
1253
|
+
debug("comparator", comp, options);
|
|
1254
|
+
this.options = options;
|
|
1255
|
+
this.loose = !!options.loose;
|
|
1256
|
+
this.parse(comp);
|
|
1257
|
+
if (this.semver === ANY) {
|
|
1258
|
+
this.value = "";
|
|
1259
|
+
} else {
|
|
1260
|
+
this.value = this.operator + this.semver.version;
|
|
1261
|
+
}
|
|
1262
|
+
debug("comp", this);
|
|
1263
|
+
}
|
|
1264
|
+
parse(comp) {
|
|
1265
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
1266
|
+
const m = comp.match(r);
|
|
1267
|
+
if (!m) {
|
|
1268
|
+
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
1269
|
+
}
|
|
1270
|
+
this.operator = m[1] !== undefined ? m[1] : "";
|
|
1271
|
+
if (this.operator === "=") {
|
|
1272
|
+
this.operator = "";
|
|
1273
|
+
}
|
|
1274
|
+
if (!m[2]) {
|
|
1275
|
+
this.semver = ANY;
|
|
1276
|
+
} else {
|
|
1277
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
toString() {
|
|
1281
|
+
return this.value;
|
|
1282
|
+
}
|
|
1283
|
+
test(version) {
|
|
1284
|
+
debug("Comparator.test", version, this.options.loose);
|
|
1285
|
+
if (this.semver === ANY || version === ANY) {
|
|
1286
|
+
return true;
|
|
1287
|
+
}
|
|
1288
|
+
if (typeof version === "string") {
|
|
1289
|
+
try {
|
|
1290
|
+
version = new SemVer(version, this.options);
|
|
1291
|
+
} catch (er) {
|
|
1292
|
+
return false;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
1296
|
+
}
|
|
1297
|
+
intersects(comp, options) {
|
|
1298
|
+
if (!(comp instanceof Comparator)) {
|
|
1299
|
+
throw new TypeError("a Comparator is required");
|
|
1300
|
+
}
|
|
1301
|
+
if (this.operator === "") {
|
|
1302
|
+
if (this.value === "") {
|
|
1303
|
+
return true;
|
|
1304
|
+
}
|
|
1305
|
+
return new Range(comp.value, options).test(this.value);
|
|
1306
|
+
} else if (comp.operator === "") {
|
|
1307
|
+
if (comp.value === "") {
|
|
1308
|
+
return true;
|
|
1309
|
+
}
|
|
1310
|
+
return new Range(this.value, options).test(comp.semver);
|
|
1311
|
+
}
|
|
1312
|
+
options = parseOptions(options);
|
|
1313
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
|
|
1314
|
+
return false;
|
|
1315
|
+
}
|
|
1316
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
|
|
1317
|
+
return false;
|
|
1318
|
+
}
|
|
1319
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
|
|
1320
|
+
return true;
|
|
1321
|
+
}
|
|
1322
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
|
|
1323
|
+
return true;
|
|
1324
|
+
}
|
|
1325
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
1326
|
+
return true;
|
|
1327
|
+
}
|
|
1328
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
1329
|
+
return true;
|
|
1330
|
+
}
|
|
1331
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
1332
|
+
return true;
|
|
1333
|
+
}
|
|
1334
|
+
return false;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
module.exports = Comparator;
|
|
1338
|
+
var parseOptions = require_parse_options();
|
|
1339
|
+
var { safeRe: re, t } = require_re();
|
|
1340
|
+
var cmp = require_cmp();
|
|
1341
|
+
var debug = require_debug();
|
|
1342
|
+
var SemVer = require_semver();
|
|
1343
|
+
var Range = require_range();
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// node_modules/semver/functions/satisfies.js
|
|
1347
|
+
var require_satisfies = __commonJS((exports, module) => {
|
|
1348
|
+
var Range = require_range();
|
|
1349
|
+
var satisfies = (version, range, options) => {
|
|
1350
|
+
try {
|
|
1351
|
+
range = new Range(range, options);
|
|
1352
|
+
} catch (er) {
|
|
1353
|
+
return false;
|
|
1354
|
+
}
|
|
1355
|
+
return range.test(version);
|
|
1356
|
+
};
|
|
1357
|
+
module.exports = satisfies;
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
// node_modules/semver/ranges/to-comparators.js
|
|
1361
|
+
var require_to_comparators = __commonJS((exports, module) => {
|
|
1362
|
+
var Range = require_range();
|
|
1363
|
+
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1364
|
+
module.exports = toComparators;
|
|
1365
|
+
});
|
|
1366
|
+
|
|
1367
|
+
// node_modules/semver/ranges/max-satisfying.js
|
|
1368
|
+
var require_max_satisfying = __commonJS((exports, module) => {
|
|
1369
|
+
var SemVer = require_semver();
|
|
1370
|
+
var Range = require_range();
|
|
1371
|
+
var maxSatisfying = (versions, range, options) => {
|
|
1372
|
+
let max = null;
|
|
1373
|
+
let maxSV = null;
|
|
1374
|
+
let rangeObj = null;
|
|
1375
|
+
try {
|
|
1376
|
+
rangeObj = new Range(range, options);
|
|
1377
|
+
} catch (er) {
|
|
1378
|
+
return null;
|
|
1379
|
+
}
|
|
1380
|
+
versions.forEach((v) => {
|
|
1381
|
+
if (rangeObj.test(v)) {
|
|
1382
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
1383
|
+
max = v;
|
|
1384
|
+
maxSV = new SemVer(max, options);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
return max;
|
|
1389
|
+
};
|
|
1390
|
+
module.exports = maxSatisfying;
|
|
1391
|
+
});
|
|
1392
|
+
|
|
1393
|
+
// node_modules/semver/ranges/min-satisfying.js
|
|
1394
|
+
var require_min_satisfying = __commonJS((exports, module) => {
|
|
1395
|
+
var SemVer = require_semver();
|
|
1396
|
+
var Range = require_range();
|
|
1397
|
+
var minSatisfying = (versions, range, options) => {
|
|
1398
|
+
let min = null;
|
|
1399
|
+
let minSV = null;
|
|
1400
|
+
let rangeObj = null;
|
|
1401
|
+
try {
|
|
1402
|
+
rangeObj = new Range(range, options);
|
|
1403
|
+
} catch (er) {
|
|
1404
|
+
return null;
|
|
1405
|
+
}
|
|
1406
|
+
versions.forEach((v) => {
|
|
1407
|
+
if (rangeObj.test(v)) {
|
|
1408
|
+
if (!min || minSV.compare(v) === 1) {
|
|
1409
|
+
min = v;
|
|
1410
|
+
minSV = new SemVer(min, options);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
return min;
|
|
1415
|
+
};
|
|
1416
|
+
module.exports = minSatisfying;
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
// node_modules/semver/ranges/min-version.js
|
|
1420
|
+
var require_min_version = __commonJS((exports, module) => {
|
|
1421
|
+
var SemVer = require_semver();
|
|
1422
|
+
var Range = require_range();
|
|
1423
|
+
var gt = require_gt();
|
|
1424
|
+
var minVersion = (range, loose) => {
|
|
1425
|
+
range = new Range(range, loose);
|
|
1426
|
+
let minver = new SemVer("0.0.0");
|
|
1427
|
+
if (range.test(minver)) {
|
|
1428
|
+
return minver;
|
|
1429
|
+
}
|
|
1430
|
+
minver = new SemVer("0.0.0-0");
|
|
1431
|
+
if (range.test(minver)) {
|
|
1432
|
+
return minver;
|
|
1433
|
+
}
|
|
1434
|
+
minver = null;
|
|
1435
|
+
for (let i = 0;i < range.set.length; ++i) {
|
|
1436
|
+
const comparators = range.set[i];
|
|
1437
|
+
let setMin = null;
|
|
1438
|
+
comparators.forEach((comparator) => {
|
|
1439
|
+
const compver = new SemVer(comparator.semver.version);
|
|
1440
|
+
switch (comparator.operator) {
|
|
1441
|
+
case ">":
|
|
1442
|
+
if (compver.prerelease.length === 0) {
|
|
1443
|
+
compver.patch++;
|
|
1444
|
+
} else {
|
|
1445
|
+
compver.prerelease.push(0);
|
|
1446
|
+
}
|
|
1447
|
+
compver.raw = compver.format();
|
|
1448
|
+
case "":
|
|
1449
|
+
case ">=":
|
|
1450
|
+
if (!setMin || gt(compver, setMin)) {
|
|
1451
|
+
setMin = compver;
|
|
1452
|
+
}
|
|
1453
|
+
break;
|
|
1454
|
+
case "<":
|
|
1455
|
+
case "<=":
|
|
1456
|
+
break;
|
|
1457
|
+
default:
|
|
1458
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
if (setMin && (!minver || gt(minver, setMin))) {
|
|
1462
|
+
minver = setMin;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
if (minver && range.test(minver)) {
|
|
1466
|
+
return minver;
|
|
1467
|
+
}
|
|
1468
|
+
return null;
|
|
1469
|
+
};
|
|
1470
|
+
module.exports = minVersion;
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
// node_modules/semver/ranges/valid.js
|
|
1474
|
+
var require_valid2 = __commonJS((exports, module) => {
|
|
1475
|
+
var Range = require_range();
|
|
1476
|
+
var validRange = (range, options) => {
|
|
1477
|
+
try {
|
|
1478
|
+
return new Range(range, options).range || "*";
|
|
1479
|
+
} catch (er) {
|
|
1480
|
+
return null;
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
module.exports = validRange;
|
|
1484
|
+
});
|
|
1485
|
+
|
|
1486
|
+
// node_modules/semver/ranges/outside.js
|
|
1487
|
+
var require_outside = __commonJS((exports, module) => {
|
|
1488
|
+
var SemVer = require_semver();
|
|
1489
|
+
var Comparator = require_comparator();
|
|
1490
|
+
var { ANY } = Comparator;
|
|
1491
|
+
var Range = require_range();
|
|
1492
|
+
var satisfies = require_satisfies();
|
|
1493
|
+
var gt = require_gt();
|
|
1494
|
+
var lt = require_lt();
|
|
1495
|
+
var lte = require_lte();
|
|
1496
|
+
var gte = require_gte();
|
|
1497
|
+
var outside = (version, range, hilo, options) => {
|
|
1498
|
+
version = new SemVer(version, options);
|
|
1499
|
+
range = new Range(range, options);
|
|
1500
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
1501
|
+
switch (hilo) {
|
|
1502
|
+
case ">":
|
|
1503
|
+
gtfn = gt;
|
|
1504
|
+
ltefn = lte;
|
|
1505
|
+
ltfn = lt;
|
|
1506
|
+
comp = ">";
|
|
1507
|
+
ecomp = ">=";
|
|
1508
|
+
break;
|
|
1509
|
+
case "<":
|
|
1510
|
+
gtfn = lt;
|
|
1511
|
+
ltefn = gte;
|
|
1512
|
+
ltfn = gt;
|
|
1513
|
+
comp = "<";
|
|
1514
|
+
ecomp = "<=";
|
|
1515
|
+
break;
|
|
1516
|
+
default:
|
|
1517
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
1518
|
+
}
|
|
1519
|
+
if (satisfies(version, range, options)) {
|
|
1520
|
+
return false;
|
|
1521
|
+
}
|
|
1522
|
+
for (let i = 0;i < range.set.length; ++i) {
|
|
1523
|
+
const comparators = range.set[i];
|
|
1524
|
+
let high = null;
|
|
1525
|
+
let low = null;
|
|
1526
|
+
comparators.forEach((comparator) => {
|
|
1527
|
+
if (comparator.semver === ANY) {
|
|
1528
|
+
comparator = new Comparator(">=0.0.0");
|
|
1529
|
+
}
|
|
1530
|
+
high = high || comparator;
|
|
1531
|
+
low = low || comparator;
|
|
1532
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
1533
|
+
high = comparator;
|
|
1534
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
1535
|
+
low = comparator;
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
1539
|
+
return false;
|
|
1540
|
+
}
|
|
1541
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
|
1542
|
+
return false;
|
|
1543
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
1544
|
+
return false;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
return true;
|
|
1548
|
+
};
|
|
1549
|
+
module.exports = outside;
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
// node_modules/semver/ranges/gtr.js
|
|
1553
|
+
var require_gtr = __commonJS((exports, module) => {
|
|
1554
|
+
var outside = require_outside();
|
|
1555
|
+
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1556
|
+
module.exports = gtr;
|
|
1557
|
+
});
|
|
1558
|
+
|
|
1559
|
+
// node_modules/semver/ranges/ltr.js
|
|
1560
|
+
var require_ltr = __commonJS((exports, module) => {
|
|
1561
|
+
var outside = require_outside();
|
|
1562
|
+
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1563
|
+
module.exports = ltr;
|
|
1564
|
+
});
|
|
1565
|
+
|
|
1566
|
+
// node_modules/semver/ranges/intersects.js
|
|
1567
|
+
var require_intersects = __commonJS((exports, module) => {
|
|
1568
|
+
var Range = require_range();
|
|
1569
|
+
var intersects = (r1, r2, options) => {
|
|
1570
|
+
r1 = new Range(r1, options);
|
|
1571
|
+
r2 = new Range(r2, options);
|
|
1572
|
+
return r1.intersects(r2, options);
|
|
1573
|
+
};
|
|
1574
|
+
module.exports = intersects;
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
// node_modules/semver/ranges/simplify.js
|
|
1578
|
+
var require_simplify = __commonJS((exports, module) => {
|
|
1579
|
+
var satisfies = require_satisfies();
|
|
1580
|
+
var compare = require_compare();
|
|
1581
|
+
module.exports = (versions, range, options) => {
|
|
1582
|
+
const set = [];
|
|
1583
|
+
let first = null;
|
|
1584
|
+
let prev = null;
|
|
1585
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
1586
|
+
for (const version of v) {
|
|
1587
|
+
const included = satisfies(version, range, options);
|
|
1588
|
+
if (included) {
|
|
1589
|
+
prev = version;
|
|
1590
|
+
if (!first) {
|
|
1591
|
+
first = version;
|
|
1592
|
+
}
|
|
1593
|
+
} else {
|
|
1594
|
+
if (prev) {
|
|
1595
|
+
set.push([first, prev]);
|
|
1596
|
+
}
|
|
1597
|
+
prev = null;
|
|
1598
|
+
first = null;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
if (first) {
|
|
1602
|
+
set.push([first, null]);
|
|
1603
|
+
}
|
|
1604
|
+
const ranges = [];
|
|
1605
|
+
for (const [min, max] of set) {
|
|
1606
|
+
if (min === max) {
|
|
1607
|
+
ranges.push(min);
|
|
1608
|
+
} else if (!max && min === v[0]) {
|
|
1609
|
+
ranges.push("*");
|
|
1610
|
+
} else if (!max) {
|
|
1611
|
+
ranges.push(`>=${min}`);
|
|
1612
|
+
} else if (min === v[0]) {
|
|
1613
|
+
ranges.push(`<=${max}`);
|
|
1614
|
+
} else {
|
|
1615
|
+
ranges.push(`${min} - ${max}`);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
const simplified = ranges.join(" || ");
|
|
1619
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
1620
|
+
return simplified.length < original.length ? simplified : range;
|
|
1621
|
+
};
|
|
1622
|
+
});
|
|
1623
|
+
|
|
1624
|
+
// node_modules/semver/ranges/subset.js
|
|
1625
|
+
var require_subset = __commonJS((exports, module) => {
|
|
1626
|
+
var Range = require_range();
|
|
1627
|
+
var Comparator = require_comparator();
|
|
1628
|
+
var { ANY } = Comparator;
|
|
1629
|
+
var satisfies = require_satisfies();
|
|
1630
|
+
var compare = require_compare();
|
|
1631
|
+
var subset = (sub, dom, options = {}) => {
|
|
1632
|
+
if (sub === dom) {
|
|
1633
|
+
return true;
|
|
1634
|
+
}
|
|
1635
|
+
sub = new Range(sub, options);
|
|
1636
|
+
dom = new Range(dom, options);
|
|
1637
|
+
let sawNonNull = false;
|
|
1638
|
+
OUTER:
|
|
1639
|
+
for (const simpleSub of sub.set) {
|
|
1640
|
+
for (const simpleDom of dom.set) {
|
|
1641
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
1642
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
1643
|
+
if (isSub) {
|
|
1644
|
+
continue OUTER;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
if (sawNonNull) {
|
|
1648
|
+
return false;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
return true;
|
|
1652
|
+
};
|
|
1653
|
+
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
1654
|
+
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
1655
|
+
var simpleSubset = (sub, dom, options) => {
|
|
1656
|
+
if (sub === dom) {
|
|
1657
|
+
return true;
|
|
1658
|
+
}
|
|
1659
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
1660
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1661
|
+
return true;
|
|
1662
|
+
} else if (options.includePrerelease) {
|
|
1663
|
+
sub = minimumVersionWithPreRelease;
|
|
1664
|
+
} else {
|
|
1665
|
+
sub = minimumVersion;
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1669
|
+
if (options.includePrerelease) {
|
|
1670
|
+
return true;
|
|
1671
|
+
} else {
|
|
1672
|
+
dom = minimumVersion;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
const eqSet = new Set;
|
|
1676
|
+
let gt, lt;
|
|
1677
|
+
for (const c of sub) {
|
|
1678
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1679
|
+
gt = higherGT(gt, c, options);
|
|
1680
|
+
} else if (c.operator === "<" || c.operator === "<=") {
|
|
1681
|
+
lt = lowerLT(lt, c, options);
|
|
1682
|
+
} else {
|
|
1683
|
+
eqSet.add(c.semver);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
if (eqSet.size > 1) {
|
|
1687
|
+
return null;
|
|
1688
|
+
}
|
|
1689
|
+
let gtltComp;
|
|
1690
|
+
if (gt && lt) {
|
|
1691
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
1692
|
+
if (gtltComp > 0) {
|
|
1693
|
+
return null;
|
|
1694
|
+
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
1695
|
+
return null;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
for (const eq of eqSet) {
|
|
1699
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
1700
|
+
return null;
|
|
1701
|
+
}
|
|
1702
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
1703
|
+
return null;
|
|
1704
|
+
}
|
|
1705
|
+
for (const c of dom) {
|
|
1706
|
+
if (!satisfies(eq, String(c), options)) {
|
|
1707
|
+
return false;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
return true;
|
|
1711
|
+
}
|
|
1712
|
+
let higher, lower;
|
|
1713
|
+
let hasDomLT, hasDomGT;
|
|
1714
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
1715
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
1716
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
1717
|
+
needDomLTPre = false;
|
|
1718
|
+
}
|
|
1719
|
+
for (const c of dom) {
|
|
1720
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
1721
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
1722
|
+
if (gt) {
|
|
1723
|
+
if (needDomGTPre) {
|
|
1724
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
1725
|
+
needDomGTPre = false;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1729
|
+
higher = higherGT(gt, c, options);
|
|
1730
|
+
if (higher === c && higher !== gt) {
|
|
1731
|
+
return false;
|
|
1732
|
+
}
|
|
1733
|
+
} else if (gt.operator === ">=" && !c.test(gt.semver)) {
|
|
1734
|
+
return false;
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
if (lt) {
|
|
1738
|
+
if (needDomLTPre) {
|
|
1739
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
1740
|
+
needDomLTPre = false;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
1744
|
+
lower = lowerLT(lt, c, options);
|
|
1745
|
+
if (lower === c && lower !== lt) {
|
|
1746
|
+
return false;
|
|
1747
|
+
}
|
|
1748
|
+
} else if (lt.operator === "<=" && !c.test(lt.semver)) {
|
|
1749
|
+
return false;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
1753
|
+
return false;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
1757
|
+
return false;
|
|
1758
|
+
}
|
|
1759
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
1760
|
+
return false;
|
|
1761
|
+
}
|
|
1762
|
+
if (needDomGTPre || needDomLTPre) {
|
|
1763
|
+
return false;
|
|
1764
|
+
}
|
|
1765
|
+
return true;
|
|
1766
|
+
};
|
|
1767
|
+
var higherGT = (a, b, options) => {
|
|
1768
|
+
if (!a) {
|
|
1769
|
+
return b;
|
|
1770
|
+
}
|
|
1771
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1772
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
1773
|
+
};
|
|
1774
|
+
var lowerLT = (a, b, options) => {
|
|
1775
|
+
if (!a) {
|
|
1776
|
+
return b;
|
|
1777
|
+
}
|
|
1778
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1779
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
1780
|
+
};
|
|
1781
|
+
module.exports = subset;
|
|
1782
|
+
});
|
|
1783
|
+
|
|
1784
|
+
// node_modules/semver/index.js
|
|
1785
|
+
var require_semver2 = __commonJS((exports, module) => {
|
|
1786
|
+
var internalRe = require_re();
|
|
1787
|
+
var constants2 = require_constants();
|
|
1788
|
+
var SemVer = require_semver();
|
|
1789
|
+
var identifiers = require_identifiers();
|
|
1790
|
+
var parse = require_parse();
|
|
1791
|
+
var valid = require_valid();
|
|
1792
|
+
var clean = require_clean();
|
|
1793
|
+
var inc = require_inc();
|
|
1794
|
+
var diff = require_diff();
|
|
1795
|
+
var major = require_major();
|
|
1796
|
+
var minor = require_minor();
|
|
1797
|
+
var patch = require_patch();
|
|
1798
|
+
var prerelease = require_prerelease();
|
|
1799
|
+
var compare = require_compare();
|
|
1800
|
+
var rcompare = require_rcompare();
|
|
1801
|
+
var compareLoose = require_compare_loose();
|
|
1802
|
+
var compareBuild = require_compare_build();
|
|
1803
|
+
var sort = require_sort();
|
|
1804
|
+
var rsort = require_rsort();
|
|
1805
|
+
var gt = require_gt();
|
|
1806
|
+
var lt = require_lt();
|
|
1807
|
+
var eq = require_eq();
|
|
1808
|
+
var neq = require_neq();
|
|
1809
|
+
var gte = require_gte();
|
|
1810
|
+
var lte = require_lte();
|
|
1811
|
+
var cmp = require_cmp();
|
|
1812
|
+
var coerce = require_coerce();
|
|
1813
|
+
var truncate = require_truncate();
|
|
1814
|
+
var Comparator = require_comparator();
|
|
1815
|
+
var Range = require_range();
|
|
1816
|
+
var satisfies = require_satisfies();
|
|
1817
|
+
var toComparators = require_to_comparators();
|
|
1818
|
+
var maxSatisfying = require_max_satisfying();
|
|
1819
|
+
var minSatisfying = require_min_satisfying();
|
|
1820
|
+
var minVersion = require_min_version();
|
|
1821
|
+
var validRange = require_valid2();
|
|
1822
|
+
var outside = require_outside();
|
|
1823
|
+
var gtr = require_gtr();
|
|
1824
|
+
var ltr = require_ltr();
|
|
1825
|
+
var intersects = require_intersects();
|
|
1826
|
+
var simplifyRange = require_simplify();
|
|
1827
|
+
var subset = require_subset();
|
|
1828
|
+
module.exports = {
|
|
1829
|
+
parse,
|
|
1830
|
+
valid,
|
|
1831
|
+
clean,
|
|
1832
|
+
inc,
|
|
1833
|
+
diff,
|
|
1834
|
+
major,
|
|
1835
|
+
minor,
|
|
1836
|
+
patch,
|
|
1837
|
+
prerelease,
|
|
1838
|
+
compare,
|
|
1839
|
+
rcompare,
|
|
1840
|
+
compareLoose,
|
|
1841
|
+
compareBuild,
|
|
1842
|
+
sort,
|
|
1843
|
+
rsort,
|
|
1844
|
+
gt,
|
|
1845
|
+
lt,
|
|
1846
|
+
eq,
|
|
1847
|
+
neq,
|
|
1848
|
+
gte,
|
|
1849
|
+
lte,
|
|
1850
|
+
cmp,
|
|
1851
|
+
coerce,
|
|
1852
|
+
truncate,
|
|
1853
|
+
Comparator,
|
|
1854
|
+
Range,
|
|
1855
|
+
satisfies,
|
|
1856
|
+
toComparators,
|
|
1857
|
+
maxSatisfying,
|
|
1858
|
+
minSatisfying,
|
|
1859
|
+
minVersion,
|
|
1860
|
+
validRange,
|
|
1861
|
+
outside,
|
|
1862
|
+
gtr,
|
|
1863
|
+
ltr,
|
|
1864
|
+
intersects,
|
|
1865
|
+
simplifyRange,
|
|
1866
|
+
subset,
|
|
1867
|
+
SemVer,
|
|
1868
|
+
re: internalRe.re,
|
|
1869
|
+
src: internalRe.src,
|
|
1870
|
+
tokens: internalRe.t,
|
|
1871
|
+
SEMVER_SPEC_VERSION: constants2.SEMVER_SPEC_VERSION,
|
|
1872
|
+
RELEASE_TYPES: constants2.RELEASE_TYPES,
|
|
1873
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
1874
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
1875
|
+
};
|
|
1876
|
+
});
|
|
1877
|
+
|
|
1878
|
+
// src/cli.ts
|
|
1879
|
+
import { parseArgs } from "node:util";
|
|
1880
|
+
|
|
1881
|
+
// src/commands/config/config.command.ts
|
|
1882
|
+
import { resolve } from "node:path";
|
|
1883
|
+
|
|
1884
|
+
// src/config/config.ts
|
|
1885
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
1886
|
+
import { homedir } from "node:os";
|
|
1887
|
+
import { join } from "node:path";
|
|
1888
|
+
var CONFIG_PATH = join(homedir(), ".bumperrc");
|
|
1889
|
+
function configPath() {
|
|
1890
|
+
return CONFIG_PATH;
|
|
1891
|
+
}
|
|
1892
|
+
function defaultRepoConfig() {
|
|
1893
|
+
return { mode: "auto" /* Auto */, exclude: [], modules: {} };
|
|
1894
|
+
}
|
|
1895
|
+
function normalize(entry) {
|
|
1896
|
+
return {
|
|
1897
|
+
mode: entry.mode ?? "auto" /* Auto */,
|
|
1898
|
+
exclude: entry.exclude ?? [],
|
|
1899
|
+
modules: entry.modules ?? {}
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
async function loadConfig() {
|
|
1903
|
+
try {
|
|
1904
|
+
const parsed = JSON.parse(await readFile(CONFIG_PATH, "utf8"));
|
|
1905
|
+
return { repos: parsed.repos ?? {} };
|
|
1906
|
+
} catch {
|
|
1907
|
+
return { repos: {} };
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
async function saveConfig(config) {
|
|
1911
|
+
await writeFile(CONFIG_PATH, `${JSON.stringify(config, null, 2)}
|
|
1912
|
+
`);
|
|
1913
|
+
}
|
|
1914
|
+
async function resolveForPath(repoPath) {
|
|
1915
|
+
const config = await loadConfig();
|
|
1916
|
+
const existing = config.repos[repoPath];
|
|
1917
|
+
if (existing) {
|
|
1918
|
+
return { config: normalize(existing), created: false };
|
|
1919
|
+
}
|
|
1920
|
+
const fresh = defaultRepoConfig();
|
|
1921
|
+
config.repos[repoPath] = fresh;
|
|
1922
|
+
await saveConfig(config);
|
|
1923
|
+
return { config: fresh, created: true };
|
|
1924
|
+
}
|
|
1925
|
+
async function setRepoConfig(repoPath, entry) {
|
|
1926
|
+
const config = await loadConfig();
|
|
1927
|
+
config.repos[repoPath] = entry;
|
|
1928
|
+
await saveConfig(config);
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
// src/commands/config/config.command.ts
|
|
1932
|
+
async function run({ positionals }) {
|
|
1933
|
+
const [sub, repoPath, key, value] = positionals;
|
|
1934
|
+
if (sub === "list" || sub === undefined) {
|
|
1935
|
+
const config = await loadConfig();
|
|
1936
|
+
process.stdout.write(`${JSON.stringify(config, null, 2)}
|
|
1937
|
+
`);
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
if (sub === "get") {
|
|
1941
|
+
if (!repoPath) {
|
|
1942
|
+
throw new Error("config get requires a <path>");
|
|
1943
|
+
}
|
|
1944
|
+
const { config } = await resolveForPath(resolve(repoPath));
|
|
1945
|
+
process.stdout.write(`${JSON.stringify(config, null, 2)}
|
|
1946
|
+
`);
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
if (sub === "set") {
|
|
1950
|
+
if (!repoPath || !key || value === undefined) {
|
|
1951
|
+
throw new Error("config set requires <path> <key> <value>");
|
|
1952
|
+
}
|
|
1953
|
+
const abs = resolve(repoPath);
|
|
1954
|
+
const { config } = await resolveForPath(abs);
|
|
1955
|
+
const next = { ...config, modules: { ...config.modules } };
|
|
1956
|
+
if (key === "mode") {
|
|
1957
|
+
if (value !== "auto" /* Auto */ && value !== "manual" /* Manual */) {
|
|
1958
|
+
throw new Error(`mode must be '${"auto" /* Auto */}' or '${"manual" /* Manual */}'`);
|
|
1959
|
+
}
|
|
1960
|
+
next.mode = value;
|
|
1961
|
+
} else if (key === "exclude") {
|
|
1962
|
+
next.exclude = value.split(",").map((part) => part.trim()).filter(Boolean);
|
|
1963
|
+
} else if (key.startsWith("modules.")) {
|
|
1964
|
+
const id = key.slice("modules.".length);
|
|
1965
|
+
next.modules[id] = value === "true";
|
|
1966
|
+
} else {
|
|
1967
|
+
throw new Error(`unknown config key: ${key}`);
|
|
1968
|
+
}
|
|
1969
|
+
await setRepoConfig(abs, next);
|
|
1970
|
+
process.stdout.write(`${JSON.stringify(next, null, 2)}
|
|
1971
|
+
`);
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
throw new Error(`unknown config subcommand: ${sub}`);
|
|
1975
|
+
}
|
|
1976
|
+
var configCommand = {
|
|
1977
|
+
name: "config",
|
|
1978
|
+
run,
|
|
1979
|
+
help: () => ({
|
|
1980
|
+
usage: [
|
|
1981
|
+
"bumper config list",
|
|
1982
|
+
"bumper config get <path>",
|
|
1983
|
+
"bumper config set <path> <key> <value>"
|
|
1984
|
+
],
|
|
1985
|
+
summary: "Inspect or edit ~/.bumperrc",
|
|
1986
|
+
extra: [
|
|
1987
|
+
{
|
|
1988
|
+
title: "Config keys (config set)",
|
|
1989
|
+
lines: ["mode <auto|manual> exclude <a,b,c> modules.<id> <true|false>"]
|
|
1990
|
+
}
|
|
1991
|
+
]
|
|
1992
|
+
})
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1995
|
+
// src/commands/detect/detect.command.ts
|
|
1996
|
+
import { resolve as resolve2 } from "node:path";
|
|
1997
|
+
|
|
1998
|
+
// src/context/context.ts
|
|
1999
|
+
import { relative as relative2 } from "node:path";
|
|
2000
|
+
|
|
2001
|
+
// src/context/detectors/package-manager.detector.ts
|
|
2002
|
+
import { join as join3 } from "node:path";
|
|
2003
|
+
|
|
2004
|
+
// src/utils/fs.utils.ts
|
|
2005
|
+
import { access, glob, readFile as readFile2, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
2006
|
+
import { join as join2 } from "node:path";
|
|
2007
|
+
async function pathExists(path) {
|
|
2008
|
+
try {
|
|
2009
|
+
await access(path);
|
|
2010
|
+
return true;
|
|
2011
|
+
} catch {
|
|
2012
|
+
return false;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
async function anyExists(dir, names) {
|
|
2016
|
+
const present = await Promise.all(names.map((name) => pathExists(join2(dir, name))));
|
|
2017
|
+
return present.some(Boolean);
|
|
2018
|
+
}
|
|
2019
|
+
async function globFiles(cwd, pattern) {
|
|
2020
|
+
const relative = await Array.fromAsync(glob(pattern, { cwd }));
|
|
2021
|
+
const absolute = relative.map((entry) => join2(cwd, entry));
|
|
2022
|
+
const files = await Promise.all(absolute.map(async (path) => (await stat(path)).isFile() ? path : null));
|
|
2023
|
+
return files.filter((path) => path !== null);
|
|
2024
|
+
}
|
|
2025
|
+
async function readPackageJson(dir) {
|
|
2026
|
+
try {
|
|
2027
|
+
return JSON.parse(await readFile2(join2(dir, "package.json"), "utf8"));
|
|
2028
|
+
} catch {
|
|
2029
|
+
return null;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
async function writePackageJson(dir, pkg) {
|
|
2033
|
+
await writeFile2(join2(dir, "package.json"), `${JSON.stringify(pkg, null, 2)}
|
|
2034
|
+
`);
|
|
2035
|
+
}
|
|
2036
|
+
function allDependencies(pkg) {
|
|
2037
|
+
return {
|
|
2038
|
+
...pkg.dependencies,
|
|
2039
|
+
...pkg.devDependencies,
|
|
2040
|
+
...pkg.optionalDependencies,
|
|
2041
|
+
...pkg.peerDependencies
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
// src/context/detectors/package-manager.detector.ts
|
|
2046
|
+
async function detectPackageManager(cwd) {
|
|
2047
|
+
const pkg = await readPackageJson(cwd);
|
|
2048
|
+
const field = pkg?.packageManager ?? "";
|
|
2049
|
+
if (field.startsWith("pnpm")) {
|
|
2050
|
+
return "pnpm" /* Pnpm */;
|
|
2051
|
+
}
|
|
2052
|
+
if (field.startsWith("bun")) {
|
|
2053
|
+
return "bun" /* Bun */;
|
|
2054
|
+
}
|
|
2055
|
+
if (field.startsWith("npm")) {
|
|
2056
|
+
return "npm" /* Npm */;
|
|
2057
|
+
}
|
|
2058
|
+
if (await pathExists(join3(cwd, "pnpm-lock.yaml"))) {
|
|
2059
|
+
return "pnpm" /* Pnpm */;
|
|
2060
|
+
}
|
|
2061
|
+
if (await pathExists(join3(cwd, "bun.lock")) || await pathExists(join3(cwd, "bun.lockb"))) {
|
|
2062
|
+
return "bun" /* Bun */;
|
|
2063
|
+
}
|
|
2064
|
+
if (await pathExists(join3(cwd, "package-lock.json"))) {
|
|
2065
|
+
return "npm" /* Npm */;
|
|
2066
|
+
}
|
|
2067
|
+
return "npm" /* Npm */;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
// src/context/detectors/runtime.detector.ts
|
|
2071
|
+
async function detectRuntime(cwd) {
|
|
2072
|
+
const pkg = await readPackageJson(cwd);
|
|
2073
|
+
if (pkg?.packageManager?.startsWith("bun")) {
|
|
2074
|
+
return "bun" /* Bun */;
|
|
2075
|
+
}
|
|
2076
|
+
if (await anyExists(cwd, ["bun.lock", "bun.lockb"])) {
|
|
2077
|
+
return "bun" /* Bun */;
|
|
2078
|
+
}
|
|
2079
|
+
return "node" /* Node */;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// src/utils/exec.utils.ts
|
|
2083
|
+
import { spawn } from "node:child_process";
|
|
2084
|
+
import { accessSync, constants } from "node:fs";
|
|
2085
|
+
import { delimiter, join as join4 } from "node:path";
|
|
2086
|
+
async function exec(cmd, opts = {}) {
|
|
2087
|
+
const [file, ...args] = cmd;
|
|
2088
|
+
if (file === undefined) {
|
|
2089
|
+
throw new Error("exec called with an empty command");
|
|
2090
|
+
}
|
|
2091
|
+
return new Promise((resolve2) => {
|
|
2092
|
+
const proc = spawn(file, args, {
|
|
2093
|
+
...opts.cwd ? { cwd: opts.cwd } : {},
|
|
2094
|
+
env: opts.env ? { ...process.env, ...opts.env } : process.env,
|
|
2095
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2096
|
+
});
|
|
2097
|
+
let stdout = "";
|
|
2098
|
+
let stderr = "";
|
|
2099
|
+
proc.stdout.on("data", (chunk) => stdout += chunk);
|
|
2100
|
+
proc.stderr.on("data", (chunk) => stderr += chunk);
|
|
2101
|
+
proc.on("error", (error) => resolve2({ exitCode: 1, stdout, stderr: String(error) }));
|
|
2102
|
+
proc.on("close", (code) => resolve2({ exitCode: code ?? 0, stdout, stderr }));
|
|
2103
|
+
});
|
|
2104
|
+
}
|
|
2105
|
+
async function execOk(cmd, opts = {}) {
|
|
2106
|
+
const result = await exec(cmd, opts);
|
|
2107
|
+
if (result.exitCode !== 0) {
|
|
2108
|
+
const output = [result.stdout, result.stderr].filter(Boolean).join(`
|
|
2109
|
+
`).trim();
|
|
2110
|
+
throw new Error(`\`${cmd.join(" ")}\` failed (exit ${result.exitCode})
|
|
2111
|
+
${output}`);
|
|
2112
|
+
}
|
|
2113
|
+
return result;
|
|
2114
|
+
}
|
|
2115
|
+
function toolExists(name) {
|
|
2116
|
+
const dirs = (process.env["PATH"] ?? "").split(delimiter).filter(Boolean);
|
|
2117
|
+
const isWindows = process.platform === "win32";
|
|
2118
|
+
const exts = isWindows ? (process.env["PATHEXT"] ?? ".EXE;.CMD;.BAT;.COM").split(";") : [""];
|
|
2119
|
+
const mode = isWindows ? constants.F_OK : constants.X_OK;
|
|
2120
|
+
return dirs.some((dir) => exts.some((ext) => {
|
|
2121
|
+
try {
|
|
2122
|
+
accessSync(join4(dir, `${name}${ext}`), mode);
|
|
2123
|
+
return true;
|
|
2124
|
+
} catch {
|
|
2125
|
+
return false;
|
|
2126
|
+
}
|
|
2127
|
+
}));
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
// src/context/detectors/version-manager.detector.ts
|
|
2131
|
+
function detectVersionManager() {
|
|
2132
|
+
if (toolExists("fnm")) {
|
|
2133
|
+
return "fnm" /* Fnm */;
|
|
2134
|
+
}
|
|
2135
|
+
if (toolExists("asdf")) {
|
|
2136
|
+
return "asdf" /* Asdf */;
|
|
2137
|
+
}
|
|
2138
|
+
if (process.env["NVM_DIR"]) {
|
|
2139
|
+
return "nvm" /* Nvm */;
|
|
2140
|
+
}
|
|
2141
|
+
return "none" /* None */;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
// src/context/detectors/workspace.detector.ts
|
|
2145
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
2146
|
+
import { dirname, join as join5, matchesGlob, relative } from "node:path";
|
|
2147
|
+
function parsePnpmPackages(yaml) {
|
|
2148
|
+
return yaml.split(`
|
|
2149
|
+
`).reduce((state, raw) => {
|
|
2150
|
+
const line = raw.replace(/\s+$/, "");
|
|
2151
|
+
if (/^packages:\s*$/.test(line)) {
|
|
2152
|
+
return { ...state, inBlock: true };
|
|
2153
|
+
}
|
|
2154
|
+
if (!state.inBlock) {
|
|
2155
|
+
return state;
|
|
2156
|
+
}
|
|
2157
|
+
const item = line.match(/^\s*-\s+(.+)$/);
|
|
2158
|
+
if (item?.[1]) {
|
|
2159
|
+
state.globs.push(item[1].trim().replace(/^['"]|['"]$/g, ""));
|
|
2160
|
+
return state;
|
|
2161
|
+
}
|
|
2162
|
+
if (line.trim() === "") {
|
|
2163
|
+
return state;
|
|
2164
|
+
}
|
|
2165
|
+
return /^\S/.test(line) ? { ...state, inBlock: false } : state;
|
|
2166
|
+
}, { inBlock: false, globs: [] }).globs;
|
|
2167
|
+
}
|
|
2168
|
+
async function readWorkspaceGlobs(cwd, pm) {
|
|
2169
|
+
if (pm === "pnpm" /* Pnpm */) {
|
|
2170
|
+
const file = join5(cwd, "pnpm-workspace.yaml");
|
|
2171
|
+
return await pathExists(file) ? parsePnpmPackages(await readFile3(file, "utf8")) : [];
|
|
2172
|
+
}
|
|
2173
|
+
const pkg = await readPackageJson(cwd);
|
|
2174
|
+
const ws = pkg?.workspaces;
|
|
2175
|
+
if (Array.isArray(ws)) {
|
|
2176
|
+
return ws;
|
|
2177
|
+
}
|
|
2178
|
+
if (ws && Array.isArray(ws.packages)) {
|
|
2179
|
+
return ws.packages;
|
|
2180
|
+
}
|
|
2181
|
+
return [];
|
|
2182
|
+
}
|
|
2183
|
+
async function detectWorkspaces(cwd, pm) {
|
|
2184
|
+
const globs = await readWorkspaceGlobs(cwd, pm);
|
|
2185
|
+
const positives = globs.filter((g) => !g.startsWith("!"));
|
|
2186
|
+
const negatives = globs.filter((g) => g.startsWith("!")).map((g) => g.slice(1));
|
|
2187
|
+
if (positives.length === 0) {
|
|
2188
|
+
return { isMonorepo: false, workspaces: [cwd] };
|
|
2189
|
+
}
|
|
2190
|
+
const matches = await Promise.all(positives.map((pattern) => globFiles(cwd, `${pattern}/package.json`)));
|
|
2191
|
+
const found = new Set(matches.flat().map((match) => dirname(match)).filter((dir) => !negatives.some((neg) => matchesGlob(relative(cwd, dir), neg))));
|
|
2192
|
+
const members = [...found].sort();
|
|
2193
|
+
return { isMonorepo: members.length > 0, workspaces: [cwd, ...members] };
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
// src/context/context.ts
|
|
2197
|
+
function isExcluded(cwd, dir, exclude) {
|
|
2198
|
+
const rel = relative2(cwd, dir);
|
|
2199
|
+
return exclude.some((entry) => rel === entry || rel.startsWith(`${entry}/`));
|
|
2200
|
+
}
|
|
2201
|
+
async function buildContext(cwd, options = {}) {
|
|
2202
|
+
const { config, created } = await resolveForPath(cwd);
|
|
2203
|
+
const [runtime, packageManager] = await Promise.all([
|
|
2204
|
+
detectRuntime(cwd),
|
|
2205
|
+
detectPackageManager(cwd)
|
|
2206
|
+
]);
|
|
2207
|
+
const { isMonorepo, workspaces } = await detectWorkspaces(cwd, packageManager);
|
|
2208
|
+
const versionManager = detectVersionManager();
|
|
2209
|
+
const ctx = {
|
|
2210
|
+
cwd,
|
|
2211
|
+
runtime,
|
|
2212
|
+
packageManager,
|
|
2213
|
+
isMonorepo,
|
|
2214
|
+
workspaces: workspaces.filter((dir) => !isExcluded(cwd, dir, config.exclude)),
|
|
2215
|
+
versionManager,
|
|
2216
|
+
config,
|
|
2217
|
+
dryRun: options.dryRun ?? false
|
|
2218
|
+
};
|
|
2219
|
+
return { ctx, configCreated: created };
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
// src/utils/output.utils.ts
|
|
2223
|
+
var BOLD = "\x1B[1m";
|
|
2224
|
+
var DIM = "\x1B[2m";
|
|
2225
|
+
var GREEN = "\x1B[32m";
|
|
2226
|
+
var CYAN = "\x1B[36m";
|
|
2227
|
+
var RESET = "\x1B[0m";
|
|
2228
|
+
var RED = "\x1B[31m";
|
|
2229
|
+
var CLEAR_LINE = "\r\x1B[2K";
|
|
2230
|
+
async function runStep(label, fn) {
|
|
2231
|
+
process.stdout.write(`${DIM}> ${label} ...${RESET}`);
|
|
2232
|
+
try {
|
|
2233
|
+
await fn();
|
|
2234
|
+
process.stdout.write(`${CLEAR_LINE}${GREEN}✓ ${label}${RESET}
|
|
2235
|
+
`);
|
|
2236
|
+
} catch (error) {
|
|
2237
|
+
process.stdout.write(`${CLEAR_LINE}${RED}✗ ${label}${RESET}
|
|
2238
|
+
`);
|
|
2239
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2240
|
+
process.stderr.write(`${message}
|
|
2241
|
+
`);
|
|
2242
|
+
throw error;
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
function planLine(text) {
|
|
2246
|
+
process.stdout.write(`${DIM} → ${text}${RESET}
|
|
2247
|
+
`);
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
// src/modules/features/docker/docker.feature.ts
|
|
2251
|
+
import { readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
|
|
2252
|
+
import { relative as relative3, sep } from "node:path";
|
|
2253
|
+
|
|
2254
|
+
// src/utils/npm-registry.utils.ts
|
|
2255
|
+
async function curlJson(url, run2 = execOk) {
|
|
2256
|
+
const { stdout } = await run2(["curl", "-sSL", "--fail", "--connect-timeout", "20", url]);
|
|
2257
|
+
return JSON.parse(stdout);
|
|
2258
|
+
}
|
|
2259
|
+
function viewTool(pm) {
|
|
2260
|
+
return pm === "pnpm" /* Pnpm */ ? "pnpm" : "npm";
|
|
2261
|
+
}
|
|
2262
|
+
async function latestVersion(pkg, tool, cwd, run2 = exec) {
|
|
2263
|
+
try {
|
|
2264
|
+
const { exitCode, stdout } = await run2([tool, "view", pkg, "version"], { cwd });
|
|
2265
|
+
if (exitCode !== 0) {
|
|
2266
|
+
return null;
|
|
2267
|
+
}
|
|
2268
|
+
const version = stdout.trim().split(`
|
|
2269
|
+
`).pop()?.trim();
|
|
2270
|
+
return version && /^\d/.test(version) ? version : null;
|
|
2271
|
+
} catch {
|
|
2272
|
+
return null;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
async function latestVersionInRange(pkg, range, tool, cwd, run2 = exec) {
|
|
2276
|
+
try {
|
|
2277
|
+
const { exitCode, stdout } = await run2([tool, "view", `${pkg}@${range}`, "version"], { cwd });
|
|
2278
|
+
if (exitCode !== 0) {
|
|
2279
|
+
return null;
|
|
2280
|
+
}
|
|
2281
|
+
const last = stdout.trim().split(`
|
|
2282
|
+
`).pop()?.trim();
|
|
2283
|
+
const version = last?.replace(/.*@/, "").replace(/['" ].*/, "");
|
|
2284
|
+
return version && /^\d/.test(version) ? version : null;
|
|
2285
|
+
} catch {
|
|
2286
|
+
return null;
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
// src/modules/runtimes/node/node-lts.utils.ts
|
|
2291
|
+
var DIST_INDEX = "https://nodejs.org/dist/index.json";
|
|
2292
|
+
async function fetchLatestLts() {
|
|
2293
|
+
const entries = await curlJson(DIST_INDEX);
|
|
2294
|
+
const latest = entries.find((entry) => entry.lts !== false);
|
|
2295
|
+
if (!latest) {
|
|
2296
|
+
throw new Error("No LTS release found in Node dist index");
|
|
2297
|
+
}
|
|
2298
|
+
const version = latest.version.replace(/^v/, "");
|
|
2299
|
+
const major = Number(version.split(".")[0]);
|
|
2300
|
+
return { version, major };
|
|
2301
|
+
}
|
|
2302
|
+
async function ensureNodeLts(ctx) {
|
|
2303
|
+
ctx.nodeLts ??= await fetchLatestLts();
|
|
2304
|
+
return ctx.nodeLts;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
// src/modules/features/docker/docker.feature.ts
|
|
2308
|
+
var DOCKER_GLOB = "**/{Dockerfile*,docker-compose*.yaml,docker-compose*.yml,compose*.yaml,compose*.yml}";
|
|
2309
|
+
async function findDockerFiles(cwd) {
|
|
2310
|
+
const matches = await globFiles(cwd, DOCKER_GLOB);
|
|
2311
|
+
return matches.filter((match) => !match.split(sep).includes("node_modules"));
|
|
2312
|
+
}
|
|
2313
|
+
var dockerFeature = {
|
|
2314
|
+
kind: "feature" /* Feature */,
|
|
2315
|
+
id: "docker",
|
|
2316
|
+
title: "Align Node version in Docker/Compose files",
|
|
2317
|
+
async isUsed(ctx) {
|
|
2318
|
+
const toggle = ctx.config.modules["docker"];
|
|
2319
|
+
if (toggle !== undefined) {
|
|
2320
|
+
return toggle;
|
|
2321
|
+
}
|
|
2322
|
+
return (await findDockerFiles(ctx.cwd)).length > 0;
|
|
2323
|
+
},
|
|
2324
|
+
async update(ctx) {
|
|
2325
|
+
const { version } = await ensureNodeLts(ctx);
|
|
2326
|
+
const files = await findDockerFiles(ctx.cwd);
|
|
2327
|
+
await Promise.all(files.map(async (file) => {
|
|
2328
|
+
const label = relative3(ctx.cwd, file);
|
|
2329
|
+
if (ctx.dryRun) {
|
|
2330
|
+
planLine(`align node version → ${version} in ${label}`);
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2333
|
+
const original = await readFile4(file, "utf8");
|
|
2334
|
+
const updated = original.replace(/node:[0-9]+(\.[0-9]+)*/g, `node:${version}`).replace(/NODE_VERSION=[0-9]+(\.[0-9]+)*/g, `NODE_VERSION=${version}`);
|
|
2335
|
+
if (updated !== original) {
|
|
2336
|
+
await writeFile3(file, updated);
|
|
2337
|
+
}
|
|
2338
|
+
}));
|
|
2339
|
+
}
|
|
2340
|
+
};
|
|
2341
|
+
|
|
2342
|
+
// src/modules/features/github-actions/github-actions.feature.ts
|
|
2343
|
+
import { readdir } from "node:fs/promises";
|
|
2344
|
+
import { join as join6 } from "node:path";
|
|
2345
|
+
async function hasWorkflows(cwd) {
|
|
2346
|
+
try {
|
|
2347
|
+
const entries = await readdir(join6(cwd, ".github", "workflows"));
|
|
2348
|
+
return entries.some((name) => name.endsWith(".yml") || name.endsWith(".yaml"));
|
|
2349
|
+
} catch {
|
|
2350
|
+
return false;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
var githubActionsFeature = {
|
|
2354
|
+
kind: "feature" /* Feature */,
|
|
2355
|
+
id: "github-actions",
|
|
2356
|
+
title: "Pin GitHub Actions to latest versions",
|
|
2357
|
+
async isUsed(ctx) {
|
|
2358
|
+
return hasWorkflows(ctx.cwd);
|
|
2359
|
+
},
|
|
2360
|
+
async update(ctx) {
|
|
2361
|
+
const cmd = ["bunx", "actions-up", "--yes", "--include-branches"];
|
|
2362
|
+
if (ctx.dryRun) {
|
|
2363
|
+
planLine(cmd.join(" "));
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2366
|
+
await execOk(cmd, { cwd: ctx.cwd });
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
|
|
2370
|
+
// src/modules/features/types-node/types-node.feature.ts
|
|
2371
|
+
import { relative as relative4 } from "node:path";
|
|
2372
|
+
|
|
2373
|
+
// src/utils/spec.utils.ts
|
|
2374
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
2375
|
+
function isPinnable(spec) {
|
|
2376
|
+
return import_semver.default.valid(spec.replace(/^[\^~]/, "")) !== null;
|
|
2377
|
+
}
|
|
2378
|
+
function operatorOf(spec) {
|
|
2379
|
+
return spec.startsWith("^") ? "^" : spec.startsWith("~") ? "~" : "";
|
|
2380
|
+
}
|
|
2381
|
+
function isVersionRange(spec) {
|
|
2382
|
+
if (isPinnable(spec)) {
|
|
2383
|
+
return false;
|
|
2384
|
+
}
|
|
2385
|
+
return /[<>]/.test(spec) || spec.includes("||") || /\d\s+[\d<>=~^v]/.test(spec.trim());
|
|
2386
|
+
}
|
|
2387
|
+
|
|
2388
|
+
// src/modules/features/types-node/types-node.feature.ts
|
|
2389
|
+
var TYPES_NODE_PACKAGE = "@types/node";
|
|
2390
|
+
var BUCKETS = [
|
|
2391
|
+
"dependencies",
|
|
2392
|
+
"devDependencies",
|
|
2393
|
+
"optionalDependencies",
|
|
2394
|
+
"peerDependencies"
|
|
2395
|
+
];
|
|
2396
|
+
async function dirsWithTypesNode(ctx) {
|
|
2397
|
+
const dirs = await Promise.all(ctx.workspaces.map(async (dir) => {
|
|
2398
|
+
const pkg = await readPackageJson(dir);
|
|
2399
|
+
return pkg && allDependencies(pkg)[TYPES_NODE_PACKAGE] ? dir : null;
|
|
2400
|
+
}));
|
|
2401
|
+
return dirs.filter((dir) => dir !== null);
|
|
2402
|
+
}
|
|
2403
|
+
function pinTypesNode(pkg, major) {
|
|
2404
|
+
return BUCKETS.reduce((changed, bucket) => {
|
|
2405
|
+
const deps = pkg[bucket];
|
|
2406
|
+
const spec = deps?.[TYPES_NODE_PACKAGE];
|
|
2407
|
+
if (deps && spec && !isVersionRange(spec)) {
|
|
2408
|
+
deps[TYPES_NODE_PACKAGE] = major;
|
|
2409
|
+
return true;
|
|
2410
|
+
}
|
|
2411
|
+
return changed;
|
|
2412
|
+
}, false);
|
|
2413
|
+
}
|
|
2414
|
+
var typesNodeFeature = {
|
|
2415
|
+
kind: "feature" /* Feature */,
|
|
2416
|
+
id: "types-node",
|
|
2417
|
+
title: "Align @types/node to Node LTS major",
|
|
2418
|
+
async isUsed(ctx) {
|
|
2419
|
+
return (await dirsWithTypesNode(ctx)).length > 0;
|
|
2420
|
+
},
|
|
2421
|
+
async managedDependencies() {
|
|
2422
|
+
return [TYPES_NODE_PACKAGE];
|
|
2423
|
+
},
|
|
2424
|
+
async update(ctx) {
|
|
2425
|
+
const { major } = await ensureNodeLts(ctx);
|
|
2426
|
+
const majorSpec = String(major);
|
|
2427
|
+
const dirs = await dirsWithTypesNode(ctx);
|
|
2428
|
+
await Promise.all(dirs.map(async (dir) => {
|
|
2429
|
+
const label = relative4(ctx.cwd, dir) || ".";
|
|
2430
|
+
if (ctx.dryRun) {
|
|
2431
|
+
planLine(`pin ${TYPES_NODE_PACKAGE}@${majorSpec} in ${label}`);
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
const pkg = await readPackageJson(dir);
|
|
2435
|
+
if (pkg && pinTypesNode(pkg, majorSpec)) {
|
|
2436
|
+
await writePackageJson(dir, pkg);
|
|
2437
|
+
}
|
|
2438
|
+
}));
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
// src/modules/package-managers/bun/bun.package-manager.ts
|
|
2443
|
+
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
2444
|
+
import { join as join9 } from "node:path";
|
|
2445
|
+
|
|
2446
|
+
// src/utils/deps.utils.ts
|
|
2447
|
+
import { rm } from "node:fs/promises";
|
|
2448
|
+
import { join as join7 } from "node:path";
|
|
2449
|
+
async function cleanInstall(ctx, installCmd) {
|
|
2450
|
+
if (ctx.dryRun) {
|
|
2451
|
+
planLine("rm -rf node_modules");
|
|
2452
|
+
planLine(installCmd.join(" "));
|
|
2453
|
+
return;
|
|
2454
|
+
}
|
|
2455
|
+
await rm(join7(ctx.cwd, "node_modules"), { recursive: true, force: true });
|
|
2456
|
+
await execOk(installCmd, { cwd: ctx.cwd });
|
|
2457
|
+
}
|
|
2458
|
+
async function selfUpdate(ctx, cmd) {
|
|
2459
|
+
if (ctx.dryRun) {
|
|
2460
|
+
planLine(cmd.join(" "));
|
|
2461
|
+
return;
|
|
2462
|
+
}
|
|
2463
|
+
const [bin] = cmd;
|
|
2464
|
+
if (!bin || !toolExists(bin)) {
|
|
2465
|
+
return;
|
|
2466
|
+
}
|
|
2467
|
+
try {
|
|
2468
|
+
await execOk(cmd, { cwd: ctx.cwd });
|
|
2469
|
+
} catch {}
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
// src/utils/upgrade.utils.ts
|
|
2473
|
+
import { join as join8 } from "node:path";
|
|
2474
|
+
var BUCKETS2 = [
|
|
2475
|
+
"dependencies",
|
|
2476
|
+
"devDependencies",
|
|
2477
|
+
"optionalDependencies",
|
|
2478
|
+
"peerDependencies"
|
|
2479
|
+
];
|
|
2480
|
+
var CONCURRENCY = 8;
|
|
2481
|
+
var defaultLookups = { latestVersion, latestVersionInRange };
|
|
2482
|
+
async function collectPackages(ctx) {
|
|
2483
|
+
const entries = await Promise.all(ctx.workspaces.map(async (dir) => [dir, await readPackageJson(dir)]));
|
|
2484
|
+
return new Map(entries.filter((entry) => entry[1] !== null));
|
|
2485
|
+
}
|
|
2486
|
+
function collectNames(pkgs, managed) {
|
|
2487
|
+
const names = [...pkgs.values()].flatMap((pkg) => Object.entries(allDependencies(pkg))).filter(([name, spec]) => !managed.has(name) && isPinnable(spec)).map(([name]) => name);
|
|
2488
|
+
return [...new Set(names)];
|
|
2489
|
+
}
|
|
2490
|
+
function collectDependencyNames(pkgs) {
|
|
2491
|
+
return [...new Set([...pkgs.values()].flatMap((pkg) => Object.keys(allDependencies(pkg))))];
|
|
2492
|
+
}
|
|
2493
|
+
async function collectPeerCaps(cwd, depNames, managed) {
|
|
2494
|
+
const collected = new Map;
|
|
2495
|
+
await Promise.all(depNames.map(async (dep) => {
|
|
2496
|
+
const peers = (await readPackageJson(join8(cwd, "node_modules", dep)))?.peerDependencies;
|
|
2497
|
+
if (!peers) {
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
Object.entries(peers).forEach(([peer, range]) => {
|
|
2501
|
+
if (managed.has(peer) || !isPinnable(range) && !isVersionRange(range)) {
|
|
2502
|
+
return;
|
|
2503
|
+
}
|
|
2504
|
+
(collected.get(peer) ?? collected.set(peer, new Set).get(peer))?.add(range);
|
|
2505
|
+
});
|
|
2506
|
+
}));
|
|
2507
|
+
return new Map([...collected].map(([peer, ranges]) => [peer, [...ranges].join(" ")]));
|
|
2508
|
+
}
|
|
2509
|
+
async function resolveLatest(names, tool, cwd, lookups) {
|
|
2510
|
+
const resolved = [];
|
|
2511
|
+
names.forEach((name, index) => {
|
|
2512
|
+
const slot = index < CONCURRENCY ? Promise.resolve() : resolved[index - CONCURRENCY];
|
|
2513
|
+
resolved[index] = (slot ?? Promise.resolve()).then(async () => [name, await lookups.latestVersion(name, tool, cwd)]);
|
|
2514
|
+
});
|
|
2515
|
+
return new Map(await Promise.all(resolved));
|
|
2516
|
+
}
|
|
2517
|
+
async function bumpPackageManagerField(ctx, root, lookups) {
|
|
2518
|
+
const match = root?.packageManager?.match(/^([a-z]+)@(.+)$/);
|
|
2519
|
+
const name = match?.[1];
|
|
2520
|
+
if (!root || !name) {
|
|
2521
|
+
return;
|
|
2522
|
+
}
|
|
2523
|
+
const version = await lookups.latestVersion(name, viewTool(ctx.packageManager), ctx.cwd);
|
|
2524
|
+
if (!version) {
|
|
2525
|
+
return;
|
|
2526
|
+
}
|
|
2527
|
+
const next = `${name}@${version}`;
|
|
2528
|
+
if (next !== root.packageManager) {
|
|
2529
|
+
root.packageManager = next;
|
|
2530
|
+
await writePackageJson(ctx.cwd, root);
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
async function upgradeAllWorkspaces(ctx, lookups = defaultLookups) {
|
|
2534
|
+
const managed = ctx.managedDependencies ?? new Set;
|
|
2535
|
+
const pkgs = await collectPackages(ctx);
|
|
2536
|
+
const names = collectNames(pkgs, managed);
|
|
2537
|
+
if (ctx.dryRun) {
|
|
2538
|
+
planLine(`resolve latest for ${names.length} dependency(ies) across ${pkgs.size} manifest(s)`);
|
|
2539
|
+
planLine("rewrite package.json specs (preserving ^/~), bump packageManager field");
|
|
2540
|
+
return;
|
|
2541
|
+
}
|
|
2542
|
+
const tool = viewTool(ctx.packageManager);
|
|
2543
|
+
const [latest, peerCaps] = await Promise.all([
|
|
2544
|
+
resolveLatest(names, tool, ctx.cwd, lookups),
|
|
2545
|
+
collectPeerCaps(ctx.cwd, collectDependencyNames(pkgs), managed)
|
|
2546
|
+
]);
|
|
2547
|
+
await Promise.all([...pkgs].map(async ([dir, pkg]) => {
|
|
2548
|
+
if (await rewriteSpecs(pkg, managed, latest, peerCaps, tool, ctx.cwd, lookups)) {
|
|
2549
|
+
await writePackageJson(dir, pkg);
|
|
2550
|
+
}
|
|
2551
|
+
}));
|
|
2552
|
+
await bumpPackageManagerField(ctx, pkgs.get(ctx.cwd), lookups);
|
|
2553
|
+
}
|
|
2554
|
+
function cappedRanges(pkg, managed) {
|
|
2555
|
+
const caps = new Map;
|
|
2556
|
+
BUCKETS2.forEach((bucket) => {
|
|
2557
|
+
const deps = pkg[bucket];
|
|
2558
|
+
if (!deps) {
|
|
2559
|
+
return;
|
|
2560
|
+
}
|
|
2561
|
+
Object.entries(deps).forEach(([name, spec]) => {
|
|
2562
|
+
if (!managed.has(name) && !caps.has(name) && isVersionRange(spec)) {
|
|
2563
|
+
caps.set(name, spec);
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
});
|
|
2567
|
+
return caps;
|
|
2568
|
+
}
|
|
2569
|
+
async function rewriteSpecs(pkg, managed, latest, peerCaps, tool, cwd, lookups) {
|
|
2570
|
+
const present = allDependencies(pkg);
|
|
2571
|
+
const caps = cappedRanges(pkg, managed);
|
|
2572
|
+
peerCaps.forEach((range, name) => {
|
|
2573
|
+
if (!(name in present)) {
|
|
2574
|
+
return;
|
|
2575
|
+
}
|
|
2576
|
+
const own = caps.get(name);
|
|
2577
|
+
caps.set(name, own ? `${own} ${range}` : range);
|
|
2578
|
+
});
|
|
2579
|
+
const capped = new Map(await Promise.all([...caps].map(async ([name, range]) => [name, await lookups.latestVersionInRange(name, range, tool, cwd)])));
|
|
2580
|
+
return BUCKETS2.reduce((bucketChanged, bucket) => {
|
|
2581
|
+
const deps = pkg[bucket];
|
|
2582
|
+
if (!deps) {
|
|
2583
|
+
return bucketChanged;
|
|
2584
|
+
}
|
|
2585
|
+
const entryChanged = Object.entries(deps).reduce((acc, [name, spec]) => {
|
|
2586
|
+
if (managed.has(name) || !isPinnable(spec)) {
|
|
2587
|
+
return acc;
|
|
2588
|
+
}
|
|
2589
|
+
const version = caps.has(name) ? capped.get(name) : latest.get(name);
|
|
2590
|
+
if (!version) {
|
|
2591
|
+
return acc;
|
|
2592
|
+
}
|
|
2593
|
+
const next = `${operatorOf(spec)}${version}`;
|
|
2594
|
+
if (next === spec) {
|
|
2595
|
+
return acc;
|
|
2596
|
+
}
|
|
2597
|
+
deps[name] = next;
|
|
2598
|
+
return true;
|
|
2599
|
+
}, false);
|
|
2600
|
+
return bucketChanged || entryChanged;
|
|
2601
|
+
}, false);
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
// src/modules/package-managers/bun/bun.package-manager.ts
|
|
2605
|
+
async function pinBunVersion(ctx) {
|
|
2606
|
+
const pkg = await readPackageJson(ctx.cwd);
|
|
2607
|
+
const version = pkg?.packageManager?.match(/^bun@(.+)$/)?.[1];
|
|
2608
|
+
if (!version) {
|
|
2609
|
+
return;
|
|
2610
|
+
}
|
|
2611
|
+
if (ctx.dryRun) {
|
|
2612
|
+
planLine(`write ${version} to .bun-version`);
|
|
2613
|
+
return;
|
|
2614
|
+
}
|
|
2615
|
+
await writeFile4(join9(ctx.cwd, ".bun-version"), `${version}
|
|
2616
|
+
`);
|
|
2617
|
+
}
|
|
2618
|
+
var bunPackageManager = {
|
|
2619
|
+
kind: "package-manager" /* PackageManager */,
|
|
2620
|
+
id: "bun",
|
|
2621
|
+
title: "Update dependencies (bun)",
|
|
2622
|
+
async isUsed(ctx) {
|
|
2623
|
+
return ctx.packageManager === "bun" /* Bun */;
|
|
2624
|
+
},
|
|
2625
|
+
async update(ctx) {
|
|
2626
|
+
await selfUpdate(ctx, ["bun", "upgrade"]);
|
|
2627
|
+
await upgradeAllWorkspaces(ctx);
|
|
2628
|
+
await pinBunVersion(ctx);
|
|
2629
|
+
await cleanInstall(ctx, ["bun", "install"]);
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
|
|
2633
|
+
// src/modules/package-managers/npm/npm.package-manager.ts
|
|
2634
|
+
var npmPackageManager = {
|
|
2635
|
+
kind: "package-manager" /* PackageManager */,
|
|
2636
|
+
id: "npm",
|
|
2637
|
+
title: "Update dependencies (npm)",
|
|
2638
|
+
async isUsed(ctx) {
|
|
2639
|
+
return ctx.packageManager === "npm" /* Npm */;
|
|
2640
|
+
},
|
|
2641
|
+
async update(ctx) {
|
|
2642
|
+
await upgradeAllWorkspaces(ctx);
|
|
2643
|
+
await cleanInstall(ctx, ["npm", "install"]);
|
|
2644
|
+
}
|
|
2645
|
+
};
|
|
2646
|
+
|
|
2647
|
+
// src/modules/package-managers/pnpm/pnpm.package-manager.ts
|
|
2648
|
+
var pnpmPackageManager = {
|
|
2649
|
+
kind: "package-manager" /* PackageManager */,
|
|
2650
|
+
id: "pnpm",
|
|
2651
|
+
title: "Update dependencies (pnpm)",
|
|
2652
|
+
async isUsed(ctx) {
|
|
2653
|
+
return ctx.packageManager === "pnpm" /* Pnpm */;
|
|
2654
|
+
},
|
|
2655
|
+
async update(ctx) {
|
|
2656
|
+
await selfUpdate(ctx, ["pnpm", "self-update"]);
|
|
2657
|
+
await upgradeAllWorkspaces(ctx);
|
|
2658
|
+
await cleanInstall(ctx, ["pnpm", "install"]);
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
|
|
2662
|
+
// src/modules/runtimes/node/node.runtime.ts
|
|
2663
|
+
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
2664
|
+
import { join as join10 } from "node:path";
|
|
2665
|
+
async function anyWorkspaceHasNodeVersionFile(ctx) {
|
|
2666
|
+
const present = await Promise.all(ctx.workspaces.map((dir) => anyExists(dir, [".node-version", ".nvmrc"])));
|
|
2667
|
+
return present.some(Boolean);
|
|
2668
|
+
}
|
|
2669
|
+
async function installNode(ctx, version) {
|
|
2670
|
+
switch (ctx.versionManager) {
|
|
2671
|
+
case "fnm" /* Fnm */:
|
|
2672
|
+
if (toolExists("fnm")) {
|
|
2673
|
+
await execOk(["fnm", "install", version]);
|
|
2674
|
+
}
|
|
2675
|
+
return;
|
|
2676
|
+
case "asdf" /* Asdf */:
|
|
2677
|
+
if (toolExists("asdf")) {
|
|
2678
|
+
await execOk(["asdf", "install", "nodejs", version]);
|
|
2679
|
+
}
|
|
2680
|
+
return;
|
|
2681
|
+
default:
|
|
2682
|
+
return;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
var nodeRuntime = {
|
|
2686
|
+
kind: "runtime" /* Runtime */,
|
|
2687
|
+
id: "node",
|
|
2688
|
+
title: "Update Node.js to current LTS",
|
|
2689
|
+
async isUsed(ctx) {
|
|
2690
|
+
return ctx.runtime === "node" /* Node */ || anyWorkspaceHasNodeVersionFile(ctx);
|
|
2691
|
+
},
|
|
2692
|
+
async update(ctx) {
|
|
2693
|
+
const lts = await ensureNodeLts(ctx);
|
|
2694
|
+
if (ctx.dryRun) {
|
|
2695
|
+
planLine(`install Node ${lts.version} via ${ctx.versionManager}`);
|
|
2696
|
+
planLine(`write v${lts.version} to .node-version (root + existing package files)`);
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
await installNode(ctx, lts.version);
|
|
2700
|
+
await Promise.all(ctx.workspaces.map(async (dir) => {
|
|
2701
|
+
const target = join10(dir, ".node-version");
|
|
2702
|
+
if (dir === ctx.cwd || await pathExists(target)) {
|
|
2703
|
+
await writeFile5(target, `v${lts.version}
|
|
2704
|
+
`);
|
|
2705
|
+
}
|
|
2706
|
+
}));
|
|
2707
|
+
}
|
|
2708
|
+
};
|
|
2709
|
+
|
|
2710
|
+
// src/modules/module.registry.ts
|
|
2711
|
+
var MODULES = [
|
|
2712
|
+
nodeRuntime,
|
|
2713
|
+
typesNodeFeature,
|
|
2714
|
+
bunPackageManager,
|
|
2715
|
+
npmPackageManager,
|
|
2716
|
+
pnpmPackageManager,
|
|
2717
|
+
dockerFeature,
|
|
2718
|
+
githubActionsFeature
|
|
2719
|
+
];
|
|
2720
|
+
async function collectManagedDependencies(ctx) {
|
|
2721
|
+
const owned = await Promise.all(MODULES.map(async (module) => module.managedDependencies && await module.isUsed(ctx) ? module.managedDependencies(ctx) : []));
|
|
2722
|
+
return new Set(owned.flat());
|
|
2723
|
+
}
|
|
2724
|
+
async function runUpdate(ctx, options = {}) {
|
|
2725
|
+
ctx.managedDependencies = await collectManagedDependencies(ctx);
|
|
2726
|
+
await MODULES.reduce(async (previous, module) => {
|
|
2727
|
+
await previous;
|
|
2728
|
+
if (options.only && !options.only.includes(module.id)) {
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
if (options.skip?.includes(module.id)) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
if (!await module.isUsed(ctx)) {
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
await runStep(module.title, () => module.update(ctx));
|
|
2738
|
+
}, Promise.resolve());
|
|
2739
|
+
}
|
|
2740
|
+
async function detectModules(ctx) {
|
|
2741
|
+
return Promise.all(MODULES.map(async (module) => {
|
|
2742
|
+
return { id: module.id, title: module.title, used: await module.isUsed(ctx) };
|
|
2743
|
+
}));
|
|
2744
|
+
}
|
|
2745
|
+
|
|
2746
|
+
// src/commands/detect/detect.command.ts
|
|
2747
|
+
async function run2({ values, positionals }) {
|
|
2748
|
+
const cwd = resolve2(positionals[0] ?? process.cwd());
|
|
2749
|
+
const json = values.json ?? false;
|
|
2750
|
+
const { ctx, configCreated } = await buildContext(cwd);
|
|
2751
|
+
const modules = await detectModules(ctx);
|
|
2752
|
+
if (json) {
|
|
2753
|
+
process.stdout.write(`${JSON.stringify({
|
|
2754
|
+
cwd: ctx.cwd,
|
|
2755
|
+
runtime: ctx.runtime,
|
|
2756
|
+
packageManager: ctx.packageManager,
|
|
2757
|
+
isMonorepo: ctx.isMonorepo,
|
|
2758
|
+
workspaces: ctx.workspaces,
|
|
2759
|
+
versionManager: ctx.versionManager,
|
|
2760
|
+
config: ctx.config,
|
|
2761
|
+
configCreated,
|
|
2762
|
+
modules
|
|
2763
|
+
}, null, 2)}
|
|
2764
|
+
`);
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
process.stdout.write(`${BOLD}${CYAN}${ctx.cwd}${RESET}
|
|
2768
|
+
`);
|
|
2769
|
+
process.stdout.write(` runtime ${ctx.runtime}
|
|
2770
|
+
`);
|
|
2771
|
+
process.stdout.write(` packageManager ${ctx.packageManager}
|
|
2772
|
+
`);
|
|
2773
|
+
process.stdout.write(` monorepo ${ctx.isMonorepo} (${ctx.workspaces.length} package(s))
|
|
2774
|
+
`);
|
|
2775
|
+
process.stdout.write(` versionManager ${ctx.versionManager}
|
|
2776
|
+
`);
|
|
2777
|
+
process.stdout.write(` config mode ${ctx.config.mode}${configCreated ? " (new)" : ""}
|
|
2778
|
+
`);
|
|
2779
|
+
if (ctx.config.exclude.length > 0) {
|
|
2780
|
+
process.stdout.write(` excludes ${ctx.config.exclude.join(", ")}
|
|
2781
|
+
`);
|
|
2782
|
+
}
|
|
2783
|
+
process.stdout.write(`
|
|
2784
|
+
${BOLD}${CYAN}Modules${RESET}
|
|
2785
|
+
`);
|
|
2786
|
+
modules.forEach((module) => {
|
|
2787
|
+
const mark = module.used ? `${GREEN}✓${RESET}` : `${DIM}·${RESET}`;
|
|
2788
|
+
const title = module.used ? module.title : `${DIM}${module.title}${RESET}`;
|
|
2789
|
+
process.stdout.write(` ${mark} ${module.id.padEnd(15)} ${title}
|
|
2790
|
+
`);
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2793
|
+
var detectCommand = {
|
|
2794
|
+
name: "detect",
|
|
2795
|
+
run: run2,
|
|
2796
|
+
help: () => ({
|
|
2797
|
+
usage: ["bumper detect [path] [--json]"],
|
|
2798
|
+
summary: "Show resolved context + which modules apply",
|
|
2799
|
+
options: ["--json Machine-readable detect output"]
|
|
2800
|
+
})
|
|
2801
|
+
};
|
|
2802
|
+
|
|
2803
|
+
// src/commands/help/help.command.ts
|
|
2804
|
+
var HEADER = `${BOLD}bumper${RESET} — central, module-based repo updater`;
|
|
2805
|
+
var GLOBAL_OPTIONS = ["--help, -h Show this help"];
|
|
2806
|
+
function render() {
|
|
2807
|
+
const parts = commands.map((command) => command.help());
|
|
2808
|
+
const usage = parts.flatMap((part) => part.usage);
|
|
2809
|
+
const summaries = commands.map((command) => ` ${GREEN}${command.name.padEnd(8)}${RESET} ${command.help().summary}`);
|
|
2810
|
+
const options = [...parts.flatMap((part) => part.options ?? []), ...GLOBAL_OPTIONS];
|
|
2811
|
+
const extras = parts.flatMap((part) => part.extra ?? []);
|
|
2812
|
+
const sections = [
|
|
2813
|
+
HEADER,
|
|
2814
|
+
section("Usage", usage),
|
|
2815
|
+
section("Commands", summaries, true),
|
|
2816
|
+
section("Options", options),
|
|
2817
|
+
...extras.map((extra) => section(extra.title, extra.lines))
|
|
2818
|
+
];
|
|
2819
|
+
return `${sections.join(`
|
|
2820
|
+
|
|
2821
|
+
`)}
|
|
2822
|
+
`;
|
|
2823
|
+
}
|
|
2824
|
+
function section(title, lines, preformatted = false) {
|
|
2825
|
+
const body = lines.map((line) => preformatted ? line : ` ${line}`).join(`
|
|
2826
|
+
`);
|
|
2827
|
+
return `${BOLD}${CYAN}${title}${RESET}
|
|
2828
|
+
${body}`;
|
|
2829
|
+
}
|
|
2830
|
+
function run3(_ctx) {
|
|
2831
|
+
process.stdout.write(render());
|
|
2832
|
+
}
|
|
2833
|
+
var helpCommand = {
|
|
2834
|
+
name: "help",
|
|
2835
|
+
run: run3,
|
|
2836
|
+
help: () => ({
|
|
2837
|
+
usage: [],
|
|
2838
|
+
summary: "Show this help"
|
|
2839
|
+
})
|
|
2840
|
+
};
|
|
2841
|
+
function commandHelp(stream = process.stdout) {
|
|
2842
|
+
stream.write(render());
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
// src/commands/update/update.command.ts
|
|
2846
|
+
import { resolve as resolve3 } from "node:path";
|
|
2847
|
+
async function run4({ values, positionals }) {
|
|
2848
|
+
const cwd = resolve3(positionals[0] ?? process.cwd());
|
|
2849
|
+
const dryRun = values["dry-run"] ?? false;
|
|
2850
|
+
const { ctx, configCreated } = await buildContext(cwd, { dryRun });
|
|
2851
|
+
if (configCreated) {
|
|
2852
|
+
process.stdout.write(`${DIM}Discovered new repo, wrote entry to ${configPath()}${RESET}
|
|
2853
|
+
`);
|
|
2854
|
+
}
|
|
2855
|
+
process.stdout.write(`${BOLD}${CYAN}Updating${RESET} ${ctx.cwd}${dryRun ? `${DIM} (dry run)${RESET}` : ""}
|
|
2856
|
+
`);
|
|
2857
|
+
await runUpdate(ctx, { only: values.only, skip: values.skip });
|
|
2858
|
+
}
|
|
2859
|
+
var updateCommand = {
|
|
2860
|
+
name: "update",
|
|
2861
|
+
run: run4,
|
|
2862
|
+
help: () => ({
|
|
2863
|
+
usage: ["bumper update [path] [--dry-run] [--only id]... [--skip id]..."],
|
|
2864
|
+
summary: "Run every applicable module in order",
|
|
2865
|
+
options: [
|
|
2866
|
+
"--dry-run Print intended steps without changing anything",
|
|
2867
|
+
"--only id Module id to run exclusively (repeat for several)",
|
|
2868
|
+
"--skip id Module id to skip (repeat for several)"
|
|
2869
|
+
]
|
|
2870
|
+
})
|
|
2871
|
+
};
|
|
2872
|
+
|
|
2873
|
+
// src/commands/command.registry.ts
|
|
2874
|
+
var commands = [detectCommand, updateCommand, configCommand, helpCommand];
|
|
2875
|
+
function findCommand(name) {
|
|
2876
|
+
return commands.find((command) => command.name === name);
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
// src/commands/command.types.ts
|
|
2880
|
+
var cliOptions = {
|
|
2881
|
+
json: { type: "boolean" },
|
|
2882
|
+
"dry-run": { type: "boolean" },
|
|
2883
|
+
only: { type: "string", multiple: true },
|
|
2884
|
+
skip: { type: "string", multiple: true },
|
|
2885
|
+
help: { type: "boolean", short: "h" }
|
|
2886
|
+
};
|
|
2887
|
+
|
|
2888
|
+
// src/cli.ts
|
|
2889
|
+
var emitWarning = process.emitWarning.bind(process);
|
|
2890
|
+
process.emitWarning = (warning, ...rest) => {
|
|
2891
|
+
const type = typeof rest[0] === "string" ? rest[0] : rest[0]?.type;
|
|
2892
|
+
if (type === "ExperimentalWarning" && String(warning).includes("glob")) {
|
|
2893
|
+
return;
|
|
2894
|
+
}
|
|
2895
|
+
emitWarning(warning, ...rest);
|
|
2896
|
+
};
|
|
2897
|
+
async function main() {
|
|
2898
|
+
const { values, positionals } = parseArgs({
|
|
2899
|
+
args: process.argv.slice(2),
|
|
2900
|
+
allowPositionals: true,
|
|
2901
|
+
options: cliOptions
|
|
2902
|
+
});
|
|
2903
|
+
const [name, ...rest] = positionals;
|
|
2904
|
+
if (values.help || name === undefined || name === "help") {
|
|
2905
|
+
commandHelp();
|
|
2906
|
+
return;
|
|
2907
|
+
}
|
|
2908
|
+
const command = findCommand(name);
|
|
2909
|
+
if (command === undefined) {
|
|
2910
|
+
process.stderr.write(`unknown command: ${name}
|
|
2911
|
+
|
|
2912
|
+
`);
|
|
2913
|
+
commandHelp(process.stderr);
|
|
2914
|
+
process.exitCode = 1;
|
|
2915
|
+
return;
|
|
2916
|
+
}
|
|
2917
|
+
await command.run({ values, positionals: rest });
|
|
2918
|
+
}
|
|
2919
|
+
main().catch((error) => {
|
|
2920
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2921
|
+
process.stderr.write(`\x1B[31m${message}\x1B[0m
|
|
2922
|
+
`);
|
|
2923
|
+
process.exitCode = 1;
|
|
2924
|
+
});
|