From ea96136c3b020684d5d31f9aa0e2ebb2d3dac6e2 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 5 May 2017 11:27:08 -0700 Subject: [PATCH] Move auto-updater to use github releases (#165) * Move auto-updater to use github releases * Adjust remoteReleases * Bump version * More reliable update notification * More reliable update notifications --- .appveyor.yml | 1 - app/main/updates.js | 25 ++++++++++------------ app/main/window-utils.js | 6 +++--- app/package.json | 2 +- package.json | 3 +-- webpack/webpack.config.production.babel.js | 1 - 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 120d91d2c5..22bc9e1c86 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -51,5 +51,4 @@ deploy: secure: Ffmgxn+wt5WSf/jgJ/L+/3mkUs4fn9Z5j4Dz73VATsgL14Rf/xUp2nOyE0ecow+1 artifact: dist on: - branch: master appveyor_repo_tag: true diff --git a/app/main/updates.js b/app/main/updates.js index ca6cd2832d..5373f1604f 100644 --- a/app/main/updates.js +++ b/app/main/updates.js @@ -3,10 +3,14 @@ import {CHECK_FOR_UPDATES_INTERVAL, getAppVersion, isDevelopment, isLinux} from const {autoUpdater, BrowserWindow} = electron; -const UPDATE_URLS = { +const UPDATE_URLS = isDevelopment() ? { + darwin: `http://localhost:8000/builds/check/mac?v=${getAppVersion()}`, + linux: `http://localhost:8000/builds/check/linux?v=${getAppVersion()}`, + win32: `http://localhost:8000/updates/win?v=${getAppVersion()}` +} : { darwin: `https://updates.insomnia.rest/builds/check/mac?v=${getAppVersion()}`, linux: `https://updates.insomnia.rest/builds/check/linux?v=${getAppVersion()}`, - win32: `https://downloads.insomnia.rest/win` + win32: `https://updates.insomnia.rest/updates/win?v=${getAppVersion()}` }; let hasPromptedForUpdates = false; @@ -44,12 +48,11 @@ function _showUpdateNotification () { return; } - const window = BrowserWindow.getFocusedWindow(); - if (!window || !window.webContents) { - return; + const windows = BrowserWindow.getAllWindows(); + if (windows.length && windows[0].webContents) { + windows[0].webContents.send('update-available'); } - window.webContents.send('update-available'); hasPromptedForUpdates = true; } @@ -59,19 +62,13 @@ function _checkForUpdates () { return; } - if (isDevelopment()) { - console.log('-- Skipping update check in Development --'); - return; - } else { - console.log('-- Checking for Updates --'); - } - if (!isLinux()) { try { autoUpdater.setFeedURL(UPDATE_URLS[process.platform]); autoUpdater.checkForUpdates(); - } catch (e) { + } catch (err) { // This will fail in development + console.warn('Failed to check for updates:', err.message); } } } diff --git a/app/main/window-utils.js b/app/main/window-utils.js index b4d2420079..e711c3bd1d 100644 --- a/app/main/window-utils.js +++ b/app/main/window-utils.js @@ -292,12 +292,12 @@ function showUnresponsiveModal () { } function trackEvent (...args) { - const window = BrowserWindow.getFocusedWindow(); - if (!window || !window.webContents) { + const windows = BrowserWindow.getAllWindows(); + if (!windows.length || !windows[0].webContents) { return; } - window.webContents.send('analytics-track-event', args); + windows[0].webContents.send('analytics-track-event', args); } function saveBounds () { diff --git a/app/package.json b/app/package.json index e2f4859d20..0ea1c9f1f3 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "insomnia", - "version": "5.0.16", + "version": "5.0.19", "productName": "Insomnia", "longName": "Insomnia REST Client", "description": "Debug APIs like a human, not a robot", diff --git a/package.json b/package.json index 7d7cf4c7a6..d935957b47 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "homepage": "https://insomnia.rest", "repository": { "type": "git", - "url": "https://github.com/gschier/insomnia" + "url": "https://github.com/getinsomnia/insomnia" }, "scripts": { "test:lint": "eslint \"**/*.js\" \"**/*.html\" \"**/*.json\"", @@ -81,7 +81,6 @@ }, "win": { "iconUrl": "https://insomnia.rest/images/icon.png", - "remoteReleases": "https://s3.amazonaws.com/downloads.insomnia.rest/win", "target": "squirrel", "msi": false }, diff --git a/webpack/webpack.config.production.babel.js b/webpack/webpack.config.production.babel.js index 4d19436fae..38f378e2e2 100644 --- a/webpack/webpack.config.production.babel.js +++ b/webpack/webpack.config.production.babel.js @@ -11,7 +11,6 @@ module.exports = { new webpack.DefinePlugin({ __DEV__: false, 'process.env.NODE_ENV': JSON.stringify('production'), - 'process.env.INSOMNIA_ENV': JSON.stringify('production'), 'process.env.HOT': JSON.stringify(null) }) ]