Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/desktop/src/main/updater/config.test.ts
Original file line number Diff line number Diff line change
@@ -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,
})
})
11 changes: 11 additions & 0 deletions packages/desktop/src/main/updater/config.ts
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 2 additions & 3 deletions packages/desktop/src/main/updater/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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", {
Expand Down
Loading