@vltpkg/cli-js 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/{access-QPX4QXV4.js → access-AJ654YKY.js} +8 -8
  2. package/{bugs-TLOECXEM.js → bugs-N73DVYHD.js} +23 -19
  3. package/{build-IQOS3LKO.js → build-VZ3EZKMM.js} +49 -14
  4. package/{cache-O5IBYYSB.js → cache-VROEWG2C.js} +16 -13
  5. package/cache-unzip-src-unzip.js +23 -4
  6. package/{chunk-7UWRR6EE.js → chunk-22LZBDEC.js} +1 -1
  7. package/{chunk-4UH3KMTD.js → chunk-36UIE654.js} +252 -448
  8. package/{chunk-43EJ4Q42.js → chunk-3JIN46K5.js} +1 -1
  9. package/{chunk-35EG6T3J.js → chunk-44AWMA4F.js} +21 -9
  10. package/chunk-4E65BBTM.js +77 -0
  11. package/{chunk-5KW6AOTT.js → chunk-4GMNWW4C.js} +1 -1
  12. package/{chunk-LUVDMEW4.js → chunk-6D3QAFNZ.js} +1 -1
  13. package/{chunk-6W5XMVIZ.js → chunk-75HGJVNG.js} +7 -7
  14. package/{chunk-UZ6ICZE3.js → chunk-7M2VTFLP.js} +12 -1
  15. package/{chunk-XCSNI6AO.js → chunk-ANW36H4T.js} +4 -4
  16. package/{chunk-6LZM3I4Q.js → chunk-BF5DRGRZ.js} +25 -4
  17. package/chunk-BH5CVXNY.js +115 -0
  18. package/{chunk-F7NPYSI2.js → chunk-CAV7FKWQ.js} +2 -2
  19. package/{chunk-MYX4JCIJ.js → chunk-CYK6I4M6.js} +1 -1
  20. package/chunk-DXED4ARV.js +436 -0
  21. package/chunk-E74WGW5C.js +49 -0
  22. package/{chunk-CMLDLZZ3.js → chunk-EFHOWRKU.js} +56 -0
  23. package/{chunk-IFEZ6BFV.js → chunk-EMTGRCSE.js} +2 -2
  24. package/{chunk-4TSHLSRK.js → chunk-EYGOEAJM.js} +1 -1
  25. package/{chunk-2U4PVHP4.js → chunk-F5LZMLAQ.js} +123 -40
  26. package/{chunk-Z5D5KODU.js → chunk-FXD3IV2S.js} +4 -2
  27. package/chunk-GCTREKA4.js +115 -0
  28. package/{chunk-G3FZ2ZJK.js → chunk-GEQFMH5M.js} +1 -1
  29. package/{chunk-CS6AYPY5.js → chunk-GZVI75KX.js} +6 -13
  30. package/{chunk-CW56EJIL.js → chunk-HT6FS4VB.js} +1 -1
  31. package/{chunk-LH7J5BDU.js → chunk-IXAMCWIT.js} +3 -3
  32. package/{chunk-ARE7FKDG.js → chunk-JCNI6ZHH.js} +5 -5
  33. package/chunk-JV5XR5JQ.js +349 -0
  34. package/{chunk-IJUVVD7E.js → chunk-KD5ZK72K.js} +1 -1
  35. package/{chunk-WHWPAYZY.js → chunk-KVWGMSPW.js} +26 -6
  36. package/{chunk-VR7NRWAD.js → chunk-LCLRP64K.js} +8 -8
  37. package/{chunk-X6JKMIOU.js → chunk-LGQVZTYR.js} +4 -36
  38. package/{chunk-XCQCYB6G.js → chunk-LP3ORD3D.js} +142 -16
  39. package/chunk-MCDLJZXT.js +82 -0
  40. package/{chunk-ISAMD2FE.js → chunk-N6HV7JWC.js} +1 -1
  41. package/chunk-O6MQ7NN6.js +1155 -0
  42. package/{chunk-3S3W7QEM.js → chunk-PC2HOBAQ.js} +3 -3
  43. package/{chunk-GUP55DM6.js → chunk-RBQO54TG.js} +2 -2
  44. package/{chunk-C6ZVVEFV.js → chunk-TQQO2F56.js} +4 -3
  45. package/{chunk-XD5KUDXX.js → chunk-TWDSXQPN.js} +10 -8
  46. package/{chunk-T5EP7QEF.js → chunk-VLVMLSIF.js} +2 -2
  47. package/{chunk-SMXXFQPI.js → chunk-YTDABXPD.js} +3 -3
  48. package/{ci-ESVUMOZO.js → ci-3BVMVQIT.js} +21 -17
  49. package/cli-package.json +3 -1
  50. package/{config-ZVVLFKR7.js → config-2KQV7N5A.js} +12 -11
  51. package/{config-TMB2X6DW.js → config-EKHBW6I5.js} +10 -9
  52. package/{create-BLTNKSBQ.js → create-QVHNOIV3.js} +28 -24
  53. package/{deprecate-VA6PGHYL.js → deprecate-E254QBH6.js} +12 -12
  54. package/{dist-tag-OYJREFO2.js → dist-tag-SITRFD7O.js} +8 -8
  55. package/{docs-6OC3OQNM.js → docs-IDL2P7CA.js} +23 -19
  56. package/{exec-AZPGFVRY.js → exec-7BK2W2WL.js} +28 -24
  57. package/{exec-cache-D75UY2WI.js → exec-cache-VY46L7DR.js} +24 -20
  58. package/{exec-local-E2JKB4X4.js → exec-local-D7R5T3DF.js} +22 -18
  59. package/{help-UPW77X5N.js → help-RMRIEJQL.js} +5 -4
  60. package/{init-SNO6QL7C.js → init-BGW4HJ6V.js} +13 -12
  61. package/{install-TEJM2YVX.js → install-U5GATZ2N.js} +108 -52
  62. package/{list-NHCC2RNB.js → list-3VG4M2XL.js} +29 -22
  63. package/{login-XNZXCGFD.js → login-PHQWI6S6.js} +14 -13
  64. package/{logout-YCM7O36Q.js → logout-DJCOGRFF.js} +8 -8
  65. package/{outdated-4LA7N63W.js → outdated-JH3O6R3Y.js} +18 -17
  66. package/{pack-RC4CZSWF.js → pack-U5W5YWHK.js} +15 -14
  67. package/package.json +1 -1
  68. package/{ping-RLVAZGDL.js → ping-EKX43AOW.js} +8 -8
  69. package/{pkg-FED5C6TP.js → pkg-SW5GMERT.js} +15 -14
  70. package/{profile-DJZNLQPG.js → profile-UGDRDMQ6.js} +8 -8
  71. package/{publish-54AMVMTQ.js → publish-HTWKK3NN.js} +24 -20
  72. package/{query-ZQLMSJ7O.js → query-YE3FUVGG.js} +29 -22
  73. package/{registry-6HKQYSZX.js → registry-ZGGWVLBM.js} +5 -5
  74. package/registry-client-src-revalidate.js +41 -11
  75. package/{repo-ITA4BLZ4.js → repo-WDOCU6SE.js} +23 -19
  76. package/{reporter-UYVR2WMB.js → reporter-N5PAXB26.js} +61 -15
  77. package/{run-TP2HTJRN.js → run-IPARVIIQ.js} +22 -18
  78. package/{run-exec-UGCC53DV.js → run-exec-C4RTREEW.js} +22 -18
  79. package/security-archive-src-update-expired.js +24 -5
  80. package/{setup-XPAM5U3Z.js → setup-SYYUEHZL.js} +206 -27
  81. package/{skills-YD2TB2VD.js → skills-KA2VR5Q5.js} +41 -56
  82. package/{skills-LR6GXW3X.js → skills-UBBMSBDQ.js} +24 -21
  83. package/{src-34D4DOOH.js → src-FUSTSM4J.js} +25 -19
  84. package/{src-H6DFCAPH.js → src-QO5G2S4O.js} +6 -4
  85. package/{src-LHDC4NJO.js → src-W2VQULRG.js} +2 -2
  86. package/{token-OF63PFTQ.js → token-UQNABECH.js} +10 -9
  87. package/{uninstall-B54FQ5KQ.js → uninstall-FHBJ3OUV.js} +53 -17
  88. package/{unpublish-CSHIGMDQ.js → unpublish-APJTEUBA.js} +8 -8
  89. package/{update-HS4VJ5ZG.js → update-NWZTL4S7.js} +19 -17
  90. package/{version-L7S3DHUS.js → version-EMKKTL77.js} +14 -13
  91. package/{view-NWKKWFVA.js → view-BUUI33RV.js} +12 -12
  92. package/vlr.js +1 -1
  93. package/vlrx.js +1 -1
  94. package/vlt.js +1 -1
  95. package/vlx.js +1 -1
  96. package/vlxl.js +1 -1
  97. package/{whoami-65K35VGW.js → whoami-F6BSXGQ2.js} +8 -8
  98. package/chunk-T2VBCUF5.js +0 -77
@@ -0,0 +1,436 @@
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
+ findSelf,
14
+ globalSpec,
15
+ writeInstallReceipt
16
+ } from "./chunk-O6MQ7NN6.js";
17
+ import {
18
+ prettyPath
19
+ } from "./chunk-BH5CVXNY.js";
20
+ import {
21
+ findCmdShimIfExists
22
+ } from "./chunk-JV5XR5JQ.js";
23
+ import {
24
+ loadPackageJson
25
+ } from "./chunk-E74WGW5C.js";
26
+ import {
27
+ readGlobalState,
28
+ updateGlobalState
29
+ } from "./chunk-GCTREKA4.js";
30
+ import {
31
+ globalWorkspacePath,
32
+ isInside,
33
+ samePath
34
+ } from "./chunk-MCDLJZXT.js";
35
+ import {
36
+ parseSpecArg
37
+ } from "./chunk-7M2VTFLP.js";
38
+ import {
39
+ isDepID
40
+ } from "./chunk-CAV7FKWQ.js";
41
+ import {
42
+ Spec
43
+ } from "./chunk-6D3QAFNZ.js";
44
+ import {
45
+ which
46
+ } from "./chunk-SUU2WETN.js";
47
+ import {
48
+ lt,
49
+ valid
50
+ } from "./chunk-BF5DRGRZ.js";
51
+ import {
52
+ error
53
+ } from "./chunk-WZWDS3W4.js";
54
+
55
+ // ../../src/cli-sdk/src/self-update.ts
56
+ import { spawn } from "node:child_process";
57
+ import { createHash } from "node:crypto";
58
+ import { constants, existsSync } from "node:fs";
59
+ import {
60
+ access,
61
+ chmod,
62
+ lstat,
63
+ readFile,
64
+ realpath,
65
+ rename,
66
+ rm,
67
+ stat
68
+ } from "node:fs/promises";
69
+ import {
70
+ basename,
71
+ dirname,
72
+ extname,
73
+ join,
74
+ relative,
75
+ resolve,
76
+ sep
77
+ } from "node:path";
78
+ var { version: running } = loadPackageJson(
79
+ import.meta.filename,
80
+ "cli-package.json"
81
+ );
82
+ var installerLine = "Re-run the installer to update vlt:\n curl -fsSL https://install.vlt.sh | bash";
83
+ var writable = (dir) => access(dir, constants.W_OK).then(
84
+ () => true,
85
+ () => false
86
+ );
87
+ var refuse = (self, message) => {
88
+ process.exitCode = 1;
89
+ return { status: "refused", from: running, dir: self.dir, message };
90
+ };
91
+ var isFile = (f) => stat(f).then(
92
+ (s) => s.isFile(),
93
+ () => false
94
+ );
95
+ var cellars = () => [
96
+ process.env.HOMEBREW_CELLAR,
97
+ "/opt/homebrew/Cellar",
98
+ "/usr/local/Cellar",
99
+ "/home/linuxbrew/.linuxbrew/Cellar"
100
+ ].filter((c) => !!c);
101
+ var whichNpm = async () => {
102
+ try {
103
+ const found = await which("npm", { nothrow: true });
104
+ if (!found) return;
105
+ const real = await realpath(
106
+ (await findCmdShimIfExists(found))?.[1] ?? found
107
+ );
108
+ return basename(real) === "npm-cli.js" ? real : void 0;
109
+ } catch {
110
+ }
111
+ };
112
+ var findNpm = async (self) => {
113
+ const i = self.target.lastIndexOf(
114
+ `${sep}node_modules${sep}vlt${sep}`
115
+ );
116
+ if (i === -1) return;
117
+ const nm = self.target.slice(0, i) + sep + "node_modules";
118
+ const win32 = process.platform === "win32";
119
+ const up = dirname(nm);
120
+ const prefix = win32 ? (
121
+ // vlt.cmd is in the prefix
122
+ samePath(up, self.dir) && up
123
+ ) : basename(up) === "lib" && dirname(up);
124
+ if (!prefix) return;
125
+ const node = dirname(process.execPath);
126
+ const candidates = [
127
+ join(nm, "npm/bin/npm-cli.js"),
128
+ win32 ? join(node, "node_modules/npm/bin/npm-cli.js") : join(dirname(node), "lib/node_modules/npm/bin/npm-cli.js")
129
+ ];
130
+ for (const c of candidates) {
131
+ if (await isFile(c)) return { npmCli: c, prefix };
132
+ }
133
+ const npmCli = await whichNpm();
134
+ return npmCli && { npmCli, prefix };
135
+ };
136
+ var classify = async (self, root) => {
137
+ const g = await realpath(root).catch(() => resolve(root));
138
+ if (isInside(g, self.target)) return { kind: "global-project" };
139
+ const { receipt } = self;
140
+ if (receipt?.data.method === "standalone") {
141
+ if (self.standalone)
142
+ return { kind: "standalone-receipt", receipt };
143
+ } else if (receipt) {
144
+ const npm2 = receipt.data.method === "npm" && await findNpm(self);
145
+ return npm2 ? { kind: "npm", ...npm2, receipt } : { kind: "installer" };
146
+ }
147
+ if (cellars().some((c) => isInside(c, self.target))) {
148
+ return { kind: "homebrew" };
149
+ }
150
+ if (self.standalone) return { kind: "standalone" };
151
+ const npm = await findNpm(self);
152
+ return npm ? { kind: "npm", ...npm } : { kind: "unknown" };
153
+ };
154
+ var sha512 = async (file) => `sha512-${createHash("sha512").update(await readFile(file)).digest("base64")}`;
155
+ var safeBin = (b) => /^[a-z0-9][\w.-]*$/i.test(b);
156
+ var updateStandalone = async (self, receipt, to, fetchRelease) => {
157
+ const { target, channel, binaries = [] } = receipt.data;
158
+ if (!fetchRelease || !target) return installerLine;
159
+ const win32 = process.platform === "win32";
160
+ const at = prettyPath(self.dir);
161
+ if (!win32 && (await stat(self.found)).uid === 0 && process.getuid?.() !== 0) {
162
+ return `vlt at ${at} is owned by root. Update it the way you installed it, or run this as root.`;
163
+ }
164
+ if (!await writable(self.dir)) {
165
+ return `vlt at ${at} is not writable. Update it the way you installed it.`;
166
+ }
167
+ const ext = extname(self.found).toLowerCase() === ".exe" ? ".exe" : "";
168
+ const entries = [];
169
+ for (const bin of new Set(binaries)) {
170
+ if (bin === "vlt" || !safeBin(bin)) continue;
171
+ const file = join(self.dir, bin + ext);
172
+ const st = await lstat(file).catch(() => void 0);
173
+ if (st && !st.isSymbolicLink()) entries.push({ bin, file });
174
+ }
175
+ entries.push({
176
+ bin: "vlt",
177
+ file: join(self.dir, basename(self.found))
178
+ });
179
+ const tmps = [];
180
+ const cleanup = () => Promise.all(tmps.map((f) => rm(f, { force: true })));
181
+ const ready = [];
182
+ try {
183
+ for (const { bin, file } of entries) {
184
+ if (win32)
185
+ await rm(`${file}.old`, { force: true }).catch(() => {
186
+ });
187
+ const dest = join(self.dir, `.${bin}-${to}.tmp`);
188
+ tmps.push(dest);
189
+ const { checksum } = await fetchRelease({
190
+ version: to,
191
+ target,
192
+ channel,
193
+ bin,
194
+ dest
195
+ });
196
+ const found = await sha512(dest);
197
+ if (found !== checksum) {
198
+ throw error(`Checksum mismatch for ${bin} ${to}`, {
199
+ code: "EINTEGRITY",
200
+ wanted: checksum,
201
+ found
202
+ });
203
+ }
204
+ await chmod(dest, (await stat(file)).mode & 511);
205
+ ready.push({ file, dest });
206
+ }
207
+ } catch (er) {
208
+ await cleanup();
209
+ throw er;
210
+ }
211
+ for (const { file, dest } of ready) {
212
+ try {
213
+ if (win32) {
214
+ await rename(file, `${file}.old`);
215
+ await rename(dest, file).catch(async (er) => {
216
+ await rename(`${file}.old`, file).catch(() => {
217
+ });
218
+ throw er;
219
+ });
220
+ } else {
221
+ await rename(dest, file);
222
+ }
223
+ } catch (cause) {
224
+ await cleanup();
225
+ throw error(
226
+ `Could not replace ${file}. Close other vlt processes and editors, and check permissions.`,
227
+ { path: file, cause }
228
+ );
229
+ }
230
+ }
231
+ };
232
+ var runNpm = (npmCli, prefix, arg) => new Promise((res, rej) => {
233
+ const child = spawn(
234
+ process.execPath,
235
+ [npmCli, "install", "--global", "--prefix", prefix, arg],
236
+ { stdio: ["inherit", 2, 2] }
237
+ );
238
+ child.on("error", rej);
239
+ child.on("close", (code) => res(code ?? 1));
240
+ });
241
+ var rewriteReceipt = (receipt, to) => receipt && writeInstallReceipt(receipt.file, { version: to }).catch(() => {
242
+ });
243
+ var vltArg = /^vlt(@|$)|(^|[/\\:])vlt-\d[^/\\]*\.tgz$/;
244
+ var isSelfUpdateArgs = (conf) => conf.command === "install" && !!conf.globalRoot && conf.positionals.some((p) => vltArg.test(p));
245
+ var selfUpdate = async (conf, { fetchRelease } = {}) => {
246
+ const { globalRoot, positionals } = conf;
247
+ if (!globalRoot || !positionals.length) return;
248
+ const specs = await Promise.all(
249
+ positionals.map((p) => globalSpec(p, conf))
250
+ );
251
+ const [spec] = specs;
252
+ if (!spec || !specs.some((s) => s.name === "vlt")) return;
253
+ if (specs.length > 1) {
254
+ throw error("Update vlt on its own, without other packages", {
255
+ code: "EUSAGE",
256
+ found: positionals.join(" ")
257
+ });
258
+ }
259
+ const self = await findSelf();
260
+ if (!self) {
261
+ throw error(
262
+ `Can't tell which vlt to update: run the vlt on your PATH, not ${process.argv[1] ?? process.execPath}`,
263
+ { code: "EUSAGE" }
264
+ );
265
+ }
266
+ const owner = await classify(self, globalRoot);
267
+ const at = prettyPath(self.dir);
268
+ const foreign = `vlt at ${at} is not managed by vlt or npm. Update it the way you installed it.`;
269
+ if (owner.kind === "installer") {
270
+ return { done: refuse(self, installerLine) };
271
+ }
272
+ if (owner.kind === "homebrew") {
273
+ return {
274
+ done: refuse(
275
+ self,
276
+ `vlt at ${at} was installed by Homebrew. Run \`brew upgrade vlt\`.`
277
+ )
278
+ };
279
+ }
280
+ if (owner.kind === "standalone") {
281
+ return { done: refuse(self, foreign) };
282
+ }
283
+ const bootstrap = (owner.kind === "npm" || owner.kind === "unknown") && !await writable(self.dir);
284
+ if (owner.kind === "unknown" && !bootstrap) {
285
+ return { done: refuse(self, foreign) };
286
+ }
287
+ const raw = String(positionals[0]);
288
+ const implicit = !parseSpecArg(raw, conf.options).bareSpec;
289
+ const receipt = "receipt" in owner ? owner.receipt : void 0;
290
+ const channel = receipt?.data.channel;
291
+ const tag = channel ?? conf.options.tag;
292
+ const { name, version: to } = await conf.options.packageInfo.manifest(
293
+ implicit && channel ? Spec.parse("vlt", tag, conf.options) : spec
294
+ );
295
+ if (name !== "vlt" || !to) {
296
+ throw error(`${raw} is not a version of vlt`, {
297
+ code: "EUSAGE",
298
+ found: name
299
+ });
300
+ }
301
+ const kind = bootstrap ? "bootstrap" : owner.kind === "standalone-receipt" ? "standalone" : owner.kind === "npm" ? "npm" : "global-project";
302
+ const base = { case: kind, from: running, to, dir: self.dir };
303
+ if (to === running)
304
+ return { done: { ...base, status: "up-to-date" } };
305
+ if (implicit && lt(to, running)) {
306
+ return { done: { ...base, status: "newer-running", tag } };
307
+ }
308
+ const registry = spec.final.type === "registry";
309
+ if (owner.kind === "standalone-receipt") {
310
+ if (!registry || !valid(to)) {
311
+ throw error(`${raw} is not a vlt release`, {
312
+ code: "EUSAGE",
313
+ found: raw
314
+ });
315
+ }
316
+ const refused = await updateStandalone(
317
+ self,
318
+ owner.receipt,
319
+ to,
320
+ fetchRelease
321
+ );
322
+ if (refused) return { done: refuse(self, refused) };
323
+ await rewriteReceipt(owner.receipt, to);
324
+ return { done: { ...base, status: "updated" } };
325
+ }
326
+ if (owner.kind === "npm" && !bootstrap) {
327
+ const code = await runNpm(
328
+ owner.npmCli,
329
+ owner.prefix,
330
+ registry ? `vlt@${to}` : `vlt@${spec.bareSpec}`
331
+ );
332
+ if (code !== 0) {
333
+ process.exitCode = code;
334
+ return { done: { ...base, status: "failed" } };
335
+ }
336
+ await rewriteReceipt(receipt, to);
337
+ return { done: { ...base, status: "updated" } };
338
+ }
339
+ if (registry) conf.positionals = [`vlt@${to}`];
340
+ return {
341
+ selfUnwritable: bootstrap,
342
+ finish: async (global) => {
343
+ const u = {
344
+ ...base,
345
+ status: "updated",
346
+ dir: global?.binDir ?? self.dir,
347
+ ...bootstrap ? { notWritable: self.dir } : {}
348
+ };
349
+ if (bootstrap && global?.inPath && global.bins.includes("vlt")) {
350
+ const now = await which("vlt", { nothrow: true }).catch(
351
+ () => null
352
+ );
353
+ const first = now && dirname(now);
354
+ if (first && !samePath(
355
+ await realpath(first).catch(() => first),
356
+ global.binDir
357
+ )) {
358
+ u.shadowedBy = first;
359
+ }
360
+ }
361
+ return u;
362
+ }
363
+ };
364
+ };
365
+ var refuseSelfUninstall = async (conf) => {
366
+ const { globalRoot, positionals } = conf;
367
+ if (!globalRoot || !positionals.includes("vlt")) return;
368
+ const ws = resolve(globalRoot, globalWorkspacePath("vlt"));
369
+ if (existsSync(resolve(ws, "package.json"))) return;
370
+ const self = await findSelf();
371
+ if (!self) return;
372
+ const { kind } = await classify(self, globalRoot);
373
+ return refuse(
374
+ self,
375
+ kind === "npm" ? "vlt was installed by npm. Run `npm uninstall -g vlt` to remove it." : kind === "homebrew" ? "vlt was installed by Homebrew. Run `brew uninstall vlt` to remove it." : `vlt at ${prettyPath(self.dir)} is not managed by vlt. Remove it the way you installed it.`
376
+ );
377
+ };
378
+ var runningStoreDep = async (root) => {
379
+ const script = process.argv[1];
380
+ if (!script) return;
381
+ try {
382
+ const [real, store] = await Promise.all([
383
+ realpath(script),
384
+ realpath(resolve(root, "node_modules/.vlt"))
385
+ ]);
386
+ const [id] = relative(store, real).split(sep);
387
+ return isDepID(id) ? id : void 0;
388
+ } catch {
389
+ }
390
+ };
391
+ var deferSelfRemove = async (root, graph, keep) => {
392
+ const store = resolve(await realpath(root), "node_modules/.vlt");
393
+ const add = keep && !graph.nodes.has(keep) ? [resolve(store, keep)] : [];
394
+ const { pendingRemove = [] } = await readGlobalState(root);
395
+ const kept = pendingRemove.filter((p) => {
396
+ const id = basename(p);
397
+ return !(isDepID(id) && graph.nodes.has(id));
398
+ });
399
+ if (!add.length && kept.length === pendingRemove.length) return;
400
+ await updateGlobalState(root, (s) => ({
401
+ ...s,
402
+ pendingRemove: [.../* @__PURE__ */ new Set([...kept, ...add])]
403
+ }));
404
+ };
405
+ var selfUpdateLines = (s) => {
406
+ if (s.status === "refused") return [s.message];
407
+ if (s.status === "up-to-date") {
408
+ return [`\u2705 vlt ${s.to} is already up to date`];
409
+ }
410
+ if (s.status === "newer-running") {
411
+ return [
412
+ `\u2139\uFE0F vlt ${s.from} is running but "${s.tag}" is ${s.to}; run \`vlt i -g vlt@${s.tag}\` to downgrade`
413
+ ];
414
+ }
415
+ if (s.status === "failed") return [];
416
+ if (s.case === "bootstrap") {
417
+ return [
418
+ `\u2139\uFE0F ${prettyPath(s.notWritable ?? s.dir)} is not writable, so vlt ${s.to} was installed as a global package.`,
419
+ ...s.shadowedBy ? [
420
+ `\u26A0\uFE0F ${prettyPath(s.shadowedBy)} is earlier in your PATH, so \`vlt\` still runs vlt ${s.from}.`
421
+ ] : []
422
+ ];
423
+ }
424
+ return [
425
+ `\u2B06\uFE0F Updated vlt ${s.from} \u2192 ${s.to} in ${prettyPath(s.dir)}${s.case === "npm" ? " (via npm)" : ""}`
426
+ ];
427
+ };
428
+
429
+ export {
430
+ isSelfUpdateArgs,
431
+ selfUpdate,
432
+ refuseSelfUninstall,
433
+ runningStoreDep,
434
+ deferSelfRemove,
435
+ selfUpdateLines
436
+ };
@@ -0,0 +1,49 @@
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
+
13
+ // ../../node_modules/.vlt/~npm~package-json-from-dist@1.0.1/node_modules/package-json-from-dist/dist/esm/index.js
14
+ import { readFileSync } from "node:fs";
15
+ import { dirname, resolve, sep } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+ var NM = `${sep}node_modules${sep}`;
18
+ var STORE = `.store${sep}`;
19
+ var PKG = `${sep}package${sep}`;
20
+ var DIST = `${sep}dist${sep}`;
21
+ var findPackageJson = (from, pathFromSrc = "../package.json") => {
22
+ const f = typeof from === "object" || from.startsWith("file://") ? fileURLToPath(from) : from;
23
+ const __dirname = dirname(f);
24
+ const nms = __dirname.lastIndexOf(NM);
25
+ if (nms !== -1) {
26
+ const nm = __dirname.substring(0, nms + NM.length);
27
+ const pkgDir = __dirname.substring(nms + NM.length);
28
+ if (pkgDir.startsWith(STORE)) {
29
+ const pkg = pkgDir.indexOf(PKG, STORE.length);
30
+ if (pkg) {
31
+ return resolve(nm, pkgDir.substring(0, pkg + PKG.length), "package.json");
32
+ }
33
+ }
34
+ const pkgName = pkgDir.startsWith("@") ? pkgDir.split(sep, 2).join(sep) : String(pkgDir.split(sep)[0]);
35
+ return resolve(nm, pkgName, "package.json");
36
+ } else {
37
+ const d = __dirname.lastIndexOf(DIST);
38
+ if (d !== -1) {
39
+ return resolve(__dirname.substring(0, d), "package.json");
40
+ } else {
41
+ return resolve(__dirname, pathFromSrc);
42
+ }
43
+ }
44
+ };
45
+ var loadPackageJson = (from, pathFromSrc = "../package.json") => JSON.parse(readFileSync(findPackageJson(from, pathFromSrc), "utf8"));
46
+
47
+ export {
48
+ loadPackageJson
49
+ };
@@ -1518,6 +1518,62 @@ var definition = j2.heading("Configuration").description(
1518
1518
  description: `Specify named workspace group names to load and operate on
1519
1519
  when doing recursive operations on workspaces.`
1520
1520
  }
1521
+ }).flag({
1522
+ global: {
1523
+ short: "g",
1524
+ description: `Operate on the global project instead of the current
1525
+ one. Supported by \`install\`, \`uninstall\`, \`list\`,
1526
+ \`query\` and \`build\`.
1527
+
1528
+ Each global package is installed in its own workspace of
1529
+ the project in \`--global-dir\`, and its bins are linked
1530
+ into \`--global-bin-dir\`.`
1531
+ }
1532
+ }).opt({
1533
+ "global-dir": {
1534
+ hint: "path",
1535
+ default: xdg.data("global"),
1536
+ description: `Location of the global project used by \`--global\`.
1537
+ Defaults to \`vlt/global\` in the XDG data directory.
1538
+
1539
+ Only read from the command line, environment or the user
1540
+ config, never from a project \`vlt.json\`. A leading
1541
+ \`~\` is the home directory. Must be absolute in the
1542
+ user config.`
1543
+ }
1544
+ }).opt({
1545
+ "global-bin-dir": {
1546
+ hint: "path",
1547
+ description: `Folder where bins of global packages are linked.
1548
+
1549
+ Defaults to the folder of the \`vlt\` found in your
1550
+ \`PATH\` when it is writable, so bins run right away.
1551
+ If it is not writable, \`~/.local/bin\` is used when
1552
+ it is in your \`PATH\` (not on Windows). Otherwise
1553
+ \`<global-dir>/bin\`.
1554
+
1555
+ Only read from the command line, environment or the
1556
+ user config, never from a project \`vlt.json\`. A
1557
+ leading \`~\` is the home directory. Must be absolute
1558
+ in the user config.`
1559
+ }
1560
+ }).flag({
1561
+ path: {
1562
+ description: `With \`vlt setup\`, add the global bin folder
1563
+ (\`--global-bin-dir\`) to your \`PATH\` by editing
1564
+ your shell config (your user \`Path\` on Windows).
1565
+ Asks first, unless \`--yes\`. Command line only.`
1566
+ },
1567
+ "no-modify-path": {
1568
+ description: `Never edit shell config files (or the user
1569
+ \`Path\` on Windows) to add a folder to your
1570
+ \`PATH\`: turns off \`vlt setup --path\` edits
1571
+ and the \`vlt install -g\` offer (printing the line
1572
+ to add instead), and the \`vlt setup\` PATH prompt.
1573
+ Set \`VLT_NO_MODIFY_PATH=1\` (any value but \`0\`)
1574
+ in images or on machines whose dotfiles are
1575
+ managed elsewhere.`
1576
+ }
1521
1577
  }).opt({
1522
1578
  scope: {
1523
1579
  short: "s",
@@ -11,7 +11,7 @@ import {createRequire as _vlt_createRequire} from "node:module";
11
11
  var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  Spec
14
- } from "./chunk-LUVDMEW4.js";
14
+ } from "./chunk-6D3QAFNZ.js";
15
15
  import {
16
16
  promiseSpawn,
17
17
  whichSync
@@ -26,7 +26,7 @@ import {
26
26
  isSpec,
27
27
  parse,
28
28
  satisfies
29
- } from "./chunk-6LZM3I4Q.js";
29
+ } from "./chunk-BF5DRGRZ.js";
30
30
  import {
31
31
  error
32
32
  } from "./chunk-WZWDS3W4.js";
@@ -12,7 +12,7 @@ var require = _vlt_createRequire(import.meta.filename);
12
12
  import {
13
13
  isError,
14
14
  isObject
15
- } from "./chunk-6LZM3I4Q.js";
15
+ } from "./chunk-BF5DRGRZ.js";
16
16
 
17
17
  // ../../src/output/src/error.ts
18
18
  var parseError = (err) => {