diff --git a/packages/desktop/src/main/updater/config.test.ts b/packages/desktop/src/main/updater/config.test.ts new file mode 100644 index 000000000000..c484035a8ae3 --- /dev/null +++ b/packages/desktop/src/main/updater/config.test.ts @@ -0,0 +1,18 @@ +import { expect, test } from "bun:test" +import { configureStableUpdates } from "./config" + +test("stable updates do not install older releases", () => { + const client = { + channel: null, + allowPrerelease: null, + allowDowngrade: true, + } + + configureStableUpdates(client) + + expect(client).toEqual({ + channel: "latest", + allowPrerelease: false, + allowDowngrade: false, + }) +}) diff --git a/packages/desktop/src/main/updater/config.ts b/packages/desktop/src/main/updater/config.ts new file mode 100644 index 000000000000..3dd2d00707b7 --- /dev/null +++ b/packages/desktop/src/main/updater/config.ts @@ -0,0 +1,11 @@ +type UpdateClient = { + channel: string | null + allowPrerelease: boolean | null + allowDowngrade: boolean +} + +export function configureStableUpdates(client: UpdateClient) { + client.channel = "latest" + client.allowPrerelease = false + client.allowDowngrade = false +} diff --git a/packages/desktop/src/main/updater/platform.ts b/packages/desktop/src/main/updater/platform.ts index 8033870365d9..8a07a9b85a99 100644 --- a/packages/desktop/src/main/updater/platform.ts +++ b/packages/desktop/src/main/updater/platform.ts @@ -2,6 +2,7 @@ import { app, autoUpdater } from "electron" import pkg from "electron-updater" import { Effect } from "effect" import { setAppQuitting } from "../windows" +import { configureStableUpdates } from "./config" import type { Platform } from "./index" const updateClient = pkg.autoUpdater @@ -15,9 +16,7 @@ export const make = Effect.gen(function* () { error: (...args) => runFork(Effect.logError(...args)), debug: (...args) => runFork(Effect.logDebug(...args)), } - updateClient.channel = "latest" - updateClient.allowPrerelease = false - updateClient.allowDowngrade = true + configureStableUpdates(updateClient) updateClient.autoDownload = false updateClient.autoInstallOnAppQuit = process.platform === "darwin" yield* Effect.logInfo("auto updater configured", {