MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / configureAutoUpdate

Function configureAutoUpdate

apps/desktop/src/auto-update.ts:10–71  ·  view source on GitHub ↗
(win: BrowserWindow, hooks: AutoUpdateHooks)

Source from the content-addressed store, hash-verified

8}
9
10export function configureAutoUpdate(win: BrowserWindow, hooks: AutoUpdateHooks): void {
11 if (!app.isPackaged) return
12
13 autoUpdater.autoDownload = true
14 autoUpdater.autoInstallOnAppQuit = false
15 autoUpdater.allowPrerelease = app.getVersion().includes('-')
16 autoUpdater.channel = channelForVersion(app.getVersion())
17 autoUpdater.allowDowngrade = false
18
19 autoUpdater.on('error', (err) => {
20 console.error('[updater] update check failed:', err)
21 })
22
23 autoUpdater.on('update-available', (info) => {
24 console.log(`[updater] update available: ${info.version}`)
25 })
26
27 autoUpdater.on('update-not-available', (info) => {
28 console.log(`[updater] no update available (latest=${info.version})`)
29 })
30
31 autoUpdater.on('download-progress', (progress) => {
32 console.log(`[updater] downloading ${progress.percent.toFixed(1)}%`)
33 })
34
35 autoUpdater.on('update-downloaded', (info) => {
36 void dialog
37 .showMessageBox(win, {
38 type: 'info',
39 title: 'OpenAlice — update ready',
40 message: `OpenAlice ${info.version} is ready to install.`,
41 detail: 'Restart OpenAlice to install the update. Running UTA and Alice child processes will be stopped gracefully first.',
42 buttons: ['Restart now', 'Later', 'View release'],
43 defaultId: 0,
44 cancelId: 1,
45 })
46 .then(async ({ response }) => {
47 if (response === 2) {
48 const releaseUrl = `https://github.com/TraderAlice/OpenAlice/releases/tag/v${info.version}`
49 void shell.openExternal(releaseUrl)
50 return
51 }
52 if (response !== 0) return
53 try {
54 await hooks.beforeInstall()
55 autoUpdater.quitAndInstall(false, true)
56 } catch (err) {
57 console.error('[updater] failed to prepare update install:', err)
58 await dialog.showMessageBox(win, {
59 type: 'error',
60 title: 'OpenAlice — update install failed',
61 message: 'OpenAlice could not prepare for the update.',
62 detail: err instanceof Error ? err.message : String(err),
63 })
64 }
65 })
66 })
67

Callers 1

main.tsFile · 0.85

Calls 3

channelForVersionFunction · 0.85
errorMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected