fix(cli): keep opencode2 as a working alias

This commit is contained in:
Dax Raad
2026-09-11 20:55:03 -04:00
parent b08ad82518
commit 0f26ad8787
5 changed files with 7 additions and 22 deletions
+1 -1
View File
@@ -12,5 +12,5 @@ COPY dist/cli-linux-arm64-musl/bin/opencode /usr/local/bin/opencode
ARG TARGETARCH
FROM build-${TARGETARCH}
RUN opencode --version
RUN ln -s opencode /usr/local/bin/opencode2 && opencode --version && opencode2 --version
ENTRYPOINT ["opencode"]
+1 -4
View File
@@ -1,6 +1,3 @@
#!/usr/bin/env node
console.log(
'"opencode2" has been renamed to "opencode". Run "opencode" instead.\n\nIf you have OpenCode v1 installed, you may need to uninstall it so the "opencode" command launches the correct installation.',
)
process.exit(1)
require("./opencode.cjs")
+1 -4
View File
@@ -18,10 +18,7 @@ const dryRun = process.argv.includes("--dry-run")
const pkgver = Script.version.replaceAll("-", ".")
const license = Bun.file(path.join(dir, "..", "..", "LICENSE"))
const shim = `#!/bin/sh
echo '"opencode2" has been renamed to "opencode". Run "opencode" instead.'
echo
echo 'If you have OpenCode v1 installed, you may need to uninstall it so the "opencode" command launches the correct installation.'
exit 1
exec "$(dirname "$0")/opencode" "$@"
`
await rm(outdir, { recursive: true, force: true })
+1 -5
View File
@@ -60,17 +60,13 @@ async function publishDistribution(input: {
"",
].join("\n"),
)
if (input.legacyCommand)
await Bun.file(`${input.root}/${input.name}/bin/${input.legacyCommand}.cjs`).write(
`#!/usr/bin/env node\n\nconsole.log(${JSON.stringify(`"opencode2" has been renamed to "${input.command}". Run "${input.command}" instead.\n\nIf you have OpenCode v1 installed, you may need to uninstall it so the "${input.command}" command launches the correct installation.`)})\nprocess.exit(1)\n`,
)
await Bun.file(`${input.root}/${input.name}/package.json`).write(
JSON.stringify(
{
name: input.name,
bin: {
[input.command]: `./bin/${input.command}.exe`,
...(input.legacyCommand ? { [input.legacyCommand]: `./bin/${input.legacyCommand}.cjs` } : {}),
...(input.legacyCommand ? { [input.legacyCommand]: `./bin/${input.command}.exe` } : {}),
},
...(input.command !== input.binary ? { opencodeSourceBinary: input.binary } : {}),
scripts: { postinstall: "node ./postinstall.mjs" },