summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2025-12-02 17:43:20 -0600
committerAiden Cline <[email protected]>2025-12-02 17:43:33 -0600
commite2e2b7934e94606b376bee1c42911ace394535b6 (patch)
treead7cf4a80937d8988dde33c7b177f7eb606aedee /packages
parent28c802f39949d512a56ad8c0596c294ff6fe9e66 (diff)
downloadopencode-e2e2b7934e94606b376bee1c42911ace394535b6.tar.gz
opencode-e2e2b7934e94606b376bee1c42911ace394535b6.zip
Make homebrew update check use homebrew registry version info
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/cli/upgrade.ts4
-rw-r--r--packages/opencode/src/installation/index.ts15
2 files changed, 16 insertions, 3 deletions
diff --git a/packages/opencode/src/cli/upgrade.ts b/packages/opencode/src/cli/upgrade.ts
index 2bea760b3..2d46ae39f 100644
--- a/packages/opencode/src/cli/upgrade.ts
+++ b/packages/opencode/src/cli/upgrade.ts
@@ -5,7 +5,8 @@ import { Installation } from "@/installation"
export async function upgrade() {
const config = await Config.global()
- const latest = await Installation.latest().catch(() => {})
+ const method = await Installation.method()
+ const latest = await Installation.latest(method).catch(() => {})
if (!latest) return
if (Installation.VERSION === latest) return
@@ -17,7 +18,6 @@ export async function upgrade() {
return
}
- const method = await Installation.method()
if (method === "unknown") return
await Installation.upgrade(method, latest)
.then(() => Bus.publish(Installation.Event.Updated, { version: latest }))
diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.ts
index 37b74fc39..0f3e2ce6b 100644
--- a/packages/opencode/src/installation/index.ts
+++ b/packages/opencode/src/installation/index.ts
@@ -163,7 +163,20 @@ export namespace Installation {
export const CHANNEL = typeof OPENCODE_CHANNEL === "string" ? OPENCODE_CHANNEL : "local"
export const USER_AGENT = `opencode/${CHANNEL}/${VERSION}`
- export async function latest() {
+ export async function latest(installMethod?: Method) {
+ const detectedMethod = installMethod || (await method())
+ if (detectedMethod === "brew") {
+ const formula = await getBrewFormula()
+ if (formula === "opencode") {
+ return fetch("https://formulae.brew.sh/api/formula/opencode.json")
+ .then((res) => {
+ if (!res.ok) throw new Error(res.statusText)
+ return res.json()
+ })
+ .then((data: any) => data.versions.stable)
+ }
+ }
+
const registry = await iife(async () => {
const r = (await $`npm config get registry`.quiet().nothrow().text()).trim()
const reg = r || "https://registry.npmjs.org"