From b655aef44c5ca6e368380dbd03d27a911c0a9871 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 26 Jun 2019 12:52:12 -0700 Subject: [PATCH 1/3] Add nagUser option to disable the upgrade dialog prompt --- index.js | 37 ++++++++++++++++++++----------------- readme.md | 16 +++++++++------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 9dcd754..5f27d0e 100644 --- a/index.js +++ b/index.js @@ -70,21 +70,23 @@ function initUpdater (opts) { log('update-not-available') }) - autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, releaseDate, updateURL) => { - log('update-downloaded', arguments) - - const dialogOpts = { - type: 'info', - buttons: ['Restart', 'Later'], - title: 'Application Update', - message: process.platform === 'win32' ? releaseNotes : releaseName, - detail: 'A new version has been downloaded. Restart the application to apply the updates.' - } - - dialog.showMessageBox(dialogOpts, (response) => { - if (response === 0) autoUpdater.quitAndInstall() + if (opts.nagUser) { + autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, releaseDate, updateURL) => { + log('update-downloaded', arguments) + + const dialogOpts = { + type: 'info', + buttons: ['Restart', 'Later'], + title: 'Application Update', + message: process.platform === 'win32' ? releaseNotes : releaseName, + detail: 'A new version has been downloaded. Restart the application to apply the updates.' + } + + dialog.showMessageBox(dialogOpts, (response) => { + if (response === 0) autoUpdater.quitAndInstall() + }) }) - }) + } // check for updates right away and keep checking later autoUpdater.checkForUpdates() @@ -95,9 +97,10 @@ function validateInput (opts) { const defaults = { host: 'https://update.electronjs.org', updateInterval: '10 minutes', - logger: console + logger: console, + nagUser: true } - const {host, updateInterval, logger} = Object.assign({}, defaults, opts) + const {host, updateInterval, logger, nagUser} = Object.assign({}, defaults, opts) // allows electron to be mocked in tests const electron = opts.electron || require('electron') @@ -140,5 +143,5 @@ function validateInput (opts) { 'function' ) - return {host, repo, updateInterval, logger, electron} + return {host, repo, updateInterval, logger, electron, nagUser} } diff --git a/readme.md b/readme.md index 36309de..f14f10c 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# update-electron-app +# update-electron-app > A drop-in module that adds autoUpdating capabilities to Electron apps @@ -57,20 +57,22 @@ Options: - `host` String (optional) - Defaults to `https://update.electronjs.org` - `updateInterval` String (optional) - How frequently to check for updates. Defaults to `10 minutes`. Minimum allowed interval is `5 minutes`. - `logger` Object (optional) - A custom logger object that defines a `log` function. Defaults to `console`. See [electron-log](https://github.com/megahertz/electron-log), a module that aggregates logs from main and renderer processes into a single file. +- `nagUser` Boolean (optional) - Defaults to true. When enabled the user will be + prompted to apply the update immediately after download. ## FAQ #### What kinds of assets do I need to build? -For macOS, you'll need to build a `.zip` file and include it in your GitHub Release. +For macOS, you'll need to build a `.zip` file and include it in your GitHub Release. Use [electron-forge] or [electron-installer-zip] to package your app as a zip. -For Windows, you'll need to build a `.exe` file and include it in your GitHub Release. +For Windows, you'll need to build a `.exe` file and include it in your GitHub Release. #### Why is my app launching multiple times? Windows apps have an update process that requires multiple application restarts. -You can use the [electron-squirrel-startup](https://github.com/mongodb-js/electron-squirrel-startup) module to improve this +You can use the [electron-squirrel-startup](https://github.com/mongodb-js/electron-squirrel-startup) module to improve this behavior. #### Can I use this module by uploading my private app's builds to a public GitHub repository? @@ -83,10 +85,10 @@ MIT ## See Also -If your app is packaged with `electron-builder`, you may not need this module. -Builder has its own built-in mechanism for updating apps. Find out more at +If your app is packaged with `electron-builder`, you may not need this module. +Builder has its own built-in mechanism for updating apps. Find out more at [electron.build/auto-update](https://www.electron.build/auto-update). [electron-forge]: https://github.com/electron-userland/electron-forge [electron-installer-zip]: https://github.com/mongodb-js/electron-installer-zip -[code signed]: https://github.com/electron/electron/blob/master/docs/tutorial/code-signing.md \ No newline at end of file +[code signed]: https://github.com/electron/electron/blob/master/docs/tutorial/code-signing.md From f4daa4bb1a80a02f8b3fb313a0aacdca6ac936d6 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 10 Jul 2019 14:35:36 -0700 Subject: [PATCH 2/3] s/nagUser/notifyUser/g --- index.js | 8 ++++---- readme.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 5f27d0e..2402fd3 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ function initUpdater (opts) { log('update-not-available') }) - if (opts.nagUser) { + if (opts.notifyUser) { autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, releaseDate, updateURL) => { log('update-downloaded', arguments) @@ -98,9 +98,9 @@ function validateInput (opts) { host: 'https://update.electronjs.org', updateInterval: '10 minutes', logger: console, - nagUser: true + notifyUser: true } - const {host, updateInterval, logger, nagUser} = Object.assign({}, defaults, opts) + const {host, updateInterval, logger, notifyUser} = Object.assign({}, defaults, opts) // allows electron to be mocked in tests const electron = opts.electron || require('electron') @@ -143,5 +143,5 @@ function validateInput (opts) { 'function' ) - return {host, repo, updateInterval, logger, electron, nagUser} + return {host, repo, updateInterval, logger, electron, notifyUser} } diff --git a/readme.md b/readme.md index f14f10c..4ed4ea1 100644 --- a/readme.md +++ b/readme.md @@ -57,7 +57,7 @@ Options: - `host` String (optional) - Defaults to `https://update.electronjs.org` - `updateInterval` String (optional) - How frequently to check for updates. Defaults to `10 minutes`. Minimum allowed interval is `5 minutes`. - `logger` Object (optional) - A custom logger object that defines a `log` function. Defaults to `console`. See [electron-log](https://github.com/megahertz/electron-log), a module that aggregates logs from main and renderer processes into a single file. -- `nagUser` Boolean (optional) - Defaults to true. When enabled the user will be +- `notifyUser` Boolean (optional) - Defaults to true. When enabled the user will be prompted to apply the update immediately after download. ## FAQ From cd002965d79c6aa729b326b1f24a4fdbe9ed41ae Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 10 Jul 2019 14:38:51 -0700 Subject: [PATCH 3/3] Update readme.md Co-Authored-By: Mark Lee --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 4ed4ea1..e6d5e8b 100644 --- a/readme.md +++ b/readme.md @@ -57,7 +57,7 @@ Options: - `host` String (optional) - Defaults to `https://update.electronjs.org` - `updateInterval` String (optional) - How frequently to check for updates. Defaults to `10 minutes`. Minimum allowed interval is `5 minutes`. - `logger` Object (optional) - A custom logger object that defines a `log` function. Defaults to `console`. See [electron-log](https://github.com/megahertz/electron-log), a module that aggregates logs from main and renderer processes into a single file. -- `notifyUser` Boolean (optional) - Defaults to true. When enabled the user will be +- `notifyUser` Boolean (optional) - Defaults to `true`. When enabled the user will be prompted to apply the update immediately after download. ## FAQ