@vantaloom/runtime-darwin-arm64 0.3.2 → 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 +1 -1
- package/cli/src/cli.mjs +123 -13
- package/package.json +1 -1
package/cli/package.json
CHANGED
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,15 +227,45 @@ 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
|
-
|
|
223
|
-
|
|
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,
|
|
227
243
|
})
|
|
228
244
|
}
|
|
229
245
|
|
|
246
|
+
// Ensure binaries are executable on Unix (cross-compiled from Windows they lose +x)
|
|
247
|
+
const binDir = path.join(prefix, "bin")
|
|
248
|
+
if (process.platform !== "win32" && existsSync(binDir)) {
|
|
249
|
+
for (const entry of readdirSync(binDir)) {
|
|
250
|
+
const binPath = path.join(binDir, entry)
|
|
251
|
+
try { chmodSync(binPath, 0o755) } catch {}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
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
|
+
|
|
230
269
|
await writeLauncher(prefix)
|
|
231
270
|
await writeText(path.join(prefix, "cli", "config.json"), `${JSON.stringify(mergedConfig, null, 2)}\n`)
|
|
232
271
|
await writeText(path.join(prefix, "VERSION"), `${version}\n`)
|
|
@@ -234,7 +273,7 @@ async function applyPackage(packageRoot, prefix, options) {
|
|
|
234
273
|
force: true,
|
|
235
274
|
})
|
|
236
275
|
|
|
237
|
-
run(
|
|
276
|
+
run(ctlBin, [
|
|
238
277
|
"install",
|
|
239
278
|
"--prefix",
|
|
240
279
|
prefix,
|
|
@@ -243,7 +282,7 @@ async function applyPackage(packageRoot, prefix, options) {
|
|
|
243
282
|
])
|
|
244
283
|
|
|
245
284
|
if (!options.noStart) {
|
|
246
|
-
run(
|
|
285
|
+
run(ctlBin, [
|
|
247
286
|
"start",
|
|
248
287
|
"--prefix",
|
|
249
288
|
prefix,
|
|
@@ -256,7 +295,10 @@ async function applyPackage(packageRoot, prefix, options) {
|
|
|
256
295
|
async function syncFromNpmRegistry(options, action) {
|
|
257
296
|
const prefix = safeDirectory(options.prefix ?? defaultPrefix())
|
|
258
297
|
const installedConfig = readInstalledConfig(prefix)
|
|
259
|
-
|
|
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())
|
|
260
302
|
const runtimeVersion = options.runtimeVersion || installedConfig.runtimeVersion || "latest"
|
|
261
303
|
const explicitRegistry = options.npmRegistry || installedConfig.npmRegistry
|
|
262
304
|
const registry = normalizeRegistry(explicitRegistry || detectNpmRegistry() || defaultNpmRegistry)
|
|
@@ -293,6 +335,7 @@ async function syncFromNpmRegistry(options, action) {
|
|
|
293
335
|
console.log(`version: ${version}`)
|
|
294
336
|
console.log(`source: ${runtimePackage}@${resolved.version}`)
|
|
295
337
|
console.log(`registry: ${resolved.registry}`)
|
|
338
|
+
ensureInPath(prefix)
|
|
296
339
|
console.log(`run: ${displayCommand(prefix)} status`)
|
|
297
340
|
} finally {
|
|
298
341
|
removeKnownPath(tempRoot, os.tmpdir())
|
|
@@ -334,6 +377,7 @@ async function syncFromRelease(options, action) {
|
|
|
334
377
|
console.log(`${action === "update" ? "updated" : "installed"} Vantaloom: ${prefix}`)
|
|
335
378
|
console.log(`version: ${version}`)
|
|
336
379
|
console.log(`source: ${repo}@${releaseTag}`)
|
|
380
|
+
ensureInPath(prefix)
|
|
337
381
|
console.log(`run: ${displayCommand(prefix)} status`)
|
|
338
382
|
} finally {
|
|
339
383
|
removeKnownPath(tempRoot, os.tmpdir())
|
|
@@ -511,11 +555,22 @@ async function resolveNpmPackage({ registry, name, version }) {
|
|
|
511
555
|
}
|
|
512
556
|
|
|
513
557
|
async function downloadNpmTarball({ tarballUrl, target, packageName, version }) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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
|
+
}
|
|
519
574
|
if (!response.ok) {
|
|
520
575
|
const detail = await response.text().catch(() => "")
|
|
521
576
|
throw new Error(`failed to download ${packageName}@${version}: HTTP ${response.status}${detail ? ` ${detail.slice(0, 200)}` : ""}`)
|
|
@@ -523,6 +578,7 @@ async function downloadNpmTarball({ tarballUrl, target, packageName, version })
|
|
|
523
578
|
|
|
524
579
|
const buffer = Buffer.from(await response.arrayBuffer())
|
|
525
580
|
await writeFile(target, buffer)
|
|
581
|
+
console.log(` downloaded ${(buffer.length / 1024 / 1024).toFixed(1)} MB`)
|
|
526
582
|
}
|
|
527
583
|
|
|
528
584
|
function shouldUseSourceInstall(options) {
|
|
@@ -586,9 +642,9 @@ function mergeRuntimeConfig(packageConfig, existingConfig, overrides) {
|
|
|
586
642
|
if (!merged.releaseTag) {
|
|
587
643
|
merged.releaseTag = defaultReleaseTag
|
|
588
644
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
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())
|
|
592
648
|
if (!merged.runtimeVersion) {
|
|
593
649
|
merged.runtimeVersion = "latest"
|
|
594
650
|
}
|
|
@@ -1038,6 +1094,60 @@ async function writeText(filePath, content) {
|
|
|
1038
1094
|
await writeFile(filePath, content)
|
|
1039
1095
|
}
|
|
1040
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
|
+
|
|
1041
1151
|
function killTrayProcess(prefix) {
|
|
1042
1152
|
if (process.platform === "win32") {
|
|
1043
1153
|
// Try PID file first (new tray versions write runtime/tray.pid).
|