|
|
@@ -1,9 +1,9 @@
|
|
|
-import { Bus } from "@/bus"
|
|
|
import { Config } from "@/config/config"
|
|
|
import { AppRuntime } from "@/effect/app-runtime"
|
|
|
import { Flag } from "@opencode-ai/core/flag/flag"
|
|
|
import { Installation } from "@/installation"
|
|
|
import { InstallationVersion } from "@opencode-ai/core/installation/version"
|
|
|
+import { GlobalBus } from "@/bus/global"
|
|
|
|
|
|
export async function upgrade() {
|
|
|
const config = await AppRuntime.runPromise(Config.Service.use((cfg) => cfg.getGlobal()))
|
|
|
@@ -13,7 +13,13 @@ export async function upgrade() {
|
|
|
if (!latest) return
|
|
|
|
|
|
if (Flag.OPENCODE_ALWAYS_NOTIFY_UPDATE) {
|
|
|
- await Bus.publish(Installation.Event.UpdateAvailable, { version: latest })
|
|
|
+ GlobalBus.emit("event", {
|
|
|
+ directory: "global",
|
|
|
+ payload: {
|
|
|
+ type: Installation.Event.UpdateAvailable.type,
|
|
|
+ properties: { version: latest },
|
|
|
+ },
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -22,12 +28,26 @@ export async function upgrade() {
|
|
|
const kind = Installation.getReleaseType(InstallationVersion, latest)
|
|
|
|
|
|
if (config.autoupdate === "notify" || kind !== "patch") {
|
|
|
- await Bus.publish(Installation.Event.UpdateAvailable, { version: latest })
|
|
|
+ GlobalBus.emit("event", {
|
|
|
+ directory: "global",
|
|
|
+ payload: {
|
|
|
+ type: Installation.Event.UpdateAvailable.type,
|
|
|
+ properties: { version: latest },
|
|
|
+ },
|
|
|
+ })
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (method === "unknown") return
|
|
|
await Installation.upgrade(method, latest)
|
|
|
- .then(() => Bus.publish(Installation.Event.Updated, { version: latest }))
|
|
|
+ .then(() =>
|
|
|
+ GlobalBus.emit("event", {
|
|
|
+ directory: "global",
|
|
|
+ payload: {
|
|
|
+ type: Installation.Event.Updated.type,
|
|
|
+ properties: { version: latest },
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ )
|
|
|
.catch(() => {})
|
|
|
}
|