From 4030d66f3ad826a8117f08715e4d005d4dc6f449 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Fri, 28 Aug 2015 17:58:25 +0100 Subject: [PATCH 1/9] Init auto-update --- main.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 49 insertions(+) diff --git a/main.js b/main.js index 81a14f80c..3f7336978 100644 --- a/main.js +++ b/main.js @@ -2,6 +2,8 @@ var app = require('app'); var path = require('path'); var ipc = require('ipc'); +var ghReleases = require('electron-gh-releases'); + require('crash-reporter').start(); var Menu = require('menu'); @@ -12,6 +14,52 @@ var AutoLaunch = require('auto-launch'); var iconIdle = path.join(__dirname, 'images', 'tray-idleTemplate.png'); var iconActive = path.join(__dirname, 'images', 'tray-active.png'); +var ghReleasesOptions = { + repo: 'ekonstantinidis/testify', + currentVersion: app.getVersion() +}; + +var update = new ghReleases(ghReleasesOptions, function (autoUpdater) { + // Auto updater event listener + console.log('.......'); + console.log('.......'); + console.log(app.getVersion()); + console.log('.......'); + console.log('.......'); + // autoUpdater.checkForUpdates(); + + autoUpdater + // .on('checking-for-update', function() { + // console.log('Checking for update'); + // }) + .on('update-downloaded', function (e, rNotes, rName, rDate, uUrl, quitAndUpdate) { + // Install the update + console.log('Update Downloaded...'); + quitAndUpdate(); + }); +}); + +// Check for updates +update.check(function (err, status) { + console.log('ERR: ' + err + '. STATUS: ' + status); + + if (!err && status) { + update.download(); + } +}); + +// autoUpdater +// +// .on('update-available', function() { +// console.log('Update available'); +// }) +// .on('update-not-available', function() { +// console.log('Update not available'); +// }) +// .on('update-downloaded', function() { +// console.log('Update downloaded'); +// }); + var autoStart = new AutoLaunch({ name: 'Gitify', path: process.execPath.match(/.*?\.app/)[0] diff --git a/package.json b/package.json index 20ce779d4..a558f5d7d 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "babelify": "=6.1.3", "bootstrap": "=3.3.5", "browserify": "=11.0.1", + "electron-gh-releases": "=1.0.1", "font-awesome": "=4.4.0", "octicons": "=2.4.1", "react": "=0.13.3", From b235590290b05f7602833070272ac9c21eb29365 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Fri, 28 Aug 2015 18:53:29 +0100 Subject: [PATCH 2/9] Fix repo url and clean up --- main.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index 3f7336978..d1fc955f4 100644 --- a/main.js +++ b/main.js @@ -15,23 +15,15 @@ var iconIdle = path.join(__dirname, 'images', 'tray-idleTemplate.png'); var iconActive = path.join(__dirname, 'images', 'tray-active.png'); var ghReleasesOptions = { - repo: 'ekonstantinidis/testify', + repo: 'ekonstantinidis/gitify', currentVersion: app.getVersion() }; var update = new ghReleases(ghReleasesOptions, function (autoUpdater) { - // Auto updater event listener - console.log('.......'); - console.log('.......'); - console.log(app.getVersion()); - console.log('.......'); - console.log('.......'); - // autoUpdater.checkForUpdates(); - autoUpdater - // .on('checking-for-update', function() { - // console.log('Checking for update'); - // }) + .on('checking-for-update', function() { + console.log('Checking for update'); + }) .on('update-downloaded', function (e, rNotes, rName, rDate, uUrl, quitAndUpdate) { // Install the update console.log('Update Downloaded...'); @@ -41,9 +33,13 @@ var update = new ghReleases(ghReleasesOptions, function (autoUpdater) { // Check for updates update.check(function (err, status) { - console.log('ERR: ' + err + '. STATUS: ' + status); + if (err) { + console.log('ERRORED.'); + console.log('ERR: ' + err + '. STATUS: ' + status); + } if (!err && status) { + console.log('There is an update!'); update.download(); } }); From 468f24968f444058ec632bf42f0318ba59374b87 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sat, 29 Aug 2015 00:03:13 +0100 Subject: [PATCH 3/9] Auto Update :sparkles: --- main.js | 63 +++++++++++++++---------------------------- scripts/codesign.bash | 1 + 2 files changed, 23 insertions(+), 41 deletions(-) create mode 100644 scripts/codesign.bash diff --git a/main.js b/main.js index d1fc955f4..c657a950a 100644 --- a/main.js +++ b/main.js @@ -1,8 +1,7 @@ var app = require('app'); var path = require('path'); var ipc = require('ipc'); - -var ghReleases = require('electron-gh-releases'); +var autoUpdater = require('auto-updater'); require('crash-reporter').start(); @@ -14,47 +13,29 @@ var AutoLaunch = require('auto-launch'); var iconIdle = path.join(__dirname, 'images', 'tray-idleTemplate.png'); var iconActive = path.join(__dirname, 'images', 'tray-active.png'); -var ghReleasesOptions = { - repo: 'ekonstantinidis/gitify', - currentVersion: app.getVersion() -}; - -var update = new ghReleases(ghReleasesOptions, function (autoUpdater) { - autoUpdater - .on('checking-for-update', function() { - console.log('Checking for update'); - }) - .on('update-downloaded', function (e, rNotes, rName, rDate, uUrl, quitAndUpdate) { - // Install the update - console.log('Update Downloaded...'); - quitAndUpdate(); - }); -}); - -// Check for updates -update.check(function (err, status) { - if (err) { +autoUpdater + .on('error', function(event, message) { console.log('ERRORED.'); - console.log('ERR: ' + err + '. STATUS: ' + status); - } - - if (!err && status) { - console.log('There is an update!'); - update.download(); - } -}); + console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); + }) + .on('checking-for-update', function () { + console.log('Checking for update'); + }) + .on('update-available', function () { + console.log('Update available'); + }) + .on('update-not-available', function () { + console.log('Update not available'); + }) + .on('update-downloaded', function (event, releaseNotes, releaseName, + releaseDate, updateUrl, quitAndUpdate) { + console.log('Update downloaded'); + quitAndUpdate(); + }); -// autoUpdater -// -// .on('update-available', function() { -// console.log('Update available'); -// }) -// .on('update-not-available', function() { -// console.log('Update not available'); -// }) -// .on('update-downloaded', function() { -// console.log('Update downloaded'); -// }); +autoUpdater.setFeedUrl('https://raw.githubusercontent.com/' + + 'ekonstantinidis/gitify/master/auto_updater.json'); +autoUpdater.checkForUpdates(); var autoStart = new AutoLaunch({ name: 'Gitify', diff --git a/scripts/codesign.bash b/scripts/codesign.bash new file mode 100644 index 000000000..224df5f9d --- /dev/null +++ b/scripts/codesign.bash @@ -0,0 +1 @@ +codesign --verbose --deep --force --sign "Developer ID Application: Emmanouil KONSTANTINIDIS" Gitify-darwin-x64/Gitify.app From 03f9308fad2f457411173ab99b201e272cf97211 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sat, 29 Aug 2015 00:07:54 +0100 Subject: [PATCH 4/9] Rename auto updater json --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index c657a950a..6c683b7d0 100644 --- a/main.js +++ b/main.js @@ -34,7 +34,7 @@ autoUpdater }); autoUpdater.setFeedUrl('https://raw.githubusercontent.com/' + - 'ekonstantinidis/gitify/master/auto_updater.json'); + 'ekonstantinidis/gitify/master/auto-update.json'); autoUpdater.checkForUpdates(); var autoStart = new AutoLaunch({ From f58c4221c3191472f79141de9f5fd754929dea10 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sat, 29 Aug 2015 01:52:09 +0100 Subject: [PATCH 5/9] Dialog before update --- main.js | 74 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/main.js b/main.js index 6c683b7d0..464a234cb 100644 --- a/main.js +++ b/main.js @@ -7,36 +7,13 @@ require('crash-reporter').start(); var Menu = require('menu'); var Tray = require('tray'); -var BrowserWindow = require('browser-window'); var AutoLaunch = require('auto-launch'); +var BrowserWindow = require('browser-window'); +var dialog = require('dialog'); var iconIdle = path.join(__dirname, 'images', 'tray-idleTemplate.png'); var iconActive = path.join(__dirname, 'images', 'tray-active.png'); -autoUpdater - .on('error', function(event, message) { - console.log('ERRORED.'); - console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); - }) - .on('checking-for-update', function () { - console.log('Checking for update'); - }) - .on('update-available', function () { - console.log('Update available'); - }) - .on('update-not-available', function () { - console.log('Update not available'); - }) - .on('update-downloaded', function (event, releaseNotes, releaseName, - releaseDate, updateUrl, quitAndUpdate) { - console.log('Update downloaded'); - quitAndUpdate(); - }); - -autoUpdater.setFeedUrl('https://raw.githubusercontent.com/' + - 'ekonstantinidis/gitify/master/auto-update.json'); -autoUpdater.checkForUpdates(); - var autoStart = new AutoLaunch({ name: 'Gitify', path: process.execPath.match(/.*?\.app/)[0] @@ -70,6 +47,7 @@ app.on('ready', function(){ appIcon.window.setVisibleOnAllWorkspaces(true); initMenu(); + checkAutoUpdate(); } function showWindow (bounds) { @@ -114,6 +92,51 @@ app.on('ready', function(){ appIcon.window.hide(); } + function checkAutoUpdate() { + + autoUpdater + .on('error', function(event, message) { + console.log('ERRORED.'); + console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); + }) + .on('checking-for-update', function () { + console.log('Checking for update'); + }) + .on('update-available', function () { + console.log('Update available'); + }) + .on('update-not-available', function () { + console.log('Update not available'); + app.dock.hide(); + }) + .on('update-downloaded', function (event, releaseNotes, releaseName, + releaseDate, updateUrl, quitAndUpdate) { + console.log('Update downloaded'); + confirmAutoUpdate(quitAndUpdate); + }); + + autoUpdater.setFeedUrl('https://raw.githubusercontent.com/' + + 'ekonstantinidis/gitify/master/auto-update.json'); + autoUpdater.checkForUpdates(); + } + + function confirmAutoUpdate(quitAndUpdate) { + dialog.showMessageBox({ + type: 'question', + buttons: ['Update & Restart', 'Cancel'], + title: 'Update Available', + cancelId: 99, + message: 'There is an update available. Would you like to update the app now?' + }, function (response) { + console.log('Exit: ' + response); + app.dock.hide(); + if (response === 0) { + quitAndUpdate(); + } + } + ); + } + ipc.on('reopen-window', function() { appIcon.window.show(); }); @@ -138,6 +161,5 @@ app.on('ready', function(){ app.quit(); }); - app.dock.hide(); appIcon.setToolTip('GitHub Notifications on your menu bar.'); }); From 01ba443976799ddcd9d4dfa59bd0390e9fe86857 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 30 Aug 2015 00:43:06 +0100 Subject: [PATCH 6/9] Update dist script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a558f5d7d..6706ae358 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "watch-js": "watchify -t babelify src/js/app.js -o build/js/app.js -v", "watch": "npm run build && grunt build && npm run watch-js & grunt watch", "start": "electron .", - "dist": "electron-packager . Gitify --overwrite --platform=darwin --arch=x64 --version=0.31.0 --asar=true --icon=images/app-icon.icns --prune --ignore='src' --ignore='coverage'", + "dist": "electron-packager . Gitify --overwrite --platform=darwin --arch=x64 --version=0.31.0 --asar=true --icon=images/app-icon.icns --prune --ignore='src' --ignore='coverage' && bash scripts/codesign.bash", "lint": "eslint 'src/js/' 'src/js/app.js' 'main.js'", "test": "npm run lint && jest" }, From db01c604d9e5c9700cfc12b9ea68823b158cebcc Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 30 Aug 2015 01:25:17 +0100 Subject: [PATCH 7/9] Hide app icon if errored --- main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 464a234cb..cf627da5a 100644 --- a/main.js +++ b/main.js @@ -98,12 +98,14 @@ app.on('ready', function(){ .on('error', function(event, message) { console.log('ERRORED.'); console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); + app.dock.hide(); }) .on('checking-for-update', function () { console.log('Checking for update'); }) .on('update-available', function () { console.log('Update available'); + // AutoUpdater Downloads the update automatically }) .on('update-not-available', function () { console.log('Update not available'); @@ -126,7 +128,7 @@ app.on('ready', function(){ buttons: ['Update & Restart', 'Cancel'], title: 'Update Available', cancelId: 99, - message: 'There is an update available. Would you like to update the app now?' + message: 'There is an update available. Would you like to update Gitify now?' }, function (response) { console.log('Exit: ' + response); app.dock.hide(); From c3702ee5ed119b50dcf91c7c00ef254d6a6727bd Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 30 Aug 2015 12:33:14 +0100 Subject: [PATCH 8/9] Remove 'electron-gh-releases' from depedencies --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 6706ae358..8f7dddaf5 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "babelify": "=6.1.3", "bootstrap": "=3.3.5", "browserify": "=11.0.1", - "electron-gh-releases": "=1.0.1", "font-awesome": "=4.4.0", "octicons": "=2.4.1", "react": "=0.13.3", From 40397d377e771a6d26b80f6b70e086560bf3fe32 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sun, 30 Aug 2015 20:14:16 +0100 Subject: [PATCH 9/9] Use ''electron-gh-releases' --- main.js | 54 +++++++++++++++++++++++++++------------------------- package.json | 3 ++- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/main.js b/main.js index cf627da5a..b227698d4 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ var app = require('app'); var path = require('path'); var ipc = require('ipc'); -var autoUpdater = require('auto-updater'); +var ghReleases = require('electron-gh-releases'); require('crash-reporter').start(); @@ -94,32 +94,34 @@ app.on('ready', function(){ function checkAutoUpdate() { - autoUpdater - .on('error', function(event, message) { - console.log('ERRORED.'); - console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); - app.dock.hide(); - }) - .on('checking-for-update', function () { - console.log('Checking for update'); - }) - .on('update-available', function () { - console.log('Update available'); - // AutoUpdater Downloads the update automatically - }) - .on('update-not-available', function () { - console.log('Update not available'); + var autoUpdateOptions = { + repo: 'ekonstantinidis/gitify', + currentVersion: app.getVersion() + }; + + var update = new ghReleases(autoUpdateOptions, function (autoUpdater) { + autoUpdater + .on('error', function(event, message) { + console.log('ERRORED.'); + console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); + }) + .on('update-downloaded', function (event, releaseNotes, releaseName, + releaseDate, updateUrl, quitAndUpdate) { + console.log('Update downloaded'); + confirmAutoUpdate(quitAndUpdate); + }); + }); + + // Check for updates + update.check(function (err, status) { + if (err || !status) { app.dock.hide(); - }) - .on('update-downloaded', function (event, releaseNotes, releaseName, - releaseDate, updateUrl, quitAndUpdate) { - console.log('Update downloaded'); - confirmAutoUpdate(quitAndUpdate); - }); - - autoUpdater.setFeedUrl('https://raw.githubusercontent.com/' + - 'ekonstantinidis/gitify/master/auto-update.json'); - autoUpdater.checkForUpdates(); + } + + if (!err && status) { + update.download(); + } + }); } function confirmAutoUpdate(quitAndUpdate) { diff --git a/package.json b/package.json index 8f7dddaf5..4cc4e1723 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitify", - "version": "0.0.14", + "version": "0.0.15", "description": "GitHub Notifications on your menu bar.", "main": "main.js", "scripts": { @@ -78,6 +78,7 @@ "babelify": "=6.1.3", "bootstrap": "=3.3.5", "browserify": "=11.0.1", + "electron-gh-releases": "=1.0.1", "font-awesome": "=4.4.0", "octicons": "=2.4.1", "react": "=0.13.3",