@vltpkg/cli-js 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{access-QPX4QXV4.js → access-YSLEWR2C.js} +8 -8
- package/{bugs-TLOECXEM.js → bugs-S6CRUEA2.js} +23 -19
- package/{build-IQOS3LKO.js → build-SG3KPX3W.js} +49 -14
- package/{cache-O5IBYYSB.js → cache-HA77ROM7.js} +16 -13
- package/cache-unzip-src-unzip.js +23 -4
- package/{chunk-3S3W7QEM.js → chunk-3E3ISOYM.js} +10 -5
- package/{chunk-43EJ4Q42.js → chunk-3JIN46K5.js} +1 -1
- package/{chunk-5KW6AOTT.js → chunk-4GMNWW4C.js} +1 -1
- package/{chunk-6W5XMVIZ.js → chunk-4UAIPIAV.js} +7 -7
- package/{chunk-7UWRR6EE.js → chunk-5Q2HSLVV.js} +1 -1
- package/{chunk-LUVDMEW4.js → chunk-6D3QAFNZ.js} +1 -1
- package/{chunk-LH7J5BDU.js → chunk-6XVW7CWJ.js} +3 -3
- package/{chunk-UZ6ICZE3.js → chunk-7M2VTFLP.js} +12 -1
- package/{chunk-XCQCYB6G.js → chunk-AEVT3CHK.js} +142 -16
- package/{chunk-SMXXFQPI.js → chunk-AHLBPSGQ.js} +3 -3
- package/{chunk-6LZM3I4Q.js → chunk-BF5DRGRZ.js} +25 -4
- package/chunk-BH5CVXNY.js +115 -0
- package/{chunk-CS6AYPY5.js → chunk-BQMHDAYL.js} +6 -13
- package/{chunk-2U4PVHP4.js → chunk-C4RJ4NNS.js} +137 -47
- package/{chunk-F7NPYSI2.js → chunk-CAV7FKWQ.js} +2 -2
- package/chunk-DXED4ARV.js +436 -0
- package/chunk-E74WGW5C.js +49 -0
- package/{chunk-CMLDLZZ3.js → chunk-EFHOWRKU.js} +56 -0
- package/{chunk-IFEZ6BFV.js → chunk-EMTGRCSE.js} +2 -2
- package/{chunk-4TSHLSRK.js → chunk-EYGOEAJM.js} +1 -1
- package/{chunk-DBANBIL2.js → chunk-FZCPQWCJ.js} +1 -0
- package/chunk-GCTREKA4.js +115 -0
- package/{chunk-CW56EJIL.js → chunk-HT6FS4VB.js} +1 -1
- package/{chunk-VR7NRWAD.js → chunk-IHERL3TA.js} +17 -16
- package/chunk-JV5XR5JQ.js +349 -0
- package/{chunk-T5EP7QEF.js → chunk-JZXNHIQE.js} +28 -28
- package/{chunk-IJUVVD7E.js → chunk-KD5ZK72K.js} +1 -1
- package/{chunk-C6ZVVEFV.js → chunk-KURQHX54.js} +5 -3
- package/{chunk-GUP55DM6.js → chunk-L3ZF7OYM.js} +2 -2
- package/{chunk-X6JKMIOU.js → chunk-LGQVZTYR.js} +4 -36
- package/{chunk-G3FZ2ZJK.js → chunk-M242QVJS.js} +1 -1
- package/chunk-MCDLJZXT.js +82 -0
- package/{chunk-WHWPAYZY.js → chunk-MSWOR3FV.js} +35 -7
- package/chunk-N3V6EK5I.js +77 -0
- package/{chunk-ISAMD2FE.js → chunk-N6HV7JWC.js} +1 -1
- package/{chunk-MYX4JCIJ.js → chunk-NO53Y3QO.js} +1 -1
- package/chunk-O6MQ7NN6.js +1155 -0
- package/{chunk-XCSNI6AO.js → chunk-OWL5G4K4.js} +4 -4
- package/{chunk-35EG6T3J.js → chunk-Q2UEILN6.js} +21 -9
- package/{chunk-Z5D5KODU.js → chunk-VGPLFOJO.js} +4 -2
- package/{chunk-ARE7FKDG.js → chunk-W24SBFY5.js} +5 -5
- package/{chunk-XD5KUDXX.js → chunk-WMMKUVAT.js} +10 -8
- package/{chunk-4UH3KMTD.js → chunk-ZJE3OTP3.js} +258 -451
- package/{ci-ESVUMOZO.js → ci-GVLL72SS.js} +21 -17
- package/cli-package.json +3 -1
- package/{config-ZVVLFKR7.js → config-KH6AEMHI.js} +13 -12
- package/{config-TMB2X6DW.js → config-TIPKOPYS.js} +10 -9
- package/{create-BLTNKSBQ.js → create-SKNEZEZY.js} +28 -24
- package/{deprecate-VA6PGHYL.js → deprecate-RFRLJZVL.js} +12 -12
- package/{dist-tag-OYJREFO2.js → dist-tag-LVYOTJHJ.js} +8 -8
- package/{docs-6OC3OQNM.js → docs-INXRFEGY.js} +23 -19
- package/{exec-AZPGFVRY.js → exec-5MA5XRPZ.js} +28 -24
- package/{exec-cache-D75UY2WI.js → exec-cache-7GS4KLWJ.js} +24 -20
- package/{exec-local-E2JKB4X4.js → exec-local-RE4KVTMN.js} +22 -18
- package/{help-UPW77X5N.js → help-JHLP565L.js} +5 -4
- package/{init-SNO6QL7C.js → init-4UFHO67B.js} +13 -12
- package/{install-TEJM2YVX.js → install-Z33YVCDK.js} +108 -52
- package/{list-NHCC2RNB.js → list-XAMKR6TL.js} +29 -22
- package/{login-XNZXCGFD.js → login-6NXUO5FF.js} +14 -13
- package/{logout-YCM7O36Q.js → logout-6P7LWTAY.js} +8 -8
- package/{outdated-4LA7N63W.js → outdated-YNUSWZJD.js} +18 -17
- package/{pack-RC4CZSWF.js → pack-LMQYH75V.js} +15 -14
- package/package.json +1 -1
- package/{ping-RLVAZGDL.js → ping-VLFZ3WCY.js} +8 -8
- package/{pkg-FED5C6TP.js → pkg-JMPBHKSW.js} +16 -15
- package/{profile-DJZNLQPG.js → profile-PJJAA2YM.js} +8 -8
- package/{publish-54AMVMTQ.js → publish-33RFJ2HJ.js} +24 -20
- package/{query-ZQLMSJ7O.js → query-LUUOK57K.js} +29 -22
- package/{registry-6HKQYSZX.js → registry-ZGGWVLBM.js} +5 -5
- package/registry-client-src-revalidate.js +41 -11
- package/{repo-ITA4BLZ4.js → repo-VLHLQP2S.js} +23 -19
- package/{reporter-UYVR2WMB.js → reporter-SNSM2TDC.js} +61 -15
- package/{run-TP2HTJRN.js → run-USWK7R3N.js} +22 -18
- package/{run-exec-UGCC53DV.js → run-exec-PHE44AWW.js} +22 -18
- package/security-archive-src-update-expired.js +24 -5
- package/{setup-XPAM5U3Z.js → setup-JMY47ERY.js} +206 -27
- package/{skills-YD2TB2VD.js → skills-7PYMTDER.js} +41 -56
- package/{skills-LR6GXW3X.js → skills-YMMV6TMN.js} +24 -21
- package/{src-34D4DOOH.js → src-2ZS4VHJP.js} +25 -19
- package/{src-H6DFCAPH.js → src-A5ZJNOHN.js} +6 -4
- package/{src-LHDC4NJO.js → src-W2VQULRG.js} +2 -2
- package/{token-OF63PFTQ.js → token-YKHELNVQ.js} +10 -9
- package/{uninstall-B54FQ5KQ.js → uninstall-Q46HWR5S.js} +53 -17
- package/{unpublish-CSHIGMDQ.js → unpublish-LBANPSJ5.js} +8 -8
- package/{update-HS4VJ5ZG.js → update-B2EGLZHI.js} +19 -17
- package/{version-L7S3DHUS.js → version-IEOBL3NN.js} +14 -13
- package/{view-NWKKWFVA.js → view-JCA5VT6F.js} +13 -13
- 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-65K35VGW.js → whoami-OWJUPO3X.js} +8 -8
- 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-
|
|
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-
|
|
29
|
+
} from "./chunk-BF5DRGRZ.js";
|
|
30
30
|
import {
|
|
31
31
|
error
|
|
32
32
|
} from "./chunk-WZWDS3W4.js";
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
isInside,
|
|
14
|
+
samePath
|
|
15
|
+
} from "./chunk-MCDLJZXT.js";
|
|
16
|
+
import {
|
|
17
|
+
isDepID
|
|
18
|
+
} from "./chunk-CAV7FKWQ.js";
|
|
19
|
+
import {
|
|
20
|
+
isObject
|
|
21
|
+
} from "./chunk-BF5DRGRZ.js";
|
|
22
|
+
|
|
23
|
+
// ../../src/cli-sdk/src/global-state.ts
|
|
24
|
+
import { randomBytes } from "node:crypto";
|
|
25
|
+
import {
|
|
26
|
+
chmod,
|
|
27
|
+
readFile,
|
|
28
|
+
realpath,
|
|
29
|
+
rename,
|
|
30
|
+
rm,
|
|
31
|
+
writeFile
|
|
32
|
+
} from "node:fs/promises";
|
|
33
|
+
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
34
|
+
var globalStateFile = (root) => resolve(root, "global-state.json");
|
|
35
|
+
var readGlobalState = async (root) => {
|
|
36
|
+
let data;
|
|
37
|
+
try {
|
|
38
|
+
data = JSON.parse(await readFile(globalStateFile(root), "utf8"));
|
|
39
|
+
} catch {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
if (!isObject(data)) return {};
|
|
43
|
+
const state = { ...data };
|
|
44
|
+
const { binDirs, localBinNoticed } = state;
|
|
45
|
+
if (Array.isArray(binDirs)) {
|
|
46
|
+
state.binDirs = binDirs.filter(
|
|
47
|
+
(d) => typeof d === "string" && isAbsolute(d)
|
|
48
|
+
);
|
|
49
|
+
} else delete state.binDirs;
|
|
50
|
+
if (Array.isArray(state.pendingRemove)) {
|
|
51
|
+
state.pendingRemove = state.pendingRemove.filter(
|
|
52
|
+
(d) => typeof d === "string" && isAbsolute(d)
|
|
53
|
+
);
|
|
54
|
+
} else delete state.pendingRemove;
|
|
55
|
+
if (typeof localBinNoticed !== "boolean")
|
|
56
|
+
delete state.localBinNoticed;
|
|
57
|
+
if (state.pathSetup !== "declined") delete state.pathSetup;
|
|
58
|
+
return state;
|
|
59
|
+
};
|
|
60
|
+
var writeFileAtomic = async (file, data, mode) => {
|
|
61
|
+
const tmp = `${file}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
62
|
+
try {
|
|
63
|
+
await writeFile(tmp, data, {
|
|
64
|
+
flag: "wx",
|
|
65
|
+
...mode === void 0 ? {} : { mode }
|
|
66
|
+
});
|
|
67
|
+
if (mode !== void 0) await chmod(tmp, mode);
|
|
68
|
+
await rename(tmp, file);
|
|
69
|
+
} catch (er) {
|
|
70
|
+
await rm(tmp, { force: true });
|
|
71
|
+
throw er;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var writeJsonAtomic = (file, data) => writeFileAtomic(file, JSON.stringify(data, null, 2) + "\n");
|
|
75
|
+
var updateGlobalState = async (root, fn) => {
|
|
76
|
+
const state = fn(await readGlobalState(root));
|
|
77
|
+
await writeJsonAtomic(globalStateFile(root), state);
|
|
78
|
+
return state;
|
|
79
|
+
};
|
|
80
|
+
var sweepPendingRemove = async (root) => {
|
|
81
|
+
try {
|
|
82
|
+
const { pendingRemove = [] } = await readGlobalState(root);
|
|
83
|
+
if (!pendingRemove.length) return;
|
|
84
|
+
const store = resolve(await realpath(root), "node_modules/.vlt");
|
|
85
|
+
const script = process.argv[1];
|
|
86
|
+
const running = script && await realpath(script).catch(() => void 0);
|
|
87
|
+
const left = [];
|
|
88
|
+
for (const entry of pendingRemove) {
|
|
89
|
+
if (!samePath(dirname(entry), store) || !isDepID(basename(entry))) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (running && isInside(entry, running)) {
|
|
93
|
+
left.push(entry);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
await rm(entry, { recursive: true, force: true }).catch(
|
|
97
|
+
() => left.push(entry)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
if (left.length === pendingRemove.length) return;
|
|
101
|
+
await updateGlobalState(root, (s) => ({
|
|
102
|
+
...s,
|
|
103
|
+
pendingRemove: left
|
|
104
|
+
}));
|
|
105
|
+
} catch {
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
readGlobalState,
|
|
111
|
+
writeFileAtomic,
|
|
112
|
+
writeJsonAtomic,
|
|
113
|
+
updateGlobalState,
|
|
114
|
+
sweepPendingRemove
|
|
115
|
+
};
|