feat: add dev mode support for auto-update testing

This commit is contained in:
Jiang Bohan
2026-01-16 15:07:12 +08:00
parent b397e52cab
commit eb6f34bd1d
3 changed files with 32 additions and 8 deletions

3
dev-app-update.yml Normal file
View File

@@ -0,0 +1,3 @@
provider: github
owner: multica-ai
repo: multica

View File

@@ -7,12 +7,13 @@ import { Conductor } from './conductor/Conductor'
import { IPC_CHANNELS } from '../shared/ipc-channels'
import type { PermissionResponse } from '../shared/electron-api'
import { PermissionManager } from './permission'
import { updater } from './updater'
import { createUpdater, AutoUpdater } from './updater'
// Global instances
let conductor: Conductor
let mainWindow: BrowserWindow | null = null
let permissionManager: PermissionManager
let updater: AutoUpdater
function createWindow(): BrowserWindow {
const window = new BrowserWindow({
@@ -122,10 +123,14 @@ app.whenReady().then(async () => {
mainWindow = createWindow()
// Initialize auto-updater (only in production)
if (!is.dev) {
updater.setMainWindow(() => mainWindow)
// Check for updates after window is ready
// Initialize auto-updater
// Set FORCE_DEV_UPDATE=true to test updates in dev mode
const forceDevUpdate = process.env.FORCE_DEV_UPDATE === 'true'
updater = createUpdater(forceDevUpdate)
updater.setMainWindow(() => mainWindow)
// Auto-check for updates (in production or when forced)
if (!is.dev || forceDevUpdate) {
mainWindow.once('ready-to-show', () => {
updater.checkForUpdates()
})

View File

@@ -16,11 +16,25 @@ export interface UpdateStatus {
export class AutoUpdater {
private mainWindow: (() => BrowserWindow | null) | null = null
constructor() {
constructor(forceDevUpdateConfig = false) {
// Configure auto-updater
autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = true
// Enable update checking in dev mode for testing
if (forceDevUpdateConfig) {
autoUpdater.forceDevUpdateConfig = true
console.log('[AutoUpdater] Force dev update config enabled')
}
// Enable logging
autoUpdater.logger = {
info: (msg) => console.log('[AutoUpdater]', msg),
warn: (msg) => console.warn('[AutoUpdater]', msg),
error: (msg) => console.error('[AutoUpdater]', msg),
debug: (msg) => console.log('[AutoUpdater:debug]', msg)
}
// Set up event handlers
autoUpdater.on('checking-for-update', () => {
this.sendStatus({ status: 'checking' })
@@ -102,5 +116,7 @@ export class AutoUpdater {
}
}
// Singleton instance
export const updater = new AutoUpdater()
// Factory function to create updater with options
export function createUpdater(forceDevUpdateConfig = false): AutoUpdater {
return new AutoUpdater(forceDevUpdateConfig)
}