From 0eea3813f3b80ac1982cbd432dd3e220dd3f5ef3 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 23 Feb 2016 02:55:06 -0600 Subject: [PATCH] Update notification handling and auto-update --- README.md | 2 ++ gulpfile.js | 48 +++++++++++++++++++++++++++++++++----- nwapp/index.js | 7 +++--- nwapp/package.json | 6 +++++ nwapp/utils/auto-update.js | 8 +++++-- nwapp/utils/notifier.js | 32 +++++++++++++++++++------ 6 files changed, 85 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2e426c6..6b1039b 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ On osx/linux, run the following commands 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) 4. On osx/linux, run `gulp autoupdate:zip:win` 4. On osx/linux, run `gulp autoupdate:zip:osx` + 4. On osx/linux, run `gulp autoupdate:zip:linux` 5. On osx/linux, create the redirect pages with `gulp redirect:source` 2. **Check that all the binaries work**. You should have: * GitterSetup-X.X.X.exe @@ -100,6 +101,7 @@ On osx/linux, run the following commands * `gulp artefacts:push:linux64` * `gulp autoupdate:push:win` * `gulp autoupdate:push:osx` + * `gulp autoupdate:push:linux` 2. on osx/linux, publish the redirects by running: * `gulp redirect:push:win` * `gulp redirect:push:linux32` diff --git a/gulpfile.js b/gulpfile.js index 17cb601..d7958dc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -210,10 +210,12 @@ var dmg_cmd = template('./osx/create-dmg/create-dmg --icon "<%= name %>" 311 50 // Only runs on OSX (requires XCode properly configured) gulp.task('sign:osx', ['build'], shell.task([ + /* * / 'codesign -v -f -s "'+ SIGN_IDENTITY +'" '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app/Contents/Frameworks/*', 'codesign -v -f -s "'+ SIGN_IDENTITY +'" '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app', 'codesign -v --display '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app', 'codesign -v --verify '+ OUTPUT_DIR +'/Gitter/osx64/Gitter.app' + /* */ ])); // Only runs on OSX @@ -238,24 +240,32 @@ gulp.task('autoupdate:zip:osx', shell.task([ 'mv '+ OUTPUT_DIR + '/Gitter/osx64/osx.zip '+ ARTEFACTS_DIR + '/osx.zip', ])); -gulp.task('autoupdate:push:osx', function() { +// Generate auto-updater packages for linux +gulp.task('autoupdate:zip:linux', shell.task([ + 'cd '+ OUTPUT_DIR + '/Gitter/osx64; zip -r osx.zip ./Gitter.app > /dev/null 2>&1', + 'mv '+ OUTPUT_DIR + '/Gitter/osx64/osx.zip '+ ARTEFACTS_DIR + '/linux32.zip', + 'cd '+ OUTPUT_DIR + '/Gitter/osx64; zip -r osx.zip ./Gitter.app > /dev/null 2>&1', + 'mv '+ OUTPUT_DIR + '/Gitter/osx64/osx.zip '+ ARTEFACTS_DIR + '/linux64.zip', +])); + +gulp.task('autoupdate:push:win', function() { return pushS3({ - localFile: ARTEFACTS_DIR + '/osx.zip', + localFile: ARTEFACTS_DIR + '/win32.zip', s3Params: { Bucket: S3_CONSTS.buckets.updates, - Key: 'osx/osx.zip', + Key: 'win/win32.zip', CacheControl: 'public, max-age=0, no-cache', ACL: 'public-read' } }); }); -gulp.task('autoupdate:push:win', function() { +gulp.task('autoupdate:push:osx', function() { return pushS3({ - localFile: ARTEFACTS_DIR + '/win32.zip', + localFile: ARTEFACTS_DIR + '/osx.zip', s3Params: { Bucket: S3_CONSTS.buckets.updates, - Key: 'win/win32.zip', + Key: 'osx/osx.zip', CacheControl: 'public, max-age=0, no-cache', ACL: 'public-read' } @@ -263,6 +273,32 @@ gulp.task('autoupdate:push:win', function() { }); +gulp.task('autoupdate:push:linux', function() { + return Promise.all([ + pushS3({ + localFile: ARTEFACTS_DIR + '/linux32.zip', + s3Params: { + Bucket: S3_CONSTS.buckets.updates, + Key: 'linux32/linux32.zip', + CacheControl: 'public, max-age=0, no-cache', + ACL: 'public-read' + } + }), + pushS3({ + localFile: ARTEFACTS_DIR + '/linux64.zip', + s3Params: { + Bucket: S3_CONSTS.buckets.updates, + Key: 'linux64/linux64.zip', + CacheControl: 'public, max-age=0, no-cache', + ACL: 'public-read' + } + }) + ]); +}); + + + + var pushManifestToDest = function(destinationKey) { return pushS3({ diff --git a/nwapp/index.js b/nwapp/index.js index 1ccf24f..2474389 100644 --- a/nwapp/index.js +++ b/nwapp/index.js @@ -230,10 +230,11 @@ function initApp() { if (msg.notification === 'user_notification') { notifier({ - title: msg.title, + title: msg.title, message: msg.text, - icon: msg.icon, - click: function () { + icon: msg.icon, + click: function() { + log.info('Notification user_notification clicked. Moving to', msg.link); navigateWindowTo(msg.link); } }); diff --git a/nwapp/package.json b/nwapp/package.json index 2a85200..5bae71a 100644 --- a/nwapp/package.json +++ b/nwapp/package.json @@ -52,6 +52,12 @@ }, "mac": { "url": "https://update.gitter.im/osx/osx.zip" + }, + "linux32": { + "url": "https://update.gitter.im/linux32/linux32.zip" + }, + "linux64": { + "url": "https://update.gitter.im/linux64/linux64.zip" } }, "single-instance": false, diff --git a/nwapp/utils/auto-update.js b/nwapp/utils/auto-update.js index b43b5fd..6b10f59 100644 --- a/nwapp/utils/auto-update.js +++ b/nwapp/utils/auto-update.js @@ -21,7 +21,7 @@ var quitApp = require('./quit-app'); // You can change the place we use to check and download updates with this CLI parameter `--update-url=192.168.0.58:3010` // We use this for testing a release -var updateUrlOption = argv['update-url'] || ''; +var updateUrlOption = argv['update-url'] || 'https://update.gitter.im'; var transposeUpdateUrl = function(targetUrl) { targetUrl = targetUrl || ''; var parsedTargetUrl = urlParse(targetUrl); @@ -39,7 +39,7 @@ var transposeUpdateUrl = function(targetUrl) { var MANIFEST_URLS = { win: 'https://update.gitter.im/win/package.json', osx: 'https://update.gitter.im/osx/package.json', - linux: 'https://update.gitter.im/linux/package.json' + linux: 'https://update.gitter.im/linux64/package.json' }; Object.keys(MANIFEST_URLS).forEach(function(key) { MANIFEST_URLS[key] = transposeUpdateUrl(MANIFEST_URLS[key]); @@ -145,6 +145,7 @@ function notifyWinOsxUser(version, newAppExecutable) { title: 'Gitter ' + version + ' Available', message: 'Click to restart and apply update.', click: function() { + log.info('Update notification clicked'); var installerArgs = [ '--current-install-path=' + updater.getAppPath(), @@ -206,6 +207,9 @@ function poll() { }); } + // A debug way to trigger another update + window.debugUpdateGitter = update; + // polling with setInterval can cause multiple downloads // to occur if left unattended, so its best to wait for the updater // to finish each poll before triggering a new request. diff --git a/nwapp/utils/notifier.js b/nwapp/utils/notifier.js index 20f8bbc..813f09f 100644 --- a/nwapp/utils/notifier.js +++ b/nwapp/utils/notifier.js @@ -36,6 +36,16 @@ function playNotificationSound() { audio = null; } +var checkActivationNotifierResponse = function(response) { + // 'activated', `timeout'` + var resp = response.trim().toLowerCase(); + if(resp.match(/^activate/)) { + return true; + } + + return false; +}; + // Cache lookup var urlFilePathCacheMap = new Map(); @@ -128,16 +138,24 @@ module.exports = function (options) { // And we set to false because Windows 10 by default makes a separate sound sound: false, // wait with callback until user action is taken on notification - wait: false - }, function (err) { - if(err) throw err; - }); - notifier.on('click', function() { - if(opts.click) opts.click(); + wait: true + }, function(err, response) { + log.info('Notification response', response); + var didActivate = checkActivationNotifierResponse(response); + + if(err) { + // If you are seeing errors on each notification on Windows, + // it isn't really a issue because everything works normally and + // we are blocked until it gets fixed: https://github.com/mikaelbr/node-notifier/issues/97 + log.error('Problem with notification', err, err.stack); + } + if(didActivate && opts.click) { + opts.click(); + } }); }) .catch(function(err) { - log.error('Problem with notification', err, err.stack); + log.error('Problem initializing notification', err, err.stack); }); };