mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-25 19:51:57 +00:00
cli: share app archive across Node builds (#44331)
This commit is contained in:
parent
6cd3da1d4c
commit
853d3534e5
2 changed files with 45 additions and 7 deletions
|
|
@ -27,6 +27,9 @@ if (outdir === path.join(dir, "dist-node")) {
|
|||
const bundleOnly = process.argv.includes("--bundle-only")
|
||||
const single = process.argv.includes("--single")
|
||||
const skipInstall = process.argv.includes("--skip-install")
|
||||
const appArchiveOnly = process.argv.includes("--app-archive-only")
|
||||
const requestedArchive = process.argv.find((arg) => arg.startsWith("--app-archive="))?.slice("--app-archive=".length)
|
||||
const archivePath = requestedArchive ? path.resolve(dir, requestedArchive) : undefined
|
||||
const requested = process.argv.find((arg) => arg.startsWith("--target="))?.slice("--target=".length)
|
||||
const allTargets = [
|
||||
nodeTarget("linux", "arm64"),
|
||||
|
|
@ -41,6 +44,14 @@ const targets = requested
|
|||
? [nodeTarget(process.platform, process.arch)]
|
||||
: allTargets
|
||||
|
||||
process.chdir(dir)
|
||||
if (!skipInstall) run(process.execPath, ["install", "--os=*", "--cpu=*"])
|
||||
if (appArchiveOnly) {
|
||||
if (!archivePath) throw new Error("--app-archive-only requires --app-archive=<path>")
|
||||
await mkdir(path.dirname(archivePath), { recursive: true })
|
||||
await writeFile(archivePath, await buildAppArchive(Script.channel))
|
||||
process.exit(0)
|
||||
}
|
||||
if (targets.length === 0) {
|
||||
if (requested === "darwin-x64") throw new Error("Node 26.4 SEA does not support macOS x64")
|
||||
throw new Error(`Unknown Node target: ${requested}`)
|
||||
|
|
@ -48,15 +59,12 @@ if (targets.length === 0) {
|
|||
if (!bundleOnly && targets.some((target) => target.platform === "darwin" && target.arch === "x64")) {
|
||||
throw new Error("Node 26.4 SEA does not support macOS x64")
|
||||
}
|
||||
|
||||
process.chdir(dir)
|
||||
if (!skipInstall) run(process.execPath, ["install", "--os=*", "--cpu=*"])
|
||||
const appArchive = archivePath ? (await Bun.file(archivePath).text()).trim() : await buildAppArchive(Script.channel)
|
||||
if (!bundleOnly) await rm(outdir, { recursive: true, force: true })
|
||||
const builder =
|
||||
!bundleOnly || targets.some((target) => target.platform === process.platform && target.arch === process.arch)
|
||||
? await resolveHostNode()
|
||||
: undefined
|
||||
const appArchive = await buildAppArchive(Script.channel)
|
||||
|
||||
// Vite silently rewrites text imports of known asset types (.txt) to asset
|
||||
// URL strings when the raw-text plugin doesn't intercept them first — the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue