@@ -3,29 +3,42 @@ import serve from 'electron-serve';
3
3
import { createWindow } from './helpers' ;
4
4
import fs from "fs"
5
5
import path from 'path' ;
6
+ import electronLogger from "electron-log"
6
7
7
8
import { autoUpdater , UpdateInfo } from "electron-updater"
8
9
9
10
const isProd : boolean = process . env . NODE_ENV === 'production' ;
10
11
11
- if ( isProd ) {
12
- // AUTO UPDATER
13
- //const server = 'https://your-deployment-url.com'
14
- //const url = `${server}/update/${process.platform}/${app.getVersion()}`
15
-
16
- autoUpdater . on ( "update-downloaded" , ( info : UpdateInfo ) => {
17
- dialog . showMessageBox ( {
18
- title : "New Update Available" ,
19
- detail : `Version ${ info . version } available` ,
20
- message : "A new version is available. Please restart to apply updates." ,
21
- buttons : [ 'Restart' , 'Later' ]
22
- } ) . then ( returnValue => {
23
- if ( returnValue . response == 0 ) autoUpdater . quitAndInstall ( true , true )
24
- } )
12
+ if ( ! isProd ) {
13
+ electronLogger . log ( app . getVersion ( ) )
14
+ }
15
+
16
+ // AUTO UPDATER
17
+ //const server = 'https://your-deployment-url.com'
18
+ //const url = `${server}/update/${process.platform}/${app.getVersion()}`
19
+ autoUpdater . logger = electronLogger
20
+
21
+ // @ts -ignore
22
+ autoUpdater . logger . transports . file . level = "info"
23
+ autoUpdater . allowPrerelease = false
24
+ autoUpdater . autoDownload = isProd
25
+ autoUpdater . autoInstallOnAppQuit = isProd
26
+
27
+ autoUpdater . on ( "update-downloaded" , ( info : UpdateInfo ) => {
28
+ electronLogger . log ( `Version ${ info . version } downloaded` )
29
+
30
+ dialog . showMessageBox ( {
31
+ title : "New Update Available" ,
32
+ detail : `Version ${ info . version } available` ,
33
+ message : "A new version is available. Please restart to apply updates." ,
34
+ buttons : [ 'Restart' , 'Later' ]
35
+ } ) . then ( returnValue => {
36
+ if ( returnValue . response == 0 ) autoUpdater . quitAndInstall ( true , true )
25
37
} )
38
+ } )
39
+
40
+ // AUTO UPDATER
26
41
27
- // AUTO UPDATER
28
- }
29
42
const renderPage = ( pageName ) => isProd ? `app://./${ pageName } .html` : `http://localhost:${ process . argv [ 2 ] } /${ pageName } `
30
43
31
44
const getPasswords = ( ) => {
@@ -66,15 +79,14 @@ if (isProd) {
66
79
67
80
mainWindow . loadURL ( renderPage ( "main" ) )
68
81
69
- if ( isProd ) {
70
- autoUpdater . on ( "update-available" , ( info : UpdateInfo ) => {
71
- setTimeout ( ( ) => {
72
- if ( mainWindow ) mainWindow . webContents . send ( 'new-update' , info . version )
73
- } , 6000 )
74
- } )
82
+ autoUpdater . on ( "update-available" , ( info : UpdateInfo ) => {
83
+ setTimeout ( ( ) => {
84
+ if ( mainWindow ) mainWindow . webContents . send ( 'new-update' , info . version )
85
+ electronLogger . log ( "UPDATE AVAILABLE:" , info )
86
+ } , 6000 )
87
+ } )
75
88
76
- autoUpdater . checkForUpdatesAndNotify ( )
77
- }
89
+ autoUpdater . checkForUpdates ( )
78
90
79
91
setInterval ( ( ) => {
80
92
if ( mainWindow ) mainWindow . webContents . send ( 'update-version' , app . getVersion ( ) )
0 commit comments