From 15b178a158953bbcd6ee20ec15d524e2c7a03703 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 13 Jun 2017 09:07:47 -0400 Subject: [PATCH] refactor(GUI): move ETCHER_DISABLE_UPDATES into package.json (#1501) Etcher supports disabling the update notification dialog by setting the `ETCHER_DISABLE_UPDATES` environment variable. In order to simplify disabling updates for when these are managed by a package manager (e.g. in a debian package), this removes support for the `ETCHER_DISABLE_UPDATES` environment variable, and instead requires packagers to tweak the `updates.enabled` property of the package.json file, which is set to `true` by default. We don't want to encourage end users to disable the update mechanism, so the documention was removed from `USER-DOCUMENTATION.md`. This option will remain as something only packagers should tweak. Change-Type: minor Changelog-Entry: Remove support for the `ETCHER_DISABLE_UPDATES` environment variable. Signed-off-by: Juan Cruz Viotti --- Makefile | 20 +++++++++++++++++-- docs/PUBLISHING.md | 6 ++++++ docs/USER-DOCUMENTATION.md | 19 ------------------ lib/gui/app.js | 9 +++------ lib/gui/models/store.js | 1 + .../pages/settings/controllers/settings.js | 7 ------- .../settings/templates/settings.tpl.html | 2 +- package.json | 1 + scripts/build/debian/config.json | 2 +- scripts/build/debian/etcher-electron.sh | 4 ---- .../build/electron-installer-debian-linux.sh | 2 -- .../build/electron-installer-redhat-linux.sh | 2 -- scripts/build/jq-insert.sh | 2 +- scripts/build/redhat/config.json | 2 +- scripts/build/redhat/etcher-electron.sh | 4 ---- 15 files changed, 33 insertions(+), 50 deletions(-) delete mode 100755 scripts/build/debian/etcher-electron.sh delete mode 100755 scripts/build/redhat/etcher-electron.sh diff --git a/Makefile b/Makefile index 04665cce..d21af0bc 100644 --- a/Makefile +++ b/Makefile @@ -149,6 +149,14 @@ ifndef ANALYTICS_MIXPANEL_TOKEN $(warning No Mixpanel token found (ANALYTICS_MIXPANEL_TOKEN is not set)) endif +# --------------------------------------------------------------------- +# Updates +# --------------------------------------------------------------------- + +ifdef DISABLE_UPDATES +$(warning Update notification dialog has been disabled (DISABLE_UPDATES is set)) +endif + # --------------------------------------------------------------------- # Extra variables # --------------------------------------------------------------------- @@ -219,7 +227,7 @@ $(BUILD_DIRECTORY)/electron-$(TARGET_PLATFORM)-$(APPLICATION_VERSION)-$(TARGET_A ifdef ANALYTICS_SENTRY_TOKEN ./scripts/build/jq-insert.sh \ -p "analytics.sentry.token" \ - -v "$(ANALYTICS_SENTRY_TOKEN)" \ + -v "\"$(ANALYTICS_SENTRY_TOKEN)\"" \ -f $@/package.json \ -t $(BUILD_TEMPORARY_DIRECTORY) endif @@ -227,7 +235,15 @@ endif ifdef ANALYTICS_MIXPANEL_TOKEN ./scripts/build/jq-insert.sh \ -p "analytics.mixpanel.token" \ - -v "$(ANALYTICS_MIXPANEL_TOKEN)" \ + -v "\"$(ANALYTICS_MIXPANEL_TOKEN)\"" \ + -f $@/package.json \ + -t $(BUILD_TEMPORARY_DIRECTORY) +endif + +ifdef DISABLE_UPDATES + ./scripts/build/jq-insert.sh \ + -p "updates.enabled" \ + -v "false" \ -f $@/package.json \ -t $(BUILD_TEMPORARY_DIRECTORY) endif diff --git a/docs/PUBLISHING.md b/docs/PUBLISHING.md index 9cb4220c..59e1d8a9 100644 --- a/docs/PUBLISHING.md +++ b/docs/PUBLISHING.md @@ -96,6 +96,12 @@ make electron-installer-zip make electron-installer-nsis ``` +Disabling updates +----------------- + +You can disable updates in the final artifact by passing `DISABLE_UPDATES=1` to +the `make` targets described above. + Publishing to Bintray --------------------- diff --git a/docs/USER-DOCUMENTATION.md b/docs/USER-DOCUMENTATION.md index 1dc46964..b13a525a 100644 --- a/docs/USER-DOCUMENTATION.md +++ b/docs/USER-DOCUMENTATION.md @@ -130,25 +130,6 @@ run Etcher on a GNU/Linux system. - liblzma (for xz decompression) -Disable update notifications ----------------------------- - -You can disable update notifications, which can be useful when running Etcher -outside a common desktop environment (like in a [resin.io] application), by -setting the `ETCHER_DISABLE_UPDATES` environment variable. - -In GNU/Linux and Mac OS X: - -```sh -export ETCHER_DISABLE_UPDATES=1 -``` - -In Windows: - -```sh -set ETCHER_DISABLE_UPDATES=1 -``` - Simulate an update alert ------------------------ diff --git a/lib/gui/app.js b/lib/gui/app.js index 7b4ae720..ae881240 100644 --- a/lib/gui/app.js +++ b/lib/gui/app.js @@ -29,7 +29,6 @@ var angular = require('angular'); const electron = require('electron'); const Bluebird = require('bluebird'); const semver = require('semver'); -const _ = require('lodash'); const EXIT_CODES = require('../shared/exit-codes'); const messages = require('../shared/messages'); const s3Packages = require('../shared/s3-packages'); @@ -98,14 +97,12 @@ app.run((ErrorService) => { }); const currentReleaseType = release.getReleaseType(currentVersion); + const updatesEnabled = settings.get('updatesEnabled'); - if (_.some([ - !shouldCheckForUpdates, - process.env.ETCHER_DISABLE_UPDATES - ])) { + if (!shouldCheckForUpdates || !updatesEnabled) { analytics.logEvent('Not checking for updates', { shouldCheckForUpdates, - disableUpdatesEnvironmentVariable: process.env.ETCHER_DISABLE_UPDATES, + updatesEnabled, releaseType: currentReleaseType }); return; diff --git a/lib/gui/models/store.js b/lib/gui/models/store.js index 6744348a..b8e76423 100644 --- a/lib/gui/models/store.js +++ b/lib/gui/models/store.js @@ -49,6 +49,7 @@ const DEFAULT_STATE = Immutable.fromJS({ errorReporting: true, unmountOnSuccess: true, validateWriteOnSuccess: true, + updatesEnabled: Boolean(packageJSON.updates.enabled), includeUnstableUpdateChannel: !release.isStableRelease(packageJSON.version), lastSleptUpdateNotifier: null, lastSleptUpdateNotifierVersion: null diff --git a/lib/gui/pages/settings/controllers/settings.js b/lib/gui/pages/settings/controllers/settings.js index 746560e9..cd1be236 100644 --- a/lib/gui/pages/settings/controllers/settings.js +++ b/lib/gui/pages/settings/controllers/settings.js @@ -55,13 +55,6 @@ module.exports = function(WarningModalService, ErrorService) { */ this.model = settings; - /** - * @summary Environment - * @type {Object} - * @public - */ - this.disableUpdates = Boolean(process.env.ETCHER_DISABLE_UPDATES); - /** * @summary Toggle setting * @function diff --git a/lib/gui/pages/settings/templates/settings.tpl.html b/lib/gui/pages/settings/templates/settings.tpl.html index a7828851..153938c4 100644 --- a/lib/gui/pages/settings/templates/settings.tpl.html +++ b/lib/gui/pages/settings/templates/settings.tpl.html @@ -40,7 +40,7 @@ -
+