Skip to content

Commit

Permalink
Implemented updater
Browse files Browse the repository at this point in the history
  • Loading branch information
zaru committed May 20, 2020
1 parent 6fdc0b3 commit 1b1c163
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 25 deletions.
36 changes: 36 additions & 0 deletions app/auto-update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const {app} = require('electron');
const log = require('electron-log');
const {autoUpdater} = require('electron-updater');

autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('App starting...');

function sendStatusToWindow(text) {
log.info(text);
}
autoUpdater.on('checking-for-update', () => {
sendStatusToWindow('Checking for update...');
});
autoUpdater.on('update-available', (info) => {
sendStatusToWindow('Update available.');
});
autoUpdater.on('update-not-available', (info) => {
sendStatusToWindow('Update not available.');
});
autoUpdater.on('error', (err) => {
sendStatusToWindow('Error in auto-updater. ' + err);
});
autoUpdater.on('download-progress', (progressObj) => {
let message = 'Download speed: ' + progressObj.bytesPerSecond;
message = message + ' - Downloaded ' + progressObj.percent + '%';
message = message + ' (' + progressObj.transferred + '/' + progressObj.total + ')';
sendStatusToWindow(message);
});
autoUpdater.on('update-downloaded', (info) => {
sendStatusToWindow('Update downloaded');
});
app.on('ready', async () => {
console.log('load auto-update');
autoUpdater.checkForUpdatesAndNotify();
});
1 change: 1 addition & 0 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const {app, BrowserWindow} = require('electron');
const isDev = require('electron-is-dev');
const os = require('os');
const path = require('path');
require('./auto-update');

if (isDev) {
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = true;
Expand Down
92 changes: 69 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mewcam",
"version": "1.1.0",
"version": "1.2.0",
"description": "",
"main": "app/main.js",
"scripts": {
Expand All @@ -17,7 +17,9 @@
"@tensorflow-models/posenet": "^2.2.1",
"@tensorflow/tfjs-converter": "^1.7.4",
"@tensorflow/tfjs-core": "^1.7.4",
"electron-is-dev": "^1.2.0"
"electron-is-dev": "^1.2.0",
"electron-log": "^4.1.2",
"electron-updater": "^4.3.1"
},
"devDependencies": {
"babel-core": "^6.26.3",
Expand Down Expand Up @@ -46,6 +48,11 @@
"package.json",
"package-lock.json"
],
"publish": [{
"provider": "github",
"owner": "zaru",
"repo": "mewcam"
}],
"mac": {
"target": "dir",
"entitlements": "entitlements.mac.plist"
Expand Down

0 comments on commit 1b1c163

Please sign in to comment.