From a8951c91df9c22754463053d3ed86929730cbd5b Mon Sep 17 00:00:00 2001 From: Thomas Beverley Date: Fri, 15 Jan 2016 18:35:43 +0000 Subject: [PATCH] Patches to update script. Prep for 1.1.3 --- package.json | 2 +- package.sh | 2 +- src/analytics.js | 1 - src/update.js | 28 ++++++++++++++++++++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ad405664..7b0372c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wmail", - "version": "1.1.2", + "version": "1.1.3", "description": "OSX app wrapper for Google Inbox and Google Mail", "main": "src/main.js", "scripts": { diff --git a/package.sh b/package.sh index 61d0d55f..66c5f33f 100644 --- a/package.sh +++ b/package.sh @@ -1,6 +1,6 @@ #!/bin/bash -electron-packager . "WMail" --platform=darwin --arch=all --version=0.36.2 --app-bundle-id="tombeverley.wmail" --app-version="1.1.2" --icon="icons/app.icns" --overwrite --ignore="/release/|/icons/|package.sh|screenshot.png|README.md"; +electron-packager . "WMail" --platform=darwin --arch=all --version=0.36.2 --app-bundle-id="tombeverley.wmail" --app-version="1.1.3" --icon="icons/app.icns" --overwrite --ignore="/release/|/icons/|package.sh|screenshot.png|README.md"; mkdir ./WMail-darwin-x64/vendor-licenses; mv ./WMail-darwin-x64/LICENSES.chromium.html ./WMail-darwin-x64/vendor-licenses/LICENSES.chromium.html; mv ./WMail-darwin-x64/LICENSE ./WMail-darwin-x64/vendor-licenses/LICENSE.electron; diff --git a/src/analytics.js b/src/analytics.js index 65d514b3..b50a382a 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -48,7 +48,6 @@ class Analytics { acc.push(k + '=' + encodeURIComponent(full_args[k])) return acc }, []).join('&') - console.log(qs) const url = 'https://www.google-analytics.com/collect?' + qs return fetch(url, { method: 'post' }) diff --git a/src/update.js b/src/update.js index 0fdd3fd9..7a9fa023 100644 --- a/src/update.js +++ b/src/update.js @@ -15,7 +15,31 @@ class Update { fetch(constants.UPDATE_CHECK_URL).then((res) => { return res.json() }).then((json) => { - let latestTag = json[0].tag_name + + const newRelease = json.find(release => { + let tag = release.tag_name + tag = tag.indexOf('v' === 0) ? tag.substr(1) : tag + return !release.prerelease && compareVersion(tag, pkg.version) >= 1 + }) + + if (newRelease) { + let tag = newRelease.tag_name + tag = tag.indexOf('v' === 0) ? tag.substr(1) : tag + dialog.showMessageBox(window, { + type: 'question', + title:'Updates Available', + message:'Version ' + tag + ' is now available. Do you want to download it now?', + buttons: ['Download Now', 'Download Later'], + defaultId: 1, + }, (response) => { + if (response === 0) { + shell.openExternal(json.download_url) + } + }) + } + + //prerelease + /*let latestTag = json[0].tag_name latestTag = latestTag.indexOf('v' === 0) ? latestTag.substr(1) : latestTag if (compareVersion(latestTag, pkg.version) >= 1) { dialog.showMessageBox(window, { @@ -29,7 +53,7 @@ class Update { shell.openExternal(json.download_url) } }) - } + }*/ }) } }