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 @@ -