diff --git a/install b/install index 01b363edba4..32348dd9427 100755 --- a/install +++ b/install @@ -366,19 +366,14 @@ install_legacy_shim() { if [[ "$shim_os" == "windows" ]]; then cat > "$INSTALL_DIR/opencode2.cmd" <<'EOF' @echo off -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 /b 1 +"%~dp0opencode.exe" %* +exit /b %errorlevel% EOF return fi cat > "$INSTALL_DIR/opencode2" <<'EOF' #!/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" "$@" EOF chmod 755 "$INSTALL_DIR/opencode2" } diff --git a/packages/cli/Dockerfile b/packages/cli/Dockerfile index 55f717447b1..dca2bb87122 100644 --- a/packages/cli/Dockerfile +++ b/packages/cli/Dockerfile @@ -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"] diff --git a/packages/cli/bin/opencode2.cjs b/packages/cli/bin/opencode2.cjs index 8a4a9b4f8af..b629523d516 100755 --- a/packages/cli/bin/opencode2.cjs +++ b/packages/cli/bin/opencode2.cjs @@ -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") diff --git a/packages/cli/script/publish-aur.ts b/packages/cli/script/publish-aur.ts index daac2ab3938..6d173ad8044 100644 --- a/packages/cli/script/publish-aur.ts +++ b/packages/cli/script/publish-aur.ts @@ -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 }) diff --git a/packages/cli/script/publish.ts b/packages/cli/script/publish.ts index 02ad9b54e73..bcb511a2e1f 100755 --- a/packages/cli/script/publish.ts +++ b/packages/cli/script/publish.ts @@ -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" },