Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 9a9e81e

Browse files
committed
[:star:] Log Implementation
1 parent a31e54b commit 9a9e81e

File tree

4 files changed

+53
-28
lines changed

4 files changed

+53
-28
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ node_modules
33
.next
44
app
55
dist
6-
electron-builder.yml
6+
electron-builder.yml
7+
dev-app-update.yml

main/background.ts

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,42 @@ import serve from 'electron-serve';
33
import { createWindow } from './helpers';
44
import fs from "fs"
55
import path from 'path';
6+
import electronLogger from "electron-log"
67

78
import { autoUpdater, UpdateInfo } from "electron-updater"
89

910
const isProd: boolean = process.env.NODE_ENV === 'production';
1011

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)
2537
})
38+
})
39+
40+
// AUTO UPDATER
2641

27-
// AUTO UPDATER
28-
}
2942
const renderPage = (pageName) => isProd ? `app://./${pageName}.html` : `http://localhost:${process.argv[2]}/${pageName}`
3043

3144
const getPasswords = () => {
@@ -66,15 +79,14 @@ if (isProd) {
6679

6780
mainWindow.loadURL(renderPage("main"))
6881

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+
})
7588

76-
autoUpdater.checkForUpdatesAndNotify()
77-
}
89+
autoUpdater.checkForUpdates()
7890

7991
setInterval(() => {
8092
if (mainWindow) mainWindow.webContents.send('update-version', app.getVersion())

package-lock.json

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"name": "lock-pass",
44
"description": "A simple password manager",
5-
"version": "1.1.2",
5+
"version": "1.2.0",
66
"author": "Nemika Hajbour <nemika@bytestobits.dev>",
77
"repository": {
88
"type": "git",
@@ -20,6 +20,7 @@
2020
"@chakra-ui/react": "^2.2.1",
2121
"@emotion/react": "^11.9.3",
2222
"@emotion/styled": "^11.9.3",
23+
"electron-log": "^4.4.7",
2324
"electron-serve": "^1.1.0",
2425
"electron-store": "^8.0.1",
2526
"electron-updater": "^5.0.1",

0 commit comments

Comments
 (0)