From 1b1c163924b32a917ac9e97c223a00e517d70fe8 Mon Sep 17 00:00:00 2001 From: zaru Date: Wed, 20 May 2020 19:02:03 +0900 Subject: [PATCH] Implemented updater --- app/auto-update.js | 36 ++++++++++++++++++ app/main.js | 1 + package-lock.json | 92 ++++++++++++++++++++++++++++++++++------------ package.json | 11 +++++- 4 files changed, 115 insertions(+), 25 deletions(-) create mode 100644 app/auto-update.js diff --git a/app/auto-update.js b/app/auto-update.js new file mode 100644 index 0000000..1f4e6dd --- /dev/null +++ b/app/auto-update.js @@ -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(); +}); diff --git a/app/main.js b/app/main.js index 57fcd06..865c3fb 100644 --- a/app/main.js +++ b/app/main.js @@ -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; diff --git a/package-lock.json b/package-lock.json index 1981770..60896f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mewcam", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1412,8 +1412,7 @@ "@types/node": { "version": "12.12.38", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.38.tgz", - "integrity": "sha512-75eLjX0pFuTcUXnnWmALMzzkYorjND0ezNEycaKesbUBg9eGZp4GHPuDmkRc4mQQvIpe29zrzATNRA6hkYqwmA==", - "dev": true + "integrity": "sha512-75eLjX0pFuTcUXnnWmALMzzkYorjND0ezNEycaKesbUBg9eGZp4GHPuDmkRc4mQQvIpe29zrzATNRA6hkYqwmA==" }, "@types/offscreencanvas": { "version": "2019.3.0", @@ -1431,6 +1430,14 @@ "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.27.tgz", "integrity": "sha1-nbVjk33YaRX2kJK8QyWdL0hXjkE=" }, + "@types/semver": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.2.0.tgz", + "integrity": "sha512-TbB0A8ACUWZt3Y6bQPstW9QNbhNeebdgLX4T/ZfkrswAfUzRiXrgd9seol+X379Wa589Pu4UEx9Uok0D4RjRCQ==", + "requires": { + "@types/node": "*" + } + }, "@types/webgl-ext": { "version": "0.0.30", "resolved": "https://registry.npmjs.org/@types/webgl-ext/-/webgl-ext-0.0.30.tgz", @@ -1703,7 +1710,6 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, "requires": { "sprintf-js": "~1.0.2" }, @@ -1711,8 +1717,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" } } }, @@ -1852,8 +1857,7 @@ "at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" }, "atob": { "version": "2.1.2", @@ -3167,7 +3171,6 @@ "version": "8.7.0", "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-8.7.0.tgz", "integrity": "sha512-G1AqqVM2vYTrSFR982c1NNzwXKrGLQjVjaZaWQdn4O6Z3YKjdMDofw88aD9jpyK9ZXkrCxR0tI3Qe9wNbyTlXg==", - "dev": true, "requires": { "debug": "^4.1.1", "sax": "^1.2.4" @@ -4431,7 +4434,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, "requires": { "ms": "^2.1.1" } @@ -4860,6 +4862,11 @@ "resolved": "https://registry.npmjs.org/electron-is-dev/-/electron-is-dev-1.2.0.tgz", "integrity": "sha512-R1oD5gMBPS7PVU8gJwH6CtT0e6VSoD0+SzSnYpNm+dBkcijgA+K7VAMHDfnRq/lkKPZArpzplTW6jfiMYosdzw==" }, + "electron-log": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/electron-log/-/electron-log-4.1.2.tgz", + "integrity": "sha512-MGPjGBEj6p0JdJmbqxbGud7kkHdV+T+D7gq1U+mfsnUM+o0bd4nPsQjVdgqQPsj0epoKdGbNIZ4FPpTQKhRfZA==" + }, "electron-publish": { "version": "22.6.0", "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-22.6.0.tgz", @@ -4912,6 +4919,47 @@ "integrity": "sha512-ty0LEroTap/xfMy31oQ3XX+Q377QvWvJaha2cmuXcbmBiX2EIB5SNDQ0hp8lhvxj63WG0zOgm/4MQ/oUBdfQqg==", "dev": true }, + "electron-updater": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-4.3.1.tgz", + "integrity": "sha512-UDC5AHCgeiHJYDYWZG/rsl1vdAFKqI/Lm7whN57LKAk8EfhTewhcEHzheRcncLgikMcQL8gFo1KeX51tf5a5Wg==", + "requires": { + "@types/semver": "^7.1.0", + "builder-util-runtime": "8.7.0", + "fs-extra": "^9.0.0", + "js-yaml": "^3.13.1", + "lazy-val": "^1.0.4", + "lodash.isequal": "^4.5.0", + "semver": "^7.1.3" + }, + "dependencies": { + "fs-extra": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz", + "integrity": "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==", + "requires": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^1.0.0" + } + }, + "jsonfile": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz", + "integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^1.0.0" + } + }, + "universalify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", + "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==" + } + } + }, "elliptic": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", @@ -5196,8 +5244,7 @@ "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { "version": "1.3.1", @@ -5894,8 +5941,7 @@ "graceful-fs": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" }, "grapheme-breaker": { "version": "0.3.2", @@ -6729,7 +6775,6 @@ "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", - "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -6943,8 +6988,7 @@ "lazy-val": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.4.tgz", - "integrity": "sha512-u93kb2fPbIrfzBuLjZE+w+fJbUUMhNDXxNmMfaqNgpfQf1CO5ZSe2LfsnBqVAk7i/2NF48OSoRj+Xe2VT+lE8Q==", - "dev": true + "integrity": "sha512-u93kb2fPbIrfzBuLjZE+w+fJbUUMhNDXxNmMfaqNgpfQf1CO5ZSe2LfsnBqVAk7i/2NF48OSoRj+Xe2VT+lE8Q==" }, "leven": { "version": "3.1.0", @@ -6992,6 +7036,11 @@ "integrity": "sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=", "dev": true }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" + }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -7285,8 +7334,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "mute-stream": { "version": "0.0.8", @@ -9472,8 +9520,7 @@ "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "saxes": { "version": "3.1.11", @@ -9492,8 +9539,7 @@ "semver": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" }, "semver-compare": { "version": "1.0.0", diff --git a/package.json b/package.json index a1acac1..0031dde 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mewcam", - "version": "1.1.0", + "version": "1.2.0", "description": "", "main": "app/main.js", "scripts": { @@ -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", @@ -46,6 +48,11 @@ "package.json", "package-lock.json" ], + "publish": [{ + "provider": "github", + "owner": "zaru", + "repo": "mewcam" + }], "mac": { "target": "dir", "entitlements": "entitlements.mac.plist"