From c5fad7cdd86026a13e3b90b9a614d90ef21137b5 Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Wed, 3 Jun 2020 14:37:50 -0300 Subject: [PATCH 1/2] Add dialog and skip version --- dev-app-update.yml | 4 ++++ public/auto-updater/index.js | 24 ++++++++++++++++-------- yarn.lock | 12 ++++++++++-- 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 dev-app-update.yml diff --git a/dev-app-update.yml b/dev-app-update.yml new file mode 100644 index 00000000..44400372 --- /dev/null +++ b/dev-app-update.yml @@ -0,0 +1,4 @@ +owner: gnosis +repo: safe-react +provider: github +updaterCacheDirName: safe-react-updater diff --git a/public/auto-updater/index.js b/public/auto-updater/index.js index 8fbb8404..d3b96607 100644 --- a/public/auto-updater/index.js +++ b/public/auto-updater/index.js @@ -1,8 +1,8 @@ const os = require('os'); -const fetch = require('node-fetch'); -const { dialog, app } = require('electron'); +const { dialog } = require('electron'); const log = require('electron-log'); -const isDev = require("electron-is-dev"); +const settings =require('electron-settings'); + const { autoUpdater } = require("electron-updater"); // This logging setup is not required for auto-updates to work, @@ -19,7 +19,7 @@ let downloadProgress = 0; function init(mainWindow) { - if(initialized || isDev) return; + if(initialized) return; initialized = true; @@ -27,24 +27,32 @@ function init(mainWindow) { log.error(error == null ? "unknown" : (error.stack || error).toString()); }); - autoUpdater.on('update-available', () => { + autoUpdater.on('update-available', (info) => { + if(info.version === settings.get('release.version')) { + log.info(`Skipped version ${info.version}`); + return; + } dialog.showMessageBox({ type: 'info', title: 'Found Updates', message: 'There is a newer version of this app available. Do you want to update now?', - buttons: ['Yes', 'Remind me later'], + detail: info.releaseNotes.replace(/(<([^>]+)>)/g, ""), + buttons: ['Install Update', 'Remind me later','Skip this version'], cancelId:1, - }).then(result => { + }).then(async result => { if(result.response === 0){ autoUpdater.downloadUpdate(); } + if(result.response === 2) { + await settings.set('release', {version: info.version }); + } }); autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { autoUpdater.logger.info("Update Downloaded..."); dialog.showMessageBox({ title: 'Install Updates', - message: process.platform === 'win32' ? releaseNotes : releaseName, + message: releaseName, detail: 'A new version has been downloaded. Restart the application to apply the updates.', buttons: ['Restart', 'Cancel'], cancelId:1, diff --git a/yarn.lock b/yarn.lock index 8991db61..4739353e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6278,6 +6278,14 @@ electron-publish@22.2.0: lazy-val "^1.0.4" mime "^2.4.4" +electron-settings@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/electron-settings/-/electron-settings-3.2.0.tgz#01461e153f95b6f18adbe0c360c70898eb0f43c3" + integrity sha512-7U+vDKd5Gch4Z9K6FjGq80eB3Anwz2GuPc2h/6hOiuvZrS1w+UNPcAA0oAU8G1s9sWAVEadCsr4ZJR6J4iTdzA== + dependencies: + clone "^2.1.1" + jsonfile "^4.0.0" + electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.413, electron-to-chromium@^1.3.47: version "1.3.453" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.453.tgz#758a8565a64b7889b27132a51d2abb8b135c9d01" @@ -17021,9 +17029,9 @@ web3-provider-engine@^15.0.4: xhr "^2.2.0" xtend "^4.0.1" -"web3-provider-engine@git+https://github.com/trufflesuite/provider-engine.git#web3-one": +"web3-provider-engine@https://github.com/trufflesuite/provider-engine#web3-one": version "14.0.6" - resolved "git+https://github.com/trufflesuite/provider-engine.git#3538c60bc4836b73ccae1ac3f64c8fed8ef19c1a" + resolved "https://github.com/trufflesuite/provider-engine#3538c60bc4836b73ccae1ac3f64c8fed8ef19c1a" dependencies: async "^2.5.0" backoff "^2.5.0" From 84c525673a172f6d89398a7fd2990c9564e88f3f Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Sun, 7 Jun 2020 22:23:05 -0300 Subject: [PATCH 2/2] Update electron-settings --- package.json | 1 + public/auto-updater/index.js | 6 +++--- yarn.lock | 40 ++++++++++++++++++++++++++++-------- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 10054eae..76d607ed 100644 --- a/package.json +++ b/package.json @@ -167,6 +167,7 @@ "date-fns": "2.14.0", "electron-is-dev": "^1.1.0", "electron-log": "4.2.1", + "electron-settings": "^4.0.0", "electron-updater": "4.3.1", "eth-sig-util": "^2.5.3", "express": "^4.17.1", diff --git a/public/auto-updater/index.js b/public/auto-updater/index.js index d3b96607..4966b25b 100644 --- a/public/auto-updater/index.js +++ b/public/auto-updater/index.js @@ -1,7 +1,7 @@ const os = require('os'); const { dialog } = require('electron'); const log = require('electron-log'); -const settings =require('electron-settings'); +const settings = require('electron-settings').default; const { autoUpdater } = require("electron-updater"); @@ -39,12 +39,12 @@ function init(mainWindow) { detail: info.releaseNotes.replace(/(<([^>]+)>)/g, ""), buttons: ['Install Update', 'Remind me later','Skip this version'], cancelId:1, - }).then(async result => { + }).then(result => { if(result.response === 0){ autoUpdater.downloadUpdate(); } if(result.response === 2) { - await settings.set('release', {version: info.version }); + settings.set('release', {version: info.version }); } }); diff --git a/yarn.lock b/yarn.lock index bb0b9704..68b5017d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6202,13 +6202,17 @@ electron-publish@22.7.0: lazy-val "^1.0.4" mime "^2.4.5" -electron-settings@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/electron-settings/-/electron-settings-3.2.0.tgz#01461e153f95b6f18adbe0c360c70898eb0f43c3" - integrity sha512-7U+vDKd5Gch4Z9K6FjGq80eB3Anwz2GuPc2h/6hOiuvZrS1w+UNPcAA0oAU8G1s9sWAVEadCsr4ZJR6J4iTdzA== +electron-settings@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/electron-settings/-/electron-settings-4.0.0.tgz#e30938204ceecf83241a9f70f16395a95705df6e" + integrity sha512-9Msvqk8pu3lT71PUIVfqlzEx9zrXmq+5AYHc7dcftD0gbDzpYP6aBIx6En6rn1352IRTSE6JbnE/ud4SpfU1mg== dependencies: - clone "^2.1.1" - jsonfile "^4.0.0" + lodash.get "^4.4.2" + lodash.has "^4.5.2" + lodash.set "^4.3.2" + lodash.unset "^4.5.2" + mkdirp "^1.0.4" + write-file-atomic "^3.0.3" electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.413, electron-to-chromium@^1.3.47: version "1.3.459" @@ -10497,6 +10501,16 @@ lodash.flatmap@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz#ef8cbf408f6e48268663345305c6acc0b778702e" integrity sha1-74y/QI9uSCaGYzRTBcaswLd4cC4= +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= + +lodash.has@^4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862" + integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI= + lodash.isequal@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" @@ -10507,6 +10521,11 @@ lodash.memoize@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= +lodash.set@^4.3.2: + version "4.3.2" + resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" + integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= + lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" @@ -10532,6 +10551,11 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= +lodash.unset@^4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/lodash.unset/-/lodash.unset-4.5.2.tgz#370d1d3e85b72a7e1b0cdf2d272121306f23e4ed" + integrity sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0= + "lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5, lodash@~4.17.12: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" @@ -11078,7 +11102,7 @@ mkdirp-promise@^5.0.1: dependencies: mkdirp "*" -mkdirp@*: +mkdirp@*, mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== @@ -17524,7 +17548,7 @@ write-file-atomic@2.4.1: imurmurhash "^0.1.4" signal-exit "^3.0.2" -write-file-atomic@^3.0.0: +write-file-atomic@^3.0.0, write-file-atomic@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8" integrity sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==