From c730910f7ca63fc2b291bb2d950b1b6fa1bd999e Mon Sep 17 00:00:00 2001 From: probablycorey Date: Wed, 29 Jan 2014 15:04:54 -0800 Subject: [PATCH 1/6] Update to atom-shell@0.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5ab373738..fd060c893 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "url": "http://github.com/atom/atom/raw/master/LICENSE.md" } ], - "atomShellVersion": "0.8.7", + "atomShellVersion": "0.9.0", "dependencies": { "async": "0.2.6", "bootstrap": "git://github.com/atom/bootstrap.git#6af81906189f1747fd6c93479e3d998ebe041372", From cc233fb7f65726f077c8548defa37ab629e7fa4d Mon Sep 17 00:00:00 2001 From: probablycorey Date: Mon, 3 Feb 2014 12:51:38 -0800 Subject: [PATCH 2/6] Use Squirrel API for auto-updates --- src/browser/atom-application.coffee | 38 +++++++++++++++++------------ src/browser/main.coffee | 5 ---- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index affabc0ae..bf773fdb0 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -72,7 +72,7 @@ class AtomApplication @listenForArgumentsFromNewProcess() @setupJavaScriptArguments() @handleEvents() - @checkForUpdates() + @setupAutoUpdater() @openWithOptions(options) @@ -117,16 +117,28 @@ class AtomApplication app.commandLine.appendSwitch 'js-flags', '--harmony_collections --harmony-proxies' # Private: Enable updates unless running from a local build of Atom. - checkForUpdates: -> - versionIsSha = /\w{7}/.test @version + setupAutoUpdater: -> + autoUpdater.setFeedUrl "http://localhost:9393/releases/latest?version=#{@version}" - if versionIsSha - autoUpdater.setAutomaticallyDownloadsUpdates false - autoUpdater.setAutomaticallyChecksForUpdates false - else - autoUpdater.setAutomaticallyDownloadsUpdates true - autoUpdater.setAutomaticallyChecksForUpdates true - autoUpdater.checkForUpdatesInBackground() + autoUpdater.on 'checking-for-update', => + @applicationMenu.showInstallUpdateItem(false) + @applicationMenu.showCheckForUpdateItem(false) + + autoUpdater.on 'update-not-available', => + @applicationMenu.showInstallUpdateItem(false) + @applicationMenu.showCheckForUpdateItem(true) + + autoUpdater.on 'update-downloaded', (event, releaseNotes, releaseName, releaseDate, releaseURL) => + atomWindow.sendCommand('window:update-available', releaseName) for atomWindow in @windows + @applicationMenu.showInstallUpdateItem(true) + @applicationMenu.showCheckForUpdateItem(false) + @updateVersion = releaseName + + autoUpdater.on 'error', (event, message)=> + @applicationMenu.showInstallUpdateItem(false) + @applicationMenu.showCheckForUpdateItem(true) + + autoUpdater.checkForUpdates() # Private: Registers basic application commands, non-idempotent. handleEvents: -> @@ -170,12 +182,6 @@ class AtomApplication event.preventDefault() @openUrl({urlToOpen, @devMode}) - autoUpdater.on 'ready-for-update-on-quit', (event, version, quitAndUpdateCallback) => - event.preventDefault() - @updateVersion = version - @applicationMenu.showDownloadUpdateItem(version, quitAndUpdateCallback) - atomWindow.sendCommand('window:update-available', version) for atomWindow in @windows - # A request from the associated render process to open a new render process. ipc.on 'open', (processId, routingId, options) => if options? diff --git a/src/browser/main.coffee b/src/browser/main.coffee index 5d4a66224..c72081cd7 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -1,6 +1,5 @@ global.shellStartTime = Date.now() -autoUpdater = require 'auto-updater' crashReporter = require 'crash-reporter' app = require 'app' fs = require 'fs' @@ -42,7 +41,6 @@ start = -> app.on 'will-finish-launching', -> setupCrashReporter() - setupAutoUpdater() app.on 'finish-launching', -> app.removeListener 'open-file', addPathToOpen @@ -66,9 +64,6 @@ global.devResourcePath = path.join(app.getHomeDir(), 'github', 'atom') setupCrashReporter = -> crashReporter.start(productName: 'Atom', companyName: 'GitHub') -setupAutoUpdater = -> - autoUpdater.setFeedUrl 'https://speakeasy.githubapp.com/apps/27/appcast.xml' - parseCommandLine = -> version = app.getVersion() options = optimist(process.argv[1..]) From caeb70cf4a6bd52dc927fe0bae254ec1c4d48720 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Mon, 3 Feb 2014 12:52:01 -0800 Subject: [PATCH 3/6] Add 'Check for Updates' menu item --- menus/darwin.cson | 3 ++- src/browser/application-menu.coffee | 20 +++++++------------- src/browser/atom-application.coffee | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/menus/darwin.cson b/menus/darwin.cson index 44e88dead..346523299 100644 --- a/menus/darwin.cson +++ b/menus/darwin.cson @@ -4,7 +4,8 @@ submenu: [ { label: 'About Atom', command: 'application:about' } { label: "VERSION", enabled: false } - { label: "Install update", command: 'application:install-update', visible: false } + { label: "Restart and Install Update", command: 'application:install-update', visible: false} + { label: "Check for Update", command: 'application:check-for-update'} { type: 'separator' } { label: 'Preferences...', command: 'application:show-settings' } { label: 'Open Your Config', command: 'application:open-your-config' } diff --git a/src/browser/application-menu.coffee b/src/browser/application-menu.coffee index 7de362838..10f2e45c2 100644 --- a/src/browser/application-menu.coffee +++ b/src/browser/application-menu.coffee @@ -69,19 +69,13 @@ class ApplicationMenu if (item = _.find(@flattenMenuTemplate(template), (i) -> i.label == 'VERSION')) item.label = "Version #{@version}" - # Public: Makes the download menu item visible if available. - # - # Note: The update menu item's must match 'Install update' exactly otherwise - # this function will fail to work. - # - # * newVersion: - # FIXME: Unused. - # * quitAndUpdateCallback: - # Function to call when the install menu item has been clicked. - showDownloadUpdateItem: (newVersion, quitAndUpdateCallback) -> - if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Install update')) - item.visible = true - item.click = quitAndUpdateCallback + showInstallUpdateItem: (visible=true) -> + if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Restart and Install Update')) + item.visible = visible + + showCheckForUpdateItem: (visible=true) -> + if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Check for Update')) + item.visible = visible # Private: Default list of menu items. # diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index bf773fdb0..d2e07f9ca 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -140,6 +140,30 @@ class AtomApplication autoUpdater.checkForUpdates() + checkForUpdate: -> + autoUpdater.once 'update-available', -> + dialog.showMessageBox + type: 'info' + buttons: ['OK'] + message: 'Update available.' + detail: 'A new update is being downloading.' + + autoUpdater.once 'update-not-available', => + dialog.showMessageBox + type: 'info' + buttons: ['OK'] + message: 'No update available.' + detail: "Version #{@version} is the latest version." + + autoUpdater.once 'error', (event, message)-> + dialog.showMessageBox + type: 'warning' + buttons: ['OK'] + message: 'There was an error checking for updates.' + detail: message + + autoUpdater.checkForUpdates() + # Private: Registers basic application commands, non-idempotent. handleEvents: -> @on 'application:about', -> Menu.sendActionToFirstResponder('orderFrontStandardAboutPanel:') @@ -159,6 +183,8 @@ class AtomApplication @on 'application:inspect', ({x,y}) -> @focusedWindow().browserWindow.inspectElement(x, y) @on 'application:open-documentation', -> shell.openExternal('https://www.atom.io/docs/latest/?app') @on 'application:report-issue', -> shell.openExternal('https://github.com/atom/atom/issues/new') + @on 'application:install-update', -> autoUpdater.quitAndInstall() + @on 'application:check-for-update', => @checkForUpdate() @openPathOnEvent('application:show-settings', 'atom://config') @openPathOnEvent('application:open-your-config', 'atom://.atom/config') From 8a85f488f30c280da708fff27b0455af6ee30a79 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Mon, 3 Feb 2014 14:41:20 -0800 Subject: [PATCH 4/6] :lipstick: --- src/browser/atom-application.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index d2e07f9ca..c0db302e2 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -134,7 +134,7 @@ class AtomApplication @applicationMenu.showCheckForUpdateItem(false) @updateVersion = releaseName - autoUpdater.on 'error', (event, message)=> + autoUpdater.on 'error', (event, message) => @applicationMenu.showInstallUpdateItem(false) @applicationMenu.showCheckForUpdateItem(true) From faf523f6983aee88a81020e56451554bcc579f79 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Mon, 3 Feb 2014 14:43:02 -0800 Subject: [PATCH 5/6] Document methods --- src/browser/application-menu.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/browser/application-menu.coffee b/src/browser/application-menu.coffee index 10f2e45c2..d87b44c20 100644 --- a/src/browser/application-menu.coffee +++ b/src/browser/application-menu.coffee @@ -69,10 +69,12 @@ class ApplicationMenu if (item = _.find(@flattenMenuTemplate(template), (i) -> i.label == 'VERSION')) item.label = "Version #{@version}" + # Toggles Install Update Item showInstallUpdateItem: (visible=true) -> if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Restart and Install Update')) item.visible = visible + # Toggles Check For Update Item showCheckForUpdateItem: (visible=true) -> if (item = _.find(@flattenMenuItems(@menu), (i) -> i.label == 'Check for Update')) item.visible = visible From e66e75593d32c42348d5cea44604de5e0e9900ba Mon Sep 17 00:00:00 2001 From: probablycorey Date: Tue, 4 Feb 2014 14:10:53 -0800 Subject: [PATCH 6/6] Update feed url --- src/browser/atom-application.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index c0db302e2..713a19bb1 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -118,7 +118,7 @@ class AtomApplication # Private: Enable updates unless running from a local build of Atom. setupAutoUpdater: -> - autoUpdater.setFeedUrl "http://localhost:9393/releases/latest?version=#{@version}" + autoUpdater.setFeedUrl "https://atom.io/api/updates?version=#{@version}" autoUpdater.on 'checking-for-update', => @applicationMenu.showInstallUpdateItem(false)