Add --method option to upgrade command for manual installation method selection

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
This commit is contained in:
Dax Raad
2025-06-20 20:48:23 -04:00
parent da35a64fa1
commit 59f0004d34
2 changed files with 25 additions and 8 deletions

View File

@@ -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"),