Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

Commit 0eea381

Browse files
committed
Update notification handling and auto-update
1 parent 420cc6e commit 0eea381

File tree

6 files changed

+85
-18
lines changed

6 files changed

+85
-18
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ On osx/linux, run the following commands
8181
3. On windows, run `node ./windows/build.js -p thepfxcertpasswordhere`. For more information, see the [windows build readme](https://github.com/gitterHQ/desktop/blob/master/windows/README.md)
8282
4. On osx/linux, run `gulp autoupdate:zip:win`
8383
4. On osx/linux, run `gulp autoupdate:zip:osx`
84+
4. On osx/linux, run `gulp autoupdate:zip:linux`
8485
5. On osx/linux, create the redirect pages with `gulp redirect:source`
8586
2. **Check that all the binaries work**. You should have:
8687
* GitterSetup-X.X.X.exe
@@ -100,6 +101,7 @@ On osx/linux, run the following commands
100101
* `gulp artefacts:push:linux64`
101102
* `gulp autoupdate:push:win`
102103
* `gulp autoupdate:push:osx`
104+
* `gulp autoupdate:push:linux`
103105
2. on osx/linux, publish the redirects by running:
104106
* `gulp redirect:push:win`
105107
* `gulp redirect:push:linux32`

gulpfile.js

+42-6
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,12 @@ var dmg_cmd = template('./osx/create-dmg/create-dmg --icon "<%= name %>" 311 50
210210

211211
// Only runs on OSX (requires XCode properly configured)
212212
gulp.task('sign:osx', ['build'], shell.task([
213+
/* * /
213214
'codesign -v -f -s "'+ SIGN_IDENTITY +'" '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app/Contents/Frameworks/*',
214215
'codesign -v -f -s "'+ SIGN_IDENTITY +'" '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app',
215216
'codesign -v --display '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app',
216217
'codesign -v --verify '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app'
218+
/* */
217219
]));
218220

219221
// Only runs on OSX
@@ -238,31 +240,65 @@ gulp.task('autoupdate:zip:osx', shell.task([
238240
'mv '+ OUTPUT_DIR + '/Gitter/osx64/osx.zip '+ ARTEFACTS_DIR + '/osx.zip',
239241
]));
240242

241-
gulp.task('autoupdate:push:osx', function() {
243+
// Generate auto-updater packages for linux
244+
gulp.task('autoupdate:zip:linux', shell.task([
245+
'cd '+ OUTPUT_DIR + '/Gitter/osx64; zip -r osx.zip ./Gitter.app > /dev/null 2>&1',
246+
'mv '+ OUTPUT_DIR + '/Gitter/osx64/osx.zip '+ ARTEFACTS_DIR + '/linux32.zip',
247+
'cd '+ OUTPUT_DIR + '/Gitter/osx64; zip -r osx.zip ./Gitter.app > /dev/null 2>&1',
248+
'mv '+ OUTPUT_DIR + '/Gitter/osx64/osx.zip '+ ARTEFACTS_DIR + '/linux64.zip',
249+
]));
250+
251+
gulp.task('autoupdate:push:win', function() {
242252
return pushS3({
243-
localFile: ARTEFACTS_DIR + '/osx.zip',
253+
localFile: ARTEFACTS_DIR + '/win32.zip',
244254
s3Params: {
245255
Bucket: S3_CONSTS.buckets.updates,
246-
Key: 'osx/osx.zip',
256+
Key: 'win/win32.zip',
247257
CacheControl: 'public, max-age=0, no-cache',
248258
ACL: 'public-read'
249259
}
250260
});
251261
});
252262

253-
gulp.task('autoupdate:push:win', function() {
263+
gulp.task('autoupdate:push:osx', function() {
254264
return pushS3({
255-
localFile: ARTEFACTS_DIR + '/win32.zip',
265+
localFile: ARTEFACTS_DIR + '/osx.zip',
256266
s3Params: {
257267
Bucket: S3_CONSTS.buckets.updates,
258-
Key: 'win/win32.zip',
268+
Key: 'osx/osx.zip',
259269
CacheControl: 'public, max-age=0, no-cache',
260270
ACL: 'public-read'
261271
}
262272
});
263273
});
264274

265275

276+
gulp.task('autoupdate:push:linux', function() {
277+
return Promise.all([
278+
pushS3({
279+
localFile: ARTEFACTS_DIR + '/linux32.zip',
280+
s3Params: {
281+
Bucket: S3_CONSTS.buckets.updates,
282+
Key: 'linux32/linux32.zip',
283+
CacheControl: 'public, max-age=0, no-cache',
284+
ACL: 'public-read'
285+
}
286+
}),
287+
pushS3({
288+
localFile: ARTEFACTS_DIR + '/linux64.zip',
289+
s3Params: {
290+
Bucket: S3_CONSTS.buckets.updates,
291+
Key: 'linux64/linux64.zip',
292+
CacheControl: 'public, max-age=0, no-cache',
293+
ACL: 'public-read'
294+
}
295+
})
296+
]);
297+
});
298+
299+
300+
301+
266302

267303
var pushManifestToDest = function(destinationKey) {
268304
return pushS3({

nwapp/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,11 @@ function initApp() {
230230

231231
if (msg.notification === 'user_notification') {
232232
notifier({
233-
title: msg.title,
233+
title: msg.title,
234234
message: msg.text,
235-
icon: msg.icon,
236-
click: function () {
235+
icon: msg.icon,
236+
click: function() {
237+
log.info('Notification user_notification clicked. Moving to', msg.link);
237238
navigateWindowTo(msg.link);
238239
}
239240
});

nwapp/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
},
5353
"mac": {
5454
"url": "https://update.gitter.im/osx/osx.zip"
55+
},
56+
"linux32": {
57+
"url": "https://update.gitter.im/linux32/linux32.zip"
58+
},
59+
"linux64": {
60+
"url": "https://update.gitter.im/linux64/linux64.zip"
5561
}
5662
},
5763
"single-instance": false,

nwapp/utils/auto-update.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var quitApp = require('./quit-app');
2121

2222
// You can change the place we use to check and download updates with this CLI parameter `--update-url=192.168.0.58:3010`
2323
// We use this for testing a release
24-
var updateUrlOption = argv['update-url'] || '';
24+
var updateUrlOption = argv['update-url'] || 'https://update.gitter.im';
2525
var transposeUpdateUrl = function(targetUrl) {
2626
targetUrl = targetUrl || '';
2727
var parsedTargetUrl = urlParse(targetUrl);
@@ -39,7 +39,7 @@ var transposeUpdateUrl = function(targetUrl) {
3939
var MANIFEST_URLS = {
4040
win: 'https://update.gitter.im/win/package.json',
4141
osx: 'https://update.gitter.im/osx/package.json',
42-
linux: 'https://update.gitter.im/linux/package.json'
42+
linux: 'https://update.gitter.im/linux64/package.json'
4343
};
4444
Object.keys(MANIFEST_URLS).forEach(function(key) {
4545
MANIFEST_URLS[key] = transposeUpdateUrl(MANIFEST_URLS[key]);
@@ -145,6 +145,7 @@ function notifyWinOsxUser(version, newAppExecutable) {
145145
title: 'Gitter ' + version + ' Available',
146146
message: 'Click to restart and apply update.',
147147
click: function() {
148+
log.info('Update notification clicked');
148149

149150
var installerArgs = [
150151
'--current-install-path=' + updater.getAppPath(),
@@ -206,6 +207,9 @@ function poll() {
206207
});
207208
}
208209

210+
// A debug way to trigger another update
211+
window.debugUpdateGitter = update;
212+
209213
// polling with setInterval can cause multiple downloads
210214
// to occur if left unattended, so its best to wait for the updater
211215
// to finish each poll before triggering a new request.

nwapp/utils/notifier.js

+25-7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ function playNotificationSound() {
3636
audio = null;
3737
}
3838

39+
var checkActivationNotifierResponse = function(response) {
40+
// 'activated', `timeout'`
41+
var resp = response.trim().toLowerCase();
42+
if(resp.match(/^activate/)) {
43+
return true;
44+
}
45+
46+
return false;
47+
};
48+
3949

4050
// Cache lookup
4151
var urlFilePathCacheMap = new Map();
@@ -128,16 +138,24 @@ module.exports = function (options) {
128138
// And we set to false because Windows 10 by default makes a separate sound
129139
sound: false,
130140
// wait with callback until user action is taken on notification
131-
wait: false
132-
}, function (err) {
133-
if(err) throw err;
134-
});
135-
notifier.on('click', function() {
136-
if(opts.click) opts.click();
141+
wait: true
142+
}, function(err, response) {
143+
log.info('Notification response', response);
144+
var didActivate = checkActivationNotifierResponse(response);
145+
146+
if(err) {
147+
// If you are seeing errors on each notification on Windows,
148+
// it isn't really a issue because everything works normally and
149+
// we are blocked until it gets fixed: https://github.com/mikaelbr/node-notifier/issues/97
150+
log.error('Problem with notification', err, err.stack);
151+
}
152+
if(didActivate && opts.click) {
153+
opts.click();
154+
}
137155
});
138156
})
139157
.catch(function(err) {
140-
log.error('Problem with notification', err, err.stack);
158+
log.error('Problem initializing notification', err, err.stack);
141159
});
142160

143161
};

0 commit comments

Comments
 (0)