@@ -12,6 +12,14 @@ import { PLATFORMS, getPlatformInfo } from './src/js/platforms.js';
1212import axios from 'axios' ;
1313import os from 'os' ;
1414
15+ // Auto-updater
16+ import { autoUpdater } from 'electron-updater' ;
17+ import log from 'electron-log' ;
18+
19+ // Enable logging
20+ autoUpdater . logger = log ;
21+ autoUpdater . logger . transports . file . level = 'info' ;
22+
1523
1624
1725let childProcesses = new Map ( ) ;
@@ -900,6 +908,35 @@ ipcMain.handle('get-versions', async () => {
900908} ) ;
901909
902910app . whenReady ( ) . then ( ( ) => {
911+ // Check for updates on startup
912+ autoUpdater . checkForUpdatesAndNotify ( ) ;
913+
914+ autoUpdater . on ( 'checking-for-update' , ( ) => {
915+ log . info ( 'Checking for update...' ) ;
916+ } ) ;
917+
918+ autoUpdater . on ( 'update-available' , ( info ) => {
919+ log . info ( 'Update available.' , info ) ;
920+ } ) ;
921+
922+ autoUpdater . on ( 'update-not-available' , ( info ) => {
923+ log . info ( 'Update not available.' , info ) ;
924+ } ) ;
925+
926+ autoUpdater . on ( 'error' , ( err ) => {
927+ log . error ( 'Error in auto-updater.' , err ) ;
928+ } ) ;
929+
930+ autoUpdater . on ( 'download-progress' , ( progressObj ) => {
931+ let log_message = "Download speed: " + progressObj . bytesPerSecond ;
932+ log_message = log_message + ' - Downloaded ' + progressObj . percent + '%' ;
933+ log_message = log_message + ' (' + progressObj . transferred + "/" + progressObj . total + ')' ;
934+ log . info ( log_message ) ;
935+ } ) ;
936+
937+ autoUpdater . on ( 'update-downloaded' , ( info ) => {
938+ log . info ( 'Update downloaded' , info ) ;
939+ } ) ;
903940
904941 session . defaultSession . webRequest . onHeadersReceived ( ( details , callback ) => {
905942 callback ( {
0 commit comments