@vantaloom/runtime-darwin-arm64 0.3.3 → 0.3.6

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/cli/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vantaloom/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Vantaloom local runtime manager.",
package/cli/src/cli.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { execFileSync, spawnSync } from "node:child_process"
2
2
  import {
3
+ appendFileSync,
3
4
  chmodSync,
4
5
  existsSync,
5
6
  mkdirSync,
@@ -44,6 +45,8 @@ if (shouldDisableTLS()) {
44
45
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
45
46
  }
46
47
 
48
+ const cliVersion = readJSONIfExists(path.join(cliRoot, "package.json")).version ?? "unknown"
49
+
47
50
  export async function main(argv) {
48
51
  const command = argv[0] ?? "help"
49
52
  const options = parseOptions(argv.slice(1))
@@ -53,6 +56,10 @@ export async function main(argv) {
53
56
  process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
54
57
  }
55
58
 
59
+ if (command === "install" || command === "update") {
60
+ console.log(`vantaloom-cli v${cliVersion} (${platformId()})`)
61
+ }
62
+
56
63
  switch (command) {
57
64
  case "install":
58
65
  if (options.package) {
@@ -119,6 +126,7 @@ async function installFromSource(options) {
119
126
 
120
127
  console.log(`${options.update ? "updated" : "installed"} Vantaloom: ${prefix}`)
121
128
  console.log(`version: ${version}`)
129
+ ensureInPath(prefix)
122
130
  console.log(`run: ${displayCommand(prefix)} status`)
123
131
  }
124
132
 
@@ -132,6 +140,7 @@ async function installFromPackage(options) {
132
140
 
133
141
  console.log(`${options.update ? "updated" : "installed"} Vantaloom: ${prefix}`)
134
142
  console.log(`version: ${version}`)
143
+ ensureInPath(prefix)
135
144
  console.log(`run: ${displayCommand(prefix)} status`)
136
145
  }
137
146
 
@@ -218,9 +227,16 @@ async function applyPackage(packageRoot, prefix, options) {
218
227
  // don't write tray.pid, so vantaloomctl stop won't find them).
219
228
  killTrayProcess(prefix)
220
229
 
230
+ // Copy package contents to install prefix
221
231
  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), {
232
+ const src = path.join(packageRoot, name)
233
+ const dst = path.join(prefix, name)
234
+ if (!existsSync(src)) {
235
+ console.error(` warning: package missing ${name}/ directory`)
236
+ continue
237
+ }
238
+ removeKnownPath(dst, prefix)
239
+ await cp(src, dst, {
224
240
  recursive: true,
225
241
  force: true,
226
242
  dereference: false,
@@ -228,14 +244,28 @@ async function applyPackage(packageRoot, prefix, options) {
228
244
  }
229
245
 
230
246
  // 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")
247
+ const binDir = path.join(prefix, "bin")
248
+ if (process.platform !== "win32" && existsSync(binDir)) {
233
249
  for (const entry of readdirSync(binDir)) {
234
250
  const binPath = path.join(binDir, entry)
235
251
  try { chmodSync(binPath, 0o755) } catch {}
236
252
  }
237
253
  }
238
254
 
255
+ // Verify vantaloomctl binary exists before trying to run it
256
+ const ctlBin = path.join(prefix, "bin", binaryName("vantaloomctl"))
257
+ if (!existsSync(ctlBin)) {
258
+ const binContents = existsSync(binDir) ? readdirSync(binDir) : []
259
+ const srcBinContents = existsSync(path.join(packageRoot, "bin")) ? readdirSync(path.join(packageRoot, "bin")) : []
260
+ throw new Error(
261
+ `vantaloomctl binary not found at ${ctlBin}\n` +
262
+ ` installed bin/: [${binContents.join(", ")}]\n` +
263
+ ` package bin/: [${srcBinContents.join(", ")}]\n` +
264
+ ` platform: ${platformId()}\n` +
265
+ ` This may indicate a corrupt download. Try again or install from source.`
266
+ )
267
+ }
268
+
239
269
  await writeLauncher(prefix)
240
270
  await writeText(path.join(prefix, "cli", "config.json"), `${JSON.stringify(mergedConfig, null, 2)}\n`)
241
271
  await writeText(path.join(prefix, "VERSION"), `${version}\n`)
@@ -243,7 +273,7 @@ async function applyPackage(packageRoot, prefix, options) {
243
273
  force: true,
244
274
  })
245
275
 
246
- run(path.join(prefix, "bin", binaryName("vantaloomctl")), [
276
+ run(ctlBin, [
247
277
  "install",
248
278
  "--prefix",
249
279
  prefix,
@@ -252,7 +282,7 @@ async function applyPackage(packageRoot, prefix, options) {
252
282
  ])
253
283
 
254
284
  if (!options.noStart) {
255
- run(path.join(prefix, "bin", binaryName("vantaloomctl")), [
285
+ run(ctlBin, [
256
286
  "start",
257
287
  "--prefix",
258
288
  prefix,
@@ -265,7 +295,10 @@ async function applyPackage(packageRoot, prefix, options) {
265
295
  async function syncFromNpmRegistry(options, action) {
266
296
  const prefix = safeDirectory(options.prefix ?? defaultPrefix())
267
297
  const installedConfig = readInstalledConfig(prefix)
268
- const runtimePackage = options.runtimePackage || installedConfig.runtimePackage || runtimePackageName(platformId())
298
+ // Always derive runtimePackage from current platform — never trust stale config
299
+ // from a different platform (e.g. win32 config baked into a darwin package).
300
+ // Only explicit --runtime-package flag can override.
301
+ const runtimePackage = options.runtimePackage || runtimePackageName(platformId())
269
302
  const runtimeVersion = options.runtimeVersion || installedConfig.runtimeVersion || "latest"
270
303
  const explicitRegistry = options.npmRegistry || installedConfig.npmRegistry
271
304
  const registry = normalizeRegistry(explicitRegistry || detectNpmRegistry() || defaultNpmRegistry)
@@ -302,6 +335,7 @@ async function syncFromNpmRegistry(options, action) {
302
335
  console.log(`version: ${version}`)
303
336
  console.log(`source: ${runtimePackage}@${resolved.version}`)
304
337
  console.log(`registry: ${resolved.registry}`)
338
+ ensureInPath(prefix)
305
339
  console.log(`run: ${displayCommand(prefix)} status`)
306
340
  } finally {
307
341
  removeKnownPath(tempRoot, os.tmpdir())
@@ -343,6 +377,7 @@ async function syncFromRelease(options, action) {
343
377
  console.log(`${action === "update" ? "updated" : "installed"} Vantaloom: ${prefix}`)
344
378
  console.log(`version: ${version}`)
345
379
  console.log(`source: ${repo}@${releaseTag}`)
380
+ ensureInPath(prefix)
346
381
  console.log(`run: ${displayCommand(prefix)} status`)
347
382
  } finally {
348
383
  removeKnownPath(tempRoot, os.tmpdir())
@@ -520,11 +555,22 @@ async function resolveNpmPackage({ registry, name, version }) {
520
555
  }
521
556
 
522
557
  async function downloadNpmTarball({ tarballUrl, target, packageName, version }) {
523
- const response = await fetch(tarballUrl, {
524
- headers: {
525
- "User-Agent": "vantaloom-cli",
526
- },
527
- })
558
+ console.log(` downloading ${packageName}@${version}...`)
559
+ let response
560
+ try {
561
+ response = await fetch(tarballUrl, {
562
+ headers: {
563
+ "User-Agent": "vantaloom-cli",
564
+ },
565
+ signal: AbortSignal.timeout(120000),
566
+ })
567
+ } catch (error) {
568
+ const causeCode = error?.cause?.code || ""
569
+ const causeMsg = causeCode || error?.cause?.message || error.message || ""
570
+ const isSsl = causeCode.includes("CERT") || causeCode === "UNABLE_TO_GET_ISSUER_CERT_LOCALLY"
571
+ const hint = isSsl ? `\n Fix: run with --no-strict-ssl` : ""
572
+ throw new Error(`failed to download ${packageName}@${version} from ${tarballUrl}: ${causeMsg}${hint}`)
573
+ }
528
574
  if (!response.ok) {
529
575
  const detail = await response.text().catch(() => "")
530
576
  throw new Error(`failed to download ${packageName}@${version}: HTTP ${response.status}${detail ? ` ${detail.slice(0, 200)}` : ""}`)
@@ -532,6 +578,7 @@ async function downloadNpmTarball({ tarballUrl, target, packageName, version })
532
578
 
533
579
  const buffer = Buffer.from(await response.arrayBuffer())
534
580
  await writeFile(target, buffer)
581
+ console.log(` downloaded ${(buffer.length / 1024 / 1024).toFixed(1)} MB`)
535
582
  }
536
583
 
537
584
  function shouldUseSourceInstall(options) {
@@ -595,9 +642,9 @@ function mergeRuntimeConfig(packageConfig, existingConfig, overrides) {
595
642
  if (!merged.releaseTag) {
596
643
  merged.releaseTag = defaultReleaseTag
597
644
  }
598
- if (!merged.runtimePackage) {
599
- merged.runtimePackage = runtimePackageName(platformId())
600
- }
645
+ // Always force runtimePackage to match the running platform — a cross-compiled
646
+ // package may carry a config for a different platform (e.g. win32 inside darwin).
647
+ merged.runtimePackage = runtimePackageName(platformId())
601
648
  if (!merged.runtimeVersion) {
602
649
  merged.runtimeVersion = "latest"
603
650
  }
@@ -1047,6 +1094,60 @@ async function writeText(filePath, content) {
1047
1094
  await writeFile(filePath, content)
1048
1095
  }
1049
1096
 
1097
+ // ensureInPath adds the Vantaloom install directory to the user's shell PATH
1098
+ // on macOS and Linux, so `vantaloom` can be run directly after install.
1099
+ // On Windows this is not needed (vantaloom.cmd is run by full path or added via installer).
1100
+ function ensureInPath(prefix) {
1101
+ if (process.platform === "win32") return
1102
+
1103
+ // Check if already in PATH
1104
+ const pathDirs = (process.env.PATH || "").split(":")
1105
+ if (pathDirs.includes(prefix)) return
1106
+
1107
+ // Determine shell profile file
1108
+ const home = os.homedir()
1109
+ const shell = process.env.SHELL || ""
1110
+ let profilePath
1111
+ if (shell.endsWith("/zsh") || existsSync(path.join(home, ".zshrc"))) {
1112
+ profilePath = path.join(home, ".zshrc")
1113
+ } else if (shell.endsWith("/bash")) {
1114
+ // On macOS, bash uses .bash_profile; on Linux, .bashrc
1115
+ profilePath = process.platform === "darwin"
1116
+ ? path.join(home, ".bash_profile")
1117
+ : path.join(home, ".bashrc")
1118
+ } else if (existsSync(path.join(home, ".profile"))) {
1119
+ profilePath = path.join(home, ".profile")
1120
+ } else {
1121
+ profilePath = path.join(home, ".profile")
1122
+ }
1123
+
1124
+ // Use $HOME-relative path for portability
1125
+ const homeRelative = prefix.startsWith(home)
1126
+ ? `$HOME${prefix.slice(home.length)}`
1127
+ : prefix
1128
+ const exportLine = `export PATH="${homeRelative}:$PATH"`
1129
+ const marker = "# vantaloom"
1130
+
1131
+ // Check if already added to profile
1132
+ try {
1133
+ if (existsSync(profilePath)) {
1134
+ const content = readFileSync(profilePath, "utf8")
1135
+ if (content.includes("vantaloom") && content.includes("PATH")) return
1136
+ }
1137
+ } catch {}
1138
+
1139
+ // Append to profile
1140
+ try {
1141
+ const entry = `\n${marker}\n${exportLine}\n`
1142
+ appendFileSync(profilePath, entry)
1143
+ console.log(`PATH: added ${prefix} to ${profilePath}`)
1144
+ console.log(` run: source ${profilePath} (or open a new terminal)`)
1145
+ } catch (error) {
1146
+ console.log(`PATH: could not update ${profilePath}: ${error.message}`)
1147
+ console.log(` add manually: ${exportLine}`)
1148
+ }
1149
+ }
1150
+
1050
1151
  function killTrayProcess(prefix) {
1051
1152
  if (process.platform === "win32") {
1052
1153
  // Try PID file first (new tray versions write runtime/tray.pid).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vantaloom/runtime-darwin-arm64",
3
- "version": "0.3.3",
3
+ "version": "0.3.6",
4
4
  "private": false,
5
5
  "description": "Vantaloom local runtime for darwin-arm64.",
6
6
  "type": "module",