vlt 0.0.0-3 → 0.0.0-4
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/README.md +2 -1
- package/package.json +17 -10
- package/postinstall.cjs +56 -0
- package/vlix +25 -0
- package/vlr +25 -0
- package/vlrx +25 -0
- package/vlt +25 -0
- package/vlx +25 -0
- package/cache-unzip-src-unzip.js +0 -7896
- package/cache-unzip-src-unzip.js.map +0 -7
- package/chunk-227OF2U2.js +0 -1183
- package/chunk-227OF2U2.js.map +0 -7
- package/chunk-3HXIYJS2.js +0 -54
- package/chunk-3HXIYJS2.js.map +0 -7
- package/chunk-AA6MVXJX.js +0 -19823
- package/chunk-AA6MVXJX.js.map +0 -7
- package/chunk-BCK4ZGNG.js +0 -41
- package/chunk-BCK4ZGNG.js.map +0 -7
- package/chunk-DH36SF3E.js +0 -35
- package/chunk-DH36SF3E.js.map +0 -7
- package/chunk-FNKWJ7AZ.js +0 -1379
- package/chunk-FNKWJ7AZ.js.map +0 -7
- package/chunk-H77UDCL3.js +0 -9820
- package/chunk-H77UDCL3.js.map +0 -7
- package/chunk-HL76E44L.js +0 -73
- package/chunk-HL76E44L.js.map +0 -7
- package/chunk-IN7DEH7F.js +0 -44
- package/chunk-IN7DEH7F.js.map +0 -7
- package/chunk-JLP2QDXQ.js +0 -1137
- package/chunk-JLP2QDXQ.js.map +0 -7
- package/chunk-JMGSFQ32.js +0 -969
- package/chunk-JMGSFQ32.js.map +0 -7
- package/chunk-JQRUGUZ3.js +0 -512
- package/chunk-JQRUGUZ3.js.map +0 -7
- package/chunk-K2BYYPM7.js +0 -8656
- package/chunk-K2BYYPM7.js.map +0 -7
- package/chunk-LNUDEBGP.js +0 -2071
- package/chunk-LNUDEBGP.js.map +0 -7
- package/chunk-MV5ZQ3LW.js +0 -1105
- package/chunk-MV5ZQ3LW.js.map +0 -7
- package/chunk-O7CDQZDW.js +0 -5234
- package/chunk-O7CDQZDW.js.map +0 -7
- package/chunk-OFW7MWFP.js +0 -82
- package/chunk-OFW7MWFP.js.map +0 -7
- package/chunk-PGDJ2ZZ6.js +0 -4810
- package/chunk-PGDJ2ZZ6.js.map +0 -7
- package/chunk-POVPHE2F.js +0 -1864
- package/chunk-POVPHE2F.js.map +0 -7
- package/chunk-PTVPYZHU.js +0 -72
- package/chunk-PTVPYZHU.js.map +0 -7
- package/chunk-SXBMMXTY.js +0 -11837
- package/chunk-SXBMMXTY.js.map +0 -7
- package/chunk-UZZ72UON.js +0 -152
- package/chunk-UZZ72UON.js.map +0 -7
- package/chunk-V7KRP7IO.js +0 -481
- package/chunk-V7KRP7IO.js.map +0 -7
- package/chunk-WVNUD273.js +0 -83
- package/chunk-WVNUD273.js.map +0 -7
- package/chunk-WYPE3MV4.js +0 -62
- package/chunk-WYPE3MV4.js.map +0 -7
- package/chunk-ZRNJWPYC.js +0 -37
- package/chunk-ZRNJWPYC.js.map +0 -7
- package/cli-package.json +0 -107
- package/config-3QQHUYLI.js +0 -179
- package/config-3QQHUYLI.js.map +0 -7
- package/devtools-5BBQJTDW.js +0 -16682
- package/devtools-5BBQJTDW.js.map +0 -7
- package/exec-C6GK336U.js +0 -50
- package/exec-C6GK336U.js.map +0 -7
- package/gui-IQ4M4K5X.js +0 -46
- package/gui-IQ4M4K5X.js.map +0 -7
- package/gui-assets/favicon.ico +0 -0
- package/gui-assets/fonts/geist-mono.ttf +0 -0
- package/gui-assets/fonts/inter.ttf +0 -0
- package/gui-assets/images/folder.png +0 -0
- package/gui-assets/index.html +0 -34
- package/gui-assets/index.js +0 -1549
- package/gui-assets/index.js.map +0 -7
- package/gui-assets/main.css +0 -1
- package/help-R6TSKVEA.js +0 -25
- package/help-R6TSKVEA.js.map +0 -7
- package/init-UTJGYULC.js +0 -25
- package/init-UTJGYULC.js.map +0 -7
- package/install-5XDTGLAU.js +0 -56
- package/install-5XDTGLAU.js.map +0 -7
- package/install-exec-VMPN3JE7.js +0 -28
- package/install-exec-VMPN3JE7.js.map +0 -7
- package/list-Q7IANZ3I.js +0 -129
- package/list-Q7IANZ3I.js.map +0 -7
- package/login-VHJEIRVU.js +0 -36
- package/login-VHJEIRVU.js.map +0 -7
- package/logout-5KMCSSR4.js +0 -36
- package/logout-5KMCSSR4.js.map +0 -7
- package/pkg-WYFDWETL.js +0 -364
- package/pkg-WYFDWETL.js.map +0 -7
- package/query-KP4F5D2Y.js +0 -117
- package/query-KP4F5D2Y.js.map +0 -7
- package/registry-client-package.json +0 -85
- package/reporter-LFGXWL6N.js +0 -18
- package/reporter-LFGXWL6N.js.map +0 -7
- package/rollback-remove-src-remove.js +0 -7398
- package/rollback-remove-src-remove.js.map +0 -7
- package/run-XNDZH72D.js +0 -68
- package/run-XNDZH72D.js.map +0 -7
- package/run-exec-NXA33NXJ.js +0 -41
- package/run-exec-NXA33NXJ.js.map +0 -7
- package/source-JWPG6PR3.js +0 -33
- package/source-JWPG6PR3.js.map +0 -7
- package/token-6IJNGEMI.js +0 -86
- package/token-6IJNGEMI.js.map +0 -7
- package/uninstall-MI7NFD27.js +0 -45
- package/uninstall-MI7NFD27.js.map +0 -7
- package/vlix.js +0 -25
- package/vlix.js.map +0 -7
- package/vlr.js +0 -25
- package/vlr.js.map +0 -7
- package/vlrx.js +0 -25
- package/vlrx.js.map +0 -7
- package/vlt.js +0 -24
- package/vlt.js.map +0 -7
- package/vlx.js +0 -25
- package/vlx.js.map +0 -7
- package/whoami-3IEXJF3U.js +0 -46
- package/whoami-3IEXJF3U.js.map +0 -7
- package/yoga.wasm +0 -0
package/chunk-POVPHE2F.js
DELETED
|
@@ -1,1864 +0,0 @@
|
|
|
1
|
-
var global = globalThis;
|
|
2
|
-
import {Buffer} from "node:buffer";
|
|
3
|
-
import {setImmediate, clearImmediate} from "node:timers";
|
|
4
|
-
import {createRequire as _vlt_createRequire} from 'node:module';
|
|
5
|
-
var require = _vlt_createRequire(import.meta.filename);
|
|
6
|
-
import {
|
|
7
|
-
error,
|
|
8
|
-
syntaxError,
|
|
9
|
-
typeError
|
|
10
|
-
} from "./chunk-ZRNJWPYC.js";
|
|
11
|
-
|
|
12
|
-
// ../../src/types/src/index.ts
|
|
13
|
-
var isObj = (o) => !!o && typeof o === "object";
|
|
14
|
-
var maybeRecordStringString = (o) => o === void 0 || isRecordStringString(o);
|
|
15
|
-
var isRecordStringString = (o) => isRecordStringT(o, (s) => typeof s === "string");
|
|
16
|
-
var isRecordStringT = (o, check) => isObj(o) && Object.entries(o).every(
|
|
17
|
-
([k, v]) => typeof k === "string" && check(v)
|
|
18
|
-
);
|
|
19
|
-
var isRecordStringManifest = (o) => isRecordStringT(o, (v) => isManifest(v));
|
|
20
|
-
var maybePeerDependenciesMetaSet = (o) => o === void 0 || isRecordStringT(
|
|
21
|
-
o,
|
|
22
|
-
(v) => isPeerDependenciesMetaValue(v)
|
|
23
|
-
);
|
|
24
|
-
var maybeBoolean = (o) => o === void 0 || typeof o === "boolean";
|
|
25
|
-
var isPeerDependenciesMetaValue = (o) => isObj(o) && maybeBoolean(o.optional);
|
|
26
|
-
var maybeString = (a) => a === void 0 || typeof a === "string";
|
|
27
|
-
var maybeDist = (a) => a === void 0 || isObj(a) && maybeString(a.tarball);
|
|
28
|
-
var isManifest = (m) => isObj(m) && !Array.isArray(m) && maybeString(m.name) && maybeString(m.version) && maybeRecordStringString(m.dependencies) && maybeRecordStringString(m.devDependencies) && maybeRecordStringString(m.optionalDependencies) && maybeRecordStringString(m.peerDependencies) && maybeRecordStringString(m.acceptDependencies) && maybePeerDependenciesMetaSet(m.peerDependenciesMeta) && maybeDist(m.dist);
|
|
29
|
-
var asManifest = (m, from) => {
|
|
30
|
-
if (!isManifest(m)) {
|
|
31
|
-
throw error("invalid manifest", { found: m }, from ?? asManifest);
|
|
32
|
-
}
|
|
33
|
-
return m;
|
|
34
|
-
};
|
|
35
|
-
var isPackument = (p) => {
|
|
36
|
-
if (!isObj(p) || typeof p.name !== "string") return false;
|
|
37
|
-
const { versions, "dist-tags": distTags, time } = p;
|
|
38
|
-
return isRecordStringString(distTags) && isRecordStringManifest(versions) && maybeRecordStringString(time) && Object.values(distTags).every((v) => versions[v]?.name == p.name);
|
|
39
|
-
};
|
|
40
|
-
var asPackument = (p, from) => {
|
|
41
|
-
if (!isPackument(p)) {
|
|
42
|
-
throw error(
|
|
43
|
-
"invalid packument",
|
|
44
|
-
{ found: p },
|
|
45
|
-
from ?? asPackument
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
return p;
|
|
49
|
-
};
|
|
50
|
-
var longDependencyTypes = /* @__PURE__ */ new Set([
|
|
51
|
-
"dependencies",
|
|
52
|
-
"devDependencies",
|
|
53
|
-
"peerDependencies",
|
|
54
|
-
"optionalDependencies"
|
|
55
|
-
]);
|
|
56
|
-
var shortDependencyTypes = /* @__PURE__ */ new Set([
|
|
57
|
-
"prod",
|
|
58
|
-
"dev",
|
|
59
|
-
"peer",
|
|
60
|
-
"optional",
|
|
61
|
-
"peerOptional"
|
|
62
|
-
]);
|
|
63
|
-
var dependencyTypes = /* @__PURE__ */ new Map([
|
|
64
|
-
["dependencies", "prod"],
|
|
65
|
-
["devDependencies", "dev"],
|
|
66
|
-
["peerDependencies", "peer"],
|
|
67
|
-
["optionalDependencies", "optional"]
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
|
-
// ../../src/package-json/src/index.ts
|
|
71
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
72
|
-
import { resolve } from "node:path";
|
|
73
|
-
|
|
74
|
-
// ../../node_modules/.pnpm/polite-json@5.0.0/node_modules/polite-json/dist/esm/index.js
|
|
75
|
-
var hexify = (s) => Array.from(s).map((c) => "0x" + c.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")).join("");
|
|
76
|
-
var parseError = (e, txt, context) => {
|
|
77
|
-
if (!txt) {
|
|
78
|
-
return {
|
|
79
|
-
message: e.message + " while parsing empty string",
|
|
80
|
-
position: 0
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const badToken = e.message.match(/^Unexpected (?:token (.*?))?/i);
|
|
84
|
-
const atPos = e.message.match(/at positions? (\d+)/);
|
|
85
|
-
const errIdx = /^Unexpected end of JSON|Unterminated string in JSON/i.test(e.message) ? txt.length - 1 : atPos && atPos[1] ? +atPos[1] : /is not valid JSON$/.test(e.message) ? 0 : null;
|
|
86
|
-
const msg = badToken && badToken[1] ? e.message.replace(/^Unexpected token ./, `Unexpected token ${JSON.stringify(badToken[1])} (${hexify(badToken[1])})`) : e.message;
|
|
87
|
-
if (errIdx !== null && errIdx !== void 0) {
|
|
88
|
-
const start = errIdx <= context ? 0 : errIdx - context;
|
|
89
|
-
const end = errIdx + context >= txt.length ? txt.length : errIdx + context;
|
|
90
|
-
const slice = (start === 0 ? "" : "...") + txt.slice(start, end) + (end === txt.length ? "" : "...");
|
|
91
|
-
const near = txt === slice ? "" : "near ";
|
|
92
|
-
return {
|
|
93
|
-
message: msg + ` while parsing ${near}${JSON.stringify(slice)}`,
|
|
94
|
-
position: errIdx
|
|
95
|
-
};
|
|
96
|
-
} else {
|
|
97
|
-
return {
|
|
98
|
-
message: msg + ` while parsing '${txt.slice(0, context * 2)}'`,
|
|
99
|
-
position: 0
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
var JSONParseError = class extends SyntaxError {
|
|
104
|
-
code;
|
|
105
|
-
cause;
|
|
106
|
-
position;
|
|
107
|
-
constructor(er, txt, context = 20, caller) {
|
|
108
|
-
const { message, position } = parseError(er, txt, context);
|
|
109
|
-
super(message);
|
|
110
|
-
this.cause = er;
|
|
111
|
-
this.position = position;
|
|
112
|
-
this.code = "EJSONPARSE";
|
|
113
|
-
Error.captureStackTrace(this, caller || this.constructor);
|
|
114
|
-
}
|
|
115
|
-
get name() {
|
|
116
|
-
return this.constructor.name;
|
|
117
|
-
}
|
|
118
|
-
set name(_) {
|
|
119
|
-
}
|
|
120
|
-
get [Symbol.toStringTag]() {
|
|
121
|
-
return this.constructor.name;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var kIndent = Symbol.for("indent");
|
|
125
|
-
var kNewline = Symbol.for("newline");
|
|
126
|
-
var formatRE = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/;
|
|
127
|
-
var emptyRE = /^(?:\{\}|\[\])((?:\r?\n)+)?$/;
|
|
128
|
-
var parse = (txt, reviver, context) => {
|
|
129
|
-
const parseText = stripBOM(String(txt));
|
|
130
|
-
if (!reviver)
|
|
131
|
-
reviver = void 0;
|
|
132
|
-
context = context || 20;
|
|
133
|
-
try {
|
|
134
|
-
const [, newline = "\n", indent = " "] = parseText.match(emptyRE) || parseText.match(formatRE) || [, "", ""];
|
|
135
|
-
const result = JSON.parse(parseText, reviver);
|
|
136
|
-
if (result && typeof result === "object") {
|
|
137
|
-
result[kNewline] = newline;
|
|
138
|
-
result[kIndent] = indent;
|
|
139
|
-
}
|
|
140
|
-
return result;
|
|
141
|
-
} catch (e) {
|
|
142
|
-
if (typeof txt !== "string" && !Buffer.isBuffer(txt)) {
|
|
143
|
-
const isEmptyArray = Array.isArray(txt) && txt.length === 0;
|
|
144
|
-
throw Object.assign(new TypeError(`Cannot parse ${isEmptyArray ? "an empty array" : String(txt)}`), {
|
|
145
|
-
code: "EJSONPARSE",
|
|
146
|
-
systemError: e
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
throw new JSONParseError(e, parseText, context, parse);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
var stripBOM = (txt) => String(txt).replace(/^\uFEFF/, "");
|
|
153
|
-
var stringify = (obj, replacer, indent) => {
|
|
154
|
-
const space = indent === void 0 ? obj[kIndent] : indent;
|
|
155
|
-
const res = (
|
|
156
|
-
/* c8 ignore start */
|
|
157
|
-
typeof replacer === "function" ? JSON.stringify(obj, replacer, space) : JSON.stringify(obj, replacer, space)
|
|
158
|
-
);
|
|
159
|
-
const nl = obj[kNewline] || "\n";
|
|
160
|
-
return space ? (nl === "\n" ? res : res.split("\n").join(nl)) + nl : res;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
// ../../src/package-json/src/index.ts
|
|
164
|
-
var PackageJson = class {
|
|
165
|
-
/**
|
|
166
|
-
* cache of `package.json` loads
|
|
167
|
-
*/
|
|
168
|
-
#cache = /* @__PURE__ */ new Map();
|
|
169
|
-
/**
|
|
170
|
-
* cache of `package.json` paths by manifest
|
|
171
|
-
*/
|
|
172
|
-
#pathCache = /* @__PURE__ */ new Map();
|
|
173
|
-
/**
|
|
174
|
-
* cache of load errors
|
|
175
|
-
*/
|
|
176
|
-
#errCache = /* @__PURE__ */ new Map();
|
|
177
|
-
/**
|
|
178
|
-
* Reads and parses contents of a `package.json` file at a directory `dir`.
|
|
179
|
-
* `reload` will optionally skip reading from the cache when set to `true`.
|
|
180
|
-
*/
|
|
181
|
-
read(dir, { reload } = {}) {
|
|
182
|
-
const cachedPackageJson = !reload && this.#cache.get(dir);
|
|
183
|
-
if (cachedPackageJson) {
|
|
184
|
-
return cachedPackageJson;
|
|
185
|
-
}
|
|
186
|
-
const filename = resolve(dir, "package.json");
|
|
187
|
-
const fail = (err) => error("Could not read package.json file", err, this.read);
|
|
188
|
-
const cachedError = !reload && this.#errCache.get(dir);
|
|
189
|
-
if (cachedError) {
|
|
190
|
-
throw fail(cachedError);
|
|
191
|
-
}
|
|
192
|
-
try {
|
|
193
|
-
const res = asManifest(
|
|
194
|
-
parse(readFileSync(filename, { encoding: "utf8" }))
|
|
195
|
-
);
|
|
196
|
-
this.#cache.set(dir, res);
|
|
197
|
-
this.#pathCache.set(res, dir);
|
|
198
|
-
return res;
|
|
199
|
-
} catch (err) {
|
|
200
|
-
const ec = {
|
|
201
|
-
path: filename,
|
|
202
|
-
cause: err
|
|
203
|
-
};
|
|
204
|
-
this.#errCache.set(dir, ec);
|
|
205
|
-
throw fail(ec);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
write(dir, manifest, indent) {
|
|
209
|
-
const filename = resolve(dir, "package.json");
|
|
210
|
-
this.fix(manifest);
|
|
211
|
-
try {
|
|
212
|
-
writeFileSync(filename, stringify(manifest, void 0, indent));
|
|
213
|
-
this.#cache.set(dir, manifest);
|
|
214
|
-
this.#pathCache.set(manifest, dir);
|
|
215
|
-
} catch (err) {
|
|
216
|
-
this.#cache.delete(dir);
|
|
217
|
-
this.#pathCache.delete(manifest);
|
|
218
|
-
throw error(
|
|
219
|
-
"Could not write package.json file",
|
|
220
|
-
{
|
|
221
|
-
path: filename,
|
|
222
|
-
cause: err
|
|
223
|
-
},
|
|
224
|
-
this.write
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
save(manifest) {
|
|
229
|
-
const dir = this.#pathCache.get(manifest);
|
|
230
|
-
if (!dir) {
|
|
231
|
-
throw error(
|
|
232
|
-
"Could not save manifest",
|
|
233
|
-
{
|
|
234
|
-
manifest
|
|
235
|
-
},
|
|
236
|
-
this.save
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
this.write(dir, manifest);
|
|
240
|
-
}
|
|
241
|
-
fix(manifest) {
|
|
242
|
-
for (const depType of longDependencyTypes) {
|
|
243
|
-
const deps = manifest[depType];
|
|
244
|
-
if (deps) {
|
|
245
|
-
manifest[depType] = Object.fromEntries(
|
|
246
|
-
Object.entries(deps).sort(
|
|
247
|
-
([a], [b]) => a.localeCompare(b, "en")
|
|
248
|
-
)
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// ../../src/spec/src/index.ts
|
|
256
|
-
import { homedir } from "node:os";
|
|
257
|
-
import {
|
|
258
|
-
isAbsolute,
|
|
259
|
-
join,
|
|
260
|
-
resolve as resolve2,
|
|
261
|
-
win32 as winPath
|
|
262
|
-
} from "node:path";
|
|
263
|
-
import { inspect } from "node:util";
|
|
264
|
-
|
|
265
|
-
// ../../src/fast-split/src/index.ts
|
|
266
|
-
function fastSplit(str, delim, limit = -1, onPart) {
|
|
267
|
-
let i = 0;
|
|
268
|
-
let p = 0;
|
|
269
|
-
const l = delim.length;
|
|
270
|
-
const parts = [];
|
|
271
|
-
while (i !== -1) {
|
|
272
|
-
i = str.indexOf(delim, p);
|
|
273
|
-
const part = i === -1 || parts.length === limit - 1 ? str.substring(p) : str.substring(p, i);
|
|
274
|
-
parts.push(onPart?.(part, parts, i) ?? part);
|
|
275
|
-
if (parts.length === limit) {
|
|
276
|
-
return parts;
|
|
277
|
-
}
|
|
278
|
-
p = i + l;
|
|
279
|
-
}
|
|
280
|
-
return parts;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// ../../src/semver/src/version.ts
|
|
284
|
-
var maybeNumber = (s) => {
|
|
285
|
-
if (!/^[0-9]+$/.test(s)) return s;
|
|
286
|
-
const n = Number(s);
|
|
287
|
-
return n <= Number.MAX_SAFE_INTEGER ? n : s;
|
|
288
|
-
};
|
|
289
|
-
var safeNumber = (s, version, field) => {
|
|
290
|
-
const n = Number(s);
|
|
291
|
-
if (n > Number.MAX_SAFE_INTEGER) {
|
|
292
|
-
throw invalidVersion(
|
|
293
|
-
version,
|
|
294
|
-
`invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
return n;
|
|
298
|
-
};
|
|
299
|
-
var re = {
|
|
300
|
-
prefix: /^[ v=]+/,
|
|
301
|
-
main: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/,
|
|
302
|
-
prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\+)/,
|
|
303
|
-
build: /\+([0-9a-zA-Z_.-]+)$/,
|
|
304
|
-
full: /^[ v=]*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\+([0-9a-zA-Z_.-]+))?$/
|
|
305
|
-
};
|
|
306
|
-
var invalidVersion = (version, message) => {
|
|
307
|
-
const er = syntaxError(
|
|
308
|
-
`invalid version: ${message}`,
|
|
309
|
-
{ version },
|
|
310
|
-
Version
|
|
311
|
-
);
|
|
312
|
-
return er;
|
|
313
|
-
};
|
|
314
|
-
var Version = class _Version {
|
|
315
|
-
/** raw string provided to create this Version */
|
|
316
|
-
raw;
|
|
317
|
-
/** major version number */
|
|
318
|
-
major;
|
|
319
|
-
/** minor version number */
|
|
320
|
-
minor;
|
|
321
|
-
/** patch version number */
|
|
322
|
-
patch;
|
|
323
|
-
/**
|
|
324
|
-
* List of `'.'`-separated strings and numbers indicating that this
|
|
325
|
-
* version is a prerelease.
|
|
326
|
-
*
|
|
327
|
-
* This is undefined if the version does not have a prerelease section.
|
|
328
|
-
*/
|
|
329
|
-
prerelease;
|
|
330
|
-
/**
|
|
331
|
-
* List of `'.'`-separated strings in the `build` section.
|
|
332
|
-
*
|
|
333
|
-
* This is undefined if the version does not have a build.
|
|
334
|
-
*/
|
|
335
|
-
build;
|
|
336
|
-
/** Canonical strict form of this version */
|
|
337
|
-
toString() {
|
|
338
|
-
return `${this.major}.${this.minor}.${this.patch}${this.prerelease ? "-" + this.prerelease.join(".") : ""}${this.build ? "+" + this.build.join(".") : ""}`;
|
|
339
|
-
}
|
|
340
|
-
/** Generate a `Version` object from a SemVer string */
|
|
341
|
-
static parse(version) {
|
|
342
|
-
version = version.replace(re.prefix, "").trim();
|
|
343
|
-
if (version.length > 256) {
|
|
344
|
-
throw invalidVersion(
|
|
345
|
-
version,
|
|
346
|
-
"must be less than 256 characters"
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
const parsed = version.match(re.full);
|
|
350
|
-
if (!parsed) {
|
|
351
|
-
const main = version.match(re.main);
|
|
352
|
-
if (!main) {
|
|
353
|
-
throw invalidVersion(
|
|
354
|
-
version,
|
|
355
|
-
"no Major.minor.patch tuple present"
|
|
356
|
-
);
|
|
357
|
-
} else {
|
|
358
|
-
throw invalidVersion(
|
|
359
|
-
version,
|
|
360
|
-
"invalid build or patch section"
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
const [_, major_, minor_, patch_, prerelease, build] = parsed;
|
|
365
|
-
const major2 = safeNumber(major_, version, "major");
|
|
366
|
-
const minor2 = safeNumber(minor_, version, "minor");
|
|
367
|
-
const patch2 = safeNumber(patch_, version, "patch");
|
|
368
|
-
return new _Version(
|
|
369
|
-
version,
|
|
370
|
-
major2,
|
|
371
|
-
minor2,
|
|
372
|
-
patch2,
|
|
373
|
-
prerelease,
|
|
374
|
-
build
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
constructor(version, major2, minor2, patch2, prerelease, build) {
|
|
378
|
-
this.raw = version;
|
|
379
|
-
this.major = major2;
|
|
380
|
-
this.minor = minor2;
|
|
381
|
-
this.patch = patch2;
|
|
382
|
-
if (prerelease) {
|
|
383
|
-
this.prerelease = fastSplit(prerelease, ".", -1, (c) => {
|
|
384
|
-
if (!c) {
|
|
385
|
-
throw invalidVersion(
|
|
386
|
-
version,
|
|
387
|
-
"invalid prerelease, empty identifiers not allowed"
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
return maybeNumber(c);
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
if (build) {
|
|
394
|
-
this.build = fastSplit(build, ".", -1, (c) => {
|
|
395
|
-
if (!c) {
|
|
396
|
-
throw invalidVersion(
|
|
397
|
-
version,
|
|
398
|
-
"invalid build metadata, empty identifiers not allowed"
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Return 1 if this is > the provided version, -1 if we're less, or 0 if
|
|
406
|
-
* they are equal.
|
|
407
|
-
*
|
|
408
|
-
* No special handling for prerelease versions, this is just a precedence
|
|
409
|
-
* comparison.
|
|
410
|
-
*
|
|
411
|
-
* This can be used to sort a list of versions by precedence:
|
|
412
|
-
*
|
|
413
|
-
* ```ts
|
|
414
|
-
* const versions: Version[] = getVersionsSomehow()
|
|
415
|
-
* const sorted = versions.sort((a, b) => a.compare(b))
|
|
416
|
-
* ```
|
|
417
|
-
*/
|
|
418
|
-
compare(v) {
|
|
419
|
-
if (this.major > v.major) return 1;
|
|
420
|
-
if (this.major < v.major) return -1;
|
|
421
|
-
if (this.minor > v.minor) return 1;
|
|
422
|
-
if (this.minor < v.minor) return -1;
|
|
423
|
-
if (this.patch > v.patch) return 1;
|
|
424
|
-
if (this.patch < v.patch) return -1;
|
|
425
|
-
if (!v.prerelease?.length)
|
|
426
|
-
return !this.prerelease?.length ? 0 : -1;
|
|
427
|
-
if (!this.prerelease?.length) return 1;
|
|
428
|
-
const len = Math.max(this.prerelease.length, v.prerelease.length);
|
|
429
|
-
const me = this.prerelease;
|
|
430
|
-
const thee = v.prerelease;
|
|
431
|
-
for (let i = 0; i < len; i++) {
|
|
432
|
-
const m = me[i];
|
|
433
|
-
const t = thee[i];
|
|
434
|
-
if (m === t) continue;
|
|
435
|
-
if (t === void 0) return 1;
|
|
436
|
-
if (m === void 0) return -1;
|
|
437
|
-
if (typeof m !== typeof t) {
|
|
438
|
-
return typeof m === "string" ? 1 : -1;
|
|
439
|
-
}
|
|
440
|
-
return m > t ? 1 : -1;
|
|
441
|
-
}
|
|
442
|
-
return 0;
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* The inverse of compare, for sorting version lists in reverse order
|
|
446
|
-
*/
|
|
447
|
-
rcompare(v) {
|
|
448
|
-
return -1 * this.compare(v);
|
|
449
|
-
}
|
|
450
|
-
/** true if this version is > the argument */
|
|
451
|
-
greaterThan(v) {
|
|
452
|
-
return this.compare(v) === 1;
|
|
453
|
-
}
|
|
454
|
-
/** true if this version is >= the argument */
|
|
455
|
-
greaterThanEqual(v) {
|
|
456
|
-
return this.compare(v) > -1;
|
|
457
|
-
}
|
|
458
|
-
/** true if this version is < the argument */
|
|
459
|
-
lessThan(v) {
|
|
460
|
-
return this.compare(v) === -1;
|
|
461
|
-
}
|
|
462
|
-
/** true if this version is <= the argument */
|
|
463
|
-
lessThanEqual(v) {
|
|
464
|
-
return this.compare(v) < 1;
|
|
465
|
-
}
|
|
466
|
-
/** true if these two versions have equal SemVer precedence */
|
|
467
|
-
equals(v) {
|
|
468
|
-
return this.compare(v) === 0;
|
|
469
|
-
}
|
|
470
|
-
/** just compare the M.m.p parts of the version */
|
|
471
|
-
tupleEquals(v) {
|
|
472
|
-
return this.major === v.major && this.minor === v.minor && this.patch === v.patch;
|
|
473
|
-
}
|
|
474
|
-
/** true if this version satisfies the range */
|
|
475
|
-
satisfies(r) {
|
|
476
|
-
return r.test(this);
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Increment the version in place, in the manner specified.
|
|
480
|
-
*
|
|
481
|
-
* Part behaviors:
|
|
482
|
-
*
|
|
483
|
-
* - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
|
|
484
|
-
* simply drop the prerelease. Otherwise, set the minor and patch to 0, and
|
|
485
|
-
* increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
|
|
486
|
-
* `2.0.0`
|
|
487
|
-
*
|
|
488
|
-
* - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
|
|
489
|
-
* simply drop the prerelease. Otherwise, set the patch to 0, and increment the
|
|
490
|
-
* minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
|
|
491
|
-
*
|
|
492
|
-
* - `'patch'` If the version has a prerelease, then simply drop the
|
|
493
|
-
* prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
|
|
494
|
-
* `1.2.3` and `1.2.3` becomes `1.2.4`.
|
|
495
|
-
*
|
|
496
|
-
* - `'premajor'` Set the patch and minor versions to `0`, increment the major
|
|
497
|
-
* version, and add a prerelease, using the optional identifier.
|
|
498
|
-
*
|
|
499
|
-
* - `'preminor'` Set the patch version to `0`, increment the minor version,
|
|
500
|
-
* and add a prerelease, using the optional identifier.
|
|
501
|
-
*
|
|
502
|
-
* - `'prepatch'` If a prerelease is already present, increment the patch
|
|
503
|
-
* version, otherwise leave it untouched, and add a prerelease, using the
|
|
504
|
-
* optional identifier.
|
|
505
|
-
*
|
|
506
|
-
* - `'prerelease'` If a prerelease version is present, then behave the same as
|
|
507
|
-
* `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
|
|
508
|
-
*
|
|
509
|
-
* - `'pre'` This is mostly for use by the other prerelease incrementers.
|
|
510
|
-
*
|
|
511
|
-
* - If a prerelease identifier is provided:
|
|
512
|
-
*
|
|
513
|
-
* Update that named portion of the prerelease. For example,
|
|
514
|
-
* `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
|
|
515
|
-
*
|
|
516
|
-
* If there is no prerelease identifier by that name, then replace the
|
|
517
|
-
* prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
|
|
518
|
-
* would result in `1.2.3-beta`.
|
|
519
|
-
*
|
|
520
|
-
* If the prerelease identifer is present, but has no numeric value
|
|
521
|
-
* following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
|
|
522
|
-
* would result in `1.2.3-beta.0`.
|
|
523
|
-
*
|
|
524
|
-
* - If no prerelease identifier is provided:
|
|
525
|
-
*
|
|
526
|
-
* If there is no current prerelease, then set the prerelease to `0`. So,
|
|
527
|
-
* `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
|
|
528
|
-
*
|
|
529
|
-
* If the last item in the prerelease is numeric, then increment it. So,
|
|
530
|
-
* `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
|
|
531
|
-
*/
|
|
532
|
-
inc(part, prereleaseIdentifier) {
|
|
533
|
-
switch (part) {
|
|
534
|
-
case "premajor":
|
|
535
|
-
this.prerelease = void 0;
|
|
536
|
-
this.patch = 0;
|
|
537
|
-
this.minor = 0;
|
|
538
|
-
this.major++;
|
|
539
|
-
this.inc("pre", prereleaseIdentifier);
|
|
540
|
-
break;
|
|
541
|
-
case "preminor":
|
|
542
|
-
this.prerelease = void 0;
|
|
543
|
-
this.patch = 0;
|
|
544
|
-
this.minor++;
|
|
545
|
-
this.inc("pre", prereleaseIdentifier);
|
|
546
|
-
break;
|
|
547
|
-
case "prepatch":
|
|
548
|
-
this.prerelease = void 0;
|
|
549
|
-
this.inc("patch");
|
|
550
|
-
this.inc("pre", prereleaseIdentifier);
|
|
551
|
-
break;
|
|
552
|
-
case "prerelease":
|
|
553
|
-
if (!this.prerelease?.length)
|
|
554
|
-
this.inc("patch", prereleaseIdentifier);
|
|
555
|
-
this.inc("pre", prereleaseIdentifier);
|
|
556
|
-
break;
|
|
557
|
-
case "pre": {
|
|
558
|
-
if (!prereleaseIdentifier) {
|
|
559
|
-
if (!this.prerelease?.length) {
|
|
560
|
-
this.prerelease = [0];
|
|
561
|
-
break;
|
|
562
|
-
}
|
|
563
|
-
const last = this.prerelease[this.prerelease.length - 1];
|
|
564
|
-
if (typeof last === "number") {
|
|
565
|
-
this.prerelease[this.prerelease.length - 1] = last + 1;
|
|
566
|
-
} else {
|
|
567
|
-
this.prerelease.push(0);
|
|
568
|
-
}
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
if (!this.prerelease?.length) {
|
|
572
|
-
this.prerelease = [prereleaseIdentifier];
|
|
573
|
-
break;
|
|
574
|
-
}
|
|
575
|
-
const i = this.prerelease.indexOf(
|
|
576
|
-
maybeNumber(prereleaseIdentifier)
|
|
577
|
-
);
|
|
578
|
-
if (i === -1) {
|
|
579
|
-
this.prerelease = [prereleaseIdentifier];
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
const baseValue = this.prerelease[i + 1];
|
|
583
|
-
if (typeof baseValue === "number") {
|
|
584
|
-
this.prerelease[i + 1] = baseValue + 1;
|
|
585
|
-
break;
|
|
586
|
-
}
|
|
587
|
-
if (i === this.prerelease.length - 1) {
|
|
588
|
-
this.prerelease.push(0);
|
|
589
|
-
break;
|
|
590
|
-
}
|
|
591
|
-
this.prerelease.splice(i + 1, 0, 0);
|
|
592
|
-
break;
|
|
593
|
-
}
|
|
594
|
-
case "major":
|
|
595
|
-
if (!this.prerelease?.length || this.minor || this.patch)
|
|
596
|
-
this.major++;
|
|
597
|
-
this.prerelease = void 0;
|
|
598
|
-
this.patch = 0;
|
|
599
|
-
this.minor = 0;
|
|
600
|
-
break;
|
|
601
|
-
case "minor":
|
|
602
|
-
if (!this.prerelease?.length || this.patch) this.minor++;
|
|
603
|
-
this.prerelease = void 0;
|
|
604
|
-
this.patch = 0;
|
|
605
|
-
break;
|
|
606
|
-
case "patch":
|
|
607
|
-
if (!this.prerelease?.length) this.patch++;
|
|
608
|
-
this.prerelease = void 0;
|
|
609
|
-
break;
|
|
610
|
-
default:
|
|
611
|
-
throw typeError(
|
|
612
|
-
"Invalid increment identifier",
|
|
613
|
-
{
|
|
614
|
-
version: this,
|
|
615
|
-
found: part,
|
|
616
|
-
validOptions: [
|
|
617
|
-
"major",
|
|
618
|
-
"minor",
|
|
619
|
-
"patch",
|
|
620
|
-
"premajor",
|
|
621
|
-
"preminor",
|
|
622
|
-
"prepatch",
|
|
623
|
-
"prerelease",
|
|
624
|
-
"pre"
|
|
625
|
-
]
|
|
626
|
-
},
|
|
627
|
-
this.inc
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
this.raw = this.toString();
|
|
631
|
-
return this;
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
// ../../src/semver/src/comparator.ts
|
|
636
|
-
var isOperator = (o) => !!o && (o === ">" || o === "<" || o === ">=" || o === "<=" || o === "" || o === "~" || o === "^" || o === "~>");
|
|
637
|
-
var preJunk = new Set("=v ");
|
|
638
|
-
var invalidComp = (c, message) => syntaxError(
|
|
639
|
-
`invalid comparator: '${c}' ${message}`,
|
|
640
|
-
{ found: c },
|
|
641
|
-
Comparator
|
|
642
|
-
);
|
|
643
|
-
var assertNumber = (value, c, field) => {
|
|
644
|
-
const n = Number(value);
|
|
645
|
-
if (n !== n) {
|
|
646
|
-
throw invalidComp(
|
|
647
|
-
c,
|
|
648
|
-
`${field} must be numeric or 'x', got: '${value}'`
|
|
649
|
-
);
|
|
650
|
-
}
|
|
651
|
-
return n;
|
|
652
|
-
};
|
|
653
|
-
var assertVersion = (v, comp) => {
|
|
654
|
-
if (!v) {
|
|
655
|
-
throw invalidComp(comp, "no value provided for operator");
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
var assertMissing = (value, c, field) => {
|
|
659
|
-
if (value && !isX(value)) {
|
|
660
|
-
throw invalidComp(
|
|
661
|
-
c,
|
|
662
|
-
`cannot omit '${field}' and include subsequent fields`
|
|
663
|
-
);
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
var MAJOR = 0;
|
|
667
|
-
var MINOR = 1;
|
|
668
|
-
var PATCH = 2;
|
|
669
|
-
var isX = (c) => !c || c === "X" || c === "x" || c === "*";
|
|
670
|
-
var isFullVersion = (parsed) => void 0 !== parsed[PATCH];
|
|
671
|
-
var isXPatch = (parsed) => void 0 !== parsed[MINOR] && void 0 === parsed[PATCH];
|
|
672
|
-
var isXMinor = (parsed) => void 0 !== parsed[MAJOR] && void 0 === parsed[MINOR];
|
|
673
|
-
var isXMajor = (parsed) => void 0 === parsed[MAJOR];
|
|
674
|
-
var Comparator = class {
|
|
675
|
-
/**
|
|
676
|
-
* does this range include prereleases, even when they do not
|
|
677
|
-
* match the tuple in the comparator?
|
|
678
|
-
*/
|
|
679
|
-
includePrerelease;
|
|
680
|
-
/** raw string used to create this comparator */
|
|
681
|
-
raw;
|
|
682
|
-
/** tokens extracted from the raw string input */
|
|
683
|
-
tokens;
|
|
684
|
-
/**
|
|
685
|
-
* Either the `any` comparator, the `none` comparator, or an operator
|
|
686
|
-
* and a {@link ParsedXRange}
|
|
687
|
-
*/
|
|
688
|
-
tuples = [];
|
|
689
|
-
/** true if this comparator can not match anything */
|
|
690
|
-
isNone = false;
|
|
691
|
-
/**
|
|
692
|
-
* true if this comparator is a `'*'` type of range.
|
|
693
|
-
*
|
|
694
|
-
* Note that it still will not match versions with a prerelease value,
|
|
695
|
-
* unless the tuple in the version matches the tuple provided to the
|
|
696
|
-
* comparator, and the comparator version also has a prerelease value,
|
|
697
|
-
* unless `includePrerelease` is set.
|
|
698
|
-
*/
|
|
699
|
-
isAny = false;
|
|
700
|
-
/** the canonical strict simplified parsed form of this constructor */
|
|
701
|
-
toString() {
|
|
702
|
-
return this.isNone ? "<0.0.0-0" : this.isAny ? "*" : (
|
|
703
|
-
/* c8 ignore next */
|
|
704
|
-
this.tuples.map((c) => isAny(c) ? "*" : c.join("")).join(" ")
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
constructor(comp, includePrerelease = false) {
|
|
708
|
-
this.includePrerelease = includePrerelease;
|
|
709
|
-
comp = comp.trim();
|
|
710
|
-
this.raw = comp;
|
|
711
|
-
let hyphen = false;
|
|
712
|
-
const rawComps = fastSplit(comp, " ", -1, (part, parts, i) => {
|
|
713
|
-
if (part === "-") {
|
|
714
|
-
if (hyphen) {
|
|
715
|
-
throw invalidComp(
|
|
716
|
-
comp,
|
|
717
|
-
"multiple hyphen ranges not allowed"
|
|
718
|
-
);
|
|
719
|
-
}
|
|
720
|
-
if (parts.length !== 1 || i === -1) {
|
|
721
|
-
throw invalidComp(
|
|
722
|
-
comp,
|
|
723
|
-
"hyphen must be between two versions"
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
hyphen = true;
|
|
727
|
-
} else if (hyphen && parts.length !== 2) {
|
|
728
|
-
throw invalidComp(comp, "hyphen range must be alone");
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
const comps = [];
|
|
732
|
-
let followingOperator = false;
|
|
733
|
-
let l = 0;
|
|
734
|
-
for (const c of rawComps) {
|
|
735
|
-
if (c === "") continue;
|
|
736
|
-
if (!followingOperator) {
|
|
737
|
-
followingOperator = isOperator(c);
|
|
738
|
-
comps.push(c);
|
|
739
|
-
l++;
|
|
740
|
-
continue;
|
|
741
|
-
}
|
|
742
|
-
comps[l - 1] += c;
|
|
743
|
-
followingOperator = false;
|
|
744
|
-
}
|
|
745
|
-
if (hyphen) {
|
|
746
|
-
const [min, _, max] = comps;
|
|
747
|
-
if (!min || !max) {
|
|
748
|
-
throw invalidComp(comp, "hyphen must be between two versions");
|
|
749
|
-
}
|
|
750
|
-
this.#parseHyphenRange(min, max);
|
|
751
|
-
} else if (!comps.length || comps.length === 1 && isX(comps[0])) {
|
|
752
|
-
this.tuples.push(this.#getComparatorAny());
|
|
753
|
-
} else {
|
|
754
|
-
for (const c of comps) {
|
|
755
|
-
this.#parse(c);
|
|
756
|
-
if (this.isNone) break;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
this.tokens = comps;
|
|
760
|
-
this.isAny = true;
|
|
761
|
-
for (const c of this.tuples) {
|
|
762
|
-
if (Array.isArray(c) || !c.isAny) {
|
|
763
|
-
this.isAny = false;
|
|
764
|
-
break;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
// inclusive min
|
|
769
|
-
#xInclusiveMin(raw) {
|
|
770
|
-
const z = this.includePrerelease ? "0" : void 0;
|
|
771
|
-
const [M, m = 0, p = 0, pr = z, build] = this.#parseX(raw);
|
|
772
|
-
return M === void 0 ? this.#getComparatorAny() : [">=", new Version(raw, M, m, p, pr, build)];
|
|
773
|
-
}
|
|
774
|
-
// exclusive min
|
|
775
|
-
#xExclusiveMin(raw) {
|
|
776
|
-
const parsed = this.#parseX(raw);
|
|
777
|
-
if (isFullVersion(parsed)) {
|
|
778
|
-
return [">", new Version(raw, ...parsed)];
|
|
779
|
-
}
|
|
780
|
-
const z = this.includePrerelease ? "0" : void 0;
|
|
781
|
-
if (isXPatch(parsed)) {
|
|
782
|
-
return [
|
|
783
|
-
">=",
|
|
784
|
-
new Version(
|
|
785
|
-
raw,
|
|
786
|
-
parsed[MAJOR],
|
|
787
|
-
parsed[MINOR] + 1,
|
|
788
|
-
0,
|
|
789
|
-
z,
|
|
790
|
-
void 0
|
|
791
|
-
)
|
|
792
|
-
];
|
|
793
|
-
}
|
|
794
|
-
if (isXMinor(parsed)) {
|
|
795
|
-
return [
|
|
796
|
-
">=",
|
|
797
|
-
new Version(raw, parsed[MAJOR] + 1, 0, 0, z, void 0)
|
|
798
|
-
];
|
|
799
|
-
}
|
|
800
|
-
this.isNone = true;
|
|
801
|
-
this.tuples.length = 0;
|
|
802
|
-
return comparatorNone;
|
|
803
|
-
}
|
|
804
|
-
#xInclusiveMax(raw) {
|
|
805
|
-
const parsed = this.#parseX(raw);
|
|
806
|
-
return isFullVersion(parsed) ? ["<=", new Version(raw, ...parsed)] : isXPatch(parsed) ? [
|
|
807
|
-
"<",
|
|
808
|
-
new Version(
|
|
809
|
-
raw,
|
|
810
|
-
parsed[MAJOR],
|
|
811
|
-
parsed[MINOR] + 1,
|
|
812
|
-
0,
|
|
813
|
-
"0",
|
|
814
|
-
void 0
|
|
815
|
-
)
|
|
816
|
-
] : isXMinor(parsed) ? [
|
|
817
|
-
"<",
|
|
818
|
-
new Version(raw, parsed[MAJOR] + 1, 0, 0, "0", void 0)
|
|
819
|
-
] : this.#getComparatorAny();
|
|
820
|
-
}
|
|
821
|
-
#xExclusiveMax(raw) {
|
|
822
|
-
const z = this.includePrerelease ? "0" : void 0;
|
|
823
|
-
const [M = 0, m = 0, p = 0, pr = z, build] = this.#parseX(raw);
|
|
824
|
-
if (M === 0 && m === 0 && p === 0 && pr === "0") {
|
|
825
|
-
this.isNone = true;
|
|
826
|
-
this.tuples.length = 0;
|
|
827
|
-
return comparatorNone;
|
|
828
|
-
}
|
|
829
|
-
return ["<", new Version(raw, M, m, p, pr, build)];
|
|
830
|
-
}
|
|
831
|
-
#validXM(raw, m, p) {
|
|
832
|
-
assertMissing(m, raw, "major");
|
|
833
|
-
assertMissing(p, raw, "major");
|
|
834
|
-
if (m === "" || p === "") {
|
|
835
|
-
throw invalidComp(raw, `(Did you mean '*'?)`);
|
|
836
|
-
}
|
|
837
|
-
return [];
|
|
838
|
-
}
|
|
839
|
-
#validXm(raw, M, m, p) {
|
|
840
|
-
assertMissing(p, raw, "major");
|
|
841
|
-
if (m === "" || p === "") {
|
|
842
|
-
throw invalidComp(raw, `(Did you mean '${M}'?)`);
|
|
843
|
-
}
|
|
844
|
-
return [assertNumber(M, raw, "major")];
|
|
845
|
-
}
|
|
846
|
-
#validXp(raw, M, m, p) {
|
|
847
|
-
if (p === "") {
|
|
848
|
-
throw invalidComp(raw, `(Did you mean '${M}.${m}'?)`);
|
|
849
|
-
}
|
|
850
|
-
return [
|
|
851
|
-
assertNumber(M, raw, "major"),
|
|
852
|
-
assertNumber(m, raw, "minor")
|
|
853
|
-
];
|
|
854
|
-
}
|
|
855
|
-
#validTuple(raw, M, m, p) {
|
|
856
|
-
return [
|
|
857
|
-
assertNumber(M, raw, "major"),
|
|
858
|
-
assertNumber(m, raw, "minor"),
|
|
859
|
-
assertNumber(p, raw, "patch")
|
|
860
|
-
];
|
|
861
|
-
}
|
|
862
|
-
#validXbuild(raw, M, m, p, pl) {
|
|
863
|
-
const patch2 = p.substring(0, pl);
|
|
864
|
-
const build = p.substring(pl + 1);
|
|
865
|
-
if (!patch2) {
|
|
866
|
-
throw invalidComp(raw, "cannot specify build without patch");
|
|
867
|
-
}
|
|
868
|
-
if (!build) {
|
|
869
|
-
throw invalidComp(raw, `encountered '+', but no build value`);
|
|
870
|
-
}
|
|
871
|
-
return [
|
|
872
|
-
assertNumber(M, raw, "major"),
|
|
873
|
-
assertNumber(m, raw, "minor"),
|
|
874
|
-
assertNumber(patch2, raw, "patch"),
|
|
875
|
-
void 0,
|
|
876
|
-
build
|
|
877
|
-
];
|
|
878
|
-
}
|
|
879
|
-
#validXpr(raw, M, m, p, hy) {
|
|
880
|
-
{
|
|
881
|
-
const patch2 = p.substring(0, hy);
|
|
882
|
-
const pr = p.substring(hy + 1);
|
|
883
|
-
if (!patch2) {
|
|
884
|
-
throw invalidComp(
|
|
885
|
-
raw,
|
|
886
|
-
"cannot specify prerelease without patch"
|
|
887
|
-
);
|
|
888
|
-
}
|
|
889
|
-
if (!pr) {
|
|
890
|
-
throw invalidComp(
|
|
891
|
-
raw,
|
|
892
|
-
`encountered '-', but no prerelease value`
|
|
893
|
-
);
|
|
894
|
-
}
|
|
895
|
-
return [
|
|
896
|
-
assertNumber(M, raw, "major"),
|
|
897
|
-
assertNumber(m, raw, "minor"),
|
|
898
|
-
assertNumber(patch2, raw, "patch"),
|
|
899
|
-
pr,
|
|
900
|
-
void 0
|
|
901
|
-
];
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
#validXprbuild(raw, M, m, p, hy, pl) {
|
|
905
|
-
const patch2 = p.substring(0, hy);
|
|
906
|
-
const pr = p.substring(hy + 1, pl);
|
|
907
|
-
const build = p.substring(pl + 1);
|
|
908
|
-
if (!patch2) {
|
|
909
|
-
throw invalidComp(
|
|
910
|
-
raw,
|
|
911
|
-
"cannot specify prerelease without patch"
|
|
912
|
-
);
|
|
913
|
-
}
|
|
914
|
-
if (!pr) {
|
|
915
|
-
throw invalidComp(
|
|
916
|
-
raw,
|
|
917
|
-
`encountered '-', but no prerelease value`
|
|
918
|
-
);
|
|
919
|
-
}
|
|
920
|
-
if (!build) {
|
|
921
|
-
throw invalidComp(raw, `encountered '+', but no build value`);
|
|
922
|
-
}
|
|
923
|
-
return [
|
|
924
|
-
assertNumber(M, raw, "major"),
|
|
925
|
-
assertNumber(m, raw, "minor"),
|
|
926
|
-
assertNumber(patch2, raw, "patch"),
|
|
927
|
-
pr,
|
|
928
|
-
build
|
|
929
|
-
];
|
|
930
|
-
}
|
|
931
|
-
// pull the relevant values out of an X-range or version
|
|
932
|
-
// return the fields for creating a Version object.
|
|
933
|
-
// only call once operator is stripped off
|
|
934
|
-
#parseX(raw) {
|
|
935
|
-
let [M, m, p] = fastSplit(raw, ".", 3);
|
|
936
|
-
let prune = 0;
|
|
937
|
-
while (M && preJunk.has(M.charAt(prune))) prune++;
|
|
938
|
-
if (M !== void 0 && prune !== 0) M = M.substring(prune);
|
|
939
|
-
if (!M || isX(M)) return this.#validXM(raw, m, p);
|
|
940
|
-
if (!m || isX(m)) return this.#validXm(raw, M, m, p);
|
|
941
|
-
if (!p || isX(p)) return this.#validXp(raw, M, m, p);
|
|
942
|
-
const hy = p.indexOf("-");
|
|
943
|
-
const pl = p.indexOf("+");
|
|
944
|
-
if (pl === -1 && hy === -1) return this.#validTuple(raw, M, m, p);
|
|
945
|
-
if (pl === -1) return this.#validXpr(raw, M, m, p, hy);
|
|
946
|
-
if (hy === -1) return this.#validXbuild(raw, M, m, p, pl);
|
|
947
|
-
return this.#validXprbuild(raw, M, m, p, hy, pl);
|
|
948
|
-
}
|
|
949
|
-
#parseHyphenRange(min, max) {
|
|
950
|
-
const minv = this.#xInclusiveMin(min);
|
|
951
|
-
const maxv = this.#xInclusiveMax(max);
|
|
952
|
-
const minAny = isAny(minv);
|
|
953
|
-
const maxAny = isAny(maxv);
|
|
954
|
-
if (minAny && maxAny) this.tuples.push(this.#getComparatorAny());
|
|
955
|
-
else if (minAny) this.tuples.push(maxv);
|
|
956
|
-
else if (maxAny) this.tuples.push(minv);
|
|
957
|
-
else this.tuples.push(minv, maxv);
|
|
958
|
-
}
|
|
959
|
-
#parse(comp) {
|
|
960
|
-
const first = comp.charAt(0);
|
|
961
|
-
const first2 = comp.substring(0, 2);
|
|
962
|
-
const v1 = comp.substring(1);
|
|
963
|
-
const v2 = comp.substring(2);
|
|
964
|
-
switch (first2) {
|
|
965
|
-
case "~>":
|
|
966
|
-
assertVersion(v2, comp);
|
|
967
|
-
return this.#parseTilde(v2);
|
|
968
|
-
case ">=":
|
|
969
|
-
assertVersion(v2, comp);
|
|
970
|
-
return this.tuples.push(this.#xInclusiveMin(v2));
|
|
971
|
-
case "<=":
|
|
972
|
-
assertVersion(v2, comp);
|
|
973
|
-
return this.tuples.push(this.#xInclusiveMax(v2));
|
|
974
|
-
}
|
|
975
|
-
switch (first) {
|
|
976
|
-
case "~":
|
|
977
|
-
assertVersion(v1, comp);
|
|
978
|
-
return this.#parseTilde(v1);
|
|
979
|
-
case "^":
|
|
980
|
-
assertVersion(v1, comp);
|
|
981
|
-
return this.#parseCaret(v1);
|
|
982
|
-
case ">":
|
|
983
|
-
assertVersion(v1, comp);
|
|
984
|
-
return this.tuples.push(this.#xExclusiveMin(v1));
|
|
985
|
-
case "<":
|
|
986
|
-
assertVersion(v1, comp);
|
|
987
|
-
return this.tuples.push(this.#xExclusiveMax(v1));
|
|
988
|
-
}
|
|
989
|
-
return this.#parseEq(comp);
|
|
990
|
-
}
|
|
991
|
-
#parseTilde(comp) {
|
|
992
|
-
const parsed = this.#parseX(comp);
|
|
993
|
-
if (isXMajor(parsed)) {
|
|
994
|
-
this.tuples.push(this.#getComparatorAny());
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
const z = this.includePrerelease ? "0" : void 0;
|
|
998
|
-
if (isXMinor(parsed)) {
|
|
999
|
-
const [M2] = parsed;
|
|
1000
|
-
this.tuples.push(
|
|
1001
|
-
[">=", new Version(comp, M2, 0, 0, z, void 0)],
|
|
1002
|
-
["<", new Version(comp, M2 + 1, 0, 0, "0", void 0)]
|
|
1003
|
-
);
|
|
1004
|
-
return;
|
|
1005
|
-
}
|
|
1006
|
-
if (isXPatch(parsed)) {
|
|
1007
|
-
const [M2, m2] = parsed;
|
|
1008
|
-
const z2 = this.includePrerelease ? "0" : void 0;
|
|
1009
|
-
this.tuples.push(
|
|
1010
|
-
[">=", new Version(comp, M2, m2, 0, z2, void 0)],
|
|
1011
|
-
["<", new Version(comp, M2, m2 + 1, 0, "0", void 0)]
|
|
1012
|
-
);
|
|
1013
|
-
return;
|
|
1014
|
-
}
|
|
1015
|
-
const [M, m, p, pr = z, build] = parsed;
|
|
1016
|
-
this.tuples.push(
|
|
1017
|
-
[">=", new Version(comp, M, m, p, pr, build)],
|
|
1018
|
-
["<", new Version(comp, M, m + 1, 0, "0", build)]
|
|
1019
|
-
);
|
|
1020
|
-
}
|
|
1021
|
-
#parseCaret(comp) {
|
|
1022
|
-
const min = this.#xInclusiveMin(comp);
|
|
1023
|
-
if (isAny(min)) {
|
|
1024
|
-
this.tuples.push(min);
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
const minv = min[1];
|
|
1028
|
-
if (minv.major !== 0) {
|
|
1029
|
-
this.tuples.push(min, [
|
|
1030
|
-
"<",
|
|
1031
|
-
new Version(comp, minv.major + 1, 0, 0, "0", void 0)
|
|
1032
|
-
]);
|
|
1033
|
-
} else if (minv.minor !== 0) {
|
|
1034
|
-
this.tuples.push(min, [
|
|
1035
|
-
"<",
|
|
1036
|
-
new Version(
|
|
1037
|
-
comp,
|
|
1038
|
-
minv.major,
|
|
1039
|
-
minv.minor + 1,
|
|
1040
|
-
0,
|
|
1041
|
-
"0",
|
|
1042
|
-
void 0
|
|
1043
|
-
)
|
|
1044
|
-
]);
|
|
1045
|
-
} else if (!minv.prerelease?.length) {
|
|
1046
|
-
this.tuples.push(["", minv]);
|
|
1047
|
-
} else {
|
|
1048
|
-
this.tuples.push(min, [
|
|
1049
|
-
"<",
|
|
1050
|
-
new Version(
|
|
1051
|
-
comp,
|
|
1052
|
-
minv.major,
|
|
1053
|
-
minv.minor,
|
|
1054
|
-
minv.patch + 1,
|
|
1055
|
-
"0",
|
|
1056
|
-
void 0
|
|
1057
|
-
)
|
|
1058
|
-
]);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
#parseEq(comp) {
|
|
1062
|
-
const parsed = this.#parseX(comp);
|
|
1063
|
-
const z = this.includePrerelease ? "0" : void 0;
|
|
1064
|
-
if (isFullVersion(parsed)) {
|
|
1065
|
-
this.tuples.push(["", new Version(comp, ...parsed)]);
|
|
1066
|
-
} else if (isXMajor(parsed)) {
|
|
1067
|
-
this.tuples.push(this.#getComparatorAny());
|
|
1068
|
-
} else if (isXMinor(parsed)) {
|
|
1069
|
-
this.tuples.push([
|
|
1070
|
-
">=",
|
|
1071
|
-
new Version(comp, parsed[MAJOR], 0, 0, z, void 0)
|
|
1072
|
-
]);
|
|
1073
|
-
this.tuples.push([
|
|
1074
|
-
"<",
|
|
1075
|
-
new Version(comp, parsed[MAJOR] + 1, 0, 0, "0", void 0)
|
|
1076
|
-
]);
|
|
1077
|
-
} else if (isXPatch(parsed)) {
|
|
1078
|
-
this.tuples.push(
|
|
1079
|
-
[
|
|
1080
|
-
">=",
|
|
1081
|
-
new Version(
|
|
1082
|
-
comp,
|
|
1083
|
-
parsed[MAJOR],
|
|
1084
|
-
parsed[MINOR],
|
|
1085
|
-
0,
|
|
1086
|
-
z,
|
|
1087
|
-
void 0
|
|
1088
|
-
)
|
|
1089
|
-
],
|
|
1090
|
-
[
|
|
1091
|
-
"<",
|
|
1092
|
-
new Version(
|
|
1093
|
-
comp,
|
|
1094
|
-
parsed[MAJOR],
|
|
1095
|
-
parsed[MINOR] + 1,
|
|
1096
|
-
0,
|
|
1097
|
-
"0",
|
|
1098
|
-
void 0
|
|
1099
|
-
)
|
|
1100
|
-
]
|
|
1101
|
-
);
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
/** return true if the version is a match for this comparator */
|
|
1105
|
-
test(v) {
|
|
1106
|
-
if (this.isNone) return false;
|
|
1107
|
-
const ip = this.includePrerelease;
|
|
1108
|
-
const hasPR = !!v.prerelease?.length;
|
|
1109
|
-
let prOK = ip || !hasPR;
|
|
1110
|
-
for (const c of this.tuples) {
|
|
1111
|
-
if (isAny(c)) {
|
|
1112
|
-
continue;
|
|
1113
|
-
}
|
|
1114
|
-
const [op, cv] = c;
|
|
1115
|
-
prOK ||= !!cv.prerelease?.length && v.tupleEquals(cv);
|
|
1116
|
-
switch (op) {
|
|
1117
|
-
case "":
|
|
1118
|
-
if (!v.equals(cv)) return false;
|
|
1119
|
-
continue;
|
|
1120
|
-
case ">":
|
|
1121
|
-
if (!v.greaterThan(cv)) return false;
|
|
1122
|
-
continue;
|
|
1123
|
-
case ">=":
|
|
1124
|
-
if (!v.greaterThanEqual(cv)) return false;
|
|
1125
|
-
continue;
|
|
1126
|
-
case "<":
|
|
1127
|
-
if (!v.lessThan(cv)) return false;
|
|
1128
|
-
continue;
|
|
1129
|
-
case "<=":
|
|
1130
|
-
if (!v.lessThanEqual(cv)) return false;
|
|
1131
|
-
continue;
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
return prOK;
|
|
1135
|
-
}
|
|
1136
|
-
#getComparatorAny() {
|
|
1137
|
-
return this.includePrerelease ? comparatorAnyPR : comparatorAny;
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
var isAny = (c) => c === comparatorAny || c === comparatorAnyPR;
|
|
1141
|
-
var comparatorAny = {
|
|
1142
|
-
isAny: true,
|
|
1143
|
-
toString: () => "*",
|
|
1144
|
-
includePrerelease: false,
|
|
1145
|
-
test: (v) => !v.prerelease?.length
|
|
1146
|
-
};
|
|
1147
|
-
var comparatorAnyPR = {
|
|
1148
|
-
isAny: true,
|
|
1149
|
-
toString: () => "*",
|
|
1150
|
-
includePrerelease: true,
|
|
1151
|
-
test: (_) => true
|
|
1152
|
-
};
|
|
1153
|
-
var comparatorNone = {
|
|
1154
|
-
isNone: true,
|
|
1155
|
-
toString: () => "<0.0.0-0",
|
|
1156
|
-
includePrerelease: false,
|
|
1157
|
-
test: (_) => false
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
// ../../src/semver/src/range.ts
|
|
1161
|
-
var Range = class {
|
|
1162
|
-
/** raw string used to create this Range */
|
|
1163
|
-
raw;
|
|
1164
|
-
/** true if the range is `*` */
|
|
1165
|
-
isAny;
|
|
1166
|
-
/** true if the range is a single semver version */
|
|
1167
|
-
isSingle;
|
|
1168
|
-
/** true if the range cannot match anything */
|
|
1169
|
-
/**
|
|
1170
|
-
* set of {@link Comparator} objects representing the `||`-separated sections
|
|
1171
|
-
* of the range. If at least one of these matches, then the version is a
|
|
1172
|
-
* match.
|
|
1173
|
-
*/
|
|
1174
|
-
set = [];
|
|
1175
|
-
/** true if all prerelease versions should be included */
|
|
1176
|
-
includePrerelease;
|
|
1177
|
-
/** cached toString */
|
|
1178
|
-
#toString;
|
|
1179
|
-
constructor(range, includePrerelease = false) {
|
|
1180
|
-
this.raw = range;
|
|
1181
|
-
this.includePrerelease = includePrerelease;
|
|
1182
|
-
this.isAny = false;
|
|
1183
|
-
let isFirst = true;
|
|
1184
|
-
this.isSingle = false;
|
|
1185
|
-
fastSplit(range, "||", -1, (part) => {
|
|
1186
|
-
if (this.isAny) return;
|
|
1187
|
-
const cmp = new Comparator(part, this.includePrerelease);
|
|
1188
|
-
if (cmp.isAny) {
|
|
1189
|
-
this.set = [cmp];
|
|
1190
|
-
this.isAny = true;
|
|
1191
|
-
return;
|
|
1192
|
-
}
|
|
1193
|
-
this.set.push(cmp);
|
|
1194
|
-
if (!isFirst) this.isSingle = false;
|
|
1195
|
-
else if (Array.isArray(cmp.tuples) && cmp.tuples.length === 1 && Array.isArray(cmp.tuples[0]) && cmp.tuples[0][0] === "") {
|
|
1196
|
-
this.isSingle = true;
|
|
1197
|
-
}
|
|
1198
|
-
isFirst = false;
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* test a {@link Version} against the range
|
|
1203
|
-
*/
|
|
1204
|
-
test(v) {
|
|
1205
|
-
return this.set.some((c) => c.test(v));
|
|
1206
|
-
}
|
|
1207
|
-
/** return the simplified canonical form of this range */
|
|
1208
|
-
toString() {
|
|
1209
|
-
if (this.#toString) return this.#toString;
|
|
1210
|
-
if (this.isSingle) {
|
|
1211
|
-
this.#toString = String(this.set[0]);
|
|
1212
|
-
return this.#toString;
|
|
1213
|
-
}
|
|
1214
|
-
this.#toString = this.set.map((c) => String(c)).join(" || ");
|
|
1215
|
-
return this.#toString;
|
|
1216
|
-
}
|
|
1217
|
-
};
|
|
1218
|
-
|
|
1219
|
-
// ../../src/semver/src/index.ts
|
|
1220
|
-
var parse2 = (version) => {
|
|
1221
|
-
if (version instanceof Version) return version;
|
|
1222
|
-
try {
|
|
1223
|
-
return Version.parse(String(version));
|
|
1224
|
-
} catch {
|
|
1225
|
-
return void 0;
|
|
1226
|
-
}
|
|
1227
|
-
};
|
|
1228
|
-
var parseRange = (range, includePrerelease = false) => {
|
|
1229
|
-
if (typeof range === "object") {
|
|
1230
|
-
if (range.includePrerelease === includePrerelease) return range;
|
|
1231
|
-
range = range.raw;
|
|
1232
|
-
}
|
|
1233
|
-
try {
|
|
1234
|
-
return new Range(range, includePrerelease);
|
|
1235
|
-
} catch {
|
|
1236
|
-
return void 0;
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
var satisfies = (version, range, includePrerelease = false) => {
|
|
1240
|
-
if (typeof version === "string") {
|
|
1241
|
-
const parsed = parse2(version);
|
|
1242
|
-
if (!parsed) return false;
|
|
1243
|
-
version = parsed;
|
|
1244
|
-
}
|
|
1245
|
-
if (typeof range === "string") {
|
|
1246
|
-
const parsed = parseRange(range, includePrerelease);
|
|
1247
|
-
if (!parsed) return false;
|
|
1248
|
-
range = parsed;
|
|
1249
|
-
}
|
|
1250
|
-
return version.satisfies(range);
|
|
1251
|
-
};
|
|
1252
|
-
var compare = (versionA, versionB) => {
|
|
1253
|
-
const a = parse2(versionA);
|
|
1254
|
-
if (!a) {
|
|
1255
|
-
throw syntaxError("invalid version", { found: versionA });
|
|
1256
|
-
}
|
|
1257
|
-
const b = parse2(versionB);
|
|
1258
|
-
if (!b) {
|
|
1259
|
-
throw syntaxError("invalid version", { found: versionB });
|
|
1260
|
-
}
|
|
1261
|
-
return a.compare(b);
|
|
1262
|
-
};
|
|
1263
|
-
var gt = (versionA, versionB) => compare(versionA, versionB) > 0;
|
|
1264
|
-
var gte = (versionA, versionB) => compare(versionA, versionB) >= 0;
|
|
1265
|
-
var lt = (versionA, versionB) => compare(versionA, versionB) < 0;
|
|
1266
|
-
var lte = (versionA, versionB) => compare(versionA, versionB) <= 0;
|
|
1267
|
-
var neq = (versionA, versionB) => compare(versionA, versionB) !== 0;
|
|
1268
|
-
var eq = (versionA, versionB) => compare(versionA, versionB) === 0;
|
|
1269
|
-
var major = (version) => parse2(version)?.major;
|
|
1270
|
-
var minor = (version) => parse2(version)?.minor;
|
|
1271
|
-
var patch = (version) => parse2(version)?.patch;
|
|
1272
|
-
|
|
1273
|
-
// ../../src/spec/src/browser.ts
|
|
1274
|
-
var kCustomInspect = Symbol.for("nodejs.util.inspect.custom");
|
|
1275
|
-
var defaultRegistry = "https://registry.npmjs.org/";
|
|
1276
|
-
var defaultRegistries = {
|
|
1277
|
-
npm: "https://registry.npmjs.org/"
|
|
1278
|
-
};
|
|
1279
|
-
var defaultGitHosts = {
|
|
1280
|
-
github: "git+ssh://git@github.com:$1/$2.git",
|
|
1281
|
-
bitbucket: "git+ssh://git@bitbucket.org:$1/$2.git",
|
|
1282
|
-
gitlab: "git+ssh://git@gitlab.com:$1/$2.git",
|
|
1283
|
-
gist: "git+ssh://git@gist.github.com/$1.git"
|
|
1284
|
-
};
|
|
1285
|
-
var defaultGitHostArchives = {
|
|
1286
|
-
github: "https://codeload.github.com/$1/$2/tar.gz/$committish",
|
|
1287
|
-
bitbucket: "https://bitbucket.org/$1/$2/get/$committish.tar.gz",
|
|
1288
|
-
gist: "https://codeload.github.com/gist/$1/tar.gz/$committish",
|
|
1289
|
-
gitlab: "https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish"
|
|
1290
|
-
};
|
|
1291
|
-
var gitHostWebsites = {
|
|
1292
|
-
github: "https://github.com/",
|
|
1293
|
-
bitbucket: "https://bitbucket.org/",
|
|
1294
|
-
gist: "https://gist.github.com/",
|
|
1295
|
-
gitlab: "https://gitlab.com/"
|
|
1296
|
-
};
|
|
1297
|
-
var defaultScopeRegistries = {};
|
|
1298
|
-
var getOptions = (options) => ({
|
|
1299
|
-
...options,
|
|
1300
|
-
registry: options?.registry ?? defaultRegistry,
|
|
1301
|
-
"scope-registries": options?.["scope-registries"] ?? {},
|
|
1302
|
-
"git-hosts": options?.["git-hosts"] ? {
|
|
1303
|
-
...defaultGitHosts,
|
|
1304
|
-
...options["git-hosts"]
|
|
1305
|
-
} : defaultGitHosts,
|
|
1306
|
-
registries: options?.registries ? {
|
|
1307
|
-
...defaultRegistries,
|
|
1308
|
-
...options.registries
|
|
1309
|
-
} : defaultRegistries,
|
|
1310
|
-
"git-host-archives": options?.["git-host-archives"] ? {
|
|
1311
|
-
...defaultGitHostArchives,
|
|
1312
|
-
...options["git-host-archives"]
|
|
1313
|
-
} : defaultGitHostArchives
|
|
1314
|
-
});
|
|
1315
|
-
var startsWithSpecIdentifier = (spec, options) => spec.startsWith("/") || spec.startsWith("./") || spec.startsWith("../") || spec.startsWith("file:") || spec.startsWith("http:") || spec.startsWith("https:") || spec.startsWith("workspace:") || spec.startsWith("git@") || spec.startsWith("git://") || spec.startsWith("git+ssh://") || spec.startsWith("git+http://") || spec.startsWith("git+https://") || spec.startsWith("git+file://") || spec.startsWith("git@github.com") || spec.startsWith("registry:") || // anything that starts with a known git host key, or a
|
|
1316
|
-
// custom registered registry protocol e.g: `github:`, `custom:`
|
|
1317
|
-
[
|
|
1318
|
-
...Object.keys(options["git-hosts"]),
|
|
1319
|
-
...Object.keys(options.registries)
|
|
1320
|
-
].some((key) => spec.startsWith(`${key}:`));
|
|
1321
|
-
var findFirstAt = (spec, hasScope) => spec.indexOf("@", hasScope ? 1 : 0);
|
|
1322
|
-
var findGitIdentifier = (spec) => spec.indexOf("#") > 2;
|
|
1323
|
-
var findFileIdentifier = (spec) => spec.includes("/");
|
|
1324
|
-
var Spec = class {
|
|
1325
|
-
static parse(spec, bareOrOptions, options) {
|
|
1326
|
-
return typeof spec === "object" ? spec : new this(spec, bareOrOptions, options);
|
|
1327
|
-
}
|
|
1328
|
-
static parseArgs(specOrBareSpec, opts) {
|
|
1329
|
-
const options = getOptions(opts ?? {});
|
|
1330
|
-
if (startsWithSpecIdentifier(specOrBareSpec, options)) {
|
|
1331
|
-
const parsed = this.parse("(unknown)", specOrBareSpec, options);
|
|
1332
|
-
if (parsed.subspec) {
|
|
1333
|
-
parsed.name = parsed.subspec.name;
|
|
1334
|
-
parsed.spec = `${parsed.name}@${parsed.bareSpec}`;
|
|
1335
|
-
}
|
|
1336
|
-
return parsed;
|
|
1337
|
-
} else {
|
|
1338
|
-
const hasScope = specOrBareSpec.startsWith("@");
|
|
1339
|
-
const at = findFirstAt(specOrBareSpec, hasScope);
|
|
1340
|
-
if (at > -1) {
|
|
1341
|
-
return this.parse(
|
|
1342
|
-
specOrBareSpec.substring(0, at),
|
|
1343
|
-
specOrBareSpec.substring(at + 1),
|
|
1344
|
-
options
|
|
1345
|
-
);
|
|
1346
|
-
} else if (findGitIdentifier(specOrBareSpec) || !hasScope && findFileIdentifier(specOrBareSpec)) {
|
|
1347
|
-
return this.parse("(unknown)", specOrBareSpec, options);
|
|
1348
|
-
} else {
|
|
1349
|
-
return this.parse(`${specOrBareSpec}@`, options);
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
static nodejsDependencies;
|
|
1354
|
-
type;
|
|
1355
|
-
spec;
|
|
1356
|
-
options;
|
|
1357
|
-
name;
|
|
1358
|
-
scope;
|
|
1359
|
-
scopeRegistry;
|
|
1360
|
-
bareSpec;
|
|
1361
|
-
gitRemote;
|
|
1362
|
-
gitSelector;
|
|
1363
|
-
gitSelectorParsed;
|
|
1364
|
-
gitCommittish;
|
|
1365
|
-
namedGitHost;
|
|
1366
|
-
namedGitHostPath;
|
|
1367
|
-
workspaceSpec;
|
|
1368
|
-
workspace;
|
|
1369
|
-
namedRegistry;
|
|
1370
|
-
registry;
|
|
1371
|
-
registrySpec;
|
|
1372
|
-
conventionalRegistryTarball;
|
|
1373
|
-
semver;
|
|
1374
|
-
range;
|
|
1375
|
-
distTag;
|
|
1376
|
-
remoteURL;
|
|
1377
|
-
file;
|
|
1378
|
-
subspec;
|
|
1379
|
-
#final;
|
|
1380
|
-
#toString;
|
|
1381
|
-
/**
|
|
1382
|
-
* Return the final entry in the chain of subspecs
|
|
1383
|
-
* When deciding which thing to actually fetch, spec.final is the thing
|
|
1384
|
-
* to look at.
|
|
1385
|
-
*/
|
|
1386
|
-
get final() {
|
|
1387
|
-
if (this.#final) return this.#final;
|
|
1388
|
-
return this.#final = this.subspec ? this.subspec.final : this;
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* Normally, the string value of a Spec is just the string passed in to
|
|
1392
|
-
* be parsed. However, in the case of a chain of subspecs, like
|
|
1393
|
-
* `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
|
|
1394
|
-
* parts of the chain, returning just `foo@npm:quux@latest`
|
|
1395
|
-
*/
|
|
1396
|
-
toString() {
|
|
1397
|
-
if (this.#toString !== void 0) return this.#toString;
|
|
1398
|
-
let sub = this;
|
|
1399
|
-
while (sub.subspec?.subspec) sub = sub.subspec;
|
|
1400
|
-
if (sub.subspec && sub.subspec.type !== "registry")
|
|
1401
|
-
sub = sub.subspec;
|
|
1402
|
-
return this.#toString = this.name + "@" + sub.bareSpec;
|
|
1403
|
-
}
|
|
1404
|
-
constructor(spec, bareOrOptions, options = {}) {
|
|
1405
|
-
if (bareOrOptions && typeof bareOrOptions === "object") {
|
|
1406
|
-
options = bareOrOptions;
|
|
1407
|
-
bareOrOptions = void 0;
|
|
1408
|
-
}
|
|
1409
|
-
this.options = getOptions(options);
|
|
1410
|
-
if (typeof bareOrOptions === "string") {
|
|
1411
|
-
this.name = spec;
|
|
1412
|
-
this.#parseScope(spec);
|
|
1413
|
-
this.bareSpec = bareOrOptions;
|
|
1414
|
-
this.spec = `${this.name}@${bareOrOptions}`;
|
|
1415
|
-
} else {
|
|
1416
|
-
this.spec = spec;
|
|
1417
|
-
const hasScope = spec.startsWith("@");
|
|
1418
|
-
let at = findFirstAt(spec, hasScope);
|
|
1419
|
-
if (at === -1) {
|
|
1420
|
-
at = spec.length;
|
|
1421
|
-
spec += "@";
|
|
1422
|
-
}
|
|
1423
|
-
this.name = spec.substring(0, at);
|
|
1424
|
-
if (hasScope) this.#parseScope(this.name);
|
|
1425
|
-
this.bareSpec = spec.substring(at + 1);
|
|
1426
|
-
}
|
|
1427
|
-
if (this.bareSpec.startsWith("https://")) {
|
|
1428
|
-
for (const [name, origin] of Object.entries(gitHostWebsites)) {
|
|
1429
|
-
if (this.bareSpec.startsWith(origin)) {
|
|
1430
|
-
const parsed = new URL(this.bareSpec);
|
|
1431
|
-
const [user, project] = parsed.pathname.replace(/\.git$/, "").replace(/\/+/g, " ").trim().split(" ");
|
|
1432
|
-
if (user && project) {
|
|
1433
|
-
this.bareSpec = `${name}:${user}/${project}${parsed.hash}`;
|
|
1434
|
-
this.spec = `${this.name}@${this.bareSpec}`;
|
|
1435
|
-
break;
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
if (this.bareSpec.startsWith("workspace:")) {
|
|
1441
|
-
this.type = "workspace";
|
|
1442
|
-
const ws = this.bareSpec.substring("workspace:".length).trim();
|
|
1443
|
-
const w = ws.lastIndexOf("@");
|
|
1444
|
-
if (w === -1) {
|
|
1445
|
-
this.workspace = this.name;
|
|
1446
|
-
} else {
|
|
1447
|
-
const wsName = ws.substring(0, w);
|
|
1448
|
-
if (!wsName || wsName === "*" || wsName === "~" || wsName === "^" || (wsName.startsWith("@") ? wsName.split("/").length !== 2 || wsName.substring(1).includes("@") : wsName.includes("@"))) {
|
|
1449
|
-
throw this.#error(
|
|
1450
|
-
"workspace: name must be a path or valid package name",
|
|
1451
|
-
{ found: wsName }
|
|
1452
|
-
);
|
|
1453
|
-
}
|
|
1454
|
-
this.workspace = wsName;
|
|
1455
|
-
}
|
|
1456
|
-
const wss = w === -1 ? ws : ws.substring(w + 1) || "*";
|
|
1457
|
-
const range2 = wss === "*" ? void 0 : parseRange(wss);
|
|
1458
|
-
if (wss !== "*" && wss !== "~" && wss !== "^" && !range2) {
|
|
1459
|
-
throw this.#error(
|
|
1460
|
-
"workspace: spec must be one of *, ~, or ^, or a valid semver range",
|
|
1461
|
-
{
|
|
1462
|
-
found: wss,
|
|
1463
|
-
wanted: `'*'|'~'|'^'|SemverRange`
|
|
1464
|
-
}
|
|
1465
|
-
);
|
|
1466
|
-
}
|
|
1467
|
-
this.workspaceSpec = wss;
|
|
1468
|
-
if (range2) {
|
|
1469
|
-
this.semver = wss;
|
|
1470
|
-
this.range = range2;
|
|
1471
|
-
}
|
|
1472
|
-
return;
|
|
1473
|
-
}
|
|
1474
|
-
if (this.bareSpec.startsWith("git://") || this.bareSpec.startsWith("git+ssh://") || this.bareSpec.startsWith("git+http://") || this.bareSpec.startsWith("git+https://") || this.bareSpec.startsWith("git+file://") || // legacy affordance
|
|
1475
|
-
this.bareSpec.startsWith("git@github.com")) {
|
|
1476
|
-
if (this.bareSpec.startsWith("git@")) {
|
|
1477
|
-
this.bareSpec = `git+ssh://${this.bareSpec}`;
|
|
1478
|
-
this.spec = `${this.name}@${this.bareSpec}`;
|
|
1479
|
-
}
|
|
1480
|
-
this.type = "git";
|
|
1481
|
-
for (const [name, host] of Object.entries(
|
|
1482
|
-
this.options["git-hosts"]
|
|
1483
|
-
)) {
|
|
1484
|
-
const s = host.indexOf("$");
|
|
1485
|
-
if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {
|
|
1486
|
-
const p = this.bareSpec.substring(s).replace(/\.git(#.*)?$/, "$1");
|
|
1487
|
-
this.bareSpec = `${name}:${p}`;
|
|
1488
|
-
this.spec = `${this.name}@${this.bareSpec}`;
|
|
1489
|
-
this.#parseHostedGit(name, host);
|
|
1490
|
-
this.type = "git";
|
|
1491
|
-
return;
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
this.#parseGitSelector(this.bareSpec);
|
|
1495
|
-
return;
|
|
1496
|
-
}
|
|
1497
|
-
const ghosts = Object.entries(this.options["git-hosts"]);
|
|
1498
|
-
for (const [name, template] of ghosts) {
|
|
1499
|
-
if (this.#parseHostedGit(name, template)) {
|
|
1500
|
-
this.type = "git";
|
|
1501
|
-
return;
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
if (this.bareSpec.startsWith("registry:")) {
|
|
1505
|
-
const reg = this.bareSpec.substring("registry:".length);
|
|
1506
|
-
const h = reg.indexOf("#");
|
|
1507
|
-
if (h === -1) {
|
|
1508
|
-
throw this.#error("registry: must include name/version");
|
|
1509
|
-
}
|
|
1510
|
-
this.type = "registry";
|
|
1511
|
-
let url = reg.substring(0, h);
|
|
1512
|
-
if (!url.endsWith("/")) url += "/";
|
|
1513
|
-
const regSpec = reg.substring(h + 1);
|
|
1514
|
-
for (let [name, u] of Object.entries(this.options.registries)) {
|
|
1515
|
-
if (!u.endsWith("/")) {
|
|
1516
|
-
u += "/";
|
|
1517
|
-
this.options.registries[name] = u;
|
|
1518
|
-
}
|
|
1519
|
-
if (u === url) this.namedRegistry = name;
|
|
1520
|
-
}
|
|
1521
|
-
this.#parseRegistrySpec(regSpec, url);
|
|
1522
|
-
this.#guessRegistryTarball();
|
|
1523
|
-
return;
|
|
1524
|
-
}
|
|
1525
|
-
const regs = Object.entries(this.options.registries);
|
|
1526
|
-
for (const [host, url] of regs) {
|
|
1527
|
-
const h = `${host}:`;
|
|
1528
|
-
if (this.bareSpec.startsWith(h)) {
|
|
1529
|
-
this.type = "registry";
|
|
1530
|
-
this.namedRegistry = host;
|
|
1531
|
-
this.#parseRegistrySpec(
|
|
1532
|
-
this.bareSpec.substring(h.length),
|
|
1533
|
-
url
|
|
1534
|
-
).namedRegistry ??= host;
|
|
1535
|
-
this.#guessRegistryTarball();
|
|
1536
|
-
return;
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
if (this.bareSpec.startsWith("https://") || this.bareSpec.startsWith("http://")) {
|
|
1540
|
-
this.remoteURL = this.bareSpec;
|
|
1541
|
-
this.type = "remote";
|
|
1542
|
-
return;
|
|
1543
|
-
}
|
|
1544
|
-
if (this.bareSpec.startsWith("file:")) {
|
|
1545
|
-
this.type = "file";
|
|
1546
|
-
const [path, uri] = getNormalizeFile(
|
|
1547
|
-
this.constructor.nodejsDependencies
|
|
1548
|
-
)(this.bareSpec, this);
|
|
1549
|
-
this.file = path;
|
|
1550
|
-
this.bareSpec = uri.replace(/\/+$/, "");
|
|
1551
|
-
this.spec = `${this.name}@${this.bareSpec}`;
|
|
1552
|
-
return;
|
|
1553
|
-
}
|
|
1554
|
-
if (!this.bareSpec.startsWith("./") && !this.bareSpec.startsWith("../") && this.options["git-hosts"].github) {
|
|
1555
|
-
const hash = this.bareSpec.indexOf("#");
|
|
1556
|
-
const up = hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash);
|
|
1557
|
-
if (up.split("/").length === 2) {
|
|
1558
|
-
this.bareSpec = `github:${this.bareSpec}`;
|
|
1559
|
-
this.spec = `${this.name}@${this.bareSpec}`;
|
|
1560
|
-
this.#parseHostedGit(
|
|
1561
|
-
"github",
|
|
1562
|
-
this.options["git-hosts"].github
|
|
1563
|
-
);
|
|
1564
|
-
this.type = "git";
|
|
1565
|
-
return;
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
if (this.bareSpec.includes("/") || this.bareSpec === "." || this.bareSpec === "..") {
|
|
1569
|
-
this.type = "file";
|
|
1570
|
-
const [file, uri] = getNormalizeFile(
|
|
1571
|
-
this.constructor.nodejsDependencies
|
|
1572
|
-
)(`file:${this.bareSpec}`, this);
|
|
1573
|
-
this.bareSpec = uri;
|
|
1574
|
-
this.spec = `${this.name}@${this.bareSpec}`;
|
|
1575
|
-
this.file = file;
|
|
1576
|
-
return;
|
|
1577
|
-
}
|
|
1578
|
-
this.type = "registry";
|
|
1579
|
-
const range = parseRange(this.bareSpec);
|
|
1580
|
-
if (range) {
|
|
1581
|
-
this.semver = this.bareSpec.trim();
|
|
1582
|
-
this.range = range;
|
|
1583
|
-
} else {
|
|
1584
|
-
this.distTag = this.bareSpec;
|
|
1585
|
-
}
|
|
1586
|
-
this.registrySpec = this.bareSpec;
|
|
1587
|
-
const { "scope-registries": scopeRegs, registry } = this.options;
|
|
1588
|
-
const scopeReg = this.scope && scopeRegs[this.scope];
|
|
1589
|
-
this.registry = scopeReg ?? registry;
|
|
1590
|
-
this.#guessRegistryTarball();
|
|
1591
|
-
}
|
|
1592
|
-
#parseScope(name) {
|
|
1593
|
-
if (!name.startsWith("@")) return;
|
|
1594
|
-
const s = name.indexOf("/");
|
|
1595
|
-
if (s > 1 && s < name.length - 1) {
|
|
1596
|
-
const scope = name.substring(0, s);
|
|
1597
|
-
this.registry = this.scopeRegistry = this.options["scope-registries"][scope];
|
|
1598
|
-
this.scope = scope;
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
#parseHostedGit(name, template) {
|
|
1602
|
-
if (this.bareSpec.startsWith(`${name}:`)) {
|
|
1603
|
-
const h = this.bareSpec.indexOf("#");
|
|
1604
|
-
const bare = h === -1 ? this.bareSpec : this.bareSpec.substring(0, h);
|
|
1605
|
-
const hash = h === -1 ? "" : this.bareSpec.substring(h);
|
|
1606
|
-
const hostPath = bare.substring(name.length + 1);
|
|
1607
|
-
if (!hostPath) {
|
|
1608
|
-
throw error("invalid named git host specifier", {
|
|
1609
|
-
spec: this
|
|
1610
|
-
});
|
|
1611
|
-
}
|
|
1612
|
-
const split = hostPath.split("/");
|
|
1613
|
-
let t = template;
|
|
1614
|
-
for (let i = 0; i < split.length; i++) {
|
|
1615
|
-
t = t.split(`$${i + 1}`).join(split[i]);
|
|
1616
|
-
}
|
|
1617
|
-
t += hash;
|
|
1618
|
-
this.namedGitHost = name;
|
|
1619
|
-
this.namedGitHostPath = hostPath;
|
|
1620
|
-
this.#parseGitSelector(t);
|
|
1621
|
-
if (this.gitCommittish && !this.gitSelectorParsed?.path) {
|
|
1622
|
-
const archiveHost = this.options["git-host-archives"][name];
|
|
1623
|
-
if (archiveHost) {
|
|
1624
|
-
this.type = "remote";
|
|
1625
|
-
let t2 = archiveHost;
|
|
1626
|
-
t2 = t2.split("$committish").join(this.gitCommittish);
|
|
1627
|
-
for (let i = 0; i < split.length; i++) {
|
|
1628
|
-
t2 = t2.split(`$${i + 1}`).join(split[i]);
|
|
1629
|
-
}
|
|
1630
|
-
this.remoteURL = t2;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
return true;
|
|
1634
|
-
}
|
|
1635
|
-
return false;
|
|
1636
|
-
}
|
|
1637
|
-
/* c8 ignore start */
|
|
1638
|
-
[kCustomInspect]() {
|
|
1639
|
-
return `@vltpkg/spec.Spec ${String(this)}`;
|
|
1640
|
-
}
|
|
1641
|
-
/* c8 ignore stop */
|
|
1642
|
-
#guessRegistryTarball() {
|
|
1643
|
-
const { name, registry, range } = this.final;
|
|
1644
|
-
if (!registry || !range?.isSingle) return;
|
|
1645
|
-
const stripScope = /^@[^/]+\//;
|
|
1646
|
-
this.conventionalRegistryTarball = String(
|
|
1647
|
-
new URL(
|
|
1648
|
-
`/${name}/-/${name.replace(stripScope, "")}-${range}.tgz`,
|
|
1649
|
-
registry
|
|
1650
|
-
)
|
|
1651
|
-
);
|
|
1652
|
-
}
|
|
1653
|
-
#parseRegistrySpec(s, url) {
|
|
1654
|
-
this.registry = url;
|
|
1655
|
-
this.subspec = this.constructor.parse(s, {
|
|
1656
|
-
...this.options,
|
|
1657
|
-
registry: url
|
|
1658
|
-
});
|
|
1659
|
-
return this.subspec;
|
|
1660
|
-
}
|
|
1661
|
-
#error(message, extra = {}) {
|
|
1662
|
-
return error(message, { spec: this.spec, ...extra }, this.#error);
|
|
1663
|
-
}
|
|
1664
|
-
#parseGitSelector(s) {
|
|
1665
|
-
const h = s.indexOf("#");
|
|
1666
|
-
if (h === -1) {
|
|
1667
|
-
this.gitRemote = s;
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
this.gitRemote = s.substring(0, h);
|
|
1671
|
-
this.gitSelector = s.substring(h + 1);
|
|
1672
|
-
const [selectorParsed, committish, range] = this.constructor.parseGitSelector(this.gitSelector, this);
|
|
1673
|
-
this.range = range;
|
|
1674
|
-
this.gitCommittish = committish;
|
|
1675
|
-
this.gitSelectorParsed = selectorParsed;
|
|
1676
|
-
}
|
|
1677
|
-
/**
|
|
1678
|
-
* Should only ever be called with the bit that comes AFTER the #
|
|
1679
|
-
* in the git remote url.
|
|
1680
|
-
*/
|
|
1681
|
-
static parseGitSelector(selector, spec) {
|
|
1682
|
-
if (!selector) return [{}];
|
|
1683
|
-
const split = selector.split("::");
|
|
1684
|
-
const first = split[0];
|
|
1685
|
-
let committish = void 0;
|
|
1686
|
-
let range = void 0;
|
|
1687
|
-
const parsed = {};
|
|
1688
|
-
if (typeof first !== "string") {
|
|
1689
|
-
throw typeError("impossible", {
|
|
1690
|
-
found: first,
|
|
1691
|
-
wanted: String
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
if (!first.includes(":")) {
|
|
1695
|
-
committish = first;
|
|
1696
|
-
split.shift();
|
|
1697
|
-
}
|
|
1698
|
-
for (const kv of split) {
|
|
1699
|
-
const c = kv.indexOf(":");
|
|
1700
|
-
if (c === -1) continue;
|
|
1701
|
-
const k = kv.substring(0, c);
|
|
1702
|
-
const v = kv.substring(c + 1);
|
|
1703
|
-
if (k === "semver") {
|
|
1704
|
-
if (committish) {
|
|
1705
|
-
throw error(
|
|
1706
|
-
"Cannot specify a semver range and committish value",
|
|
1707
|
-
{ spec }
|
|
1708
|
-
);
|
|
1709
|
-
}
|
|
1710
|
-
range = parseRange(v);
|
|
1711
|
-
if (!range) {
|
|
1712
|
-
throw error(`Invalid git tag semver range: ${v}`, { spec });
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
if (k === "semver" || k === "path") {
|
|
1716
|
-
if (k === "path") {
|
|
1717
|
-
if (
|
|
1718
|
-
/* c8 ignore next */
|
|
1719
|
-
this.nodejsDependencies?.isAbsolute(
|
|
1720
|
-
v
|
|
1721
|
-
) || /(^|\/|\\)\.\.($|\\|\/)/.test(v)
|
|
1722
|
-
) {
|
|
1723
|
-
throw error("Invalid path in git selector", { spec });
|
|
1724
|
-
}
|
|
1725
|
-
parsed.path = (this.nodejsDependencies ? this.nodejsDependencies.join("/", v).substring(1) : v).replace(/\\/g, "/");
|
|
1726
|
-
} else {
|
|
1727
|
-
parsed[k] = v;
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
return [parsed, committish, range];
|
|
1732
|
-
}
|
|
1733
|
-
};
|
|
1734
|
-
var getNormalizeFile = (opts) => (bareSpec, spec) => {
|
|
1735
|
-
const slashes = bareSpec.substring(
|
|
1736
|
-
"file:".length,
|
|
1737
|
-
"file://".length
|
|
1738
|
-
);
|
|
1739
|
-
const pref = `file:${slashes === "//" ? slashes : ""}`;
|
|
1740
|
-
const rest = bareSpec.substring(pref.length);
|
|
1741
|
-
const [a = "", b = "/", c = "/", d = "/"] = rest.split("", 4);
|
|
1742
|
-
if (!a) {
|
|
1743
|
-
return [".", "file:."];
|
|
1744
|
-
}
|
|
1745
|
-
if (a === "/" && b === "~" && c !== "/" || a === "~" && b !== "/") {
|
|
1746
|
-
throw error(
|
|
1747
|
-
`invalid file: specifier. '~username' not supported`,
|
|
1748
|
-
{ spec }
|
|
1749
|
-
);
|
|
1750
|
-
}
|
|
1751
|
-
if (a === "~") {
|
|
1752
|
-
return (
|
|
1753
|
-
/* c8 ignore start */
|
|
1754
|
-
opts ? [
|
|
1755
|
-
opts.resolve(opts.homedir(), rest.substring(2)),
|
|
1756
|
-
`file:${rest}`
|
|
1757
|
-
] : [rest, `file:${rest}`]
|
|
1758
|
-
);
|
|
1759
|
-
}
|
|
1760
|
-
if (a === "/" && b === "~") {
|
|
1761
|
-
return opts ? [
|
|
1762
|
-
opts.resolve(opts.homedir(), rest.substring(3)),
|
|
1763
|
-
`file:${rest.substring(1)}`
|
|
1764
|
-
] : (
|
|
1765
|
-
/* c8 ignore stop */
|
|
1766
|
-
[rest.substring(1), `file:${rest.substring(1)}`]
|
|
1767
|
-
);
|
|
1768
|
-
}
|
|
1769
|
-
if (a === "/" && b === "." && (c === "/" || c === "." && d === "/")) {
|
|
1770
|
-
return [rest.substring(1), `file:${rest.substring(1)}`];
|
|
1771
|
-
}
|
|
1772
|
-
if (a === "." && (b === "/" || b === "." && c === "/")) {
|
|
1773
|
-
return [rest, `file:${rest}`];
|
|
1774
|
-
}
|
|
1775
|
-
if (slashes === "//") {
|
|
1776
|
-
try {
|
|
1777
|
-
const parsed = new URL(bareSpec);
|
|
1778
|
-
if (parsed.host) {
|
|
1779
|
-
if (parsed.host !== "localhost") {
|
|
1780
|
-
throw error(
|
|
1781
|
-
`invalid file:// specifier. host must be empty or 'localhost'`,
|
|
1782
|
-
{
|
|
1783
|
-
spec,
|
|
1784
|
-
found: parsed.host,
|
|
1785
|
-
validOptions: ["", "localhost"]
|
|
1786
|
-
}
|
|
1787
|
-
);
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return [
|
|
1791
|
-
parsed.pathname.replace(/^\/([a-zA-Z]:\/)/, "$1"),
|
|
1792
|
-
`file://${parsed.pathname}`
|
|
1793
|
-
];
|
|
1794
|
-
} catch (er) {
|
|
1795
|
-
throw error("invalid file:// specifier", {
|
|
1796
|
-
spec,
|
|
1797
|
-
cause: er
|
|
1798
|
-
});
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
if (opts?.winPath.isAbsolute(rest)) {
|
|
1802
|
-
return [rest, `file://${rest}`];
|
|
1803
|
-
}
|
|
1804
|
-
return [`./${rest}`, `file:./${rest}`];
|
|
1805
|
-
};
|
|
1806
|
-
|
|
1807
|
-
// ../../src/spec/src/index.ts
|
|
1808
|
-
var Spec2 = class extends Spec {
|
|
1809
|
-
[kCustomInspect](_depth, options) {
|
|
1810
|
-
const str = inspect(
|
|
1811
|
-
Object.fromEntries(
|
|
1812
|
-
Object.entries(this).filter(([k, v]) => {
|
|
1813
|
-
return k !== "options" && v !== void 0;
|
|
1814
|
-
})
|
|
1815
|
-
),
|
|
1816
|
-
options
|
|
1817
|
-
);
|
|
1818
|
-
return `@vltpkg/spec.Spec ${str}`;
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
Spec2.nodejsDependencies = {
|
|
1822
|
-
homedir,
|
|
1823
|
-
isAbsolute,
|
|
1824
|
-
join,
|
|
1825
|
-
resolve: resolve2,
|
|
1826
|
-
winPath
|
|
1827
|
-
};
|
|
1828
|
-
|
|
1829
|
-
export {
|
|
1830
|
-
asManifest,
|
|
1831
|
-
asPackument,
|
|
1832
|
-
longDependencyTypes,
|
|
1833
|
-
shortDependencyTypes,
|
|
1834
|
-
dependencyTypes,
|
|
1835
|
-
kIndent,
|
|
1836
|
-
kNewline,
|
|
1837
|
-
parse,
|
|
1838
|
-
stringify,
|
|
1839
|
-
PackageJson,
|
|
1840
|
-
fastSplit,
|
|
1841
|
-
Version,
|
|
1842
|
-
Range,
|
|
1843
|
-
parse2,
|
|
1844
|
-
parseRange,
|
|
1845
|
-
satisfies,
|
|
1846
|
-
compare,
|
|
1847
|
-
gt,
|
|
1848
|
-
gte,
|
|
1849
|
-
lt,
|
|
1850
|
-
lte,
|
|
1851
|
-
neq,
|
|
1852
|
-
eq,
|
|
1853
|
-
major,
|
|
1854
|
-
minor,
|
|
1855
|
-
patch,
|
|
1856
|
-
defaultRegistry,
|
|
1857
|
-
defaultRegistries,
|
|
1858
|
-
defaultGitHosts,
|
|
1859
|
-
defaultGitHostArchives,
|
|
1860
|
-
defaultScopeRegistries,
|
|
1861
|
-
Spec,
|
|
1862
|
-
Spec2
|
|
1863
|
-
};
|
|
1864
|
-
//# sourceMappingURL=chunk-POVPHE2F.js.map
|