@vltpkg/cli-js 1.0.0-rc.27 → 1.0.0-rc.29
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-6HRR4HXE.js +293 -0
- package/{bugs-CS34LDPD.js → bugs-2CAZQ32S.js} +19 -22
- package/{build-XHEFAWMN.js → build-OAWTNBMS.js} +10 -13
- package/{cache-LII2V5IM.js → cache-JTAFST6T.js} +14 -15
- package/cache-unzip-src-unzip.js +606 -575
- package/{chunk-D27QPHKI.js → chunk-2V4AQPBR.js} +67 -20
- package/{chunk-JQHMLTO5.js → chunk-3MWZTKGK.js} +419 -328
- package/{chunk-DJBBJDHI.js → chunk-7RZL7BZI.js} +159 -74
- package/chunk-7WHVJ56C.js +73 -0
- package/{chunk-LAG2R3YJ.js → chunk-BW6C3YUV.js} +6 -6
- package/{chunk-6YTJVEK2.js → chunk-CLDF5XLG.js} +11 -11
- package/{chunk-DYL7AFY7.js → chunk-CPM47YUH.js} +5 -3
- package/{chunk-QWWYZ3TT.js → chunk-D2MVJDUA.js} +1 -1
- package/{chunk-5E5GX4G6.js → chunk-FBTBHRPG.js} +1 -1
- package/{chunk-AZLX27EM.js → chunk-FXDRM4ZO.js} +296 -258
- package/chunk-G2YT2GWF.js +120 -0
- package/{chunk-INXSTZAX.js → chunk-HAGUS4HI.js} +21 -21
- package/{chunk-FI5TUER7.js → chunk-HQ4US6G3.js} +681 -687
- package/chunk-IEISSXS4.js +711 -0
- package/{chunk-TRXTSZFT.js → chunk-IYO5QKUW.js} +1 -1
- package/{chunk-DJBVQKBB.js → chunk-K3RN3BGU.js} +5 -5
- package/{chunk-P2HZ4ISK.js → chunk-LPLXAVG7.js} +54 -6
- package/{chunk-XSUIV5NF.js → chunk-M7HPHM7B.js} +14 -12
- package/{chunk-BIUCOMBH.js → chunk-MAIQR5GM.js} +5 -5
- package/{chunk-TDTJOKF2.js → chunk-NLFBANVO.js} +8 -1
- package/{chunk-XWF3GJKE.js → chunk-Q3DNNTPG.js} +27 -1
- package/{chunk-VCSVHRCS.js → chunk-R44FR7BY.js} +1269 -590
- package/{chunk-QDGZZ5FZ.js → chunk-TYV4N3S3.js} +6 -692
- package/{chunk-LKFTVDWS.js → chunk-VPKJNCKL.js} +26 -13
- package/{chunk-VTZZIXYW.js → chunk-VRIS5HAW.js} +3 -3
- package/{chunk-S5I2UOBT.js → chunk-WX2DCAG2.js} +7 -7
- package/{chunk-YR47M5L7.js → chunk-XYCCQT7N.js} +34 -39
- package/{chunk-D7U7KDEM.js → chunk-YCQTLBWF.js} +1 -1
- package/{chunk-SR66HWMM.js → chunk-ZINDEKAU.js} +144 -93
- package/{ci-EEXNEPKP.js → ci-TOJJVHI4.js} +13 -16
- package/cli-package.json +2 -1
- package/{config-4ZFJD5AY.js → config-DVAPEE5D.js} +12 -14
- package/{config-6MUU2TRJ.js → config-GOV4E2KK.js} +26 -26
- package/{create-DEKJKPYX.js → create-NGJD7K4L.js} +24 -26
- package/deprecate-WROL4AHK.js +176 -0
- package/{devtools-NOLON5YL.js → devtools-TPMVKPB5.js} +80 -77
- package/dist-tag-WZXXWXMB.js +204 -0
- package/{docs-5EKPZANX.js → docs-YCOZFMZG.js} +19 -22
- package/{exec-I4YPE6YW.js → exec-URG5OWLH.js} +24 -26
- package/{exec-cache-XEWPABLK.js → exec-cache-KHDOEH2F.js} +21 -23
- package/{exec-local-OQXG2VPW.js → exec-local-52TVUL5K.js} +19 -21
- package/{help-OG655SE5.js → help-LNSDVBGJ.js} +4 -5
- package/{init-LJH2YTBM.js → init-XNMWYATA.js} +10 -8
- package/{install-KP2FGWOR.js → install-SKUZERZJ.js} +28 -17
- package/{list-ACZ3ZSIZ.js → list-XEDVFUD5.js} +19 -21
- package/{login-VFTRKZE2.js → login-52SA2DSI.js} +6 -9
- package/{logout-Z4AVG64D.js → logout-5YYHNV5W.js} +6 -9
- package/{pack-GPJNX7RP.js → pack-B7QZHMYP.js} +14 -17
- package/package.json +1 -1
- package/{ping-B2YS4SR3.js → ping-PRGDYDRI.js} +6 -9
- package/{pkg-WUYJDFSH.js → pkg-UEIQIVVD.js} +15 -19
- package/profile-46FKVQEL.js +129 -0
- package/{publish-WTMGC4ET.js → publish-HBYHOSKH.js} +17 -20
- package/{query-UCM35VVC.js → query-5A4YLS2C.js} +19 -21
- package/registry-client-package.json +1 -1
- package/registry-client-src-revalidate.js +1157 -1032
- package/{repo-MZCPTQZU.js → repo-I6X66PHD.js} +19 -22
- package/{reporter-XRZ37LFK.js → reporter-NUXJTV4G.js} +2 -3
- package/{run-CAX4Z2SC.js → run-VEZMUMVH.js} +19 -21
- package/{run-exec-SM42FE7W.js → run-exec-6ADY4BKH.js} +19 -21
- package/security-archive-src-update-expired.js +8 -7
- package/{src-SDJWTPCU.js → src-O32QL33R.js} +20 -22
- package/token-YK6L74PA.js +206 -0
- package/{uninstall-YYPPXM2O.js → uninstall-UBUZBV7E.js} +14 -17
- package/unpublish-ZHJEKT7A.js +224 -0
- package/{update-YFUTH33A.js → update-WO4BHJF4.js} +13 -16
- package/{version-SK256WED.js → version-RLESYHML.js} +13 -16
- package/{view-CBYGJ76J.js → view-UA5HXFXG.js} +16 -17
- 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-ZT4ZEN2C.js → whoami-7H3FPR2O.js} +6 -9
- package/chunk-52LBC3AX.js +0 -75
- package/chunk-BGQCUUCA.js +0 -667
- package/chunk-E74WGW5C.js +0 -49
- package/chunk-JLJKOF75.js +0 -40
- package/chunk-YP4YNE5Y.js +0 -68
- package/token-YCURCCNR.js +0 -103
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
var global = globalThis;
|
|
2
|
+
import {Buffer} from "node:buffer";
|
|
3
|
+
import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
|
|
4
|
+
globalThis.setTimeout = _vlt_setTimeout;
|
|
5
|
+
globalThis.clearTimeout = _vlt_clearTimeout;
|
|
6
|
+
globalThis.setImmediate = _vlt_setImmediate;
|
|
7
|
+
globalThis.clearImmediate = _vlt_clearImmediate;
|
|
8
|
+
globalThis.setInterval = _vlt_setInterval;
|
|
9
|
+
globalThis.clearInterval = _vlt_clearInterval;
|
|
10
|
+
import {createRequire as _vlt_createRequire} from "node:module";
|
|
11
|
+
var require = _vlt_createRequire(import.meta.filename);
|
|
12
|
+
import {
|
|
13
|
+
parseRange
|
|
14
|
+
} from "./chunk-Q3DNNTPG.js";
|
|
15
|
+
import {
|
|
16
|
+
error,
|
|
17
|
+
typeError
|
|
18
|
+
} from "./chunk-WZWDS3W4.js";
|
|
19
|
+
|
|
20
|
+
// ../../src/spec/src/browser.ts
|
|
21
|
+
var kCustomInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
22
|
+
var defaultRegistry = "https://registry.npmjs.org/";
|
|
23
|
+
var defaultRegistryName = "npm";
|
|
24
|
+
var defaultRegistries = {
|
|
25
|
+
npm: defaultRegistry,
|
|
26
|
+
gh: "https://npm.pkg.github.com/"
|
|
27
|
+
};
|
|
28
|
+
var defaultJsrRegistries = { jsr: "https://npm.jsr.io/" };
|
|
29
|
+
var defaultGitHosts = {
|
|
30
|
+
github: "git+ssh://git@github.com:$1/$2.git",
|
|
31
|
+
bitbucket: "git+ssh://git@bitbucket.org:$1/$2.git",
|
|
32
|
+
gitlab: "git+ssh://git@gitlab.com:$1/$2.git",
|
|
33
|
+
gist: "git+ssh://git@gist.github.com/$1.git"
|
|
34
|
+
};
|
|
35
|
+
var defaultGitHostArchives = {
|
|
36
|
+
github: "https://api.github.com/repos/$1/$2/tarball/$committish",
|
|
37
|
+
bitbucket: "https://bitbucket.org/$1/$2/get/$committish.tar.gz",
|
|
38
|
+
gist: "https://codeload.github.com/gist/$1/tar.gz/$committish",
|
|
39
|
+
gitlab: "https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish"
|
|
40
|
+
};
|
|
41
|
+
var gitHostWebsites = {
|
|
42
|
+
github: "https://github.com/",
|
|
43
|
+
bitbucket: "https://bitbucket.org/",
|
|
44
|
+
gist: "https://gist.github.com/",
|
|
45
|
+
gitlab: "https://gitlab.com/"
|
|
46
|
+
};
|
|
47
|
+
var defaultScopeRegistries = {
|
|
48
|
+
"@jsr": "https://npm.jsr.io/"
|
|
49
|
+
};
|
|
50
|
+
var getOptions = (options) => ({
|
|
51
|
+
catalog: {},
|
|
52
|
+
catalogs: {},
|
|
53
|
+
...options,
|
|
54
|
+
"jsr-registries": {
|
|
55
|
+
...options?.["jsr-registries"] ?? {},
|
|
56
|
+
...defaultJsrRegistries
|
|
57
|
+
},
|
|
58
|
+
registry: options?.registry ?? defaultRegistry,
|
|
59
|
+
"scoped-registries": options?.["scoped-registries"] ?? {},
|
|
60
|
+
"git-hosts": options?.["git-hosts"] ? {
|
|
61
|
+
...defaultGitHosts,
|
|
62
|
+
...options["git-hosts"]
|
|
63
|
+
} : defaultGitHosts,
|
|
64
|
+
registries: {
|
|
65
|
+
...options?.registries ?? {},
|
|
66
|
+
...defaultRegistries
|
|
67
|
+
},
|
|
68
|
+
"git-host-archives": options?.["git-host-archives"] ? {
|
|
69
|
+
...defaultGitHostArchives,
|
|
70
|
+
...options["git-host-archives"]
|
|
71
|
+
} : defaultGitHostArchives
|
|
72
|
+
});
|
|
73
|
+
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
|
|
74
|
+
// custom registered registry protocol e.g: `github:`, `custom:`
|
|
75
|
+
[
|
|
76
|
+
...Object.keys(options["git-hosts"]),
|
|
77
|
+
...Object.keys(options.registries),
|
|
78
|
+
...Object.keys(options["jsr-registries"])
|
|
79
|
+
].some((key) => spec.startsWith(`${key}:`));
|
|
80
|
+
var findFirstAt = (spec, hasScope) => spec.indexOf("@", hasScope ? 1 : 0);
|
|
81
|
+
var findGitIdentifier = (spec) => spec.indexOf("#") > 2;
|
|
82
|
+
var findFileIdentifier = (spec) => spec.includes("/");
|
|
83
|
+
var isSpec = (spec) => typeof spec === "object" && spec !== null && "spec" in spec && "bareSpec" in spec && "name" in spec && "type" in spec && "options" in spec && typeof spec.spec === "string" && typeof spec.bareSpec === "string" && typeof spec.name === "string";
|
|
84
|
+
var currentDefaultRegistryName = (registry, options) => {
|
|
85
|
+
for (const [name, url] of Object.entries(
|
|
86
|
+
options.registries ?? {}
|
|
87
|
+
)) {
|
|
88
|
+
const specRegURL = registry.endsWith("/") ? registry : registry + "/";
|
|
89
|
+
const knownRegURL = url.endsWith("/") ? url : url + "/";
|
|
90
|
+
if (specRegURL === knownRegURL) {
|
|
91
|
+
return name;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var Spec = class _Spec {
|
|
96
|
+
static parse(spec, bareOrOptions, options) {
|
|
97
|
+
return typeof spec === "object" ? spec : new this(spec, bareOrOptions, options);
|
|
98
|
+
}
|
|
99
|
+
static parseArgs(specOrBareSpec, opts) {
|
|
100
|
+
const options = getOptions(opts ?? {});
|
|
101
|
+
if (startsWithSpecIdentifier(specOrBareSpec, options)) {
|
|
102
|
+
const parsed = this.parse("(unknown)", specOrBareSpec, options);
|
|
103
|
+
if (parsed.subspec) {
|
|
104
|
+
const { namedJsrRegistry: jsrHost } = parsed;
|
|
105
|
+
if (!jsrHost) {
|
|
106
|
+
parsed.name = parsed.subspec.name;
|
|
107
|
+
}
|
|
108
|
+
parsed.spec = `${parsed.name}@${parsed.bareSpec}`;
|
|
109
|
+
}
|
|
110
|
+
return parsed;
|
|
111
|
+
} else {
|
|
112
|
+
const hasScope = specOrBareSpec.startsWith("@");
|
|
113
|
+
const at = findFirstAt(specOrBareSpec, hasScope);
|
|
114
|
+
if (at > -1) {
|
|
115
|
+
return this.parse(
|
|
116
|
+
specOrBareSpec.substring(0, at),
|
|
117
|
+
specOrBareSpec.substring(at + 1),
|
|
118
|
+
options
|
|
119
|
+
);
|
|
120
|
+
} else if (findGitIdentifier(specOrBareSpec) || !hasScope && findFileIdentifier(specOrBareSpec)) {
|
|
121
|
+
return this.parse("(unknown)", specOrBareSpec, options);
|
|
122
|
+
} else {
|
|
123
|
+
return this.parse(`${specOrBareSpec}@`, options);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
static nodejsDependencies;
|
|
128
|
+
type;
|
|
129
|
+
spec;
|
|
130
|
+
options;
|
|
131
|
+
name;
|
|
132
|
+
scope;
|
|
133
|
+
scopeRegistry;
|
|
134
|
+
bareSpec;
|
|
135
|
+
gitRemote;
|
|
136
|
+
gitSelector;
|
|
137
|
+
gitSelectorParsed;
|
|
138
|
+
gitCommittish;
|
|
139
|
+
namedGitHost;
|
|
140
|
+
namedGitHostPath;
|
|
141
|
+
workspaceSpec;
|
|
142
|
+
workspace;
|
|
143
|
+
namedRegistry;
|
|
144
|
+
namedJsrRegistry;
|
|
145
|
+
registry;
|
|
146
|
+
registrySpec;
|
|
147
|
+
conventionalRegistryTarball;
|
|
148
|
+
semver;
|
|
149
|
+
range;
|
|
150
|
+
distTag;
|
|
151
|
+
remoteURL;
|
|
152
|
+
file;
|
|
153
|
+
catalog;
|
|
154
|
+
subspec;
|
|
155
|
+
overridden = false;
|
|
156
|
+
#final;
|
|
157
|
+
#toString;
|
|
158
|
+
/**
|
|
159
|
+
* Return the final entry in the chain of subspecs
|
|
160
|
+
* When deciding which thing to actually fetch, spec.final is the thing
|
|
161
|
+
* to look at.
|
|
162
|
+
*/
|
|
163
|
+
get final() {
|
|
164
|
+
if (this.#final) return this.#final;
|
|
165
|
+
const final = this.subspec ? this.subspec.final : this;
|
|
166
|
+
if (final.type === "catalog") {
|
|
167
|
+
throw error('invalid Spec.final value, type is "catalog"');
|
|
168
|
+
}
|
|
169
|
+
return this.#final = final;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Normally, the string value of a Spec is just the string passed in to
|
|
173
|
+
* be parsed. However, in the case of a chain of subspecs, like
|
|
174
|
+
* `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
|
|
175
|
+
* parts of the chain, returning just `foo@npm:quux@latest`
|
|
176
|
+
*/
|
|
177
|
+
toString() {
|
|
178
|
+
if (this.#toString !== void 0) return this.#toString;
|
|
179
|
+
let sub = this;
|
|
180
|
+
while (sub.subspec?.subspec) sub = sub.subspec;
|
|
181
|
+
if (sub.subspec && sub.subspec.type !== "registry")
|
|
182
|
+
sub = sub.subspec;
|
|
183
|
+
return this.#toString = this.name + "@" + sub.bareSpec;
|
|
184
|
+
}
|
|
185
|
+
constructor(spec, bareOrOptions, options = {}) {
|
|
186
|
+
if (bareOrOptions && typeof bareOrOptions === "object") {
|
|
187
|
+
options = bareOrOptions;
|
|
188
|
+
bareOrOptions = void 0;
|
|
189
|
+
}
|
|
190
|
+
this.options = getOptions(options);
|
|
191
|
+
if (typeof bareOrOptions === "string") {
|
|
192
|
+
this.name = spec;
|
|
193
|
+
this.#parseScope(spec);
|
|
194
|
+
this.bareSpec = bareOrOptions;
|
|
195
|
+
this.spec = `${this.name}@${bareOrOptions}`;
|
|
196
|
+
} else {
|
|
197
|
+
this.spec = spec;
|
|
198
|
+
if (!spec.startsWith("git@") && startsWithSpecIdentifier(spec, this.options) && spec.includes(":") && [
|
|
199
|
+
...Object.keys(this.options.registries),
|
|
200
|
+
...Object.keys(defaultRegistries)
|
|
201
|
+
].some((key) => spec.startsWith(`${key}:`))) {
|
|
202
|
+
this.name = spec;
|
|
203
|
+
this.bareSpec = spec;
|
|
204
|
+
} else {
|
|
205
|
+
const hasScope = spec.startsWith("@");
|
|
206
|
+
let at = findFirstAt(spec, hasScope);
|
|
207
|
+
if (at === -1) {
|
|
208
|
+
at = spec.length;
|
|
209
|
+
spec += "@";
|
|
210
|
+
}
|
|
211
|
+
this.name = spec.substring(0, at);
|
|
212
|
+
if (hasScope) this.#parseScope(this.name);
|
|
213
|
+
this.bareSpec = spec.substring(at + 1);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (this.bareSpec.startsWith("catalog:")) {
|
|
217
|
+
this.catalog = this.bareSpec.substring("catalog:".length);
|
|
218
|
+
const catalog = this.catalog ? this.options.catalogs?.[this.catalog] : this.options.catalog;
|
|
219
|
+
if (!catalog) {
|
|
220
|
+
throw this.#error("Named catalog not found", {
|
|
221
|
+
name: this.catalog,
|
|
222
|
+
validOptions: this.options.catalogs && Object.keys(this.options.catalogs)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
const sub = catalog[this.name];
|
|
226
|
+
if (!sub) {
|
|
227
|
+
throw this.#error("Name not found in catalog", {
|
|
228
|
+
name: this.name,
|
|
229
|
+
validOptions: Object.keys(catalog)
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
this.subspec = _Spec.parse(this.name, sub);
|
|
233
|
+
this.type = "catalog";
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (this.bareSpec.startsWith("https://")) {
|
|
237
|
+
for (const [name, origin] of Object.entries(gitHostWebsites)) {
|
|
238
|
+
if (this.bareSpec.startsWith(origin)) {
|
|
239
|
+
const parsed = new URL(this.bareSpec);
|
|
240
|
+
const [user, project] = parsed.pathname.replace(/\.git$/, "").replace(/\/+/g, " ").trim().split(" ");
|
|
241
|
+
if (user && project) {
|
|
242
|
+
this.bareSpec = `${name}:${user}/${project}${parsed.hash}`;
|
|
243
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (this.bareSpec.startsWith("workspace:")) {
|
|
250
|
+
this.type = "workspace";
|
|
251
|
+
const ws = this.bareSpec.substring("workspace:".length).trim();
|
|
252
|
+
const w = ws.lastIndexOf("@");
|
|
253
|
+
if (w === -1) {
|
|
254
|
+
this.workspace = this.name;
|
|
255
|
+
} else {
|
|
256
|
+
const wsName = ws.substring(0, w);
|
|
257
|
+
if (!wsName || wsName === "*" || wsName === "~" || wsName === "^" || (wsName.startsWith("@") ? wsName.split("/").length !== 2 || wsName.substring(1).includes("@") : wsName.includes("@"))) {
|
|
258
|
+
throw this.#error(
|
|
259
|
+
"workspace: name must be a path or valid package name",
|
|
260
|
+
{ found: wsName }
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
this.workspace = wsName;
|
|
264
|
+
}
|
|
265
|
+
const wss = w === -1 ? ws : ws.substring(w + 1) || "*";
|
|
266
|
+
const range2 = wss === "*" ? void 0 : parseRange(wss);
|
|
267
|
+
if (wss !== "*" && wss !== "~" && wss !== "^" && !range2) {
|
|
268
|
+
throw this.#error(
|
|
269
|
+
"workspace: spec must be one of *, ~, or ^, or a valid semver range",
|
|
270
|
+
{
|
|
271
|
+
found: wss,
|
|
272
|
+
wanted: `'*'|'~'|'^'|SemverRange`
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
this.workspaceSpec = wss;
|
|
277
|
+
if (range2) {
|
|
278
|
+
this.semver = wss;
|
|
279
|
+
this.range = range2;
|
|
280
|
+
}
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
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
|
|
284
|
+
this.bareSpec.startsWith("git@github.com")) {
|
|
285
|
+
if (this.bareSpec.startsWith("git@")) {
|
|
286
|
+
this.bareSpec = `git+ssh://${this.bareSpec}`;
|
|
287
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
288
|
+
}
|
|
289
|
+
this.type = "git";
|
|
290
|
+
for (const [name, host] of Object.entries(
|
|
291
|
+
this.options["git-hosts"]
|
|
292
|
+
)) {
|
|
293
|
+
const s = host.indexOf("$");
|
|
294
|
+
if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {
|
|
295
|
+
const p = this.bareSpec.substring(s).replace(/\.git(#.*)?$/, "$1");
|
|
296
|
+
this.bareSpec = `${name}:${p}`;
|
|
297
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
298
|
+
this.#parseHostedGit(name, host);
|
|
299
|
+
this.type = "git";
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
this.#parseGitSelector(this.bareSpec);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const regs = Object.entries(this.options.registries);
|
|
307
|
+
if (this.bareSpec.startsWith("registry:")) {
|
|
308
|
+
const reg = this.bareSpec.substring("registry:".length);
|
|
309
|
+
const h = reg.indexOf("#");
|
|
310
|
+
if (h === -1) {
|
|
311
|
+
throw this.#error("registry: must include name/version");
|
|
312
|
+
}
|
|
313
|
+
this.type = "registry";
|
|
314
|
+
let url = reg.substring(0, h);
|
|
315
|
+
if (!url.endsWith("/")) url += "/";
|
|
316
|
+
const regSpec = reg.substring(h + 1);
|
|
317
|
+
for (let [name, u] of regs) {
|
|
318
|
+
if (!u.endsWith("/")) {
|
|
319
|
+
u += "/";
|
|
320
|
+
this.options.registries[name] = u;
|
|
321
|
+
}
|
|
322
|
+
if (u === url) this.namedRegistry = name;
|
|
323
|
+
}
|
|
324
|
+
this.#parseRegistrySpec(regSpec, url);
|
|
325
|
+
this.#guessRegistryTarball();
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
for (const [host, url] of regs) {
|
|
329
|
+
const h = `${host}:`;
|
|
330
|
+
if (this.bareSpec.startsWith(h)) {
|
|
331
|
+
this.type = "registry";
|
|
332
|
+
this.namedRegistry = host;
|
|
333
|
+
this.#parseRegistrySpec(
|
|
334
|
+
this.bareSpec.substring(h.length),
|
|
335
|
+
url
|
|
336
|
+
).namedRegistry ??= host;
|
|
337
|
+
if (this.subspec && this.name === this.bareSpec) {
|
|
338
|
+
this.name = this.subspec.name;
|
|
339
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
340
|
+
}
|
|
341
|
+
this.#guessRegistryTarball();
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const ghosts = Object.entries(this.options["git-hosts"]);
|
|
346
|
+
for (const [name, template] of ghosts) {
|
|
347
|
+
if (this.#parseHostedGit(name, template)) {
|
|
348
|
+
this.type = "git";
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const jsrs = Object.entries(this.options["jsr-registries"]);
|
|
353
|
+
for (const [host, url] of jsrs) {
|
|
354
|
+
const h = `${host}:`;
|
|
355
|
+
if (this.bareSpec.startsWith(h)) {
|
|
356
|
+
this.type = "registry";
|
|
357
|
+
this.namedJsrRegistry = host;
|
|
358
|
+
this.#parseJsrRegistrySpec(
|
|
359
|
+
this.bareSpec.substring(h.length),
|
|
360
|
+
url
|
|
361
|
+
).namedJsrRegistry ??= host;
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (this.bareSpec.startsWith("https://") || this.bareSpec.startsWith("http://")) {
|
|
366
|
+
this.remoteURL = this.bareSpec;
|
|
367
|
+
this.type = "remote";
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (this.bareSpec.startsWith("file:")) {
|
|
371
|
+
this.type = "file";
|
|
372
|
+
const [path, uri] = getNormalizeFile(
|
|
373
|
+
this.constructor.nodejsDependencies
|
|
374
|
+
)(this.bareSpec, this);
|
|
375
|
+
this.file = path;
|
|
376
|
+
this.bareSpec = uri.replace(/\/+$/, "");
|
|
377
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (!this.bareSpec.startsWith("./") && !this.bareSpec.startsWith("../") && this.options["git-hosts"].github) {
|
|
381
|
+
const hash = this.bareSpec.indexOf("#");
|
|
382
|
+
const up = hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash);
|
|
383
|
+
if (up.split("/").length === 2) {
|
|
384
|
+
this.bareSpec = `github:${this.bareSpec}`;
|
|
385
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
386
|
+
this.#parseHostedGit(
|
|
387
|
+
"github",
|
|
388
|
+
this.options["git-hosts"].github
|
|
389
|
+
);
|
|
390
|
+
this.type = "git";
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (this.bareSpec.includes("/") || this.bareSpec === "." || this.bareSpec === "..") {
|
|
395
|
+
this.type = "file";
|
|
396
|
+
const [file, uri] = getNormalizeFile(
|
|
397
|
+
this.constructor.nodejsDependencies
|
|
398
|
+
)(`file:${this.bareSpec}`, this);
|
|
399
|
+
this.bareSpec = uri;
|
|
400
|
+
this.spec = `${this.name}@${this.bareSpec}`;
|
|
401
|
+
this.file = file;
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
this.type = "registry";
|
|
405
|
+
const range = parseRange(this.bareSpec);
|
|
406
|
+
if (range) {
|
|
407
|
+
this.semver = this.bareSpec.trim();
|
|
408
|
+
this.range = range;
|
|
409
|
+
} else {
|
|
410
|
+
this.distTag = this.bareSpec;
|
|
411
|
+
}
|
|
412
|
+
this.registrySpec = this.bareSpec;
|
|
413
|
+
const { "scoped-registries": scopeRegs, registry } = this.options;
|
|
414
|
+
const scopeReg = this.scope && scopeRegs[this.scope];
|
|
415
|
+
this.registry = scopeReg ?? registry;
|
|
416
|
+
for (const r of Object.values(this.options["jsr-registries"])) {
|
|
417
|
+
if (this.registry === r) return;
|
|
418
|
+
}
|
|
419
|
+
this.#guessRegistryTarball();
|
|
420
|
+
}
|
|
421
|
+
#parseScope(name) {
|
|
422
|
+
if (!name.startsWith("@")) return;
|
|
423
|
+
const s = name.indexOf("/");
|
|
424
|
+
if (s > 1 && s < name.length - 1) {
|
|
425
|
+
const scope = name.substring(0, s);
|
|
426
|
+
this.registry = this.scopeRegistry = this.options["scoped-registries"][scope];
|
|
427
|
+
this.scope = scope;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
#parseHostedGit(name, template) {
|
|
431
|
+
if (this.bareSpec.startsWith(`${name}:`)) {
|
|
432
|
+
const h = this.bareSpec.indexOf("#");
|
|
433
|
+
const bare = h === -1 ? this.bareSpec : this.bareSpec.substring(0, h);
|
|
434
|
+
const hash = h === -1 ? "" : this.bareSpec.substring(h);
|
|
435
|
+
const hostPath = bare.substring(name.length + 1);
|
|
436
|
+
if (!hostPath) {
|
|
437
|
+
throw this.#error("invalid named git host specifier");
|
|
438
|
+
}
|
|
439
|
+
const split = hostPath.split("/");
|
|
440
|
+
let t = template;
|
|
441
|
+
for (let i = 0; i < split.length; i++) {
|
|
442
|
+
t = t.split(`$${i + 1}`).join(split[i]);
|
|
443
|
+
}
|
|
444
|
+
t += hash;
|
|
445
|
+
this.namedGitHost = name;
|
|
446
|
+
this.namedGitHostPath = hostPath;
|
|
447
|
+
this.#parseGitSelector(t);
|
|
448
|
+
if (this.gitCommittish && !this.gitSelectorParsed?.path) {
|
|
449
|
+
const archiveHost = this.options["git-host-archives"][name];
|
|
450
|
+
if (name === "github" && this.gitCommittish.startsWith("pull/") && this.gitCommittish.match(/\//g)?.length === 1) {
|
|
451
|
+
this.gitCommittish += "/head";
|
|
452
|
+
}
|
|
453
|
+
if (archiveHost) {
|
|
454
|
+
this.type = "remote";
|
|
455
|
+
let t2 = archiveHost;
|
|
456
|
+
t2 = t2.split("$committish").join(this.gitCommittish);
|
|
457
|
+
for (let i = 0; i < split.length; i++) {
|
|
458
|
+
t2 = t2.split(`$${i + 1}`).join(split[i]);
|
|
459
|
+
}
|
|
460
|
+
this.remoteURL = t2;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return true;
|
|
464
|
+
}
|
|
465
|
+
return false;
|
|
466
|
+
}
|
|
467
|
+
/* c8 ignore start */
|
|
468
|
+
[kCustomInspect]() {
|
|
469
|
+
return `@vltpkg/spec.Spec ${String(this)}`;
|
|
470
|
+
}
|
|
471
|
+
/* c8 ignore stop */
|
|
472
|
+
#guessRegistryTarball() {
|
|
473
|
+
const { name, registry, range } = this.final;
|
|
474
|
+
if (!registry || !range?.isSingle) return;
|
|
475
|
+
const stripScope = /^@[^/]+\//;
|
|
476
|
+
const base = registry.endsWith("/") ? registry : registry + "/";
|
|
477
|
+
this.conventionalRegistryTarball = String(
|
|
478
|
+
new URL(
|
|
479
|
+
`${name}/-/${name.replace(stripScope, "")}-${range}.tgz`,
|
|
480
|
+
base
|
|
481
|
+
)
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
#parseRegistrySpec(s, url) {
|
|
485
|
+
this.registry = url;
|
|
486
|
+
this.subspec = this.constructor.parse(s, {
|
|
487
|
+
...this.options,
|
|
488
|
+
registry: url
|
|
489
|
+
});
|
|
490
|
+
return this.subspec;
|
|
491
|
+
}
|
|
492
|
+
#parseJsrRegistrySpec(s, url) {
|
|
493
|
+
this.registry = url;
|
|
494
|
+
if (!s.startsWith("@")) s = `${this.name}@${s}`;
|
|
495
|
+
const name = s.startsWith("@jsr/") ? s : `@jsr/${s.replace(/^@/, "").replace(/\//, "__")}`;
|
|
496
|
+
this.subspec = this.constructor.parse(name, {
|
|
497
|
+
...this.options,
|
|
498
|
+
"scoped-registries": {
|
|
499
|
+
...this.options["scoped-registries"],
|
|
500
|
+
"@jsr": url
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
if (this.name === "(unknown)") {
|
|
504
|
+
const nextAt = s.indexOf("@", 1);
|
|
505
|
+
if (nextAt === -1) {
|
|
506
|
+
this.name = s;
|
|
507
|
+
} else {
|
|
508
|
+
this.name = s.substring(0, s.indexOf("@", 1));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
const reg = `${this.namedJsrRegistry}:`;
|
|
512
|
+
const n = `${reg}${this.name}`;
|
|
513
|
+
if (this.bareSpec.startsWith(n + "@")) {
|
|
514
|
+
this.bareSpec = reg + this.bareSpec.substring(n.length + 1);
|
|
515
|
+
} else if (this.bareSpec === n) {
|
|
516
|
+
this.bareSpec = reg;
|
|
517
|
+
}
|
|
518
|
+
this.spec = this.name + "@" + this.bareSpec;
|
|
519
|
+
return this.subspec;
|
|
520
|
+
}
|
|
521
|
+
#error(message, extra = {}) {
|
|
522
|
+
return error(message, { spec: this.spec, ...extra }, this.#error);
|
|
523
|
+
}
|
|
524
|
+
#parseGitSelector(s) {
|
|
525
|
+
const h = s.indexOf("#");
|
|
526
|
+
if (h === -1) {
|
|
527
|
+
this.gitRemote = s;
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
this.gitRemote = s.substring(0, h);
|
|
531
|
+
this.gitSelector = s.substring(h + 1);
|
|
532
|
+
const [selectorParsed, committish, range] = this.constructor.parseGitSelector(this.gitSelector, this);
|
|
533
|
+
this.range = range;
|
|
534
|
+
this.gitCommittish = committish;
|
|
535
|
+
this.gitSelectorParsed = selectorParsed;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Should only ever be called with the bit that comes AFTER the #
|
|
539
|
+
* in the git remote url.
|
|
540
|
+
*/
|
|
541
|
+
static parseGitSelector(selector, spec) {
|
|
542
|
+
if (!selector) return [{}];
|
|
543
|
+
const split = selector.split("::");
|
|
544
|
+
const first = split[0];
|
|
545
|
+
let committish = void 0;
|
|
546
|
+
let range = void 0;
|
|
547
|
+
const parsed = {};
|
|
548
|
+
if (typeof first !== "string") {
|
|
549
|
+
throw typeError("impossible", {
|
|
550
|
+
found: first,
|
|
551
|
+
wanted: String
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
if (!first.includes(":")) {
|
|
555
|
+
committish = first;
|
|
556
|
+
split.shift();
|
|
557
|
+
}
|
|
558
|
+
for (const kv of split) {
|
|
559
|
+
const c = kv.indexOf(":");
|
|
560
|
+
if (c === -1) continue;
|
|
561
|
+
const k = kv.substring(0, c);
|
|
562
|
+
const v = kv.substring(c + 1);
|
|
563
|
+
if (k === "semver") {
|
|
564
|
+
if (committish) {
|
|
565
|
+
throw error(
|
|
566
|
+
"Cannot specify a semver range and committish value",
|
|
567
|
+
{ spec }
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
range = parseRange(v);
|
|
571
|
+
if (!range) {
|
|
572
|
+
throw error(`Invalid git tag semver range: ${v}`, { spec });
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
if (k === "semver" || k === "path") {
|
|
576
|
+
if (k === "path") {
|
|
577
|
+
if (
|
|
578
|
+
/* c8 ignore next */
|
|
579
|
+
this.nodejsDependencies?.isAbsolute(
|
|
580
|
+
v
|
|
581
|
+
) || /(^|\/|\\)\.\.($|\\|\/)/.test(v)
|
|
582
|
+
) {
|
|
583
|
+
throw error("Invalid path in git selector", { spec });
|
|
584
|
+
}
|
|
585
|
+
parsed.path = (this.nodejsDependencies ? this.nodejsDependencies.join("/", v).substring(1) : v).replace(/\\/g, "/");
|
|
586
|
+
} else {
|
|
587
|
+
parsed[k] = v;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return [parsed, committish, range];
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
var getNormalizeFile = (opts) => (bareSpec, spec) => {
|
|
595
|
+
const slashes = bareSpec.substring(
|
|
596
|
+
"file:".length,
|
|
597
|
+
"file://".length
|
|
598
|
+
);
|
|
599
|
+
const pref = `file:${slashes === "//" ? slashes : ""}`;
|
|
600
|
+
const rest = bareSpec.substring(pref.length);
|
|
601
|
+
const [a = "", b = "/", c = "/", d = "/"] = rest.split("", 4);
|
|
602
|
+
if (!a) {
|
|
603
|
+
return [".", "file:."];
|
|
604
|
+
}
|
|
605
|
+
if (a === "/" && b === "~" && c !== "/" || a === "~" && b !== "/") {
|
|
606
|
+
throw error(
|
|
607
|
+
`invalid file: specifier. '~username' not supported`,
|
|
608
|
+
{ spec }
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
if (a === "~") {
|
|
612
|
+
return (
|
|
613
|
+
/* c8 ignore start */
|
|
614
|
+
opts ? [
|
|
615
|
+
opts.resolve(opts.homedir(), rest.substring(2)),
|
|
616
|
+
`file:${rest}`
|
|
617
|
+
] : [rest, `file:${rest}`]
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
if (a === "/" && b === "~") {
|
|
621
|
+
return opts ? [
|
|
622
|
+
opts.resolve(opts.homedir(), rest.substring(3)),
|
|
623
|
+
`file:${rest.substring(1)}`
|
|
624
|
+
] : (
|
|
625
|
+
/* c8 ignore stop */
|
|
626
|
+
[rest.substring(1), `file:${rest.substring(1)}`]
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
if (a === "/" && b === "." && (c === "/" || c === "." && d === "/")) {
|
|
630
|
+
return [rest.substring(1), `file:${rest.substring(1)}`];
|
|
631
|
+
}
|
|
632
|
+
if (a === "." && (b === "/" || b === "." && c === "/")) {
|
|
633
|
+
return [rest, `file:${rest}`];
|
|
634
|
+
}
|
|
635
|
+
if (slashes === "//") {
|
|
636
|
+
try {
|
|
637
|
+
const parsed = new URL(bareSpec);
|
|
638
|
+
if (parsed.host) {
|
|
639
|
+
if (parsed.host !== "localhost") {
|
|
640
|
+
throw error(
|
|
641
|
+
`invalid file:// specifier. host must be empty or 'localhost'`,
|
|
642
|
+
{
|
|
643
|
+
spec,
|
|
644
|
+
found: parsed.host,
|
|
645
|
+
validOptions: ["", "localhost"]
|
|
646
|
+
}
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return [
|
|
651
|
+
parsed.pathname.replace(/^\/([a-zA-Z]:\/)/, "$1"),
|
|
652
|
+
`file://${parsed.pathname}`
|
|
653
|
+
];
|
|
654
|
+
} catch (er) {
|
|
655
|
+
throw error("invalid file:// specifier", {
|
|
656
|
+
spec,
|
|
657
|
+
cause: er
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (opts?.winPath.isAbsolute(rest)) {
|
|
662
|
+
return [rest, `file://${rest}`];
|
|
663
|
+
}
|
|
664
|
+
return [`./${rest}`, `file:./${rest}`];
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
// ../../src/spec/src/index.ts
|
|
668
|
+
import { homedir } from "node:os";
|
|
669
|
+
import {
|
|
670
|
+
isAbsolute,
|
|
671
|
+
join,
|
|
672
|
+
resolve,
|
|
673
|
+
win32 as winPath
|
|
674
|
+
} from "node:path";
|
|
675
|
+
import { inspect } from "node:util";
|
|
676
|
+
var Spec2 = class extends Spec {
|
|
677
|
+
[kCustomInspect](_depth, options) {
|
|
678
|
+
const str = inspect(
|
|
679
|
+
Object.fromEntries(
|
|
680
|
+
Object.entries(this).filter(([k, v]) => {
|
|
681
|
+
return k !== "options" && v !== void 0;
|
|
682
|
+
})
|
|
683
|
+
),
|
|
684
|
+
options
|
|
685
|
+
);
|
|
686
|
+
return `@vltpkg/spec.Spec ${str}`;
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
Spec2.nodejsDependencies = {
|
|
690
|
+
homedir,
|
|
691
|
+
isAbsolute,
|
|
692
|
+
join,
|
|
693
|
+
resolve,
|
|
694
|
+
winPath
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
export {
|
|
698
|
+
defaultRegistry,
|
|
699
|
+
defaultRegistryName,
|
|
700
|
+
defaultRegistries,
|
|
701
|
+
defaultJsrRegistries,
|
|
702
|
+
defaultGitHosts,
|
|
703
|
+
defaultGitHostArchives,
|
|
704
|
+
gitHostWebsites,
|
|
705
|
+
defaultScopeRegistries,
|
|
706
|
+
getOptions,
|
|
707
|
+
isSpec,
|
|
708
|
+
currentDefaultRegistryName,
|
|
709
|
+
Spec,
|
|
710
|
+
Spec2
|
|
711
|
+
};
|