@vantaloom/cli 0.3.3 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.mjs +50 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vantaloom/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Vantaloom local runtime manager.",
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,9 +224,16 @@ 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
- removeKnownPath(path.join(prefix, name), prefix)
223
- await cp(path.join(packageRoot, name), path.join(prefix, name), {
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,
@@ -228,14 +241,28 @@ async function applyPackage(packageRoot, prefix, options) {
228
241
  }
229
242
 
230
243
  // Ensure binaries are executable on Unix (cross-compiled from Windows they lose +x)
231
- if (process.platform !== "win32") {
232
- const binDir = path.join(prefix, "bin")
244
+ const binDir = path.join(prefix, "bin")
245
+ if (process.platform !== "win32" && existsSync(binDir)) {
233
246
  for (const entry of readdirSync(binDir)) {
234
247
  const binPath = path.join(binDir, entry)
235
248
  try { chmodSync(binPath, 0o755) } catch {}
236
249
  }
237
250
  }
238
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
+
239
266
  await writeLauncher(prefix)
240
267
  await writeText(path.join(prefix, "cli", "config.json"), `${JSON.stringify(mergedConfig, null, 2)}\n`)
241
268
  await writeText(path.join(prefix, "VERSION"), `${version}\n`)
@@ -243,7 +270,7 @@ async function applyPackage(packageRoot, prefix, options) {
243
270
  force: true,
244
271
  })
245
272
 
246
- run(path.join(prefix, "bin", binaryName("vantaloomctl")), [
273
+ run(ctlBin, [
247
274
  "install",
248
275
  "--prefix",
249
276
  prefix,
@@ -252,7 +279,7 @@ async function applyPackage(packageRoot, prefix, options) {
252
279
  ])
253
280
 
254
281
  if (!options.noStart) {
255
- run(path.join(prefix, "bin", binaryName("vantaloomctl")), [
282
+ run(ctlBin, [
256
283
  "start",
257
284
  "--prefix",
258
285
  prefix,
@@ -520,11 +547,22 @@ async function resolveNpmPackage({ registry, name, version }) {
520
547
  }
521
548
 
522
549
  async function downloadNpmTarball({ tarballUrl, target, packageName, version }) {
523
- const response = await fetch(tarballUrl, {
524
- headers: {
525
- "User-Agent": "vantaloom-cli",
526
- },
527
- })
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
+ }
528
566
  if (!response.ok) {
529
567
  const detail = await response.text().catch(() => "")
530
568
  throw new Error(`failed to download ${packageName}@${version}: HTTP ${response.status}${detail ? ` ${detail.slice(0, 200)}` : ""}`)
@@ -532,6 +570,7 @@ async function downloadNpmTarball({ tarballUrl, target, packageName, version })
532
570
 
533
571
  const buffer = Buffer.from(await response.arrayBuffer())
534
572
  await writeFile(target, buffer)
573
+ console.log(` downloaded ${(buffer.length / 1024 / 1024).toFixed(1)} MB`)
535
574
  }
536
575
 
537
576
  function shouldUseSourceInstall(options) {