@vantaloom/cli 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.mjs +57 -9
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -44,6 +44,8 @@ if (shouldDisableTLS()) {
|
|
|
44
44
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
const cliVersion = readJSONIfExists(path.join(cliRoot, "package.json")).version ?? "unknown"
|
|
48
|
+
|
|
47
49
|
export async function main(argv) {
|
|
48
50
|
const command = argv[0] ?? "help"
|
|
49
51
|
const options = parseOptions(argv.slice(1))
|
|
@@ -53,6 +55,10 @@ export async function main(argv) {
|
|
|
53
55
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
if (command === "install" || command === "update") {
|
|
59
|
+
console.log(`vantaloom-cli v${cliVersion} (${platformId()})`)
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
switch (command) {
|
|
57
63
|
case "install":
|
|
58
64
|
if (options.package) {
|
|
@@ -218,15 +224,45 @@ async function applyPackage(packageRoot, prefix, options) {
|
|
|
218
224
|
// don't write tray.pid, so vantaloomctl stop won't find them).
|
|
219
225
|
killTrayProcess(prefix)
|
|
220
226
|
|
|
227
|
+
// Copy package contents to install prefix
|
|
221
228
|
for (const name of ["bin", "web", "cli"]) {
|
|
222
|
-
|
|
223
|
-
|
|
229
|
+
const src = path.join(packageRoot, name)
|
|
230
|
+
const dst = path.join(prefix, name)
|
|
231
|
+
if (!existsSync(src)) {
|
|
232
|
+
console.error(` warning: package missing ${name}/ directory`)
|
|
233
|
+
continue
|
|
234
|
+
}
|
|
235
|
+
removeKnownPath(dst, prefix)
|
|
236
|
+
await cp(src, dst, {
|
|
224
237
|
recursive: true,
|
|
225
238
|
force: true,
|
|
226
239
|
dereference: false,
|
|
227
240
|
})
|
|
228
241
|
}
|
|
229
242
|
|
|
243
|
+
// Ensure binaries are executable on Unix (cross-compiled from Windows they lose +x)
|
|
244
|
+
const binDir = path.join(prefix, "bin")
|
|
245
|
+
if (process.platform !== "win32" && existsSync(binDir)) {
|
|
246
|
+
for (const entry of readdirSync(binDir)) {
|
|
247
|
+
const binPath = path.join(binDir, entry)
|
|
248
|
+
try { chmodSync(binPath, 0o755) } catch {}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Verify vantaloomctl binary exists before trying to run it
|
|
253
|
+
const ctlBin = path.join(prefix, "bin", binaryName("vantaloomctl"))
|
|
254
|
+
if (!existsSync(ctlBin)) {
|
|
255
|
+
const binContents = existsSync(binDir) ? readdirSync(binDir) : []
|
|
256
|
+
const srcBinContents = existsSync(path.join(packageRoot, "bin")) ? readdirSync(path.join(packageRoot, "bin")) : []
|
|
257
|
+
throw new Error(
|
|
258
|
+
`vantaloomctl binary not found at ${ctlBin}\n` +
|
|
259
|
+
` installed bin/: [${binContents.join(", ")}]\n` +
|
|
260
|
+
` package bin/: [${srcBinContents.join(", ")}]\n` +
|
|
261
|
+
` platform: ${platformId()}\n` +
|
|
262
|
+
` This may indicate a corrupt download. Try again or install from source.`
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
230
266
|
await writeLauncher(prefix)
|
|
231
267
|
await writeText(path.join(prefix, "cli", "config.json"), `${JSON.stringify(mergedConfig, null, 2)}\n`)
|
|
232
268
|
await writeText(path.join(prefix, "VERSION"), `${version}\n`)
|
|
@@ -234,7 +270,7 @@ async function applyPackage(packageRoot, prefix, options) {
|
|
|
234
270
|
force: true,
|
|
235
271
|
})
|
|
236
272
|
|
|
237
|
-
run(
|
|
273
|
+
run(ctlBin, [
|
|
238
274
|
"install",
|
|
239
275
|
"--prefix",
|
|
240
276
|
prefix,
|
|
@@ -243,7 +279,7 @@ async function applyPackage(packageRoot, prefix, options) {
|
|
|
243
279
|
])
|
|
244
280
|
|
|
245
281
|
if (!options.noStart) {
|
|
246
|
-
run(
|
|
282
|
+
run(ctlBin, [
|
|
247
283
|
"start",
|
|
248
284
|
"--prefix",
|
|
249
285
|
prefix,
|
|
@@ -511,11 +547,22 @@ async function resolveNpmPackage({ registry, name, version }) {
|
|
|
511
547
|
}
|
|
512
548
|
|
|
513
549
|
async function downloadNpmTarball({ tarballUrl, target, packageName, version }) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
550
|
+
console.log(` downloading ${packageName}@${version}...`)
|
|
551
|
+
let response
|
|
552
|
+
try {
|
|
553
|
+
response = await fetch(tarballUrl, {
|
|
554
|
+
headers: {
|
|
555
|
+
"User-Agent": "vantaloom-cli",
|
|
556
|
+
},
|
|
557
|
+
signal: AbortSignal.timeout(120000),
|
|
558
|
+
})
|
|
559
|
+
} catch (error) {
|
|
560
|
+
const causeCode = error?.cause?.code || ""
|
|
561
|
+
const causeMsg = causeCode || error?.cause?.message || error.message || ""
|
|
562
|
+
const isSsl = causeCode.includes("CERT") || causeCode === "UNABLE_TO_GET_ISSUER_CERT_LOCALLY"
|
|
563
|
+
const hint = isSsl ? `\n Fix: run with --no-strict-ssl` : ""
|
|
564
|
+
throw new Error(`failed to download ${packageName}@${version} from ${tarballUrl}: ${causeMsg}${hint}`)
|
|
565
|
+
}
|
|
519
566
|
if (!response.ok) {
|
|
520
567
|
const detail = await response.text().catch(() => "")
|
|
521
568
|
throw new Error(`failed to download ${packageName}@${version}: HTTP ${response.status}${detail ? ` ${detail.slice(0, 200)}` : ""}`)
|
|
@@ -523,6 +570,7 @@ async function downloadNpmTarball({ tarballUrl, target, packageName, version })
|
|
|
523
570
|
|
|
524
571
|
const buffer = Buffer.from(await response.arrayBuffer())
|
|
525
572
|
await writeFile(target, buffer)
|
|
573
|
+
console.log(` downloaded ${(buffer.length / 1024 / 1024).toFixed(1)} MB`)
|
|
526
574
|
}
|
|
527
575
|
|
|
528
576
|
function shouldUseSourceInstall(options) {
|