From 0e112b54f87a266186ea725cc93236bf1a9bd8b0 Mon Sep 17 00:00:00 2001 From: drewprice Date: Fri, 12 May 2017 12:44:49 -0400 Subject: [PATCH 1/3] When using a beta version, check for beta updates --- lib/updater.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/updater.js b/lib/updater.js index 6f1fb04..312654f 100644 --- a/lib/updater.js +++ b/lib/updater.js @@ -10,7 +10,12 @@ import {learnCo} from './config' import {name} from '../package.json' var helpCenterUrl = `${learnCo}/ide/faq`; -var latestVersionUrl = `${learnCo}/api/v1/learn_ide/latest_version`; + +var latestVersionUrl = (function() { + var {version} = require('../package.json'); + var isBeta = version.includes('beta'); + return isBeta ? `${learnCo}/api/v1/learn_ide/latest_beta_version` : `${learnCo}/api/v1/learn_ide/latest_version` +})() export default { autoCheck() { From 35f6508fe17e1527d0ac4ff39a34782a5af83cc8 Mon Sep 17 00:00:00 2001 From: drewprice Date: Fri, 12 May 2017 13:49:37 -0400 Subject: [PATCH 2/3] Add bleeding update config --- lib/learn-ide.js | 37 ++++++++++++++++++++++++++----------- lib/updater.js | 15 +++++++++------ package.json | 13 ++++++++++--- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/lib/learn-ide.js b/lib/learn-ide.js index 0d670f9..2233568 100644 --- a/lib/learn-ide.js +++ b/lib/learn-ide.js @@ -112,17 +112,32 @@ export default { 'learn-ide:clear-terminal': () => this.term.send(' ') })); - atom.config.onDidChange(`${name}.terminalColors.basic`, () => colors.apply()) - - atom.config.onDidChange(`${name}.terminalColors.ansi`, () => colors.apply()) - - atom.config.onDidChange(`${name}.terminalColors.json`, ({newValue}) => { - colors.parseJSON(newValue); - }); - - atom.config.onDidChange(`${name}.notifier`, ({newValue}) => { - newValue ? this.activateNotifier() : this.notifier.deactivate() - }); + this.subscriptions.add( + atom.config.onDidChange(`${name}.bleedingUpdates`, ({newValue}) => { + if (!newValue) { localStorage.set('didUnsubscribeFromBleedingUpdates', Date.now()) } + updater.checkForUpdate() + }) + ) + + this.subscriptions.add( + atom.config.onDidChange(`${name}.notifier`, ({newValue}) => { + newValue ? this.activateNotifier() : this.notifier.deactivate() + }) + ) + + this.subscriptions.add( + atom.config.onDidChange(`${name}.terminalColors.basic`, () => colors.apply()) + ) + + this.subscriptions.add( + atom.config.onDidChange(`${name}.terminalColors.ansi`, () => colors.apply()) + ) + + this.subscriptions.add( + atom.config.onDidChange(`${name}.terminalColors.json`, ({newValue}) => { + colors.parseJSON(newValue); + }) + ) var openPath = localStorage.get('learnOpenLabOnActivation'); if (openPath) { diff --git a/lib/updater.js b/lib/updater.js index 312654f..a860e53 100644 --- a/lib/updater.js +++ b/lib/updater.js @@ -11,11 +11,10 @@ import {name} from '../package.json' var helpCenterUrl = `${learnCo}/ide/faq`; -var latestVersionUrl = (function() { - var {version} = require('../package.json'); - var isBeta = version.includes('beta'); - return isBeta ? `${learnCo}/api/v1/learn_ide/latest_beta_version` : `${learnCo}/api/v1/learn_ide/latest_version` -})() +function latestVersionUrl() { + var bleedingUpdates = atom.config.get(`${name}.bleedingUpdates`); + return bleedingUpdates ? `${learnCo}/api/v1/learn_ide/bleeding_version` : `${learnCo}/api/v1/learn_ide/latest_version` +} export default { autoCheck() { @@ -84,7 +83,7 @@ export default { }, _fetchLatestVersionData() { - return fetch(latestVersionUrl).then(latestVersionData => { + return fetch(latestVersionUrl()).then(latestVersionData => { this.latestVersionData = latestVersionData; return this.latestVersionData; }); @@ -105,6 +104,10 @@ export default { _shouldUpdate(latestVersion) { var {version} = require('../package.json'); + if (localStorage.remove('didUnsubscribeFromBleedingUpdates')) { + return !semver.eq(latestVersion, version) + } + if (semver.gt(latestVersion, version)) { return true; } diff --git a/package.json b/package.json index 93ea875..03991c0 100644 --- a/package.json +++ b/package.json @@ -51,15 +51,22 @@ "underscore-plus": "^1.6.6" }, "configSchema": { - "notifier": { + "bleedingUpdates": { "order": 0, "type": "boolean", + "default": false, + "title": "Subscribe to Bleeding Updates", + "description": "Recieve update notifications as beta and early releases of the Learn IDE become available. Learn more on the [help center](https://learn.co/ide/beta)." + }, + "notifier": { + "order": 1, + "type": "boolean", "default": true, "title": "Learn Status Notifications", - "description": "Receive desktop notifications that correspond to the lights on Learn.co" + "description": "Receive desktop notifications that correspond to the lights on Learn.co." }, "terminalColors": { - "order": 1, + "order": 2, "type": "object", "properties": { "basic": { From c9a015e523ba79abcd6ad13c2c894247db6e3f38 Mon Sep 17 00:00:00 2001 From: drewprice Date: Fri, 12 May 2017 13:51:05 -0400 Subject: [PATCH 3/3] Update bleeding helpcenter url --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 03991c0..8f1599a 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "type": "boolean", "default": false, "title": "Subscribe to Bleeding Updates", - "description": "Recieve update notifications as beta and early releases of the Learn IDE become available. Learn more on the [help center](https://learn.co/ide/beta)." + "description": "Recieve update notifications as beta and early releases of the Learn IDE become available. Learn more on the [help center](https://learn.co/ide/bleeding)." }, "notifier": { "order": 1,