From d7f12873b313f9e53b5e22fb25803c67ffe7a2c3 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Thu, 11 Jun 2015 12:08:47 -0700 Subject: [PATCH] feat(update): autoupdater adds an `updateLevel` param Summary: There's now an `updateLevel` that can be set in the config file. It has the valid values of "major", "minor", "patch", and "commit". By default it upgrades on the "patch" level. If you want to be on the bleeding edge, manually change the config file to add `updateLevel: 'commit'` Test Plan: A new `auto-update-manager-spec` :) Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D1567 --- dot-nylas/config.cson | 1 + .../attachments/stylesheets/attachments.less | 4 +- .../spec/inbox-composer-view-spec.cjsx | 2 +- package.json | 2 +- spec-nylas/auto-update-manager-spec.coffee | 41 +++++++++++++++++++ src/browser/application.coffee | 2 +- src/browser/auto-update-manager.coffee | 10 ++++- 7 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 spec-nylas/auto-update-manager-spec.coffee diff --git a/dot-nylas/config.cson b/dot-nylas/config.cson index 03a2ca6c7..d3f683b7e 100644 --- a/dot-nylas/config.cson +++ b/dot-nylas/config.cson @@ -7,3 +7,4 @@ "calendar-bar", "salesforce" ] + 'updateLevel': 'patch' diff --git a/internal_packages/attachments/stylesheets/attachments.less b/internal_packages/attachments/stylesheets/attachments.less index 908154634..69854edc0 100644 --- a/internal_packages/attachments/stylesheets/attachments.less +++ b/internal_packages/attachments/stylesheets/attachments.less @@ -100,7 +100,7 @@ .attachment-upload-progress { position: absolute; left: 0; - bottom: 0px; + bottom: 0; height: 2px; width: 0; // Changed by React z-index: 3; @@ -110,7 +110,7 @@ .attachment-bar-bg { position: absolute; left: 0; - bottom: 0px; + bottom: 0; height: 2px; width: 100%; z-index: 2; diff --git a/internal_packages/composer/spec/inbox-composer-view-spec.cjsx b/internal_packages/composer/spec/inbox-composer-view-spec.cjsx index f020a9798..dd42ce08a 100644 --- a/internal_packages/composer/spec/inbox-composer-view-spec.cjsx +++ b/internal_packages/composer/spec/inbox-composer-view-spec.cjsx @@ -34,7 +34,7 @@ textFieldStub = (className) -> render: ->
{@props.children}
focus: -> -passThroughStub = (props={})-> +passThroughStub = (props={}) -> React.createClass render: ->
{props.children}
diff --git a/package.json b/package.json index ab8d441c6..5183e682d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nylas", "productName": "Nylas", - "version": "0.178.0", + "version": "0.1.0", "description": "An email OS", "main": "./src/browser/main.js", "repository": { diff --git a/spec-nylas/auto-update-manager-spec.coffee b/spec-nylas/auto-update-manager-spec.coffee new file mode 100644 index 000000000..e5ad65642 --- /dev/null +++ b/spec-nylas/auto-update-manager-spec.coffee @@ -0,0 +1,41 @@ +AutoUpdateManager = require '../src/browser/auto-update-manager' + +describe "AutoUpdateManager", -> + c1 = get: -> + c2 = get: -> "major" + c3 = get: -> "minor" + c4 = get: -> "patch" + c5 = get: -> "commit" + c6 = get: -> "foo" + + base = "https://edgehill.nylas.com/update-check?version=" + + beforeEach -> + @feedUrl = (version, config) -> + m = new AutoUpdateManager(version, config) + spyOn(m, "setupAutoUpdater") + return m.feedUrl + + describe "with attached commit version", -> + beforeEach -> + @v = "3.222.1-abc" + + it "correctly sets the feedURL", -> + expect(@feedUrl(@v, c1)).toBe "#{base}3.222.1-abc&level=patch" + expect(@feedUrl(@v, c2)).toBe "#{base}3.222.1-abc&level=major" + expect(@feedUrl(@v, c3)).toBe "#{base}3.222.1-abc&level=minor" + expect(@feedUrl(@v, c4)).toBe "#{base}3.222.1-abc&level=patch" + expect(@feedUrl(@v, c5)).toBe "#{base}3.222.1-abc&level=commit" + expect(@feedUrl(@v, c6)).toBe "#{base}3.222.1-abc&level=patch" + + describe "with no attached commit", -> + beforeEach -> + @v = "3.222.1" + + it "correctly sets the feedURL", -> + expect(@feedUrl(@v, c1)).toBe "#{base}3.222.1&level=patch" + expect(@feedUrl(@v, c2)).toBe "#{base}3.222.1&level=major" + expect(@feedUrl(@v, c3)).toBe "#{base}3.222.1&level=minor" + expect(@feedUrl(@v, c4)).toBe "#{base}3.222.1&level=patch" + expect(@feedUrl(@v, c5)).toBe "#{base}3.222.1&level=commit" + expect(@feedUrl(@v, c6)).toBe "#{base}3.222.1&level=patch" diff --git a/src/browser/application.coffee b/src/browser/application.coffee index 91cf22584..c840076b2 100644 --- a/src/browser/application.coffee +++ b/src/browser/application.coffee @@ -77,7 +77,7 @@ class Application @databases = {} @windowManager = new WindowManager({@resourcePath, @config, @devMode, @safeMode}) - @autoUpdateManager = new AutoUpdateManager(@version) + @autoUpdateManager = new AutoUpdateManager(@version, @config) @applicationMenu = new ApplicationMenu(@version) @nylasProtocolHandler = new NylasProtocolHandler(@resourcePath, @safeMode) diff --git a/src/browser/auto-update-manager.coffee b/src/browser/auto-update-manager.coffee index faba96527..df07c6774 100644 --- a/src/browser/auto-update-manager.coffee +++ b/src/browser/auto-update-manager.coffee @@ -16,17 +16,23 @@ module.exports = class AutoUpdateManager _.extend @prototype, EventEmitter.prototype - constructor: (@version) -> + constructor: (@version, @config) -> @state = IdleState if process.platform is 'win32' # Squirrel for Windows can't handle query params # https://github.com/Squirrel/Squirrel.Windows/issues/132 @feedUrl = 'https://edgehill.nylas.com/update-check' else - @feedUrl = "https://edgehill.nylas.com/update-check?version=#{@version}" + upgradeLevel = @getUpgradeLevel() + @feedUrl = "https://edgehill.nylas.com/update-check?version=#{@version}&level=#{upgradeLevel}" process.nextTick => @setupAutoUpdater() + getUpgradeLevel: -> + lvl = @config.get("updateLevel") ? "patch" + if lvl not in ["major", "minor", "patch", "commit"] then lvl = "patch" + return lvl + setupAutoUpdater: -> if process.platform is 'win32' autoUpdater = require './auto-updater-win32'