@vltpkg/cli-js 1.0.1 → 1.0.2
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/{access-SXQICNAN.js → access-DB347PPG.js} +4 -4
- package/{bugs-OOPMFRCI.js → bugs-QBKI62J6.js} +10 -10
- package/{build-HDXI5OA7.js → build-EFJ3FFGU.js} +6 -6
- package/{cache-RW4Y4XNQ.js → cache-BQJCMDJN.js} +8 -8
- package/{chunk-U6DM3ROE.js → chunk-3HUTU5SO.js} +1 -1
- package/{chunk-F2FKLPZD.js → chunk-3MBSXZ62.js} +1 -1
- package/{chunk-UCD3RJYG.js → chunk-42UTZKAU.js} +5 -5
- package/{chunk-E5YE7UTZ.js → chunk-47IR6Z6C.js} +33 -16
- package/{chunk-4ZXA6RLP.js → chunk-5OGQND6H.js} +1 -1
- package/{chunk-3SQ5Y324.js → chunk-5PFGKHIS.js} +5 -7
- package/{chunk-EFWPI6IY.js → chunk-BSB4XGBB.js} +1 -1
- package/{chunk-EQ633HIM.js → chunk-CTDFRLS4.js} +3 -3
- package/{chunk-CCQYIYTA.js → chunk-DEMBZY23.js} +6 -6
- package/{chunk-ICJRCXSG.js → chunk-F2GLBPGQ.js} +8 -7
- package/{chunk-MT76WHSM.js → chunk-FM5DQZVN.js} +12 -6
- package/{chunk-MU7Y4R5E.js → chunk-L34LR5DV.js} +2 -2
- package/chunk-NS4VFXHX.js +49 -0
- package/{chunk-FAG776ZD.js → chunk-ONVLPT73.js} +1 -1
- package/{chunk-2PLIV3N3.js → chunk-Q46JRSZU.js} +718 -3
- package/{chunk-D5CP6O6G.js → chunk-TM4LHSZV.js} +4 -4
- package/{chunk-EHEVBLDB.js → chunk-ULCDRVY2.js} +4 -4
- package/{chunk-4RZDJQ5U.js → chunk-UVZJFBYE.js} +1 -1
- package/{chunk-WXMYKCQW.js → chunk-WAFERMRI.js} +39 -16
- package/{chunk-VM2RMMY4.js → chunk-YDUHQU7N.js} +3 -3
- package/{chunk-VZ7UNZHR.js → chunk-YRMICBI4.js} +2 -2
- package/chunk-ZLZ4XF46.js +75 -0
- package/{ci-MTYU2K2A.js → ci-A22A6TCQ.js} +7 -7
- package/cli-package.json +1 -1
- package/{config-TVAXCTQO.js → config-JL4TW2AV.js} +7 -7
- package/{config-6NXV2BXW.js → config-VOLRKFYD.js} +8 -8
- package/{create-LXI5DCDW.js → create-SL7HEXCS.js} +14 -14
- package/{deprecate-2AQBL5XT.js → deprecate-ZK525LQW.js} +8 -8
- package/{dist-tag-BFSYLRIH.js → dist-tag-FY3FB5VH.js} +5 -5
- package/{docs-ADPJ4B4C.js → docs-6BPWZJFW.js} +10 -10
- package/{exec-GMS54RAC.js → exec-JZ5J7DI7.js} +14 -14
- package/{exec-cache-R5LVZL5Z.js → exec-cache-VGSXKZVF.js} +12 -12
- package/{exec-local-TVCLZGIM.js → exec-local-GPZUSOSM.js} +11 -11
- package/{help-6CECUD6C.js → help-XI7TNIRU.js} +1 -1
- package/{init-XXFLGYVP.js → init-6KWM7CDI.js} +7 -7
- package/{install-6KMXYSF5.js → install-4VLOKCWH.js} +8 -8
- package/{list-RUO3SUKY.js → list-3VLGWGKU.js} +11 -11
- package/{login-6I2CGO7I.js → login-3DGPSWCG.js} +4 -4
- package/{logout-JTU4BJKH.js → logout-DBFMZC6J.js} +4 -4
- package/{pack-NCWH2TUA.js → pack-LHNYEZ5W.js} +8 -8
- package/package.json +6 -6
- package/{ping-4MEAC2WD.js → ping-VLLX5LIH.js} +4 -4
- package/{pkg-ENSKG6G7.js → pkg-FYPUMX7U.js} +8 -8
- package/{profile-62YHNFSO.js → profile-FOQ74TB7.js} +4 -4
- package/{publish-PPY724N2.js → publish-DFURU7DW.js} +10 -10
- package/{query-NLWXKOOT.js → query-NC3EABMW.js} +11 -11
- package/{registry-QGI44LG4.js → registry-5DUFCPD6.js} +3 -3
- package/registry-client-package.json +1 -1
- package/registry-client-src-revalidate.js +1679 -23
- package/{repo-BFRAXIVU.js → repo-IZXACKQ2.js} +10 -10
- package/{reporter-2XBYWAVU.js → reporter-UU654STB.js} +2 -2
- package/{run-7O65747G.js → run-RDFVO7FY.js} +11 -11
- package/{run-exec-2OYWHL6K.js → run-exec-OGMXEVN5.js} +11 -11
- package/security-archive-src-update-expired.js +28 -2
- package/{setup-MMIDAIJI.js → setup-KTJQPDJB.js} +17 -10
- package/{src-OK3KHDYR.js → src-BJU7XZNK.js} +12 -12
- package/{token-VLVXUW54.js → token-SKICECA4.js} +4 -4
- package/{uninstall-TAG6QIAG.js → uninstall-MTZJ33TO.js} +8 -8
- package/{unpublish-Y4L5J2IA.js → unpublish-3QBJZFHQ.js} +5 -5
- package/{update-RYH4RKBS.js → update-TH477PKA.js} +7 -7
- package/{version-COHB32ON.js → version-YIBQZLQS.js} +7 -7
- package/{view-P7U4MF43.js → view-FG74OAOV.js} +8 -8
- package/vlr.js +1 -1
- package/vlrx.js +1 -1
- package/vlt.js +1 -1
- package/vlx.js +1 -1
- package/vlxl.js +1 -1
- package/{whoami-47MVFMZC.js → whoami-LHJ4PRJQ.js} +4 -4
- package/chunk-HB7CKTYO.js +0 -75
- package/chunk-PW6S6AIO.js +0 -716
|
@@ -10000,9 +10000,9 @@ var require_socks5_client = __commonJS({
|
|
|
10000
10000
|
var { EventEmitter: EventEmitter2 } = __require("node:events");
|
|
10001
10001
|
var { Buffer: Buffer2 } = __require("node:buffer");
|
|
10002
10002
|
var { InvalidArgumentError, Socks5ProxyError } = require_errors();
|
|
10003
|
-
var { debuglog } = __require("node:util");
|
|
10003
|
+
var { debuglog: debuglog2 } = __require("node:util");
|
|
10004
10004
|
var { parseAddress } = require_socks5_utils();
|
|
10005
|
-
var
|
|
10005
|
+
var debug2 = debuglog2("undici:socks5");
|
|
10006
10006
|
var EMPTY_BUFFER = Buffer2.alloc(0);
|
|
10007
10007
|
var SOCKS_VERSION = 5;
|
|
10008
10008
|
var AUTH_METHODS = {
|
|
@@ -10068,7 +10068,7 @@ var require_socks5_client = __commonJS({
|
|
|
10068
10068
|
* Handle incoming data from the socket
|
|
10069
10069
|
*/
|
|
10070
10070
|
onData(data) {
|
|
10071
|
-
|
|
10071
|
+
debug2("received data", data.length, "bytes in state", this.state);
|
|
10072
10072
|
this.buffer = Buffer2.concat([this.buffer, data]);
|
|
10073
10073
|
try {
|
|
10074
10074
|
switch (this.state) {
|
|
@@ -10090,7 +10090,7 @@ var require_socks5_client = __commonJS({
|
|
|
10090
10090
|
* Handle socket errors
|
|
10091
10091
|
*/
|
|
10092
10092
|
onError(err) {
|
|
10093
|
-
|
|
10093
|
+
debug2("socket error", err);
|
|
10094
10094
|
this.state = STATES.ERROR;
|
|
10095
10095
|
this.emit("error", err);
|
|
10096
10096
|
this.destroy();
|
|
@@ -10099,7 +10099,7 @@ var require_socks5_client = __commonJS({
|
|
|
10099
10099
|
* Handle socket close
|
|
10100
10100
|
*/
|
|
10101
10101
|
onClose() {
|
|
10102
|
-
|
|
10102
|
+
debug2("socket closed");
|
|
10103
10103
|
this.state = STATES.CLOSED;
|
|
10104
10104
|
this.emit("close");
|
|
10105
10105
|
}
|
|
@@ -10122,7 +10122,7 @@ var require_socks5_client = __commonJS({
|
|
|
10122
10122
|
if (this.state !== STATES.INITIAL) {
|
|
10123
10123
|
throw new InvalidArgumentError("Handshake already started");
|
|
10124
10124
|
}
|
|
10125
|
-
|
|
10125
|
+
debug2("starting handshake with", this.authMethods.length, "auth methods");
|
|
10126
10126
|
this.state = STATES.HANDSHAKING;
|
|
10127
10127
|
const request2 = Buffer2.alloc(2 + this.authMethods.length);
|
|
10128
10128
|
request2[0] = SOCKS_VERSION;
|
|
@@ -10148,7 +10148,7 @@ var require_socks5_client = __commonJS({
|
|
|
10148
10148
|
throw new Socks5ProxyError("No acceptable authentication method", "UND_ERR_SOCKS5_AUTH_REJECTED");
|
|
10149
10149
|
}
|
|
10150
10150
|
this.buffer = this.buffer.subarray(2);
|
|
10151
|
-
|
|
10151
|
+
debug2("server selected auth method", method);
|
|
10152
10152
|
if (method === AUTH_METHODS.NO_AUTH) {
|
|
10153
10153
|
this.markAuthenticated();
|
|
10154
10154
|
} else if (method === AUTH_METHODS.USERNAME_PASSWORD) {
|
|
@@ -10166,7 +10166,7 @@ var require_socks5_client = __commonJS({
|
|
|
10166
10166
|
if (!username || !password) {
|
|
10167
10167
|
throw new InvalidArgumentError("Username and password required for authentication");
|
|
10168
10168
|
}
|
|
10169
|
-
|
|
10169
|
+
debug2("sending username/password auth");
|
|
10170
10170
|
const usernameBuffer = Buffer2.from(username);
|
|
10171
10171
|
const passwordBuffer = Buffer2.from(password);
|
|
10172
10172
|
if (usernameBuffer.length > 255 || passwordBuffer.length > 255) {
|
|
@@ -10196,7 +10196,7 @@ var require_socks5_client = __commonJS({
|
|
|
10196
10196
|
throw new Socks5ProxyError("Authentication failed", "UND_ERR_SOCKS5_AUTH_FAILED");
|
|
10197
10197
|
}
|
|
10198
10198
|
this.buffer = this.buffer.subarray(2);
|
|
10199
|
-
|
|
10199
|
+
debug2("authentication successful");
|
|
10200
10200
|
this.markAuthenticated();
|
|
10201
10201
|
}
|
|
10202
10202
|
/**
|
|
@@ -10211,7 +10211,7 @@ var require_socks5_client = __commonJS({
|
|
|
10211
10211
|
if (this.state !== STATES.AUTHENTICATED) {
|
|
10212
10212
|
throw new InvalidArgumentError("Client must be authenticated before CONNECT");
|
|
10213
10213
|
}
|
|
10214
|
-
|
|
10214
|
+
debug2("connecting to", address, port);
|
|
10215
10215
|
this.state = STATES.CONNECTING;
|
|
10216
10216
|
const request2 = this.buildConnectRequest(COMMANDS.CONNECT, address, port);
|
|
10217
10217
|
this.socket.write(request2);
|
|
@@ -10286,7 +10286,7 @@ var require_socks5_client = __commonJS({
|
|
|
10286
10286
|
this.buffer = EMPTY_BUFFER;
|
|
10287
10287
|
this.state = STATES.CONNECTED;
|
|
10288
10288
|
this.socket.removeListener("data", this.onSocketData);
|
|
10289
|
-
|
|
10289
|
+
debug2("connected, bound address:", boundAddress, "port:", boundPort);
|
|
10290
10290
|
this.emit("connected", { address: boundAddress, port: boundPort });
|
|
10291
10291
|
}
|
|
10292
10292
|
/**
|
|
@@ -10338,8 +10338,8 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10338
10338
|
var { kDispatch, kClose, kDestroy } = require_symbols();
|
|
10339
10339
|
var Pool = require_pool();
|
|
10340
10340
|
var buildConnector = require_connect();
|
|
10341
|
-
var { debuglog } = __require("node:util");
|
|
10342
|
-
var
|
|
10341
|
+
var { debuglog: debuglog2 } = __require("node:util");
|
|
10342
|
+
var debug2 = debuglog2("undici:socks5-proxy");
|
|
10343
10343
|
var kProxyUrl = /* @__PURE__ */ Symbol("proxy url");
|
|
10344
10344
|
var kProxyHeaders = /* @__PURE__ */ Symbol("proxy headers");
|
|
10345
10345
|
var kProxyAuth = /* @__PURE__ */ Symbol("proxy auth");
|
|
@@ -10385,7 +10385,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10385
10385
|
async createSocks5Connection(targetHost, targetPort) {
|
|
10386
10386
|
const proxyHost = this[kProxyUrl].hostname;
|
|
10387
10387
|
const proxyPort = parseInt(this[kProxyUrl].port) || 1080;
|
|
10388
|
-
|
|
10388
|
+
debug2("creating SOCKS5 connection to", proxyHost, proxyPort);
|
|
10389
10389
|
const socket = await new Promise((resolve10, reject) => {
|
|
10390
10390
|
this[kConnector]({
|
|
10391
10391
|
hostname: proxyHost,
|
|
@@ -10402,7 +10402,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10402
10402
|
});
|
|
10403
10403
|
const socks5Client = new Socks5Client(socket, this[kProxyAuth]);
|
|
10404
10404
|
socks5Client.on("error", (err) => {
|
|
10405
|
-
|
|
10405
|
+
debug2("SOCKS5 error:", err);
|
|
10406
10406
|
socket.destroy();
|
|
10407
10407
|
});
|
|
10408
10408
|
await socks5Client.handshake();
|
|
@@ -10434,7 +10434,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10434
10434
|
reject(new Error("SOCKS5 connection timeout"));
|
|
10435
10435
|
}, 5e3);
|
|
10436
10436
|
const onConnected = (info) => {
|
|
10437
|
-
|
|
10437
|
+
debug2("SOCKS5 tunnel established to", targetHost, targetPort, "via", info);
|
|
10438
10438
|
clearTimeout(timeout);
|
|
10439
10439
|
socks5Client.removeListener("error", onError);
|
|
10440
10440
|
resolve10();
|
|
@@ -10454,7 +10454,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10454
10454
|
*/
|
|
10455
10455
|
[kDispatch](opts, handler) {
|
|
10456
10456
|
const { origin } = opts;
|
|
10457
|
-
|
|
10457
|
+
debug2("dispatching request to", origin, "via SOCKS5");
|
|
10458
10458
|
try {
|
|
10459
10459
|
const originKey = String(origin);
|
|
10460
10460
|
let pool = this[kPools].get(originKey);
|
|
@@ -10467,14 +10467,14 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10467
10467
|
const url = new URL2(origin);
|
|
10468
10468
|
const targetHost = url.hostname;
|
|
10469
10469
|
const targetPort = parseInt(url.port) || (url.protocol === "https:" ? 443 : 80);
|
|
10470
|
-
|
|
10470
|
+
debug2("establishing SOCKS5 connection to", targetHost, targetPort);
|
|
10471
10471
|
const socket = await this.createSocks5Connection(targetHost, targetPort);
|
|
10472
10472
|
let finalSocket = socket;
|
|
10473
10473
|
if (url.protocol === "https:") {
|
|
10474
10474
|
if (!tls) {
|
|
10475
10475
|
tls = __require("node:tls");
|
|
10476
10476
|
}
|
|
10477
|
-
|
|
10477
|
+
debug2("upgrading to TLS");
|
|
10478
10478
|
finalSocket = tls.connect({
|
|
10479
10479
|
...this[kRequestTls],
|
|
10480
10480
|
socket,
|
|
@@ -10487,7 +10487,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10487
10487
|
}
|
|
10488
10488
|
callback(null, finalSocket);
|
|
10489
10489
|
} catch (err) {
|
|
10490
|
-
|
|
10490
|
+
debug2("SOCKS5 connection error:", err);
|
|
10491
10491
|
callback(err);
|
|
10492
10492
|
}
|
|
10493
10493
|
}
|
|
@@ -10496,7 +10496,7 @@ var require_socks5_proxy_agent = __commonJS({
|
|
|
10496
10496
|
}
|
|
10497
10497
|
return pool[kDispatch](opts, handler);
|
|
10498
10498
|
} catch (err) {
|
|
10499
|
-
|
|
10499
|
+
debug2("dispatch error:", err);
|
|
10500
10500
|
if (typeof handler.onResponseError === "function") {
|
|
10501
10501
|
handler.onResponseError(null, err);
|
|
10502
10502
|
return false;
|
|
@@ -25257,6 +25257,18 @@ function create(cls, defaultFrom, message, cause, from = defaultFrom) {
|
|
|
25257
25257
|
function error(message, cause, from) {
|
|
25258
25258
|
return create(Error, error, message, cause, from);
|
|
25259
25259
|
}
|
|
25260
|
+
function typeError(message, cause, from) {
|
|
25261
|
+
return create(TypeError, typeError, message, cause, from);
|
|
25262
|
+
}
|
|
25263
|
+
function syntaxError(message, cause, from) {
|
|
25264
|
+
return create(
|
|
25265
|
+
SyntaxError,
|
|
25266
|
+
syntaxError,
|
|
25267
|
+
message,
|
|
25268
|
+
cause,
|
|
25269
|
+
from
|
|
25270
|
+
);
|
|
25271
|
+
}
|
|
25260
25272
|
|
|
25261
25273
|
// ../../src/cache/src/index.ts
|
|
25262
25274
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -29972,10 +29984,1654 @@ var handleBeforeExit = () => {
|
|
|
29972
29984
|
}
|
|
29973
29985
|
};
|
|
29974
29986
|
|
|
29987
|
+
// ../../src/fast-split/src/index.ts
|
|
29988
|
+
function fastSplit(str, delim, limit = -1, onPart) {
|
|
29989
|
+
let i2 = 0;
|
|
29990
|
+
let p = 0;
|
|
29991
|
+
const l = delim.length;
|
|
29992
|
+
const parts = [];
|
|
29993
|
+
while (i2 !== -1) {
|
|
29994
|
+
i2 = str.indexOf(delim, p);
|
|
29995
|
+
const part = i2 === -1 || parts.length === limit - 1 ? str.substring(p) : str.substring(p, i2);
|
|
29996
|
+
parts.push(onPart?.(part, parts, i2) ?? part);
|
|
29997
|
+
if (parts.length === limit) {
|
|
29998
|
+
return parts;
|
|
29999
|
+
}
|
|
30000
|
+
p = i2 + l;
|
|
30001
|
+
}
|
|
30002
|
+
return parts;
|
|
30003
|
+
}
|
|
30004
|
+
|
|
30005
|
+
// ../../src/semver/src/version.ts
|
|
30006
|
+
var maybeNumber = (s) => {
|
|
30007
|
+
if (!/^[0-9]+$/.test(s)) return s;
|
|
30008
|
+
const n7 = Number(s);
|
|
30009
|
+
return n7 <= Number.MAX_SAFE_INTEGER ? n7 : s;
|
|
30010
|
+
};
|
|
30011
|
+
var safeNumber = (s, version2, field) => {
|
|
30012
|
+
const n7 = Number(s);
|
|
30013
|
+
if (n7 > Number.MAX_SAFE_INTEGER) {
|
|
30014
|
+
throw invalidVersion(
|
|
30015
|
+
version2,
|
|
30016
|
+
`invalid ${field}, must be <= ${Number.MAX_SAFE_INTEGER}`
|
|
30017
|
+
);
|
|
30018
|
+
}
|
|
30019
|
+
return n7;
|
|
30020
|
+
};
|
|
30021
|
+
var re2 = {
|
|
30022
|
+
prefix: /^[ v=]+/,
|
|
30023
|
+
main: /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/,
|
|
30024
|
+
prerelease: /-([0-9a-zA-Z_.-]+)(?:$|\+)/,
|
|
30025
|
+
build: /\+([0-9a-zA-Z_.-]+)$/,
|
|
30026
|
+
full: /^[ v=]*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9a-zA-Z_.-]+))?(?:\+([0-9a-zA-Z_.-]+))?$/
|
|
30027
|
+
};
|
|
30028
|
+
var invalidVersion = (version2, message) => {
|
|
30029
|
+
const er = syntaxError(
|
|
30030
|
+
`invalid version: ${message}`,
|
|
30031
|
+
{ version: version2 },
|
|
30032
|
+
Version
|
|
30033
|
+
);
|
|
30034
|
+
return er;
|
|
30035
|
+
};
|
|
30036
|
+
var Version = class _Version {
|
|
30037
|
+
/** raw string provided to create this Version */
|
|
30038
|
+
raw;
|
|
30039
|
+
/** major version number */
|
|
30040
|
+
major;
|
|
30041
|
+
/** minor version number */
|
|
30042
|
+
minor;
|
|
30043
|
+
/** patch version number */
|
|
30044
|
+
patch;
|
|
30045
|
+
/**
|
|
30046
|
+
* List of `'.'`-separated strings and numbers indicating that this
|
|
30047
|
+
* version is a prerelease.
|
|
30048
|
+
*
|
|
30049
|
+
* This is undefined if the version does not have a prerelease section.
|
|
30050
|
+
*/
|
|
30051
|
+
prerelease;
|
|
30052
|
+
/**
|
|
30053
|
+
* List of `'.'`-separated strings in the `build` section.
|
|
30054
|
+
*
|
|
30055
|
+
* This is undefined if the version does not have a build.
|
|
30056
|
+
*/
|
|
30057
|
+
build;
|
|
30058
|
+
/** Canonical strict form of this version */
|
|
30059
|
+
toString() {
|
|
30060
|
+
return `${this.major}.${this.minor}.${this.patch}${this.prerelease ? "-" + this.prerelease.join(".") : ""}${this.build ? "+" + this.build.join(".") : ""}`;
|
|
30061
|
+
}
|
|
30062
|
+
/** Generate a `Version` object from a SemVer string */
|
|
30063
|
+
static parse(version2) {
|
|
30064
|
+
version2 = version2.replace(re2.prefix, "").trim();
|
|
30065
|
+
if (version2.length > 256) {
|
|
30066
|
+
throw invalidVersion(
|
|
30067
|
+
version2,
|
|
30068
|
+
"must be less than 256 characters"
|
|
30069
|
+
);
|
|
30070
|
+
}
|
|
30071
|
+
const parsed = re2.full.exec(version2);
|
|
30072
|
+
if (!parsed) {
|
|
30073
|
+
const main3 = re2.main.exec(version2);
|
|
30074
|
+
if (!main3) {
|
|
30075
|
+
throw invalidVersion(
|
|
30076
|
+
version2,
|
|
30077
|
+
"no Major.minor.patch tuple present"
|
|
30078
|
+
);
|
|
30079
|
+
} else {
|
|
30080
|
+
throw invalidVersion(
|
|
30081
|
+
version2,
|
|
30082
|
+
"invalid build or patch section"
|
|
30083
|
+
);
|
|
30084
|
+
}
|
|
30085
|
+
}
|
|
30086
|
+
const [_3, major_, minor_, patch_, prerelease, build] = parsed;
|
|
30087
|
+
const major2 = safeNumber(major_, version2, "major");
|
|
30088
|
+
const minor2 = safeNumber(minor_, version2, "minor");
|
|
30089
|
+
const patch = safeNumber(patch_, version2, "patch");
|
|
30090
|
+
return new _Version(
|
|
30091
|
+
version2,
|
|
30092
|
+
major2,
|
|
30093
|
+
minor2,
|
|
30094
|
+
patch,
|
|
30095
|
+
prerelease,
|
|
30096
|
+
build
|
|
30097
|
+
);
|
|
30098
|
+
}
|
|
30099
|
+
constructor(version2, major2, minor2, patch, prerelease, build) {
|
|
30100
|
+
this.raw = version2;
|
|
30101
|
+
this.major = major2;
|
|
30102
|
+
this.minor = minor2;
|
|
30103
|
+
this.patch = patch;
|
|
30104
|
+
if (prerelease) {
|
|
30105
|
+
this.prerelease = fastSplit(prerelease, ".", -1, (c) => {
|
|
30106
|
+
if (!c) {
|
|
30107
|
+
throw invalidVersion(
|
|
30108
|
+
version2,
|
|
30109
|
+
"invalid prerelease, empty identifiers not allowed"
|
|
30110
|
+
);
|
|
30111
|
+
}
|
|
30112
|
+
return maybeNumber(c);
|
|
30113
|
+
});
|
|
30114
|
+
}
|
|
30115
|
+
if (build) {
|
|
30116
|
+
this.build = fastSplit(build, ".", -1, (c) => {
|
|
30117
|
+
if (!c) {
|
|
30118
|
+
throw invalidVersion(
|
|
30119
|
+
version2,
|
|
30120
|
+
"invalid build metadata, empty identifiers not allowed"
|
|
30121
|
+
);
|
|
30122
|
+
}
|
|
30123
|
+
});
|
|
30124
|
+
}
|
|
30125
|
+
}
|
|
30126
|
+
/**
|
|
30127
|
+
* Return 1 if this is > the provided version, -1 if we're less, or 0 if
|
|
30128
|
+
* they are equal.
|
|
30129
|
+
*
|
|
30130
|
+
* No special handling for prerelease versions, this is just a precedence
|
|
30131
|
+
* comparison.
|
|
30132
|
+
*
|
|
30133
|
+
* This can be used to sort a list of versions by precedence:
|
|
30134
|
+
*
|
|
30135
|
+
* ```ts
|
|
30136
|
+
* const versions: Version[] = getVersionsSomehow()
|
|
30137
|
+
* const sorted = versions.sort((a, b) => a.compare(b))
|
|
30138
|
+
* ```
|
|
30139
|
+
*/
|
|
30140
|
+
compare(v3) {
|
|
30141
|
+
if (this.major > v3.major) return 1;
|
|
30142
|
+
if (this.major < v3.major) return -1;
|
|
30143
|
+
if (this.minor > v3.minor) return 1;
|
|
30144
|
+
if (this.minor < v3.minor) return -1;
|
|
30145
|
+
if (this.patch > v3.patch) return 1;
|
|
30146
|
+
if (this.patch < v3.patch) return -1;
|
|
30147
|
+
if (!v3.prerelease?.length)
|
|
30148
|
+
return !this.prerelease?.length ? 0 : -1;
|
|
30149
|
+
if (!this.prerelease?.length) return 1;
|
|
30150
|
+
const len = Math.max(this.prerelease.length, v3.prerelease.length);
|
|
30151
|
+
const me2 = this.prerelease;
|
|
30152
|
+
const thee = v3.prerelease;
|
|
30153
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
30154
|
+
const m2 = me2[i2];
|
|
30155
|
+
const t = thee[i2];
|
|
30156
|
+
if (m2 === t) continue;
|
|
30157
|
+
if (t === void 0) return 1;
|
|
30158
|
+
if (m2 === void 0) return -1;
|
|
30159
|
+
if (typeof m2 !== typeof t) {
|
|
30160
|
+
return typeof m2 === "string" ? 1 : -1;
|
|
30161
|
+
}
|
|
30162
|
+
return m2 > t ? 1 : -1;
|
|
30163
|
+
}
|
|
30164
|
+
return 0;
|
|
30165
|
+
}
|
|
30166
|
+
/**
|
|
30167
|
+
* The inverse of compare, for sorting version lists in reverse order
|
|
30168
|
+
*/
|
|
30169
|
+
rcompare(v3) {
|
|
30170
|
+
return -1 * this.compare(v3);
|
|
30171
|
+
}
|
|
30172
|
+
/** true if this version is > the argument */
|
|
30173
|
+
greaterThan(v3) {
|
|
30174
|
+
return this.compare(v3) === 1;
|
|
30175
|
+
}
|
|
30176
|
+
/** true if this version is >= the argument */
|
|
30177
|
+
greaterThanEqual(v3) {
|
|
30178
|
+
return this.compare(v3) > -1;
|
|
30179
|
+
}
|
|
30180
|
+
/** true if this version is < the argument */
|
|
30181
|
+
lessThan(v3) {
|
|
30182
|
+
return this.compare(v3) === -1;
|
|
30183
|
+
}
|
|
30184
|
+
/** true if this version is <= the argument */
|
|
30185
|
+
lessThanEqual(v3) {
|
|
30186
|
+
return this.compare(v3) < 1;
|
|
30187
|
+
}
|
|
30188
|
+
/** true if these two versions have equal SemVer precedence */
|
|
30189
|
+
equals(v3) {
|
|
30190
|
+
return this.compare(v3) === 0;
|
|
30191
|
+
}
|
|
30192
|
+
/** just compare the M.m.p parts of the version */
|
|
30193
|
+
tupleEquals(v3) {
|
|
30194
|
+
return this.major === v3.major && this.minor === v3.minor && this.patch === v3.patch;
|
|
30195
|
+
}
|
|
30196
|
+
/** true if this version satisfies the range */
|
|
30197
|
+
satisfies(r) {
|
|
30198
|
+
return r.test(this);
|
|
30199
|
+
}
|
|
30200
|
+
/**
|
|
30201
|
+
* Increment the version in place, in the manner specified.
|
|
30202
|
+
*
|
|
30203
|
+
* Part behaviors:
|
|
30204
|
+
*
|
|
30205
|
+
* - `'major'` If the version is a `M.0.0-...` version with a prerelease, then
|
|
30206
|
+
* simply drop the prerelease. Otherwise, set the minor and patch to 0, and
|
|
30207
|
+
* increment the major. So `1.0.0-beta` becomes `1.0.0`, and `1.2.3` becomes
|
|
30208
|
+
* `2.0.0`
|
|
30209
|
+
*
|
|
30210
|
+
* - `'minor'` If the version is a `M.m.0-...` version with a prerelease, then
|
|
30211
|
+
* simply drop the prerelease. Otherwise, set the patch to 0, and increment the
|
|
30212
|
+
* minor. So `1.2.0-beta` becomes `1.2.0`, and `1.2.3` becomes `1.3.0`.
|
|
30213
|
+
*
|
|
30214
|
+
* - `'patch'` If the version has a prerelease, then simply drop the
|
|
30215
|
+
* prerelease. Otherwise, increment the patch value. So `1.2.3-beta` becomes
|
|
30216
|
+
* `1.2.3` and `1.2.3` becomes `1.2.4`.
|
|
30217
|
+
*
|
|
30218
|
+
* - `'premajor'` Set the patch and minor versions to `0`, increment the major
|
|
30219
|
+
* version, and add a prerelease, using the optional identifier.
|
|
30220
|
+
*
|
|
30221
|
+
* - `'preminor'` Set the patch version to `0`, increment the minor version,
|
|
30222
|
+
* and add a prerelease, using the optional identifier.
|
|
30223
|
+
*
|
|
30224
|
+
* - `'prepatch'` If a prerelease is already present, increment the patch
|
|
30225
|
+
* version, otherwise leave it untouched, and add a prerelease, using the
|
|
30226
|
+
* optional identifier.
|
|
30227
|
+
*
|
|
30228
|
+
* - `'prerelease'` If a prerelease version is present, then behave the same as
|
|
30229
|
+
* `'prepatch'`. Otherwise, add a prerelease, using the optional identifier.
|
|
30230
|
+
*
|
|
30231
|
+
* - `'pre'` This is mostly for use by the other prerelease incrementers.
|
|
30232
|
+
*
|
|
30233
|
+
* - If a prerelease identifier is provided:
|
|
30234
|
+
*
|
|
30235
|
+
* Update that named portion of the prerelease. For example,
|
|
30236
|
+
* `inc('1.2.3-beta.4', 'pre', 'beta')` would result in `1.2.3-beta.5`.
|
|
30237
|
+
*
|
|
30238
|
+
* If there is no prerelease identifier by that name, then replace the
|
|
30239
|
+
* prerelease with `[name]`. So `inc('1.2.3-alpha.4', 'pre', 'beta')`
|
|
30240
|
+
* would result in `1.2.3-beta`.
|
|
30241
|
+
*
|
|
30242
|
+
* If the prerelease identifer is present, but has no numeric value
|
|
30243
|
+
* following it, then add `0`. So `inc('1.2.3-beta', 'pre', 'beta')`
|
|
30244
|
+
* would result in `1.2.3-beta.0`.
|
|
30245
|
+
*
|
|
30246
|
+
* - If no prerelease identifier is provided:
|
|
30247
|
+
*
|
|
30248
|
+
* If there is no current prerelease, then set the prerelease to `0`. So,
|
|
30249
|
+
* `inc('1.2.3', 'pre')` becomes `1.2.3-0`.
|
|
30250
|
+
*
|
|
30251
|
+
* If the last item in the prerelease is numeric, then increment it. So,
|
|
30252
|
+
* `inc('1.2.3-beta.3', 'pre')` becomes `1.2.3-beta.4`.
|
|
30253
|
+
*/
|
|
30254
|
+
inc(part, prereleaseIdentifier) {
|
|
30255
|
+
switch (part) {
|
|
30256
|
+
case "premajor":
|
|
30257
|
+
this.prerelease = void 0;
|
|
30258
|
+
this.patch = 0;
|
|
30259
|
+
this.minor = 0;
|
|
30260
|
+
this.major++;
|
|
30261
|
+
this.inc("pre", prereleaseIdentifier);
|
|
30262
|
+
break;
|
|
30263
|
+
case "preminor":
|
|
30264
|
+
this.prerelease = void 0;
|
|
30265
|
+
this.patch = 0;
|
|
30266
|
+
this.minor++;
|
|
30267
|
+
this.inc("pre", prereleaseIdentifier);
|
|
30268
|
+
break;
|
|
30269
|
+
case "prepatch":
|
|
30270
|
+
this.prerelease = void 0;
|
|
30271
|
+
this.inc("patch");
|
|
30272
|
+
this.inc("pre", prereleaseIdentifier);
|
|
30273
|
+
break;
|
|
30274
|
+
case "prerelease":
|
|
30275
|
+
if (!this.prerelease?.length)
|
|
30276
|
+
this.inc("patch", prereleaseIdentifier);
|
|
30277
|
+
this.inc("pre", prereleaseIdentifier);
|
|
30278
|
+
break;
|
|
30279
|
+
case "pre": {
|
|
30280
|
+
if (!prereleaseIdentifier) {
|
|
30281
|
+
if (!this.prerelease?.length) {
|
|
30282
|
+
this.prerelease = [0];
|
|
30283
|
+
break;
|
|
30284
|
+
}
|
|
30285
|
+
const last = this.prerelease[this.prerelease.length - 1];
|
|
30286
|
+
if (typeof last === "number") {
|
|
30287
|
+
this.prerelease[this.prerelease.length - 1] = last + 1;
|
|
30288
|
+
} else {
|
|
30289
|
+
this.prerelease.push(0);
|
|
30290
|
+
}
|
|
30291
|
+
break;
|
|
30292
|
+
}
|
|
30293
|
+
if (!this.prerelease?.length) {
|
|
30294
|
+
this.prerelease = [prereleaseIdentifier];
|
|
30295
|
+
break;
|
|
30296
|
+
}
|
|
30297
|
+
const i2 = this.prerelease.indexOf(
|
|
30298
|
+
maybeNumber(prereleaseIdentifier)
|
|
30299
|
+
);
|
|
30300
|
+
if (i2 === -1) {
|
|
30301
|
+
this.prerelease = [prereleaseIdentifier];
|
|
30302
|
+
break;
|
|
30303
|
+
}
|
|
30304
|
+
const baseValue = this.prerelease[i2 + 1];
|
|
30305
|
+
if (typeof baseValue === "number") {
|
|
30306
|
+
this.prerelease[i2 + 1] = baseValue + 1;
|
|
30307
|
+
break;
|
|
30308
|
+
}
|
|
30309
|
+
if (i2 === this.prerelease.length - 1) {
|
|
30310
|
+
this.prerelease.push(0);
|
|
30311
|
+
break;
|
|
30312
|
+
}
|
|
30313
|
+
this.prerelease.splice(i2 + 1, 0, 0);
|
|
30314
|
+
break;
|
|
30315
|
+
}
|
|
30316
|
+
case "major":
|
|
30317
|
+
if (!this.prerelease?.length || this.minor || this.patch)
|
|
30318
|
+
this.major++;
|
|
30319
|
+
this.prerelease = void 0;
|
|
30320
|
+
this.patch = 0;
|
|
30321
|
+
this.minor = 0;
|
|
30322
|
+
break;
|
|
30323
|
+
case "minor":
|
|
30324
|
+
if (!this.prerelease?.length || this.patch) this.minor++;
|
|
30325
|
+
this.prerelease = void 0;
|
|
30326
|
+
this.patch = 0;
|
|
30327
|
+
break;
|
|
30328
|
+
case "patch":
|
|
30329
|
+
if (!this.prerelease?.length) this.patch++;
|
|
30330
|
+
this.prerelease = void 0;
|
|
30331
|
+
break;
|
|
30332
|
+
default:
|
|
30333
|
+
throw typeError(
|
|
30334
|
+
"Invalid increment identifier",
|
|
30335
|
+
{
|
|
30336
|
+
version: this,
|
|
30337
|
+
found: part,
|
|
30338
|
+
validOptions: [
|
|
30339
|
+
"major",
|
|
30340
|
+
"minor",
|
|
30341
|
+
"patch",
|
|
30342
|
+
"premajor",
|
|
30343
|
+
"preminor",
|
|
30344
|
+
"prepatch",
|
|
30345
|
+
"prerelease",
|
|
30346
|
+
"pre"
|
|
30347
|
+
]
|
|
30348
|
+
},
|
|
30349
|
+
this.inc
|
|
30350
|
+
);
|
|
30351
|
+
}
|
|
30352
|
+
this.raw = this.toString();
|
|
30353
|
+
return this;
|
|
30354
|
+
}
|
|
30355
|
+
};
|
|
30356
|
+
|
|
29975
30357
|
// ../../src/semver/src/comparator.ts
|
|
30358
|
+
var isOperator = (o) => !!o && (o === ">" || o === "<" || o === ">=" || o === "<=" || o === "" || o === "~" || o === "^" || o === "~>");
|
|
29976
30359
|
var preJunk = new Set("=v ");
|
|
30360
|
+
var invalidComp = (c, message) => syntaxError(
|
|
30361
|
+
`invalid comparator: '${c}' ${message}`,
|
|
30362
|
+
{ found: c },
|
|
30363
|
+
Comparator
|
|
30364
|
+
);
|
|
30365
|
+
var assertNumber = (value, c, field) => {
|
|
30366
|
+
const n7 = Number(value);
|
|
30367
|
+
if (n7 !== n7) {
|
|
30368
|
+
throw invalidComp(
|
|
30369
|
+
c,
|
|
30370
|
+
`${field} must be numeric or 'x', got: '${value}'`
|
|
30371
|
+
);
|
|
30372
|
+
}
|
|
30373
|
+
return n7;
|
|
30374
|
+
};
|
|
30375
|
+
var assertVersion = (v3, comp) => {
|
|
30376
|
+
if (!v3) {
|
|
30377
|
+
throw invalidComp(comp, "no value provided for operator");
|
|
30378
|
+
}
|
|
30379
|
+
};
|
|
30380
|
+
var assertMissing = (value, c, field) => {
|
|
30381
|
+
if (value && !isX(value)) {
|
|
30382
|
+
throw invalidComp(
|
|
30383
|
+
c,
|
|
30384
|
+
`cannot omit '${field}' and include subsequent fields`
|
|
30385
|
+
);
|
|
30386
|
+
}
|
|
30387
|
+
};
|
|
30388
|
+
var MAJOR = 0;
|
|
30389
|
+
var MINOR = 1;
|
|
30390
|
+
var PATCH = 2;
|
|
30391
|
+
var isX = (c) => !c || c === "X" || c === "x" || c === "*";
|
|
30392
|
+
var isFullVersion = (parsed) => void 0 !== parsed[PATCH];
|
|
30393
|
+
var isXPatch = (parsed) => void 0 !== parsed[MINOR] && void 0 === parsed[PATCH];
|
|
30394
|
+
var isXMinor = (parsed) => void 0 !== parsed[MAJOR] && void 0 === parsed[MINOR];
|
|
30395
|
+
var isXMajor = (parsed) => void 0 === parsed[MAJOR];
|
|
30396
|
+
var Comparator = class {
|
|
30397
|
+
/**
|
|
30398
|
+
* does this range include prereleases, even when they do not
|
|
30399
|
+
* match the tuple in the comparator?
|
|
30400
|
+
*/
|
|
30401
|
+
includePrerelease;
|
|
30402
|
+
/** raw string used to create this comparator */
|
|
30403
|
+
raw;
|
|
30404
|
+
/** tokens extracted from the raw string input */
|
|
30405
|
+
tokens;
|
|
30406
|
+
/**
|
|
30407
|
+
* Either the `any` comparator, the `none` comparator, or an operator
|
|
30408
|
+
* and a {@link ParsedXRange}
|
|
30409
|
+
*/
|
|
30410
|
+
tuples = [];
|
|
30411
|
+
/** true if this comparator can not match anything */
|
|
30412
|
+
isNone = false;
|
|
30413
|
+
/**
|
|
30414
|
+
* true if this comparator is a `'*'` type of range.
|
|
30415
|
+
*
|
|
30416
|
+
* Note that it still will not match versions with a prerelease value,
|
|
30417
|
+
* unless the tuple in the version matches the tuple provided to the
|
|
30418
|
+
* comparator, and the comparator version also has a prerelease value,
|
|
30419
|
+
* unless `includePrerelease` is set.
|
|
30420
|
+
*/
|
|
30421
|
+
isAny = false;
|
|
30422
|
+
/** the canonical strict simplified parsed form of this constructor */
|
|
30423
|
+
toString() {
|
|
30424
|
+
return this.isNone ? "<0.0.0-0" : this.isAny ? "*" : (
|
|
30425
|
+
/* c8 ignore next */
|
|
30426
|
+
this.tuples.map((c) => isAny(c) ? "*" : c.join("")).join(" ")
|
|
30427
|
+
);
|
|
30428
|
+
}
|
|
30429
|
+
constructor(comp, includePrerelease = false) {
|
|
30430
|
+
this.includePrerelease = includePrerelease;
|
|
30431
|
+
comp = comp.trim();
|
|
30432
|
+
this.raw = comp;
|
|
30433
|
+
let hyphen = false;
|
|
30434
|
+
const rawComps = fastSplit(comp, " ", -1, (part, parts, i2) => {
|
|
30435
|
+
if (part === "-") {
|
|
30436
|
+
if (hyphen) {
|
|
30437
|
+
throw invalidComp(
|
|
30438
|
+
comp,
|
|
30439
|
+
"multiple hyphen ranges not allowed"
|
|
30440
|
+
);
|
|
30441
|
+
}
|
|
30442
|
+
if (parts.length !== 1 || i2 === -1) {
|
|
30443
|
+
throw invalidComp(
|
|
30444
|
+
comp,
|
|
30445
|
+
"hyphen must be between two versions"
|
|
30446
|
+
);
|
|
30447
|
+
}
|
|
30448
|
+
hyphen = true;
|
|
30449
|
+
} else if (hyphen && parts.length !== 2) {
|
|
30450
|
+
throw invalidComp(comp, "hyphen range must be alone");
|
|
30451
|
+
}
|
|
30452
|
+
});
|
|
30453
|
+
const comps = [];
|
|
30454
|
+
let followingOperator = false;
|
|
30455
|
+
let l = 0;
|
|
30456
|
+
for (const c of rawComps) {
|
|
30457
|
+
if (c === "") continue;
|
|
30458
|
+
if (!followingOperator) {
|
|
30459
|
+
followingOperator = isOperator(c);
|
|
30460
|
+
comps.push(c);
|
|
30461
|
+
l++;
|
|
30462
|
+
continue;
|
|
30463
|
+
}
|
|
30464
|
+
comps[l - 1] += c;
|
|
30465
|
+
followingOperator = false;
|
|
30466
|
+
}
|
|
30467
|
+
if (hyphen) {
|
|
30468
|
+
const [min, _3, max] = comps;
|
|
30469
|
+
if (!min || !max) {
|
|
30470
|
+
throw invalidComp(comp, "hyphen must be between two versions");
|
|
30471
|
+
}
|
|
30472
|
+
this.#parseHyphenRange(min, max);
|
|
30473
|
+
} else if (!comps.length || comps.length === 1 && isX(comps[0])) {
|
|
30474
|
+
this.tuples.push(this.#getComparatorAny());
|
|
30475
|
+
} else {
|
|
30476
|
+
for (const c of comps) {
|
|
30477
|
+
this.#parse(c);
|
|
30478
|
+
if (this.isNone) break;
|
|
30479
|
+
}
|
|
30480
|
+
}
|
|
30481
|
+
this.tokens = comps;
|
|
30482
|
+
this.isAny = true;
|
|
30483
|
+
for (const c of this.tuples) {
|
|
30484
|
+
if (Array.isArray(c) || !c.isAny) {
|
|
30485
|
+
this.isAny = false;
|
|
30486
|
+
break;
|
|
30487
|
+
}
|
|
30488
|
+
}
|
|
30489
|
+
}
|
|
30490
|
+
// inclusive min
|
|
30491
|
+
#xInclusiveMin(raw) {
|
|
30492
|
+
const z = this.includePrerelease ? "0" : void 0;
|
|
30493
|
+
const [M3, m2 = 0, p = 0, pr = z, build] = this.#parseX(raw);
|
|
30494
|
+
return M3 === void 0 ? this.#getComparatorAny() : [">=", new Version(raw, M3, m2, p, pr, build)];
|
|
30495
|
+
}
|
|
30496
|
+
// exclusive min
|
|
30497
|
+
#xExclusiveMin(raw) {
|
|
30498
|
+
const parsed = this.#parseX(raw);
|
|
30499
|
+
if (isFullVersion(parsed)) {
|
|
30500
|
+
return [">", new Version(raw, ...parsed)];
|
|
30501
|
+
}
|
|
30502
|
+
const z = this.includePrerelease ? "0" : void 0;
|
|
30503
|
+
if (isXPatch(parsed)) {
|
|
30504
|
+
return [
|
|
30505
|
+
">=",
|
|
30506
|
+
new Version(
|
|
30507
|
+
raw,
|
|
30508
|
+
parsed[MAJOR],
|
|
30509
|
+
parsed[MINOR] + 1,
|
|
30510
|
+
0,
|
|
30511
|
+
z,
|
|
30512
|
+
void 0
|
|
30513
|
+
)
|
|
30514
|
+
];
|
|
30515
|
+
}
|
|
30516
|
+
if (isXMinor(parsed)) {
|
|
30517
|
+
return [
|
|
30518
|
+
">=",
|
|
30519
|
+
new Version(raw, parsed[MAJOR] + 1, 0, 0, z, void 0)
|
|
30520
|
+
];
|
|
30521
|
+
}
|
|
30522
|
+
this.isNone = true;
|
|
30523
|
+
this.tuples.length = 0;
|
|
30524
|
+
return comparatorNone;
|
|
30525
|
+
}
|
|
30526
|
+
#xInclusiveMax(raw) {
|
|
30527
|
+
const parsed = this.#parseX(raw);
|
|
30528
|
+
return isFullVersion(parsed) ? ["<=", new Version(raw, ...parsed)] : isXPatch(parsed) ? [
|
|
30529
|
+
"<",
|
|
30530
|
+
new Version(
|
|
30531
|
+
raw,
|
|
30532
|
+
parsed[MAJOR],
|
|
30533
|
+
parsed[MINOR] + 1,
|
|
30534
|
+
0,
|
|
30535
|
+
"0",
|
|
30536
|
+
void 0
|
|
30537
|
+
)
|
|
30538
|
+
] : isXMinor(parsed) ? [
|
|
30539
|
+
"<",
|
|
30540
|
+
new Version(raw, parsed[MAJOR] + 1, 0, 0, "0", void 0)
|
|
30541
|
+
] : this.#getComparatorAny();
|
|
30542
|
+
}
|
|
30543
|
+
#xExclusiveMax(raw) {
|
|
30544
|
+
const z = this.includePrerelease ? "0" : void 0;
|
|
30545
|
+
const [M3 = 0, m2 = 0, p = 0, pr = z, build] = this.#parseX(raw);
|
|
30546
|
+
if (M3 === 0 && m2 === 0 && p === 0 && pr === "0") {
|
|
30547
|
+
this.isNone = true;
|
|
30548
|
+
this.tuples.length = 0;
|
|
30549
|
+
return comparatorNone;
|
|
30550
|
+
}
|
|
30551
|
+
return ["<", new Version(raw, M3, m2, p, pr, build)];
|
|
30552
|
+
}
|
|
30553
|
+
#validXM(raw, m2, p) {
|
|
30554
|
+
assertMissing(m2, raw, "major");
|
|
30555
|
+
assertMissing(p, raw, "major");
|
|
30556
|
+
if (m2 === "" || p === "") {
|
|
30557
|
+
throw invalidComp(raw, `(Did you mean '*'?)`);
|
|
30558
|
+
}
|
|
30559
|
+
return [];
|
|
30560
|
+
}
|
|
30561
|
+
#validXm(raw, M3, m2, p) {
|
|
30562
|
+
assertMissing(p, raw, "major");
|
|
30563
|
+
if (m2 === "" || p === "") {
|
|
30564
|
+
throw invalidComp(raw, `(Did you mean '${M3}'?)`);
|
|
30565
|
+
}
|
|
30566
|
+
return [assertNumber(M3, raw, "major")];
|
|
30567
|
+
}
|
|
30568
|
+
#validXp(raw, M3, m2, p) {
|
|
30569
|
+
if (p === "") {
|
|
30570
|
+
throw invalidComp(raw, `(Did you mean '${M3}.${m2}'?)`);
|
|
30571
|
+
}
|
|
30572
|
+
return [
|
|
30573
|
+
assertNumber(M3, raw, "major"),
|
|
30574
|
+
assertNumber(m2, raw, "minor")
|
|
30575
|
+
];
|
|
30576
|
+
}
|
|
30577
|
+
#validTuple(raw, M3, m2, p) {
|
|
30578
|
+
return [
|
|
30579
|
+
assertNumber(M3, raw, "major"),
|
|
30580
|
+
assertNumber(m2, raw, "minor"),
|
|
30581
|
+
assertNumber(p, raw, "patch")
|
|
30582
|
+
];
|
|
30583
|
+
}
|
|
30584
|
+
#validXbuild(raw, M3, m2, p, pl) {
|
|
30585
|
+
const patch = p.substring(0, pl);
|
|
30586
|
+
const build = p.substring(pl + 1);
|
|
30587
|
+
if (!patch) {
|
|
30588
|
+
throw invalidComp(raw, "cannot specify build without patch");
|
|
30589
|
+
}
|
|
30590
|
+
if (!build) {
|
|
30591
|
+
throw invalidComp(raw, `encountered '+', but no build value`);
|
|
30592
|
+
}
|
|
30593
|
+
return [
|
|
30594
|
+
assertNumber(M3, raw, "major"),
|
|
30595
|
+
assertNumber(m2, raw, "minor"),
|
|
30596
|
+
assertNumber(patch, raw, "patch"),
|
|
30597
|
+
void 0,
|
|
30598
|
+
build
|
|
30599
|
+
];
|
|
30600
|
+
}
|
|
30601
|
+
#validXpr(raw, M3, m2, p, hy) {
|
|
30602
|
+
{
|
|
30603
|
+
const patch = p.substring(0, hy);
|
|
30604
|
+
const pr = p.substring(hy + 1);
|
|
30605
|
+
if (!patch) {
|
|
30606
|
+
throw invalidComp(
|
|
30607
|
+
raw,
|
|
30608
|
+
"cannot specify prerelease without patch"
|
|
30609
|
+
);
|
|
30610
|
+
}
|
|
30611
|
+
if (!pr) {
|
|
30612
|
+
throw invalidComp(
|
|
30613
|
+
raw,
|
|
30614
|
+
`encountered '-', but no prerelease value`
|
|
30615
|
+
);
|
|
30616
|
+
}
|
|
30617
|
+
return [
|
|
30618
|
+
assertNumber(M3, raw, "major"),
|
|
30619
|
+
assertNumber(m2, raw, "minor"),
|
|
30620
|
+
assertNumber(patch, raw, "patch"),
|
|
30621
|
+
pr,
|
|
30622
|
+
void 0
|
|
30623
|
+
];
|
|
30624
|
+
}
|
|
30625
|
+
}
|
|
30626
|
+
#validXprbuild(raw, M3, m2, p, hy, pl) {
|
|
30627
|
+
const patch = p.substring(0, hy);
|
|
30628
|
+
const pr = p.substring(hy + 1, pl);
|
|
30629
|
+
const build = p.substring(pl + 1);
|
|
30630
|
+
if (!patch) {
|
|
30631
|
+
throw invalidComp(
|
|
30632
|
+
raw,
|
|
30633
|
+
"cannot specify prerelease without patch"
|
|
30634
|
+
);
|
|
30635
|
+
}
|
|
30636
|
+
if (!pr) {
|
|
30637
|
+
throw invalidComp(
|
|
30638
|
+
raw,
|
|
30639
|
+
`encountered '-', but no prerelease value`
|
|
30640
|
+
);
|
|
30641
|
+
}
|
|
30642
|
+
if (!build) {
|
|
30643
|
+
throw invalidComp(raw, `encountered '+', but no build value`);
|
|
30644
|
+
}
|
|
30645
|
+
return [
|
|
30646
|
+
assertNumber(M3, raw, "major"),
|
|
30647
|
+
assertNumber(m2, raw, "minor"),
|
|
30648
|
+
assertNumber(patch, raw, "patch"),
|
|
30649
|
+
pr,
|
|
30650
|
+
build
|
|
30651
|
+
];
|
|
30652
|
+
}
|
|
30653
|
+
// pull the relevant values out of an X-range or version
|
|
30654
|
+
// return the fields for creating a Version object.
|
|
30655
|
+
// only call once operator is stripped off
|
|
30656
|
+
#parseX(raw) {
|
|
30657
|
+
let [M3, m2, p] = fastSplit(raw, ".", 3);
|
|
30658
|
+
let prune = 0;
|
|
30659
|
+
while (M3 && preJunk.has(M3.charAt(prune))) prune++;
|
|
30660
|
+
if (M3 !== void 0 && prune !== 0) M3 = M3.substring(prune);
|
|
30661
|
+
if (!M3 || isX(M3)) return this.#validXM(raw, m2, p);
|
|
30662
|
+
if (!m2 || isX(m2)) return this.#validXm(raw, M3, m2, p);
|
|
30663
|
+
if (!p || isX(p)) return this.#validXp(raw, M3, m2, p);
|
|
30664
|
+
const hy = p.indexOf("-");
|
|
30665
|
+
const pl = p.indexOf("+");
|
|
30666
|
+
if (pl === -1 && hy === -1) return this.#validTuple(raw, M3, m2, p);
|
|
30667
|
+
if (pl === -1) return this.#validXpr(raw, M3, m2, p, hy);
|
|
30668
|
+
if (hy === -1) return this.#validXbuild(raw, M3, m2, p, pl);
|
|
30669
|
+
return this.#validXprbuild(raw, M3, m2, p, hy, pl);
|
|
30670
|
+
}
|
|
30671
|
+
#parseHyphenRange(min, max) {
|
|
30672
|
+
const minv = this.#xInclusiveMin(min);
|
|
30673
|
+
const maxv = this.#xInclusiveMax(max);
|
|
30674
|
+
const minAny = isAny(minv);
|
|
30675
|
+
const maxAny = isAny(maxv);
|
|
30676
|
+
if (minAny && maxAny) this.tuples.push(this.#getComparatorAny());
|
|
30677
|
+
else if (minAny) this.tuples.push(maxv);
|
|
30678
|
+
else if (maxAny) this.tuples.push(minv);
|
|
30679
|
+
else this.tuples.push(minv, maxv);
|
|
30680
|
+
}
|
|
30681
|
+
#parse(comp) {
|
|
30682
|
+
const first = comp.charAt(0);
|
|
30683
|
+
const first2 = comp.substring(0, 2);
|
|
30684
|
+
const v1 = comp.substring(1);
|
|
30685
|
+
const v22 = comp.substring(2);
|
|
30686
|
+
switch (first2) {
|
|
30687
|
+
case "~>":
|
|
30688
|
+
assertVersion(v22, comp);
|
|
30689
|
+
return this.#parseTilde(v22);
|
|
30690
|
+
case ">=":
|
|
30691
|
+
assertVersion(v22, comp);
|
|
30692
|
+
return this.tuples.push(this.#xInclusiveMin(v22));
|
|
30693
|
+
case "<=":
|
|
30694
|
+
assertVersion(v22, comp);
|
|
30695
|
+
return this.tuples.push(this.#xInclusiveMax(v22));
|
|
30696
|
+
}
|
|
30697
|
+
switch (first) {
|
|
30698
|
+
case "~":
|
|
30699
|
+
assertVersion(v1, comp);
|
|
30700
|
+
return this.#parseTilde(v1);
|
|
30701
|
+
case "^":
|
|
30702
|
+
assertVersion(v1, comp);
|
|
30703
|
+
return this.#parseCaret(v1);
|
|
30704
|
+
case ">":
|
|
30705
|
+
assertVersion(v1, comp);
|
|
30706
|
+
return this.tuples.push(this.#xExclusiveMin(v1));
|
|
30707
|
+
case "<":
|
|
30708
|
+
assertVersion(v1, comp);
|
|
30709
|
+
return this.tuples.push(this.#xExclusiveMax(v1));
|
|
30710
|
+
}
|
|
30711
|
+
return this.#parseEq(comp);
|
|
30712
|
+
}
|
|
30713
|
+
#parseTilde(comp) {
|
|
30714
|
+
const parsed = this.#parseX(comp);
|
|
30715
|
+
if (isXMajor(parsed)) {
|
|
30716
|
+
this.tuples.push(this.#getComparatorAny());
|
|
30717
|
+
return;
|
|
30718
|
+
}
|
|
30719
|
+
const z = this.includePrerelease ? "0" : void 0;
|
|
30720
|
+
if (isXMinor(parsed)) {
|
|
30721
|
+
const [M4] = parsed;
|
|
30722
|
+
this.tuples.push(
|
|
30723
|
+
[">=", new Version(comp, M4, 0, 0, z, void 0)],
|
|
30724
|
+
["<", new Version(comp, M4 + 1, 0, 0, "0", void 0)]
|
|
30725
|
+
);
|
|
30726
|
+
return;
|
|
30727
|
+
}
|
|
30728
|
+
if (isXPatch(parsed)) {
|
|
30729
|
+
const [M4, m3] = parsed;
|
|
30730
|
+
const z2 = this.includePrerelease ? "0" : void 0;
|
|
30731
|
+
this.tuples.push(
|
|
30732
|
+
[">=", new Version(comp, M4, m3, 0, z2, void 0)],
|
|
30733
|
+
["<", new Version(comp, M4, m3 + 1, 0, "0", void 0)]
|
|
30734
|
+
);
|
|
30735
|
+
return;
|
|
30736
|
+
}
|
|
30737
|
+
const [M3, m2, p, pr = z, build] = parsed;
|
|
30738
|
+
this.tuples.push(
|
|
30739
|
+
[">=", new Version(comp, M3, m2, p, pr, build)],
|
|
30740
|
+
["<", new Version(comp, M3, m2 + 1, 0, "0", build)]
|
|
30741
|
+
);
|
|
30742
|
+
}
|
|
30743
|
+
#parseCaret(comp) {
|
|
30744
|
+
const min = this.#xInclusiveMin(comp);
|
|
30745
|
+
if (isAny(min)) {
|
|
30746
|
+
this.tuples.push(min);
|
|
30747
|
+
return;
|
|
30748
|
+
}
|
|
30749
|
+
const minv = min[1];
|
|
30750
|
+
if (minv.major !== 0) {
|
|
30751
|
+
this.tuples.push(min, [
|
|
30752
|
+
"<",
|
|
30753
|
+
new Version(comp, minv.major + 1, 0, 0, "0", void 0)
|
|
30754
|
+
]);
|
|
30755
|
+
} else if (minv.minor !== 0) {
|
|
30756
|
+
this.tuples.push(min, [
|
|
30757
|
+
"<",
|
|
30758
|
+
new Version(
|
|
30759
|
+
comp,
|
|
30760
|
+
minv.major,
|
|
30761
|
+
minv.minor + 1,
|
|
30762
|
+
0,
|
|
30763
|
+
"0",
|
|
30764
|
+
void 0
|
|
30765
|
+
)
|
|
30766
|
+
]);
|
|
30767
|
+
} else if (!minv.prerelease?.length) {
|
|
30768
|
+
this.tuples.push(["", minv]);
|
|
30769
|
+
} else {
|
|
30770
|
+
this.tuples.push(min, [
|
|
30771
|
+
"<",
|
|
30772
|
+
new Version(
|
|
30773
|
+
comp,
|
|
30774
|
+
minv.major,
|
|
30775
|
+
minv.minor,
|
|
30776
|
+
minv.patch + 1,
|
|
30777
|
+
"0",
|
|
30778
|
+
void 0
|
|
30779
|
+
)
|
|
30780
|
+
]);
|
|
30781
|
+
}
|
|
30782
|
+
}
|
|
30783
|
+
#parseEq(comp) {
|
|
30784
|
+
const parsed = this.#parseX(comp);
|
|
30785
|
+
const z = this.includePrerelease ? "0" : void 0;
|
|
30786
|
+
if (isFullVersion(parsed)) {
|
|
30787
|
+
this.tuples.push(["", new Version(comp, ...parsed)]);
|
|
30788
|
+
} else if (isXMajor(parsed)) {
|
|
30789
|
+
this.tuples.push(this.#getComparatorAny());
|
|
30790
|
+
} else if (isXMinor(parsed)) {
|
|
30791
|
+
this.tuples.push([
|
|
30792
|
+
">=",
|
|
30793
|
+
new Version(comp, parsed[MAJOR], 0, 0, z, void 0)
|
|
30794
|
+
]);
|
|
30795
|
+
this.tuples.push([
|
|
30796
|
+
"<",
|
|
30797
|
+
new Version(comp, parsed[MAJOR] + 1, 0, 0, "0", void 0)
|
|
30798
|
+
]);
|
|
30799
|
+
} else if (isXPatch(parsed)) {
|
|
30800
|
+
this.tuples.push(
|
|
30801
|
+
[
|
|
30802
|
+
">=",
|
|
30803
|
+
new Version(
|
|
30804
|
+
comp,
|
|
30805
|
+
parsed[MAJOR],
|
|
30806
|
+
parsed[MINOR],
|
|
30807
|
+
0,
|
|
30808
|
+
z,
|
|
30809
|
+
void 0
|
|
30810
|
+
)
|
|
30811
|
+
],
|
|
30812
|
+
[
|
|
30813
|
+
"<",
|
|
30814
|
+
new Version(
|
|
30815
|
+
comp,
|
|
30816
|
+
parsed[MAJOR],
|
|
30817
|
+
parsed[MINOR] + 1,
|
|
30818
|
+
0,
|
|
30819
|
+
"0",
|
|
30820
|
+
void 0
|
|
30821
|
+
)
|
|
30822
|
+
]
|
|
30823
|
+
);
|
|
30824
|
+
}
|
|
30825
|
+
}
|
|
30826
|
+
/** return true if the version is a match for this comparator */
|
|
30827
|
+
test(v3) {
|
|
30828
|
+
if (this.isNone) return false;
|
|
30829
|
+
const ip = this.includePrerelease;
|
|
30830
|
+
const hasPR = !!v3.prerelease?.length;
|
|
30831
|
+
let prOK = ip || !hasPR;
|
|
30832
|
+
for (const c of this.tuples) {
|
|
30833
|
+
if (isAny(c)) {
|
|
30834
|
+
continue;
|
|
30835
|
+
}
|
|
30836
|
+
const [op, cv] = c;
|
|
30837
|
+
prOK ||= !!cv.prerelease?.length && v3.tupleEquals(cv);
|
|
30838
|
+
switch (op) {
|
|
30839
|
+
case "":
|
|
30840
|
+
if (!v3.equals(cv)) return false;
|
|
30841
|
+
continue;
|
|
30842
|
+
case ">":
|
|
30843
|
+
if (!v3.greaterThan(cv)) return false;
|
|
30844
|
+
continue;
|
|
30845
|
+
case ">=":
|
|
30846
|
+
if (!v3.greaterThanEqual(cv)) return false;
|
|
30847
|
+
continue;
|
|
30848
|
+
case "<":
|
|
30849
|
+
if (!v3.lessThan(cv)) return false;
|
|
30850
|
+
continue;
|
|
30851
|
+
case "<=":
|
|
30852
|
+
if (!v3.lessThanEqual(cv)) return false;
|
|
30853
|
+
continue;
|
|
30854
|
+
}
|
|
30855
|
+
}
|
|
30856
|
+
return prOK;
|
|
30857
|
+
}
|
|
30858
|
+
#getComparatorAny() {
|
|
30859
|
+
return this.includePrerelease ? comparatorAnyPR : comparatorAny;
|
|
30860
|
+
}
|
|
30861
|
+
};
|
|
30862
|
+
var isAny = (c) => c === comparatorAny || c === comparatorAnyPR;
|
|
30863
|
+
var comparatorAny = {
|
|
30864
|
+
isAny: true,
|
|
30865
|
+
toString: () => "*",
|
|
30866
|
+
includePrerelease: false,
|
|
30867
|
+
test: (v3) => !v3.prerelease?.length
|
|
30868
|
+
};
|
|
30869
|
+
var comparatorAnyPR = {
|
|
30870
|
+
isAny: true,
|
|
30871
|
+
toString: () => "*",
|
|
30872
|
+
includePrerelease: true,
|
|
30873
|
+
test: (_3) => true
|
|
30874
|
+
};
|
|
30875
|
+
var comparatorNone = {
|
|
30876
|
+
isNone: true,
|
|
30877
|
+
toString: () => "<0.0.0-0",
|
|
30878
|
+
includePrerelease: false,
|
|
30879
|
+
test: (_3) => false
|
|
30880
|
+
};
|
|
30881
|
+
|
|
30882
|
+
// ../../src/semver/src/range.ts
|
|
30883
|
+
var Range = class {
|
|
30884
|
+
/** raw string used to create this Range */
|
|
30885
|
+
raw;
|
|
30886
|
+
/** true if the range is `*` */
|
|
30887
|
+
isAny;
|
|
30888
|
+
/** true if the range is a single semver version */
|
|
30889
|
+
isSingle;
|
|
30890
|
+
/** true if the range cannot match anything */
|
|
30891
|
+
/**
|
|
30892
|
+
* set of {@link Comparator} objects representing the `||`-separated sections
|
|
30893
|
+
* of the range. If at least one of these matches, then the version is a
|
|
30894
|
+
* match.
|
|
30895
|
+
*/
|
|
30896
|
+
set = [];
|
|
30897
|
+
/** true if all prerelease versions should be included */
|
|
30898
|
+
includePrerelease;
|
|
30899
|
+
/** cached toString */
|
|
30900
|
+
#toString;
|
|
30901
|
+
constructor(range, includePrerelease = false) {
|
|
30902
|
+
this.raw = range;
|
|
30903
|
+
this.includePrerelease = includePrerelease;
|
|
30904
|
+
this.isAny = false;
|
|
30905
|
+
let isFirst = true;
|
|
30906
|
+
this.isSingle = false;
|
|
30907
|
+
const comparatorErrors = [];
|
|
30908
|
+
fastSplit(range, "||", -1, (part) => {
|
|
30909
|
+
if (this.isAny) return;
|
|
30910
|
+
const cmp = this.#maybeComparator(part, this.includePrerelease);
|
|
30911
|
+
if (cmp instanceof Error) {
|
|
30912
|
+
comparatorErrors.push(cmp);
|
|
30913
|
+
return;
|
|
30914
|
+
}
|
|
30915
|
+
if (cmp.isAny) {
|
|
30916
|
+
this.set = [cmp];
|
|
30917
|
+
this.isAny = true;
|
|
30918
|
+
return;
|
|
30919
|
+
}
|
|
30920
|
+
this.set.push(cmp);
|
|
30921
|
+
if (!isFirst) this.isSingle = false;
|
|
30922
|
+
else if (Array.isArray(cmp.tuples) && cmp.tuples.length === 1 && Array.isArray(cmp.tuples[0]) && cmp.tuples[0][0] === "") {
|
|
30923
|
+
this.isSingle = true;
|
|
30924
|
+
}
|
|
30925
|
+
isFirst = false;
|
|
30926
|
+
});
|
|
30927
|
+
if (!this.set.length && comparatorErrors.length) {
|
|
30928
|
+
if (comparatorErrors.length === 1 && comparatorErrors[0]) {
|
|
30929
|
+
throw comparatorErrors[0];
|
|
30930
|
+
}
|
|
30931
|
+
throw new AggregateError(comparatorErrors);
|
|
30932
|
+
}
|
|
30933
|
+
}
|
|
30934
|
+
#maybeComparator(part, includePrerelease) {
|
|
30935
|
+
try {
|
|
30936
|
+
return new Comparator(part, includePrerelease);
|
|
30937
|
+
} catch (er) {
|
|
30938
|
+
return asError(er);
|
|
30939
|
+
}
|
|
30940
|
+
}
|
|
30941
|
+
/**
|
|
30942
|
+
* test a {@link Version} against the range
|
|
30943
|
+
*/
|
|
30944
|
+
test(v3) {
|
|
30945
|
+
return this.set.some((c) => c.test(v3));
|
|
30946
|
+
}
|
|
30947
|
+
/** return the simplified canonical form of this range */
|
|
30948
|
+
toString() {
|
|
30949
|
+
if (this.#toString) return this.#toString;
|
|
30950
|
+
if (this.isSingle) {
|
|
30951
|
+
this.#toString = String(this.set[0]);
|
|
30952
|
+
return this.#toString;
|
|
30953
|
+
}
|
|
30954
|
+
this.#toString = this.set.map((c) => String(c)).join(" || ");
|
|
30955
|
+
return this.#toString;
|
|
30956
|
+
}
|
|
30957
|
+
};
|
|
30958
|
+
|
|
30959
|
+
// ../../src/semver/src/index.ts
|
|
30960
|
+
var parseRange = (range, includePrerelease = false) => {
|
|
30961
|
+
if (typeof range === "object") {
|
|
30962
|
+
if (range.includePrerelease === includePrerelease) return range;
|
|
30963
|
+
range = range.raw;
|
|
30964
|
+
}
|
|
30965
|
+
try {
|
|
30966
|
+
return new Range(range, includePrerelease);
|
|
30967
|
+
} catch {
|
|
30968
|
+
return void 0;
|
|
30969
|
+
}
|
|
30970
|
+
};
|
|
30971
|
+
|
|
30972
|
+
// ../../src/spec/src/valid-name.ts
|
|
30973
|
+
var pathSafeName = /^(?!(?:node_modules|\.vlt)$)(?![A-Za-z]:)(?:@(?!\.\.?\/)[^/\\\x00-\x1f\x7f]+\/)?(?!\.\.?$)[^/\\\x00-\x1f\x7f]+$/i;
|
|
30974
|
+
var isPathSafeName = (name) => typeof name === "string" && pathSafeName.test(name);
|
|
30975
|
+
var assertPathSafeName = (name, from) => {
|
|
30976
|
+
if (isPathSafeName(name)) return;
|
|
30977
|
+
throw error(
|
|
30978
|
+
"Invalid package name: not usable as a path segment",
|
|
30979
|
+
{
|
|
30980
|
+
code: "EINVALIDNAME",
|
|
30981
|
+
found: name,
|
|
30982
|
+
from,
|
|
30983
|
+
wanted: "a single path segment, or a well-formed @scope/name"
|
|
30984
|
+
},
|
|
30985
|
+
assertPathSafeName
|
|
30986
|
+
);
|
|
30987
|
+
};
|
|
30988
|
+
|
|
30989
|
+
// ../../src/spec/src/browser.ts
|
|
30990
|
+
var kCustomInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
30991
|
+
var defaultRegistryName = "npm";
|
|
30992
|
+
var defaultRegistries = {
|
|
30993
|
+
gh: "https://npm.pkg.github.com/"
|
|
30994
|
+
};
|
|
30995
|
+
var defaultJsrRegistries = { jsr: "https://npm.jsr.io/" };
|
|
30996
|
+
var defaultGitHosts = {
|
|
30997
|
+
github: "git+ssh://git@github.com:$1/$2.git",
|
|
30998
|
+
bitbucket: "git+ssh://git@bitbucket.org:$1/$2.git",
|
|
30999
|
+
gitlab: "git+ssh://git@gitlab.com:$1/$2.git",
|
|
31000
|
+
gist: "git+ssh://git@gist.github.com/$1.git"
|
|
31001
|
+
};
|
|
31002
|
+
var defaultGitHostArchives = {
|
|
31003
|
+
github: "https://api.github.com/repos/$1/$2/tarball/$committish",
|
|
31004
|
+
bitbucket: "https://bitbucket.org/$1/$2/get/$committish.tar.gz",
|
|
31005
|
+
gist: "https://codeload.github.com/gist/$1/tar.gz/$committish",
|
|
31006
|
+
gitlab: "https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish"
|
|
31007
|
+
};
|
|
31008
|
+
var gitHostWebsites = {
|
|
31009
|
+
github: "https://github.com/",
|
|
31010
|
+
bitbucket: "https://bitbucket.org/",
|
|
31011
|
+
gist: "https://gist.github.com/",
|
|
31012
|
+
gitlab: "https://gitlab.com/"
|
|
31013
|
+
};
|
|
31014
|
+
var getOptions = (options) => ({
|
|
31015
|
+
catalog: {},
|
|
31016
|
+
catalogs: {},
|
|
31017
|
+
...options,
|
|
31018
|
+
// built-in aliases are user/service-overridable: user config wins
|
|
31019
|
+
"jsr-registries": {
|
|
31020
|
+
...defaultJsrRegistries,
|
|
31021
|
+
...options?.["jsr-registries"] ?? {}
|
|
31022
|
+
},
|
|
31023
|
+
registry: options?.registry,
|
|
31024
|
+
"default-registry-alias": options?.["default-registry-alias"] ?? defaultRegistryName,
|
|
31025
|
+
"scoped-registries": options?.["scoped-registries"] ?? {},
|
|
31026
|
+
"git-hosts": options?.["git-hosts"] ? {
|
|
31027
|
+
...defaultGitHosts,
|
|
31028
|
+
...options["git-hosts"]
|
|
31029
|
+
} : defaultGitHosts,
|
|
31030
|
+
registries: {
|
|
31031
|
+
...defaultRegistries,
|
|
31032
|
+
...options?.registries ?? {}
|
|
31033
|
+
},
|
|
31034
|
+
"git-host-archives": options?.["git-host-archives"] ? {
|
|
31035
|
+
...defaultGitHostArchives,
|
|
31036
|
+
...options["git-host-archives"]
|
|
31037
|
+
} : defaultGitHostArchives
|
|
31038
|
+
});
|
|
31039
|
+
var startsWithSpecIdentifier = (spec, options) => spec.startsWith("/") || spec.startsWith("./") || spec.startsWith("../") || spec.startsWith("file:") || spec.startsWith("http:") || spec.startsWith("https:") || spec.startsWith("workspace:") || spec.startsWith("catalog:") || 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:") || spec.startsWith("npm:") || spec.startsWith("jsr:") || spec.startsWith("gh:") || // anything that starts with a known git host key, or a
|
|
31040
|
+
// custom registered registry protocol e.g: `github:`, `custom:`
|
|
31041
|
+
[
|
|
31042
|
+
...Object.keys(options["git-hosts"]),
|
|
31043
|
+
...Object.keys(options.registries),
|
|
31044
|
+
...Object.keys(options["jsr-registries"])
|
|
31045
|
+
].some((key) => spec.startsWith(`${key}:`));
|
|
31046
|
+
var findFirstAt = (spec, hasScope) => spec.indexOf("@", hasScope ? 1 : 0);
|
|
31047
|
+
var findGitIdentifier = (spec) => spec.indexOf("#") > 2;
|
|
31048
|
+
var findFileIdentifier = (spec) => spec.includes("/");
|
|
31049
|
+
var Spec = class _Spec {
|
|
31050
|
+
static parse(spec, bareOrOptions, options) {
|
|
31051
|
+
return typeof spec === "object" ? spec : new this(spec, bareOrOptions, options);
|
|
31052
|
+
}
|
|
31053
|
+
static parseArgs(specOrBareSpec, opts) {
|
|
31054
|
+
const options = getOptions(opts ?? {});
|
|
31055
|
+
if (startsWithSpecIdentifier(specOrBareSpec, options)) {
|
|
31056
|
+
const parsed = this.parse("(unknown)", specOrBareSpec, options);
|
|
31057
|
+
if (parsed.subspec) {
|
|
31058
|
+
const { namedJsrRegistry: jsrHost } = parsed;
|
|
31059
|
+
if (!jsrHost) {
|
|
31060
|
+
parsed.name = parsed.subspec.name;
|
|
31061
|
+
}
|
|
31062
|
+
parsed.spec = `${parsed.name}@${parsed.bareSpec}`;
|
|
31063
|
+
assertPathSafeName(parsed.name, parsed.spec);
|
|
31064
|
+
}
|
|
31065
|
+
return parsed;
|
|
31066
|
+
} else {
|
|
31067
|
+
const hasScope = specOrBareSpec.startsWith("@");
|
|
31068
|
+
const at2 = findFirstAt(specOrBareSpec, hasScope);
|
|
31069
|
+
if (at2 > -1) {
|
|
31070
|
+
return this.parse(
|
|
31071
|
+
specOrBareSpec.substring(0, at2),
|
|
31072
|
+
specOrBareSpec.substring(at2 + 1),
|
|
31073
|
+
options
|
|
31074
|
+
);
|
|
31075
|
+
} else if (findGitIdentifier(specOrBareSpec) || !hasScope && findFileIdentifier(specOrBareSpec)) {
|
|
31076
|
+
return this.parse("(unknown)", specOrBareSpec, options);
|
|
31077
|
+
} else {
|
|
31078
|
+
return this.parse(`${specOrBareSpec}@`, options);
|
|
31079
|
+
}
|
|
31080
|
+
}
|
|
31081
|
+
}
|
|
31082
|
+
static nodejsDependencies;
|
|
31083
|
+
type;
|
|
31084
|
+
spec;
|
|
31085
|
+
options;
|
|
31086
|
+
name;
|
|
31087
|
+
scope;
|
|
31088
|
+
scopeRegistry;
|
|
31089
|
+
bareSpec;
|
|
31090
|
+
gitRemote;
|
|
31091
|
+
gitSelector;
|
|
31092
|
+
gitSelectorParsed;
|
|
31093
|
+
gitCommittish;
|
|
31094
|
+
namedGitHost;
|
|
31095
|
+
namedGitHostPath;
|
|
31096
|
+
workspaceSpec;
|
|
31097
|
+
workspace;
|
|
31098
|
+
namedRegistry;
|
|
31099
|
+
namedJsrRegistry;
|
|
31100
|
+
registry;
|
|
31101
|
+
registrySpec;
|
|
31102
|
+
conventionalRegistryTarball;
|
|
31103
|
+
semver;
|
|
31104
|
+
range;
|
|
31105
|
+
distTag;
|
|
31106
|
+
remoteURL;
|
|
31107
|
+
file;
|
|
31108
|
+
catalog;
|
|
31109
|
+
subspec;
|
|
31110
|
+
overridden = false;
|
|
31111
|
+
#final;
|
|
31112
|
+
#toString;
|
|
31113
|
+
/**
|
|
31114
|
+
* Return the final entry in the chain of subspecs
|
|
31115
|
+
* When deciding which thing to actually fetch, spec.final is the thing
|
|
31116
|
+
* to look at.
|
|
31117
|
+
*/
|
|
31118
|
+
get final() {
|
|
31119
|
+
if (this.#final) return this.#final;
|
|
31120
|
+
const final = this.subspec ? this.subspec.final : this;
|
|
31121
|
+
if (final.type === "catalog") {
|
|
31122
|
+
throw error('invalid Spec.final value, type is "catalog"');
|
|
31123
|
+
}
|
|
31124
|
+
return this.#final = final;
|
|
31125
|
+
}
|
|
31126
|
+
/**
|
|
31127
|
+
* Normally, the string value of a Spec is just the string passed in to
|
|
31128
|
+
* be parsed. However, in the case of a chain of subspecs, like
|
|
31129
|
+
* `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
|
|
31130
|
+
* parts of the chain, returning just `foo@npm:quux@latest`
|
|
31131
|
+
*/
|
|
31132
|
+
toString() {
|
|
31133
|
+
if (this.#toString !== void 0) return this.#toString;
|
|
31134
|
+
let sub = this;
|
|
31135
|
+
while (sub.subspec?.subspec) sub = sub.subspec;
|
|
31136
|
+
if (sub.subspec && sub.subspec.type !== "registry")
|
|
31137
|
+
sub = sub.subspec;
|
|
31138
|
+
return this.#toString = this.name + "@" + sub.bareSpec;
|
|
31139
|
+
}
|
|
31140
|
+
constructor(spec, bareOrOptions, options = {}) {
|
|
31141
|
+
if (bareOrOptions && typeof bareOrOptions === "object") {
|
|
31142
|
+
options = bareOrOptions;
|
|
31143
|
+
bareOrOptions = void 0;
|
|
31144
|
+
}
|
|
31145
|
+
this.options = getOptions(options);
|
|
31146
|
+
if (typeof bareOrOptions === "string") {
|
|
31147
|
+
this.name = spec;
|
|
31148
|
+
this.#parseScope(spec);
|
|
31149
|
+
this.bareSpec = bareOrOptions;
|
|
31150
|
+
this.spec = `${this.name}@${bareOrOptions}`;
|
|
31151
|
+
assertPathSafeName(this.name, this.spec);
|
|
31152
|
+
} else {
|
|
31153
|
+
this.spec = spec;
|
|
31154
|
+
if (!spec.startsWith("git@") && startsWithSpecIdentifier(spec, this.options) && spec.includes(":") && [
|
|
31155
|
+
...Object.keys(this.options.registries),
|
|
31156
|
+
...Object.keys(defaultRegistries)
|
|
31157
|
+
].some((key) => spec.startsWith(`${key}:`))) {
|
|
31158
|
+
this.name = spec;
|
|
31159
|
+
this.bareSpec = spec;
|
|
31160
|
+
} else {
|
|
31161
|
+
const hasScope = spec.startsWith("@");
|
|
31162
|
+
let at2 = findFirstAt(spec, hasScope);
|
|
31163
|
+
if (at2 === -1) {
|
|
31164
|
+
at2 = spec.length;
|
|
31165
|
+
spec += "@";
|
|
31166
|
+
}
|
|
31167
|
+
this.name = spec.substring(0, at2);
|
|
31168
|
+
assertPathSafeName(this.name, spec);
|
|
31169
|
+
if (hasScope) this.#parseScope(this.name);
|
|
31170
|
+
this.bareSpec = spec.substring(at2 + 1);
|
|
31171
|
+
}
|
|
31172
|
+
}
|
|
31173
|
+
if (this.bareSpec.startsWith("catalog:")) {
|
|
31174
|
+
this.catalog = this.bareSpec.substring("catalog:".length);
|
|
31175
|
+
const catalog = this.catalog ? this.options.catalogs?.[this.catalog] : this.options.catalog;
|
|
31176
|
+
if (!catalog) {
|
|
31177
|
+
throw this.#error("Named catalog not found", {
|
|
31178
|
+
name: this.catalog,
|
|
31179
|
+
validOptions: this.options.catalogs && Object.keys(this.options.catalogs)
|
|
31180
|
+
});
|
|
31181
|
+
}
|
|
31182
|
+
const sub = catalog[this.name];
|
|
31183
|
+
if (!sub) {
|
|
31184
|
+
throw this.#error("Name not found in catalog", {
|
|
31185
|
+
name: this.name,
|
|
31186
|
+
validOptions: Object.keys(catalog)
|
|
31187
|
+
});
|
|
31188
|
+
}
|
|
31189
|
+
this.subspec = _Spec.parse(this.name, sub, this.options);
|
|
31190
|
+
this.type = "catalog";
|
|
31191
|
+
this.registry = this.subspec.final.registry;
|
|
31192
|
+
return;
|
|
31193
|
+
}
|
|
31194
|
+
if (this.bareSpec.startsWith("https://")) {
|
|
31195
|
+
for (const [name, origin] of Object.entries(gitHostWebsites)) {
|
|
31196
|
+
if (this.bareSpec.startsWith(origin)) {
|
|
31197
|
+
const parsed = new URL(this.bareSpec);
|
|
31198
|
+
const [user, project] = parsed.pathname.replace(/\.git$/, "").replace(/\/+/g, " ").trim().split(" ");
|
|
31199
|
+
if (user && project) {
|
|
31200
|
+
this.bareSpec = `${name}:${user}/${project}${parsed.hash}`;
|
|
31201
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
31202
|
+
break;
|
|
31203
|
+
}
|
|
31204
|
+
}
|
|
31205
|
+
}
|
|
31206
|
+
}
|
|
31207
|
+
if (this.bareSpec.startsWith("workspace:")) {
|
|
31208
|
+
this.type = "workspace";
|
|
31209
|
+
const ws2 = this.bareSpec.substring("workspace:".length).trim();
|
|
31210
|
+
const w2 = ws2.lastIndexOf("@");
|
|
31211
|
+
if (w2 === -1) {
|
|
31212
|
+
this.workspace = this.name;
|
|
31213
|
+
} else {
|
|
31214
|
+
const wsName = ws2.substring(0, w2);
|
|
31215
|
+
if (!wsName || wsName === "*" || wsName === "~" || wsName === "^" || (wsName.startsWith("@") ? wsName.split("/").length !== 2 || wsName.substring(1).includes("@") : wsName.includes("@"))) {
|
|
31216
|
+
throw this.#error(
|
|
31217
|
+
"workspace: name must be a path or valid package name",
|
|
31218
|
+
{ found: wsName }
|
|
31219
|
+
);
|
|
31220
|
+
}
|
|
31221
|
+
this.workspace = wsName;
|
|
31222
|
+
}
|
|
31223
|
+
const wss = w2 === -1 ? ws2 : ws2.substring(w2 + 1) || "*";
|
|
31224
|
+
const range2 = wss === "*" ? void 0 : parseRange(wss);
|
|
31225
|
+
if (wss !== "*" && wss !== "~" && wss !== "^" && !range2) {
|
|
31226
|
+
throw this.#error(
|
|
31227
|
+
"workspace: spec must be one of *, ~, or ^, or a valid semver range",
|
|
31228
|
+
{
|
|
31229
|
+
found: wss,
|
|
31230
|
+
wanted: `'*'|'~'|'^'|SemverRange`
|
|
31231
|
+
}
|
|
31232
|
+
);
|
|
31233
|
+
}
|
|
31234
|
+
this.workspaceSpec = wss;
|
|
31235
|
+
if (range2) {
|
|
31236
|
+
this.semver = wss;
|
|
31237
|
+
this.range = range2;
|
|
31238
|
+
}
|
|
31239
|
+
return;
|
|
31240
|
+
}
|
|
31241
|
+
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
|
|
31242
|
+
this.bareSpec.startsWith("git@github.com")) {
|
|
31243
|
+
if (this.bareSpec.startsWith("git@")) {
|
|
31244
|
+
this.bareSpec = `git+ssh://${this.bareSpec}`;
|
|
31245
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
31246
|
+
}
|
|
31247
|
+
this.type = "git";
|
|
31248
|
+
for (const [name, host] of Object.entries(
|
|
31249
|
+
this.options["git-hosts"]
|
|
31250
|
+
)) {
|
|
31251
|
+
const s = host.indexOf("$");
|
|
31252
|
+
if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {
|
|
31253
|
+
const p = this.bareSpec.substring(s).replace(/\.git(#.*)?$/, "$1");
|
|
31254
|
+
this.bareSpec = `${name}:${p}`;
|
|
31255
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
31256
|
+
this.#parseHostedGit(name, host);
|
|
31257
|
+
this.type = "git";
|
|
31258
|
+
return;
|
|
31259
|
+
}
|
|
31260
|
+
}
|
|
31261
|
+
this.#parseGitSelector(this.bareSpec);
|
|
31262
|
+
return;
|
|
31263
|
+
}
|
|
31264
|
+
const regs = Object.entries(this.options.registries);
|
|
31265
|
+
if (this.bareSpec.startsWith("registry:")) {
|
|
31266
|
+
const reg = this.bareSpec.substring("registry:".length);
|
|
31267
|
+
const h = reg.indexOf("#");
|
|
31268
|
+
if (h === -1) {
|
|
31269
|
+
throw this.#error("registry: must include name/version");
|
|
31270
|
+
}
|
|
31271
|
+
this.type = "registry";
|
|
31272
|
+
let url = reg.substring(0, h);
|
|
31273
|
+
if (!url.endsWith("/")) url += "/";
|
|
31274
|
+
const regSpec = reg.substring(h + 1);
|
|
31275
|
+
for (let [name, u2] of regs) {
|
|
31276
|
+
if (!u2.endsWith("/")) {
|
|
31277
|
+
u2 += "/";
|
|
31278
|
+
this.options.registries[name] = u2;
|
|
31279
|
+
}
|
|
31280
|
+
if (u2 === url) this.namedRegistry = name;
|
|
31281
|
+
}
|
|
31282
|
+
this.#parseRegistrySpec(regSpec, url);
|
|
31283
|
+
this.#guessRegistryTarball();
|
|
31284
|
+
return;
|
|
31285
|
+
}
|
|
31286
|
+
for (const [host, url] of regs) {
|
|
31287
|
+
const h = `${host}:`;
|
|
31288
|
+
if (this.bareSpec.startsWith(h)) {
|
|
31289
|
+
this.type = "registry";
|
|
31290
|
+
this.namedRegistry = host;
|
|
31291
|
+
this.#parseRegistrySpec(
|
|
31292
|
+
this.bareSpec.substring(h.length),
|
|
31293
|
+
url
|
|
31294
|
+
).namedRegistry ??= host;
|
|
31295
|
+
if (this.subspec && this.name === this.bareSpec) {
|
|
31296
|
+
this.name = this.subspec.name;
|
|
31297
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
31298
|
+
assertPathSafeName(this.name, this.spec);
|
|
31299
|
+
}
|
|
31300
|
+
this.#guessRegistryTarball();
|
|
31301
|
+
return;
|
|
31302
|
+
}
|
|
31303
|
+
}
|
|
31304
|
+
const ghosts = Object.entries(this.options["git-hosts"]);
|
|
31305
|
+
for (const [name, template] of ghosts) {
|
|
31306
|
+
if (this.#parseHostedGit(name, template)) {
|
|
31307
|
+
this.type = "git";
|
|
31308
|
+
return;
|
|
31309
|
+
}
|
|
31310
|
+
}
|
|
31311
|
+
const jsrs = Object.entries(this.options["jsr-registries"]);
|
|
31312
|
+
for (const [host, url] of jsrs) {
|
|
31313
|
+
const h = `${host}:`;
|
|
31314
|
+
if (this.bareSpec.startsWith(h)) {
|
|
31315
|
+
this.type = "registry";
|
|
31316
|
+
this.namedJsrRegistry = host;
|
|
31317
|
+
this.#parseJsrRegistrySpec(
|
|
31318
|
+
this.bareSpec.substring(h.length),
|
|
31319
|
+
url
|
|
31320
|
+
).namedJsrRegistry ??= host;
|
|
31321
|
+
return;
|
|
31322
|
+
}
|
|
31323
|
+
}
|
|
31324
|
+
if (this.bareSpec.startsWith("https://") || this.bareSpec.startsWith("http://")) {
|
|
31325
|
+
this.remoteURL = this.bareSpec;
|
|
31326
|
+
this.type = "remote";
|
|
31327
|
+
return;
|
|
31328
|
+
}
|
|
31329
|
+
if (this.bareSpec.startsWith("file:")) {
|
|
31330
|
+
this.type = "file";
|
|
31331
|
+
const [path2, uri] = getNormalizeFile(
|
|
31332
|
+
this.constructor.nodejsDependencies
|
|
31333
|
+
)(this.bareSpec, this);
|
|
31334
|
+
this.file = path2;
|
|
31335
|
+
this.bareSpec = uri.replace(/\/+$/, "");
|
|
31336
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
31337
|
+
return;
|
|
31338
|
+
}
|
|
31339
|
+
if (!this.bareSpec.startsWith("./") && !this.bareSpec.startsWith("../") && this.options["git-hosts"].github) {
|
|
31340
|
+
const hash2 = this.bareSpec.indexOf("#");
|
|
31341
|
+
const up = hash2 === -1 ? this.bareSpec : this.bareSpec.substring(0, hash2);
|
|
31342
|
+
if (up.split("/").length === 2) {
|
|
31343
|
+
this.bareSpec = `github:${this.bareSpec}`;
|
|
31344
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
31345
|
+
this.#parseHostedGit(
|
|
31346
|
+
"github",
|
|
31347
|
+
this.options["git-hosts"].github
|
|
31348
|
+
);
|
|
31349
|
+
this.type = "git";
|
|
31350
|
+
return;
|
|
31351
|
+
}
|
|
31352
|
+
}
|
|
31353
|
+
if (this.bareSpec.includes("/") || this.bareSpec === "." || this.bareSpec === "..") {
|
|
31354
|
+
this.type = "file";
|
|
31355
|
+
const [file, uri] = getNormalizeFile(
|
|
31356
|
+
this.constructor.nodejsDependencies
|
|
31357
|
+
)(`file:${this.bareSpec}`, this);
|
|
31358
|
+
this.bareSpec = uri;
|
|
31359
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
31360
|
+
this.file = file;
|
|
31361
|
+
return;
|
|
31362
|
+
}
|
|
31363
|
+
this.type = "registry";
|
|
31364
|
+
const range = parseRange(this.bareSpec);
|
|
31365
|
+
if (range) {
|
|
31366
|
+
this.semver = this.bareSpec.trim();
|
|
31367
|
+
this.range = range;
|
|
31368
|
+
} else {
|
|
31369
|
+
this.distTag = this.bareSpec;
|
|
31370
|
+
}
|
|
31371
|
+
this.registrySpec = this.bareSpec;
|
|
31372
|
+
const {
|
|
31373
|
+
"scoped-registries": scopeRegs,
|
|
31374
|
+
registry,
|
|
31375
|
+
registries,
|
|
31376
|
+
"default-registry-alias": defaultAlias
|
|
31377
|
+
} = this.options;
|
|
31378
|
+
const scopeReg = this.scope && scopeRegs[this.scope];
|
|
31379
|
+
this.registry = scopeReg ?? registry ?? registries[defaultAlias];
|
|
31380
|
+
for (const r of Object.values(this.options["jsr-registries"])) {
|
|
31381
|
+
if (this.registry === r) return;
|
|
31382
|
+
}
|
|
31383
|
+
this.#guessRegistryTarball();
|
|
31384
|
+
}
|
|
31385
|
+
#parseScope(name) {
|
|
31386
|
+
if (!name.startsWith("@")) return;
|
|
31387
|
+
const s = name.indexOf("/");
|
|
31388
|
+
if (s > 1 && s < name.length - 1) {
|
|
31389
|
+
const scope = name.substring(0, s);
|
|
31390
|
+
this.registry = this.scopeRegistry = this.options["scoped-registries"][scope];
|
|
31391
|
+
this.scope = scope;
|
|
31392
|
+
}
|
|
31393
|
+
}
|
|
31394
|
+
#parseHostedGit(name, template) {
|
|
31395
|
+
if (this.bareSpec.startsWith(`${name}:`)) {
|
|
31396
|
+
const h = this.bareSpec.indexOf("#");
|
|
31397
|
+
const bare = h === -1 ? this.bareSpec : this.bareSpec.substring(0, h);
|
|
31398
|
+
const hash2 = h === -1 ? "" : this.bareSpec.substring(h);
|
|
31399
|
+
const hostPath = bare.substring(name.length + 1);
|
|
31400
|
+
if (!hostPath) {
|
|
31401
|
+
throw this.#error("invalid named git host specifier");
|
|
31402
|
+
}
|
|
31403
|
+
const split = hostPath.split("/");
|
|
31404
|
+
let t = template;
|
|
31405
|
+
for (let i2 = 0; i2 < split.length; i2++) {
|
|
31406
|
+
t = t.split(`$${i2 + 1}`).join(split[i2]);
|
|
31407
|
+
}
|
|
31408
|
+
t += hash2;
|
|
31409
|
+
this.namedGitHost = name;
|
|
31410
|
+
this.namedGitHostPath = hostPath;
|
|
31411
|
+
this.#parseGitSelector(t);
|
|
31412
|
+
if (this.gitCommittish && !this.gitSelectorParsed?.path) {
|
|
31413
|
+
const archiveHost = this.options["git-host-archives"][name];
|
|
31414
|
+
if (name === "github" && this.gitCommittish.startsWith("pull/") && this.gitCommittish.match(/\//g)?.length === 1) {
|
|
31415
|
+
this.gitCommittish += "/head";
|
|
31416
|
+
}
|
|
31417
|
+
if (archiveHost) {
|
|
31418
|
+
this.type = "remote";
|
|
31419
|
+
let t2 = archiveHost;
|
|
31420
|
+
t2 = t2.split("$committish").join(this.gitCommittish);
|
|
31421
|
+
for (let i2 = 0; i2 < split.length; i2++) {
|
|
31422
|
+
t2 = t2.split(`$${i2 + 1}`).join(split[i2]);
|
|
31423
|
+
}
|
|
31424
|
+
this.remoteURL = t2;
|
|
31425
|
+
}
|
|
31426
|
+
}
|
|
31427
|
+
return true;
|
|
31428
|
+
}
|
|
31429
|
+
return false;
|
|
31430
|
+
}
|
|
31431
|
+
/* c8 ignore start */
|
|
31432
|
+
[kCustomInspect]() {
|
|
31433
|
+
return `@vltpkg/spec.Spec ${String(this)}`;
|
|
31434
|
+
}
|
|
31435
|
+
/* c8 ignore stop */
|
|
31436
|
+
#guessRegistryTarball() {
|
|
31437
|
+
const { name, registry, range } = this.final;
|
|
31438
|
+
if (!registry || !range?.isSingle) return;
|
|
31439
|
+
const stripScope = /^@[^/]+\//;
|
|
31440
|
+
const base = registry.endsWith("/") ? registry : registry + "/";
|
|
31441
|
+
this.conventionalRegistryTarball = String(
|
|
31442
|
+
new URL(
|
|
31443
|
+
`${name}/-/${name.replace(stripScope, "")}-${range}.tgz`,
|
|
31444
|
+
base
|
|
31445
|
+
)
|
|
31446
|
+
);
|
|
31447
|
+
}
|
|
31448
|
+
#parseRegistrySpec(s, url) {
|
|
31449
|
+
this.registry = url;
|
|
31450
|
+
this.subspec = this.constructor.parse(s, {
|
|
31451
|
+
...this.options,
|
|
31452
|
+
registry: url
|
|
31453
|
+
});
|
|
31454
|
+
return this.subspec;
|
|
31455
|
+
}
|
|
31456
|
+
#parseJsrRegistrySpec(s, url) {
|
|
31457
|
+
this.registry = url;
|
|
31458
|
+
if (!s.startsWith("@")) s = `${this.name}@${s}`;
|
|
31459
|
+
const name = s.startsWith("@jsr/") ? s : `@jsr/${s.replace(/^@/, "").replace(/\//, "__")}`;
|
|
31460
|
+
this.subspec = this.constructor.parse(name, {
|
|
31461
|
+
...this.options,
|
|
31462
|
+
"scoped-registries": {
|
|
31463
|
+
...this.options["scoped-registries"],
|
|
31464
|
+
"@jsr": url
|
|
31465
|
+
}
|
|
31466
|
+
});
|
|
31467
|
+
if (this.name === "(unknown)") {
|
|
31468
|
+
const nextAt = s.indexOf("@", 1);
|
|
31469
|
+
if (nextAt === -1) {
|
|
31470
|
+
this.name = s;
|
|
31471
|
+
} else {
|
|
31472
|
+
this.name = s.substring(0, s.indexOf("@", 1));
|
|
31473
|
+
}
|
|
31474
|
+
assertPathSafeName(this.name, s);
|
|
31475
|
+
}
|
|
31476
|
+
const reg = `${this.namedJsrRegistry}:`;
|
|
31477
|
+
const n7 = `${reg}${this.name}`;
|
|
31478
|
+
if (this.bareSpec.startsWith(n7 + "@")) {
|
|
31479
|
+
this.bareSpec = reg + this.bareSpec.substring(n7.length + 1);
|
|
31480
|
+
} else if (this.bareSpec === n7) {
|
|
31481
|
+
this.bareSpec = reg;
|
|
31482
|
+
}
|
|
31483
|
+
this.spec = this.name + "@" + this.bareSpec;
|
|
31484
|
+
return this.subspec;
|
|
31485
|
+
}
|
|
31486
|
+
#error(message, extra = {}) {
|
|
31487
|
+
return error(message, { spec: this.spec, ...extra }, this.#error);
|
|
31488
|
+
}
|
|
31489
|
+
#parseGitSelector(s) {
|
|
31490
|
+
const h = s.indexOf("#");
|
|
31491
|
+
if (h === -1) {
|
|
31492
|
+
this.gitRemote = s;
|
|
31493
|
+
return;
|
|
31494
|
+
}
|
|
31495
|
+
this.gitRemote = s.substring(0, h);
|
|
31496
|
+
this.gitSelector = s.substring(h + 1);
|
|
31497
|
+
const [selectorParsed, committish, range] = this.constructor.parseGitSelector(this.gitSelector, this);
|
|
31498
|
+
this.range = range;
|
|
31499
|
+
this.gitCommittish = committish;
|
|
31500
|
+
this.gitSelectorParsed = selectorParsed;
|
|
31501
|
+
}
|
|
31502
|
+
/**
|
|
31503
|
+
* Should only ever be called with the bit that comes AFTER the #
|
|
31504
|
+
* in the git remote url.
|
|
31505
|
+
*/
|
|
31506
|
+
static parseGitSelector(selector, spec) {
|
|
31507
|
+
if (!selector) return [{}];
|
|
31508
|
+
const split = selector.split("::");
|
|
31509
|
+
const first = split[0];
|
|
31510
|
+
let committish = void 0;
|
|
31511
|
+
let range = void 0;
|
|
31512
|
+
const parsed = {};
|
|
31513
|
+
if (typeof first !== "string") {
|
|
31514
|
+
throw typeError("impossible", {
|
|
31515
|
+
found: first,
|
|
31516
|
+
wanted: String
|
|
31517
|
+
});
|
|
31518
|
+
}
|
|
31519
|
+
if (!first.includes(":")) {
|
|
31520
|
+
committish = first;
|
|
31521
|
+
split.shift();
|
|
31522
|
+
}
|
|
31523
|
+
for (const kv of split) {
|
|
31524
|
+
const c = kv.indexOf(":");
|
|
31525
|
+
if (c === -1) continue;
|
|
31526
|
+
const k4 = kv.substring(0, c);
|
|
31527
|
+
const v3 = kv.substring(c + 1);
|
|
31528
|
+
if (k4 === "semver") {
|
|
31529
|
+
if (committish) {
|
|
31530
|
+
throw error(
|
|
31531
|
+
"Cannot specify a semver range and committish value",
|
|
31532
|
+
{ spec }
|
|
31533
|
+
);
|
|
31534
|
+
}
|
|
31535
|
+
range = parseRange(v3);
|
|
31536
|
+
if (!range) {
|
|
31537
|
+
throw error(`Invalid git tag semver range: ${v3}`, { spec });
|
|
31538
|
+
}
|
|
31539
|
+
}
|
|
31540
|
+
if (k4 === "semver" || k4 === "path") {
|
|
31541
|
+
if (k4 === "path") {
|
|
31542
|
+
if (
|
|
31543
|
+
/* c8 ignore next */
|
|
31544
|
+
this.nodejsDependencies?.isAbsolute(
|
|
31545
|
+
v3
|
|
31546
|
+
) || /(^|\/|\\)\.\.($|\\|\/)/.test(v3)
|
|
31547
|
+
) {
|
|
31548
|
+
throw error("Invalid path in git selector", { spec });
|
|
31549
|
+
}
|
|
31550
|
+
parsed.path = (this.nodejsDependencies ? this.nodejsDependencies.join("/", v3).substring(1) : v3).replace(/\\/g, "/");
|
|
31551
|
+
} else {
|
|
31552
|
+
parsed[k4] = v3;
|
|
31553
|
+
}
|
|
31554
|
+
}
|
|
31555
|
+
}
|
|
31556
|
+
return [parsed, committish, range];
|
|
31557
|
+
}
|
|
31558
|
+
};
|
|
31559
|
+
var getNormalizeFile = (opts) => (bareSpec, spec) => {
|
|
31560
|
+
const slashes = bareSpec.substring(
|
|
31561
|
+
"file:".length,
|
|
31562
|
+
"file://".length
|
|
31563
|
+
);
|
|
31564
|
+
const pref = `file:${slashes === "//" ? slashes : ""}`;
|
|
31565
|
+
const rest = bareSpec.substring(pref.length);
|
|
31566
|
+
const [a2 = "", b = "/", c = "/", d4 = "/"] = rest.split("", 4);
|
|
31567
|
+
if (!a2) {
|
|
31568
|
+
return [".", "file:."];
|
|
31569
|
+
}
|
|
31570
|
+
if (a2 === "/" && b === "~" && c !== "/" || a2 === "~" && b !== "/") {
|
|
31571
|
+
throw error(
|
|
31572
|
+
`invalid file: specifier. '~username' not supported`,
|
|
31573
|
+
{ spec }
|
|
31574
|
+
);
|
|
31575
|
+
}
|
|
31576
|
+
if (a2 === "~") {
|
|
31577
|
+
return (
|
|
31578
|
+
/* c8 ignore start */
|
|
31579
|
+
opts ? [
|
|
31580
|
+
opts.resolve(opts.homedir(), rest.substring(2)),
|
|
31581
|
+
`file:${rest}`
|
|
31582
|
+
] : [rest, `file:${rest}`]
|
|
31583
|
+
);
|
|
31584
|
+
}
|
|
31585
|
+
if (a2 === "/" && b === "~") {
|
|
31586
|
+
return opts ? [
|
|
31587
|
+
opts.resolve(opts.homedir(), rest.substring(3)),
|
|
31588
|
+
`file:${rest.substring(1)}`
|
|
31589
|
+
] : (
|
|
31590
|
+
/* c8 ignore stop */
|
|
31591
|
+
[rest.substring(1), `file:${rest.substring(1)}`]
|
|
31592
|
+
);
|
|
31593
|
+
}
|
|
31594
|
+
if (a2 === "/" && b === "." && (c === "/" || c === "." && d4 === "/")) {
|
|
31595
|
+
return [rest.substring(1), `file:${rest.substring(1)}`];
|
|
31596
|
+
}
|
|
31597
|
+
if (a2 === "." && (b === "/" || b === "." && c === "/")) {
|
|
31598
|
+
return [rest, `file:${rest}`];
|
|
31599
|
+
}
|
|
31600
|
+
if (slashes === "//") {
|
|
31601
|
+
try {
|
|
31602
|
+
const parsed = new URL(bareSpec);
|
|
31603
|
+
if (parsed.host) {
|
|
31604
|
+
if (parsed.host !== "localhost") {
|
|
31605
|
+
throw error(
|
|
31606
|
+
`invalid file:// specifier. host must be empty or 'localhost'`,
|
|
31607
|
+
{
|
|
31608
|
+
spec,
|
|
31609
|
+
found: parsed.host,
|
|
31610
|
+
validOptions: ["", "localhost"]
|
|
31611
|
+
}
|
|
31612
|
+
);
|
|
31613
|
+
}
|
|
31614
|
+
}
|
|
31615
|
+
return [
|
|
31616
|
+
parsed.pathname.replace(/^\/([a-zA-Z]:\/)/, "$1"),
|
|
31617
|
+
`file://${parsed.pathname}`
|
|
31618
|
+
];
|
|
31619
|
+
} catch (er) {
|
|
31620
|
+
throw error("invalid file:// specifier", {
|
|
31621
|
+
spec,
|
|
31622
|
+
cause: er
|
|
31623
|
+
});
|
|
31624
|
+
}
|
|
31625
|
+
}
|
|
31626
|
+
if (opts?.winPath.isAbsolute(rest)) {
|
|
31627
|
+
return [rest, `file://${rest}`];
|
|
31628
|
+
}
|
|
31629
|
+
return [`./${rest}`, `file:./${rest}`];
|
|
31630
|
+
};
|
|
29977
31631
|
|
|
29978
31632
|
// ../../src/types/src/index.ts
|
|
31633
|
+
import { debuglog } from "node:util";
|
|
31634
|
+
var debug = debuglog("vlt");
|
|
29979
31635
|
var asError = (er, fallbackMessage = "Unknown error") => er instanceof Error ? er : new Error(String(er) || fallbackMessage);
|
|
29980
31636
|
|
|
29981
31637
|
// ../../src/output/src/index.ts
|
|
@@ -30659,7 +32315,7 @@ var readSize = (buf, offset) => {
|
|
|
30659
32315
|
}
|
|
30660
32316
|
return a2 << 24 | b << 16 | c << 8 | d4;
|
|
30661
32317
|
};
|
|
30662
|
-
var
|
|
32318
|
+
var kCustomInspect2 = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
30663
32319
|
var CacheEntry = class _CacheEntry {
|
|
30664
32320
|
#statusCode;
|
|
30665
32321
|
/** The raw headers as an array of buffers */
|
|
@@ -30748,7 +32404,7 @@ var CacheEntry = class _CacheEntry {
|
|
|
30748
32404
|
}).filter(([_3, v3]) => v3 !== void 0)
|
|
30749
32405
|
);
|
|
30750
32406
|
}
|
|
30751
|
-
[
|
|
32407
|
+
[kCustomInspect2](depth, options) {
|
|
30752
32408
|
const str = inspect2(this.toJSON(), {
|
|
30753
32409
|
depth,
|
|
30754
32410
|
...options
|