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 <jv@jviotti.com>
This commit is contained in:
Juan Cruz Viotti 2017-06-13 09:07:47 -04:00 committed by GitHub
parent 22be831535
commit 15b178a158
15 changed files with 33 additions and 50 deletions

View File

@ -149,6 +149,14 @@ ifndef ANALYTICS_MIXPANEL_TOKEN
$(warning No Mixpanel token found (ANALYTICS_MIXPANEL_TOKEN is not set)) $(warning No Mixpanel token found (ANALYTICS_MIXPANEL_TOKEN is not set))
endif endif
# ---------------------------------------------------------------------
# Updates
# ---------------------------------------------------------------------
ifdef DISABLE_UPDATES
$(warning Update notification dialog has been disabled (DISABLE_UPDATES is set))
endif
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Extra variables # Extra variables
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
@ -219,7 +227,7 @@ $(BUILD_DIRECTORY)/electron-$(TARGET_PLATFORM)-$(APPLICATION_VERSION)-$(TARGET_A
ifdef ANALYTICS_SENTRY_TOKEN ifdef ANALYTICS_SENTRY_TOKEN
./scripts/build/jq-insert.sh \ ./scripts/build/jq-insert.sh \
-p "analytics.sentry.token" \ -p "analytics.sentry.token" \
-v "$(ANALYTICS_SENTRY_TOKEN)" \ -v "\"$(ANALYTICS_SENTRY_TOKEN)\"" \
-f $@/package.json \ -f $@/package.json \
-t $(BUILD_TEMPORARY_DIRECTORY) -t $(BUILD_TEMPORARY_DIRECTORY)
endif endif
@ -227,7 +235,15 @@ endif
ifdef ANALYTICS_MIXPANEL_TOKEN ifdef ANALYTICS_MIXPANEL_TOKEN
./scripts/build/jq-insert.sh \ ./scripts/build/jq-insert.sh \
-p "analytics.mixpanel.token" \ -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 \ -f $@/package.json \
-t $(BUILD_TEMPORARY_DIRECTORY) -t $(BUILD_TEMPORARY_DIRECTORY)
endif endif

View File

@ -96,6 +96,12 @@ make electron-installer-zip
make electron-installer-nsis 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 Publishing to Bintray
--------------------- ---------------------

View File

@ -130,25 +130,6 @@ run Etcher on a GNU/Linux system.
- liblzma (for xz decompression) - 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 Simulate an update alert
------------------------ ------------------------

View File

@ -29,7 +29,6 @@ var angular = require('angular');
const electron = require('electron'); const electron = require('electron');
const Bluebird = require('bluebird'); const Bluebird = require('bluebird');
const semver = require('semver'); const semver = require('semver');
const _ = require('lodash');
const EXIT_CODES = require('../shared/exit-codes'); const EXIT_CODES = require('../shared/exit-codes');
const messages = require('../shared/messages'); const messages = require('../shared/messages');
const s3Packages = require('../shared/s3-packages'); const s3Packages = require('../shared/s3-packages');
@ -98,14 +97,12 @@ app.run((ErrorService) => {
}); });
const currentReleaseType = release.getReleaseType(currentVersion); const currentReleaseType = release.getReleaseType(currentVersion);
const updatesEnabled = settings.get('updatesEnabled');
if (_.some([ if (!shouldCheckForUpdates || !updatesEnabled) {
!shouldCheckForUpdates,
process.env.ETCHER_DISABLE_UPDATES
])) {
analytics.logEvent('Not checking for updates', { analytics.logEvent('Not checking for updates', {
shouldCheckForUpdates, shouldCheckForUpdates,
disableUpdatesEnvironmentVariable: process.env.ETCHER_DISABLE_UPDATES, updatesEnabled,
releaseType: currentReleaseType releaseType: currentReleaseType
}); });
return; return;

View File

@ -49,6 +49,7 @@ const DEFAULT_STATE = Immutable.fromJS({
errorReporting: true, errorReporting: true,
unmountOnSuccess: true, unmountOnSuccess: true,
validateWriteOnSuccess: true, validateWriteOnSuccess: true,
updatesEnabled: Boolean(packageJSON.updates.enabled),
includeUnstableUpdateChannel: !release.isStableRelease(packageJSON.version), includeUnstableUpdateChannel: !release.isStableRelease(packageJSON.version),
lastSleptUpdateNotifier: null, lastSleptUpdateNotifier: null,
lastSleptUpdateNotifierVersion: null lastSleptUpdateNotifierVersion: null

View File

@ -55,13 +55,6 @@ module.exports = function(WarningModalService, ErrorService) {
*/ */
this.model = settings; this.model = settings;
/**
* @summary Environment
* @type {Object}
* @public
*/
this.disableUpdates = Boolean(process.env.ETCHER_DISABLE_UPDATES);
/** /**
* @summary Toggle setting * @summary Toggle setting
* @function * @function

View File

@ -40,7 +40,7 @@
</label> </label>
</div> </div>
<div class="checkbox" ng-hide="settings.disableUpdates"> <div class="checkbox" ng-show="settings.model.get('updatesEnabled')">
<label> <label>
<input type="checkbox" <input type="checkbox"
ng-model="settings.currentData.includeUnstableUpdateChannel" ng-model="settings.currentData.includeUnstableUpdateChannel"

View File

@ -2,6 +2,7 @@
"name": "etcher", "name": "etcher",
"version": "1.0.0", "version": "1.0.0",
"updates": { "updates": {
"enabled": true,
"sleepDays": 7, "sleepDays": 7,
"semverRange": "<2.0.0" "semverRange": "<2.0.0"
}, },

View File

@ -4,7 +4,7 @@
"genericName": "Etcher", "genericName": "Etcher",
"homepage": "https://etcher.io/", "homepage": "https://etcher.io/",
"icon": "assets/icon.png", "icon": "assets/icon.png",
"bin": "etcher-electron.sh", "bin": "etcher",
"categories": [ "categories": [
"Utility" "Utility"
], ],

View File

@ -1,4 +0,0 @@
#!/bin/sh
export ETCHER_DISABLE_UPDATES=1
/usr/lib/etcher-electron/etcher "$@"

View File

@ -67,10 +67,8 @@ fi
DEBIAN_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t debian) DEBIAN_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t debian)
cp scripts/build/debian/etcher-electron.sh "$ARGV_DIRECTORY"
electron-installer-debian \ electron-installer-debian \
--src "$ARGV_DIRECTORY" \ --src "$ARGV_DIRECTORY" \
--dest "$ARGV_OUTPUT" \ --dest "$ARGV_OUTPUT" \
--config "$ARGV_DEBIAN_CONFIGURATION" \ --config "$ARGV_DEBIAN_CONFIGURATION" \
--arch "$DEBIAN_ARCHITECTURE" --arch "$DEBIAN_ARCHITECTURE"
rm "$ARGV_DIRECTORY/etcher-electron.sh"

View File

@ -67,10 +67,8 @@ fi
REDHAT_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t redhat) REDHAT_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t redhat)
cp scripts/build/redhat/etcher-electron.sh "$ARGV_DIRECTORY"
electron-installer-redhat \ electron-installer-redhat \
--src "$ARGV_DIRECTORY" \ --src "$ARGV_DIRECTORY" \
--dest "$ARGV_OUTPUT" \ --dest "$ARGV_OUTPUT" \
--config "$ARGV_REDHAT_CONFIGURATION" \ --config "$ARGV_REDHAT_CONFIGURATION" \
--arch "$REDHAT_ARCHITECTURE" --arch "$REDHAT_ARCHITECTURE"
rm "$ARGV_DIRECTORY/etcher-electron.sh"

View File

@ -56,5 +56,5 @@ if [ -z "$ARGV_PROPERTY" ] ||
fi fi
TEMPORARY_FILE="$ARGV_TEMPORARY_DIRECTORY/$(basename "$ARGV_FILE").TMP" TEMPORARY_FILE="$ARGV_TEMPORARY_DIRECTORY/$(basename "$ARGV_FILE").TMP"
cat "$ARGV_FILE" | jq ".$ARGV_PROPERTY=\"$ARGV_VALUE\"" > "$TEMPORARY_FILE" cat "$ARGV_FILE" | jq ".$ARGV_PROPERTY=$ARGV_VALUE" > "$TEMPORARY_FILE"
mv "$TEMPORARY_FILE" "$ARGV_FILE" mv "$TEMPORARY_FILE" "$ARGV_FILE"

View File

@ -4,7 +4,7 @@
"genericName": "Etcher", "genericName": "Etcher",
"homepage": "https://etcher.io/", "homepage": "https://etcher.io/",
"icon": "assets/icon.png", "icon": "assets/icon.png",
"bin": "etcher-electron.sh", "bin": "etcher",
"categories": [ "categories": [
"Utility" "Utility"
], ],

View File

@ -1,4 +0,0 @@
#!/bin/sh
export ETCHER_DISABLE_UPDATES=1
/usr/share/etcher-electron/etcher "$@"