1- import { BrowserWindow } from "electron" ;
1+ import { BrowserWindow , ipcMain } from "electron" ;
22import { autoUpdater } from "electron-updater" ;
33import log from "electron-log" ;
44
@@ -8,6 +8,27 @@ export class UpdateService {
88 constructor ( mainWindow : BrowserWindow ) {
99 this . mainWindow = mainWindow ;
1010 this . initializeAutoUpdater ( ) ;
11+ this . setupIpcHandlers ( ) ;
12+ }
13+
14+ private setupIpcHandlers ( ) {
15+ ipcMain . handle (
16+ "set-update-channel" ,
17+ ( _ , channel : "latest" | "latest-dev" ) => {
18+ this . setUpdateChannel ( channel ) ;
19+ }
20+ ) ;
21+ }
22+
23+ private setUpdateChannel ( channel : "latest" | "latest-dev" ) {
24+ autoUpdater . allowPrerelease = channel === "latest-dev" ;
25+
26+ let baseUrl =
27+ channel === "latest"
28+ ? "https://github.com/Hermesiss/DevNullifier/releases/latest/download/"
29+ : "https://github.com/Hermesiss/DevNullifier/releases/download/latest-dev/" ;
30+
31+ autoUpdater . setFeedURL ( baseUrl ) ;
1132 }
1233
1334 private initializeAutoUpdater ( ) {
@@ -16,22 +37,10 @@ export class UpdateService {
1637 autoUpdater . logger = log ;
1738
1839 // Configure update source and options
19- autoUpdater . channel = "latest" ;
2040 autoUpdater . allowDowngrade = false ;
21- autoUpdater . setFeedURL ( {
22- provider : "github" ,
23- owner : "Hermesiss" ,
24- repo : "DevNullifier"
25- } ) ;
2641
27- // Platform-specific configurations
28- if ( process . platform === "win32" ) {
29- autoUpdater . updateConfigPath = "latest.yml" ;
30- } else if ( process . platform === "darwin" ) {
31- autoUpdater . updateConfigPath = "latest-mac.yml" ;
32- } else if ( process . platform === "linux" ) {
33- autoUpdater . updateConfigPath = "latest-linux.yml" ;
34- }
42+ // Set update channel after config path
43+ this . setUpdateChannel ( "latest" ) ;
3544
3645 // Handle events
3746 autoUpdater . on ( "checking-for-update" , ( ) => {
0 commit comments