MCPcopy
hub / github.com/anomalyco/opencode / upgrade

Function upgrade

packages/opencode/src/cli/upgrade.ts:8–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import { GlobalBus } from "@/bus/global"
7
8export async function upgrade() {
9 const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
10 if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
11 const method = await Installation.method()
12 const latest = await Installation.latest(method).catch(() => {})
13 if (!latest) return
14
15 if (Flag.OPENCODE_ALWAYS_NOTIFY_UPDATE) {
16 GlobalBus.emit("event", {
17 directory: "global",
18 payload: {
19 type: Installation.Event.UpdateAvailable.type,
20 properties: { version: latest },
21 },
22 })
23 return
24 }
25
26 if (InstallationVersion === latest) return
27
28 const kind = Installation.getReleaseType(InstallationVersion, latest)
29
30 if (config.autoupdate === "notify" || kind !== "patch") {
31 GlobalBus.emit("event", {
32 directory: "global",
33 payload: {
34 type: Installation.Event.UpdateAvailable.type,
35 properties: { version: latest },
36 },
37 })
38 return
39 }
40
41 if (method === "unknown") return
42 await Installation.upgrade(method, latest)
43 .then(() =>
44 GlobalBus.emit("event", {
45 directory: "global",
46 payload: {
47 type: Installation.Event.Updated.type,
48 properties: { version: latest },
49 },
50 }),
51 )
52 .catch(() => {})
53}

Callers 2

checkUpgradeFunction · 0.90
global.tsFile · 0.50

Calls 3

upgradeMethod · 0.80
useMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected