summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-06-20 20:48:23 -0400
committerDax Raad <[email protected]>2025-06-20 20:48:23 -0400
commit59f0004d346e6cc4178c9ed2b8e8a78df8c9b3a9 (patch)
tree91baa3103de8f1110c91ba8ea82ec6a9db47afc7
parentda35a64fa125a3cae7d1d62fc2d5df1e67a9c37c (diff)
downloadopencode-59f0004d346e6cc4178c9ed2b8e8a78df8c9b3a9.tar.gz
opencode-59f0004d346e6cc4178c9ed2b8e8a78df8c9b3a9.zip
Add --method option to upgrade command for manual installation method selection
🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <[email protected]>
-rw-r--r--packages/opencode/src/cli/cmd/upgrade.ts22
-rw-r--r--packages/opencode/src/installation/index.ts11
2 files changed, 25 insertions, 8 deletions
diff --git a/packages/opencode/src/cli/cmd/upgrade.ts b/packages/opencode/src/cli/cmd/upgrade.ts
index ab65a3781..083b99238 100644
--- a/packages/opencode/src/cli/cmd/upgrade.ts
+++ b/packages/opencode/src/cli/cmd/upgrade.ts
@@ -7,17 +7,25 @@ export const UpgradeCommand = {
command: "upgrade [target]",
describe: "upgrade opencode to the latest version or a specific version",
builder: (yargs: Argv) => {
- return yargs.positional("target", {
- describe: "specific version to upgrade to (e.g., '0.1.48' or 'v0.1.48')",
- type: "string",
- })
+ return yargs
+ .positional("target", {
+ describe: "specific version to upgrade to (e.g., '0.1.48' or 'v0.1.48')",
+ type: "string",
+ })
+ .option("method", {
+ alias: "m",
+ describe: "installation method to use (curl, npm, pnpm, bun, brew)",
+ type: "string",
+ choices: ["curl", "npm", "pnpm", "bun", "brew"],
+ })
},
- handler: async (args: { target?: string }) => {
+ handler: async (args: { target?: string; method?: string }) => {
UI.empty()
UI.println(UI.logo(" "))
UI.empty()
prompts.intro("Upgrade")
- const method = await Installation.method()
+ const detectedMethod = await Installation.method()
+ const method = (args.method as Installation.Method) ?? detectedMethod
if (method === "unknown") {
prompts.log.error(
`opencode is installed to ${process.execPath} and seems to be managed by a package manager`,
@@ -25,7 +33,7 @@ export const UpgradeCommand = {
prompts.outro("Done")
return
}
- prompts.log.info("Installed via " + method)
+ prompts.log.info("Using method: " + method)
const target = args.target ?? (await Installation.latest())
prompts.log.info(`From ${Installation.VERSION} → ${target}`)
const spinner = prompts.spinner()
diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.ts
index de7c20c18..88c76123e 100644
--- a/packages/opencode/src/installation/index.ts
+++ b/packages/opencode/src/installation/index.ts
@@ -3,12 +3,15 @@ import { $ } from "bun"
import { z } from "zod"
import { NamedError } from "../util/error"
import { Bus } from "../bus"
+import { Log } from "../util/log"
declare global {
const OPENCODE_VERSION: string
}
export namespace Installation {
+ const log = Log.create({ service: "installation" })
+
export type Method = Awaited<ReturnType<typeof method>>
export const Event = {
@@ -102,8 +105,8 @@ export namespace Installation {
switch (method) {
case "curl":
return $`curl -fsSL https://opencode.ai/install | bash`.env({
- VERSION: target,
...process.env,
+ VERSION: target,
})
case "npm":
return $`npm install -g opencode-ai@${target}`
@@ -118,6 +121,12 @@ export namespace Installation {
}
})()
const result = await cmd.quiet().throws(false)
+ log.info("upgraded", {
+ method,
+ target,
+ stdout: result.stdout.toString(),
+ stderr: result.stderr.toString(),
+ })
if (result.exitCode !== 0)
throw new UpgradeFailedError({
stderr: result.stderr.toString("utf8"),