Skip to content

Commit e3290c1

Browse files
committed
Switch to new auto-update & add linux build
* Remove squirrel hooks (the installing & uninstalling is now done by the, er, installer) * Switch to electron-auto-update * Shorten initial update delay because we no longer need to wait for squirrel to release a lock file * Change update URLs because windows is now one installer for both 32 & 64 bit. * Update electron-builder to 10 where NSIS is now the default target for Windows. * Add linux to the target list, building a deb. * Remove sqirrel-specific installation spinner * Remove redundant !**/* from files
1 parent 4988f06 commit e3290c1

4 files changed

Lines changed: 21 additions & 62 deletions

File tree

‎electron/build/install-spinner.gif‎

-23.4 KB
Binary file not shown.

‎electron/src/electron-main.js‎

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919

20-
// Squirrel on windows starts the app with various flags
21-
// as hooks to tell us when we've been installed/uninstalled
22-
// etc.
23-
const check_squirrel_hooks = require('./squirrelhooks');
24-
if (check_squirrel_hooks()) return;
25-
2620
const electron = require('electron');
21+
22+
// Auto updater from the 'electron-auto-updater' package for NSIS
23+
// auto-update support (not the one that comes with electron).
24+
const autoUpdater = require('electron-auto-updater').autoUpdater;
2725
const url = require('url');
2826

2927
const VectorMenu = require('./vectormenu');
@@ -45,7 +43,7 @@ const PERMITTED_URL_SCHEMES = [
4543
];
4644

4745
const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000;
48-
const INITIAL_UPDATE_DELAY_MS = 30 * 1000;
46+
const INITIAL_UPDATE_DELAY_MS = 5 * 1000;
4947

5048
let mainWindow = null;
5149
let appQuitting = false;
@@ -90,12 +88,12 @@ function installUpdate() {
9088
// for some reason, quitAndInstall does not fire the
9189
// before-quit event, so we need to set the flag here.
9290
appQuitting = true;
93-
electron.autoUpdater.quitAndInstall();
91+
autoUpdater.quitAndInstall();
9492
}
9593

9694
function pollForUpdates() {
9795
try {
98-
electron.autoUpdater.checkForUpdates();
96+
autoUpdater.checkForUpdates();
9997
} catch (e) {
10098
console.log("Couldn't check for update", e);
10199
}
@@ -106,30 +104,19 @@ function startAutoUpdate(update_url) {
106104
update_url = update_url + '/';
107105
}
108106
try {
109-
// For reasons best known to Squirrel, the way it checks for updates
110-
// is completely different between macOS and windows. On macOS, it
111-
// hits a URL that either gives it a 200 with some json or
112-
// 204 No Content. On windows it takes a base path and looks for
113-
// files under that path.
107+
// Since writing, the electron auto update process has changed from being
108+
// completely different between platforms to being differently completely
109+
// different. On Mac, we set the feed URL here. On Windows, it uses a
110+
// yaml file bundled at build time from the 'publish' entry in the
111+
// package.json. There is no autoupdate for Linux: it's expected that
112+
// the distro will provide it.
114113
if (process.platform == 'darwin') {
115-
// macos only has 64 bit
116-
electron.autoUpdater.setFeedURL(update_url + 'macos/');
117-
} else if (process.platform == 'win32') {
118-
// We split by 32/64 bit too: the builds are different and entirely separate
119-
electron.autoUpdater.setFeedURL(update_url + 'win32/' + process.arch + '/');
120-
} else {
121-
// Squirrel / electron only supports auto-update on these two platforms.
122-
// I'm not even going to try to guess which feed style they'd use if they
123-
// implemented it on Linux, or if it would be different again.
124-
console.log("Auto update not supported on this platform");
114+
autoUpdater.setFeedURL(update_url + 'macos/');
125115
}
126116
// We check for updates ourselves rather than using 'updater' because we need to
127117
// do it in the main process (and we don't really need to check every 10 minutes:
128118
// every hour should be just fine for a desktop app)
129119
// However, we still let the main window listen for the update events.
130-
// We also wait a short time before checking for updates the first time because
131-
// of squirrel on windows and it taking a small amount of time to release a
132-
// lock file.
133120
setTimeout(pollForUpdates, INITIAL_UPDATE_DELAY_MS);
134121
setInterval(pollForUpdates, UPDATE_POLL_INTERVAL_MS);
135122
} catch (err) {

‎electron/src/squirrelhooks.js‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎package.json‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"build:compile": "babel --source-maps -d lib src",
3636
"build:bundle": "NODE_ENV=production webpack -p --progress",
3737
"build:bundle:dev": "webpack --optimize-occurence-order --progress",
38-
"build:electron": "rimraf electron/dist && npm run clean && npm run build && build -wm --ia32 --x64 && scripts/check-electron.sh",
38+
"build:electron": "rimraf electron/dist && npm run clean && npm run build && build -wml --ia32 --x64 && scripts/check-electron.sh",
3939
"build": "node scripts/babelcheck.js && npm run build:res && npm run build:config && npm run build:emojione && npm run build:css && npm run build:bundle",
4040
"build:dev": "node scripts/babelcheck.js && npm run build:res && npm run build:config && npm run build:emojione && npm run build:css && npm run build:bundle:dev",
4141
"dist": "scripts/package.sh",
@@ -58,6 +58,7 @@
5858
"browser-request": "^0.3.3",
5959
"classnames": "^2.1.2",
6060
"draft-js": "^0.8.1",
61+
"electron-auto-updater": "^0.6.2",
6162
"extract-text-webpack-plugin": "^0.9.1",
6263
"favico.js": "^0.3.10",
6364
"filesize": "^3.1.2",
@@ -97,7 +98,7 @@
9798
"catw": "^1.0.1",
9899
"cpx": "^1.3.2",
99100
"css-raw-loader": "^0.1.1",
100-
"electron-builder": "^7.23.2",
101+
"electron-builder": "^10.4.1",
101102
"emojione": "^2.2.3",
102103
"expect": "^1.16.0",
103104
"fs-extra": "^0.30.0",
@@ -134,14 +135,15 @@
134135
"dereference": true,
135136
"//files": "We bundle everything, so we only need to include webapp/",
136137
"files": [
137-
"!**/*",
138138
"electron/src/**",
139139
"electron/img/**",
140+
"node_modules/electron-auto-updater/**",
140141
"webapp/**",
141142
"package.json"
142143
],
143-
"squirrelWindows": {
144-
"iconUrl": "https://riot.im/favicon.ico"
144+
"linux": {
145+
"target": "deb",
146+
"maintainer": "support@riot.im"
145147
}
146148
},
147149
"directories": {

0 commit comments

Comments
 (0)