From ff7d3da490e6090c9ec3527a07d7501f093dce9a Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Fri, 1 Apr 2016 10:00:08 -0400 Subject: [PATCH 01/16] Release 0.2.4 --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e93cfe..bbb3072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [0.2.4](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.4) (2016-04-01) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.3...0.2.4) + +Add support for upcoming log color configuration feature in ember-cli-deploy. + +- add logInfo color option [\#8](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/8) ([ghedamat](https://github.com/ghedamat)) + ## [0.2.3](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.3) (2016-03-29) [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.2...0.2.3) diff --git a/package.json b/package.json index e40cc98..c89e0e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-deploy-plugin", - "version": "0.2.3", + "version": "0.2.4", "description": "For building plugins for ember-cli-deploy", "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-plugin", "engines": { From 534e9e967fe5cd4ba49fb877bd11670b59fce3e3 Mon Sep 17 00:00:00 2001 From: Mattia Gheda Date: Fri, 1 Apr 2016 13:04:03 -0400 Subject: [PATCH 02/16] release 0.2.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c89e0e9..d1bce8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-deploy-plugin", - "version": "0.2.4", + "version": "0.2.5", "description": "For building plugins for ember-cli-deploy", "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-plugin", "engines": { From bf1caf6789f9ccc58babeef20e67204eaa88afa6 Mon Sep 17 00:00:00 2001 From: Mattia Gheda Date: Wed, 13 Apr 2016 19:11:50 -0400 Subject: [PATCH 03/16] remove lodash, fix #11 lodash was accidentally added, this commit also adds test to ensure basic functionality --- .travis.yml | 22 +++++++++++ index.js | 1 - package.json | 17 ++++++-- tests/.jshintrc | 51 ++++++++++++++++++++++++ tests/runner.js | 27 +++++++++++++ tests/test-helper.js | 6 +++ tests/unit/.gitkeep | 0 tests/unit/index-nodetest.js | 76 ++++++++++++++++++++++++++++++++++++ 8 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 .travis.yml create mode 100644 tests/.jshintrc create mode 100644 tests/runner.js create mode 100644 tests/test-helper.js create mode 100644 tests/unit/.gitkeep create mode 100644 tests/unit/index-nodetest.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c082ed1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +--- +language: node_js +node_js: + - "0.12" + - "4" + +sudo: false + +cache: + directories: + - node_modules + +before_install: + - export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH + - "npm config set spin false" + - "npm install -g npm@^2" + +install: + - npm install + +script: + - npm test diff --git a/index.js b/index.js index e50f211..aba51c4 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ var CoreObject = require('core-object'); var chalk = require('chalk'); -var _ = require('lodash'); var DeployPluginBase = CoreObject.extend({ context: null, diff --git a/package.json b/package.json index d1bce8a..5b4fa92 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,21 @@ }, "author": "Luke Melia and ember-cli-deploy team", "license": "MIT", - "devDependencies": {}, + "directories": { + "test": "tests" + }, + "scripts": { + "start": "ember server", + "build": "ember build", + "test": "node tests/runner.js" + }, + "devDependencies": { + "chai": "^3.5.0", + "glob": "^7.0.3", + "mocha": "^2.2.4" + }, "dependencies": { "chalk": "^1.0.0", - "core-object": "0.0.2", - "lodash": "^4.6.1" + "core-object": "0.0.2" } } diff --git a/tests/.jshintrc b/tests/.jshintrc new file mode 100644 index 0000000..ea8b88f --- /dev/null +++ b/tests/.jshintrc @@ -0,0 +1,51 @@ +{ + "predef": [ + "document", + "window", + "location", + "setTimeout", + "$", + "-Promise", + "define", + "console", + "visit", + "exists", + "fillIn", + "click", + "keyEvent", + "triggerEvent", + "find", + "findWithAssert", + "wait", + "DS", + "andThen", + "currentURL", + "currentPath", + "currentRouteName" + ], + "node": false, + "browser": false, + "boss": true, + "curly": false, + "debug": false, + "devel": false, + "eqeqeq": true, + "evil": true, + "forin": false, + "immed": false, + "laxbreak": false, + "newcap": true, + "noarg": true, + "noempty": false, + "nonew": false, + "nomen": false, + "onevar": false, + "plusplus": false, + "regexp": false, + "undef": true, + "sub": true, + "strict": false, + "white": false, + "eqnull": true, + "esnext": true +} diff --git a/tests/runner.js b/tests/runner.js new file mode 100644 index 0000000..1ffb333 --- /dev/null +++ b/tests/runner.js @@ -0,0 +1,27 @@ +'use strict'; + +var glob = require('glob'); +var Mocha = require('mocha'); + +var mocha = new Mocha({ + reporter: 'spec' +}); + +var arg = process.argv[2]; +var root = 'tests/'; + +function addFiles(mocha, files) { + glob.sync(root + files).forEach(mocha.addFile.bind(mocha)); +} + +addFiles(mocha, '/**/*-nodetest.js'); + +if (arg === 'all') { + addFiles(mocha, '/**/*-nodetest-slow.js'); +} + +mocha.run(function(failures) { + process.on('exit', function() { + process.exit(failures); + }); +}); diff --git a/tests/test-helper.js b/tests/test-helper.js new file mode 100644 index 0000000..e6cfb70 --- /dev/null +++ b/tests/test-helper.js @@ -0,0 +1,6 @@ +import resolver from './helpers/resolver'; +import { + setResolver +} from 'ember-qunit'; + +setResolver(resolver); diff --git a/tests/unit/.gitkeep b/tests/unit/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js new file mode 100644 index 0000000..234ae10 --- /dev/null +++ b/tests/unit/index-nodetest.js @@ -0,0 +1,76 @@ +/* jshint node: true */ +/* jshint jasmine: true */ +'use strict'; +var assert = require('chai').assert; + +var stubProject = { + name: function(){ + return 'my-project'; + } +}; + +describe('base plugin', function() { + var Subject, mockUi; + + beforeEach(function() { + Subject = require('../../index'); + mockUi = { + verbose: false, + messages: [], + write: function() { + }, + writeLine: function(message) { + this.messages.push(message); + } + }; + }); + + it('has a name', function() { + var plugin = new Subject({ + name: 'test-plugin', + }); + + assert.equal(plugin.name, 'test-plugin'); + }); + + describe('log', function() { + + it('logs raw', function() { + var plugin = new Subject({ + name: 'test-plugin', + ui: mockUi + }); + plugin.logRaw('foo'); + assert.deepEqual(mockUi.messages, ['foo']); + }); + + it('logs with default blue color', function() { + var plugin = new Subject({ + name: 'test-plugin', + ui: mockUi + }); + plugin.log('foo'); + assert.deepEqual(mockUi.messages, ['\u001b[34m- foo\u001b[39m']); + }); + + it('logs verbose', function() { + var verboseUi = { + verbose: true, + messages: [], + write: function(message) { + this.messages.push(message); + }, + writeLine: function() { + } + }; + var plugin = new Subject({ + name: 'test-plugin', + ui: verboseUi + }); + plugin.log('foo', {verbose: true}); + assert.deepEqual(verboseUi.messages, ['\u001b[34m| \u001b[39m']); + }); + + }); + +}); From 4d3c11a0da4085293795cc1088b9078fb1f5805f Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Tue, 19 Apr 2016 00:05:18 -0400 Subject: [PATCH 04/16] Release v0.2.6 --- CHANGELOG.md | 52 +++++++++++++++++++++++++++++++++++++++++----------- package.json | 2 +- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbb3072..31d4fae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,35 +1,64 @@ # Change Log -## [0.2.4](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.4) (2016-04-01) -[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.3...0.2.4) +## [0.2.6](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.6) (2016-04-19) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.5...0.2.6) -Add support for upcoming log color configuration feature in ember-cli-deploy. +**Merged pull requests:** + +- remove lodash, fix \#11 [\#12](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/12) ([ghedamat](https://github.com/ghedamat)) + +## [v0.2.5](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.5) (2016-04-01) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.4...v0.2.5) + +**Merged pull requests:** + +- require proper lodash [\#10](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/10) ([ghedamat](https://github.com/ghedamat)) + +## [v0.2.4](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.4) (2016-04-01) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.3...v0.2.4) + +**Merged pull requests:** - add logInfo color option [\#8](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/8) ([ghedamat](https://github.com/ghedamat)) -## [0.2.3](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.3) (2016-03-29) -[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.2...0.2.3) +## [v0.2.3](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.3) (2016-03-29) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.2...v0.2.3) + +**Merged pull requests:** -- add logRaw method [\#9](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/9) ([ghedamat](https://github.com/ghedamat)) +- add plain option [\#9](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/9) ([ghedamat](https://github.com/ghedamat)) -## [0.2.2](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.2) (2016-02-06) -[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.1...0.2.2) +## [v0.2.2](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.2) (2016-02-06) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.1...v0.2.2) + +**Merged pull requests:** - ember cli uses the wrong spelling from originalOutputStream [\#7](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/7) ([ghedamat](https://github.com/ghedamat)) -## [0.2.1](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.1) (2016-01-23) -[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.0...0.2.1) +## [v0.2.1](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.1) (2016-01-24) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.0...v0.2.1) + +**Closed issues:** + +- Can't list or activate revisions [\#5](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/issues/5) +- No repository field [\#4](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/issues/4) + +**Merged pull requests:** - ensure that we start logging from the beginning of the line [\#6](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/6) ([ghedamat](https://github.com/ghedamat)) ## [v0.2.0](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.0) (2015-10-24) [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.1.3...v0.2.0) +**Merged pull requests:** + - Add verbose option support to log method, and update docs [\#2](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/2) ([lukemelia](https://github.com/lukemelia)) ## [v0.1.3](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.1.3) (2015-08-04) [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.1.2...v0.1.3) +**Merged pull requests:** + - Call default getters in plugin context [\#1](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/1) ([dschmidt](https://github.com/dschmidt)) ## [v0.1.2](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.1.2) (2015-07-17) @@ -37,4 +66,5 @@ Add support for upcoming log color configuration feature in ember-cli-deploy. ## [v0.1.1](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.1.1) (2015-07-12) -- Initial release + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/package.json b/package.json index 5b4fa92..e6de0ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-deploy-plugin", - "version": "0.2.5", + "version": "0.2.6", "description": "For building plugins for ember-cli-deploy", "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-plugin", "engines": { From 6b3040ff0e304a7af1934541f6e32bcf69636217 Mon Sep 17 00:00:00 2001 From: Aaron Chambers Date: Fri, 30 Sep 2016 12:55:26 +0100 Subject: [PATCH 05/16] Bind pluginConfig as 'this' to function property --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index aba51c4..0c8ac3e 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,7 @@ var DeployPluginBase = CoreObject.extend({ readConfig: function(property){ var configuredValue = this.pluginConfig[property]; if (typeof configuredValue === 'function') { - return configuredValue.call(this, this.context); + return configuredValue.call(this.pluginConfig, this.context); } return configuredValue; }, From 3dbc299cc8bebe48a94449b5d7785ceaa104f4b2 Mon Sep 17 00:00:00 2001 From: Aaron Chambers Date: Thu, 6 Oct 2016 20:16:13 +0100 Subject: [PATCH 06/16] Pass pluginHelper into config functions --- index.js | 20 +++++++++++- package.json | 3 +- tests/unit/index-nodetest.js | 63 +++++++++++++++++++++++++++++++++++- 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 0c8ac3e..9d66e95 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,18 @@ var CoreObject = require('core-object'); var chalk = require('chalk'); +var merge = require('lodash.merge'); + +function _pluginHelperDefaults() { + return { + readConfigDefault: function(property) { + var configuredValue = this.defaultConfig[property]; + if (typeof configuredValue === 'function') { + return configuredValue.call(this, this.context); + } + return configuredValue; + }.bind(this) + }; +} var DeployPluginBase = CoreObject.extend({ context: null, @@ -43,7 +56,8 @@ var DeployPluginBase = CoreObject.extend({ readConfig: function(property){ var configuredValue = this.pluginConfig[property]; if (typeof configuredValue === 'function') { - return configuredValue.call(this.pluginConfig, this.context); + var helper = merge(this.pluginHelper(this.context), _pluginHelperDefaults.call(this)); + return configuredValue.call(this.pluginConfig, this.context, helper); } return configuredValue; }, @@ -74,6 +88,10 @@ var DeployPluginBase = CoreObject.extend({ this.logRaw(chalkColor('- ' + message)); } + }, + + pluginHelper: function(/*context*/) { + return {}; } }); diff --git a/package.json b/package.json index e6de0ea..5fc6ab4 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ }, "dependencies": { "chalk": "^1.0.0", - "core-object": "0.0.2" + "core-object": "0.0.2", + "lodash.merge": "^4.6.0" } } diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js index 234ae10..08e2b61 100644 --- a/tests/unit/index-nodetest.js +++ b/tests/unit/index-nodetest.js @@ -70,7 +70,68 @@ describe('base plugin', function() { plugin.log('foo', {verbose: true}); assert.deepEqual(verboseUi.messages, ['\u001b[34m| \u001b[39m']); }); - }); + describe('plugin helper', function() { + it('provides access to the oringal default values', function() { + var Plugin = Subject.extend({ + requiredConfig: ['bar'], + defaultConfig: { + foo: function(context) { + return context.foo; + } + } + }); + + var plugin = new Plugin({ + name: 'blah' + }); + + var context = { + foo: 'foo', + config: { + blah: { + foo: function(context, pluginHelper) { + return pluginHelper.readConfigDefault('foo') + 'foo'; + }, + bar: function(context, pluginHelper) { + return pluginHelper.readConfigDefault('bar') + 'bar'; + } + } + } + }; + + plugin.beforeHook(context); + assert.equal(plugin.readConfig('foo'), 'foofoo'); + assert.equal(plugin.readConfig('bar'), 'undefinedbar'); + }); + + it('allows the implementer to add things to the pluginHelper', function() { + var Plugin = Subject.extend({ + defaultConfig: { foo: 'foo' } + }); + + var plugin = new Plugin({ + name: 'blah', + + pluginHelper: function(context) { + return { bar: context.foo }; + } + }); + + var context = { + foo: 'bar', + config: { + blah: { + foo: function(context, pluginHelper) { + return pluginHelper.readConfigDefault('foo') + pluginHelper.bar; + } + } + } + }; + + plugin.beforeHook(context); + assert.equal(plugin.readConfig('foo'), 'foobar'); + }); + }); }); From d81a88da2d1b4df00436123a64bafb7d471eb35a Mon Sep 17 00:00:00 2001 From: Aaron Chambers Date: Thu, 6 Oct 2016 20:29:57 +0100 Subject: [PATCH 07/16] [DOC] Update doc with pluginHelper example --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 2ba301d..6c63f24 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,16 @@ module.exports = { }, requiredConfig: ['awesomeApiKey'], // throw an error if this is not configured + // return an object from here to add functionality to the `pluginHelper` + // that is passed in to user defined config property functions + pluginHelper: function(context) { + return { + sayHello: function() { + return 'Hello' + context.project.name(); + } + }; + }, + // implement any hooks appropriate for your plugin willUpload: function(context) { // Use the `readConfig` method for uniform access to this plugin's config, From d4e378561937e63331e3948990d1c76103e24a69 Mon Sep 17 00:00:00 2001 From: Aaron Chambers Date: Wed, 16 Nov 2016 10:01:58 +0000 Subject: [PATCH 08/16] Remove ability for plugin author to add functions to pluginHelper --- README.md | 10 ------- index.js | 15 ++++------- package.json | 2 +- tests/unit/index-nodetest.js | 51 +++++++----------------------------- 4 files changed, 15 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 6c63f24..2ba301d 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,6 @@ module.exports = { }, requiredConfig: ['awesomeApiKey'], // throw an error if this is not configured - // return an object from here to add functionality to the `pluginHelper` - // that is passed in to user defined config property functions - pluginHelper: function(context) { - return { - sayHello: function() { - return 'Hello' + context.project.name(); - } - }; - }, - // implement any hooks appropriate for your plugin willUpload: function(context) { // Use the `readConfig` method for uniform access to this plugin's config, diff --git a/index.js b/index.js index 9d66e95..16a5359 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,15 @@ var CoreObject = require('core-object'); var chalk = require('chalk'); -var merge = require('lodash.merge'); +var cloneDeep = require('lodash.clonedeep'); -function _pluginHelperDefaults() { +function _pluginHelper() { return { readConfigDefault: function(property) { var configuredValue = this.defaultConfig[property]; if (typeof configuredValue === 'function') { - return configuredValue.call(this, this.context); + return cloneDeep(configuredValue.call(this, this.context)); } - return configuredValue; + return cloneDeep(configuredValue); }.bind(this) }; } @@ -56,8 +56,7 @@ var DeployPluginBase = CoreObject.extend({ readConfig: function(property){ var configuredValue = this.pluginConfig[property]; if (typeof configuredValue === 'function') { - var helper = merge(this.pluginHelper(this.context), _pluginHelperDefaults.call(this)); - return configuredValue.call(this.pluginConfig, this.context, helper); + return configuredValue.call(this.pluginConfig, this.context, _pluginHelper.call(this)); } return configuredValue; }, @@ -88,10 +87,6 @@ var DeployPluginBase = CoreObject.extend({ this.logRaw(chalkColor('- ' + message)); } - }, - - pluginHelper: function(/*context*/) { - return {}; } }); diff --git a/package.json b/package.json index 5fc6ab4..fe84c0e 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,6 @@ "dependencies": { "chalk": "^1.0.0", "core-object": "0.0.2", - "lodash.merge": "^4.6.0" + "lodash.clonedeep": "^4.5.0" } } diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js index 08e2b61..8efd1a4 100644 --- a/tests/unit/index-nodetest.js +++ b/tests/unit/index-nodetest.js @@ -75,63 +75,30 @@ describe('base plugin', function() { describe('plugin helper', function() { it('provides access to the oringal default values', function() { var Plugin = Subject.extend({ - requiredConfig: ['bar'], defaultConfig: { - foo: function(context) { - return context.foo; - } + distFiles: ['index.html', 'assets/logo.png'] } }); var plugin = new Plugin({ - name: 'blah' - }); - - var context = { - foo: 'foo', - config: { - blah: { - foo: function(context, pluginHelper) { - return pluginHelper.readConfigDefault('foo') + 'foo'; - }, - bar: function(context, pluginHelper) { - return pluginHelper.readConfigDefault('bar') + 'bar'; - } - } - } - }; - - plugin.beforeHook(context); - assert.equal(plugin.readConfig('foo'), 'foofoo'); - assert.equal(plugin.readConfig('bar'), 'undefinedbar'); - }); - - it('allows the implementer to add things to the pluginHelper', function() { - var Plugin = Subject.extend({ - defaultConfig: { foo: 'foo' } - }); - - var plugin = new Plugin({ - name: 'blah', - - pluginHelper: function(context) { - return { bar: context.foo }; - } + name: 'build' }); var context = { - foo: 'bar', config: { - blah: { - foo: function(context, pluginHelper) { - return pluginHelper.readConfigDefault('foo') + pluginHelper.bar; + build: { + distFiles: function(context, pluginHelper) { + var arr = pluginHelper.readConfigDefault('distFiles'); + arr.push('index.json'); + return arr; } } } }; plugin.beforeHook(context); - assert.equal(plugin.readConfig('foo'), 'foobar'); + assert.deepEqual(plugin.defaultConfig.distFiles, ['index.html', 'assets/logo.png']); + assert.deepEqual(plugin.readConfig('distFiles'), ['index.html', 'assets/logo.png', 'index.json']); }); }); }); From d47e12ac60471bed23f82874af8de7f07302f9fa Mon Sep 17 00:00:00 2001 From: Aaron Chambers Date: Fri, 18 Nov 2016 09:04:23 +0000 Subject: [PATCH 09/16] Improve tests around mutability of default values --- tests/unit/index-nodetest.js | 78 +++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js index 8efd1a4..c51e94e 100644 --- a/tests/unit/index-nodetest.js +++ b/tests/unit/index-nodetest.js @@ -76,7 +76,21 @@ describe('base plugin', function() { it('provides access to the oringal default values', function() { var Plugin = Subject.extend({ defaultConfig: { - distFiles: ['index.html', 'assets/logo.png'] + distFiles: ['index.html', 'assets/logo.png'], + jsonBlueprint: { + link: { + selector: 'link', + attributes: ['rel', 'href'] + }, + }, + git: { + sha: function() { + return '1'; + } + }, + revisionKey: function(context) { + return context.revisionData.revisionKey; + } } }); @@ -85,20 +99,80 @@ describe('base plugin', function() { }); var context = { + revisionData: { revisionKey: '111' }, config: { build: { distFiles: function(context, pluginHelper) { var arr = pluginHelper.readConfigDefault('distFiles'); arr.push('index.json'); return arr; + }, + jsonBlueprint: function(context, pluginHelper) { + var blueprint = pluginHelper.readConfigDefault('jsonBlueprint'); + blueprint.link.attributes.push('integrity'); + + return blueprint; + }, + sha: function(context, pluginHelper) { + var git = pluginHelper.readConfigDefault('git'); + + return git.sha() + '2'; + }, + revisionKey: function(context, pluginHelper) { + return pluginHelper.readConfigDefault('revisionKey') + '222'; } } } }; plugin.beforeHook(context); - assert.deepEqual(plugin.defaultConfig.distFiles, ['index.html', 'assets/logo.png']); assert.deepEqual(plugin.readConfig('distFiles'), ['index.html', 'assets/logo.png', 'index.json']); + assert.deepEqual(plugin.readConfig('jsonBlueprint').link.attributes, ['rel', 'href', 'integrity']); + assert.equal(plugin.readConfig('sha'), '12'); + assert.equal(plugin.readConfig('revisionKey'), '111222'); }); + + it('ensures default values do not get mutated', function() { + var Plugin = Subject.extend({ + defaultConfig: { + distFiles: ['index.html', 'assets/logo.png'], + jsonBlueprint: { + link: { + selector: 'link', + attributes: ['rel', 'href'] + } + } + } + }); + + var plugin = new Plugin({ + name: 'build' + }); + + var context = { + config: { + build: { + distFiles: function(context, pluginHelper) { + var arr = pluginHelper.readConfigDefault('distFiles'); + arr.push('index.json'); + return arr; + }, + jsonBlueprint: function(context, pluginHelper) { + var blueprint = pluginHelper.readConfigDefault('jsonBlueprint'); + blueprint.link.attributes.push('integrity'); + + return blueprint; + } + } + } + }; + + plugin.beforeHook(context); + plugin.readConfig('distFiles') + plugin.readConfig('jsonBlueprint') + + assert.deepEqual(plugin.defaultConfig.distFiles, ['index.html', 'assets/logo.png']); + assert.deepEqual(plugin.defaultConfig.jsonBlueprint.link.attributes, ['rel', 'href']); + }) }); }); From 61299e661b684aa5d44e4a201c529e685008e623 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Mon, 21 Nov 2016 09:30:14 -0500 Subject: [PATCH 10/16] Release 0.2.7 --- CHANGELOG.md | 18 ++++++++++-------- package.json | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31d4fae..8947347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ # Change Log -## [0.2.6](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.6) (2016-04-19) -[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.5...0.2.6) +## [0.2.7](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.7) (2016-11-21) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.6...0.2.7) + +**Merged pull requests:** + +- Add plugin helper [\#15](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/15) ([achambers](https://github.com/achambers)) + +## [v0.2.6](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.6) (2016-04-19) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.5...v0.2.6) **Merged pull requests:** @@ -38,11 +45,6 @@ ## [v0.2.1](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.1) (2016-01-24) [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.0...v0.2.1) -**Closed issues:** - -- Can't list or activate revisions [\#5](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/issues/5) -- No repository field [\#4](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/issues/4) - **Merged pull requests:** - ensure that we start logging from the beginning of the line [\#6](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/6) ([ghedamat](https://github.com/ghedamat)) @@ -67,4 +69,4 @@ ## [v0.1.1](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.1.1) (2015-07-12) -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/package.json b/package.json index fe84c0e..7d907bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-deploy-plugin", - "version": "0.2.6", + "version": "0.2.7", "description": "For building plugins for ember-cli-deploy", "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-plugin", "engines": { From bc6cf074c3813396411fee89322daabcdad89980 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Mon, 21 Nov 2016 09:33:36 -0500 Subject: [PATCH 11/16] Update core-object & mocha. Fixes #13 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7d907bf..9784c26 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "devDependencies": { "chai": "^3.5.0", "glob": "^7.0.3", - "mocha": "^2.2.4" + "mocha": "^3.1.2" }, "dependencies": { "chalk": "^1.0.0", - "core-object": "0.0.2", + "core-object": "2.0.6", "lodash.clonedeep": "^4.5.0" } } From 201fa69331cde69c928cd59da6d696442c7f1c2b Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Mon, 21 Nov 2016 09:40:37 -0500 Subject: [PATCH 12/16] Release 0.2.8 --- CHANGELOG.md | 13 +++++++++++-- package.json | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8947347..7599a5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,16 @@ # Change Log -## [0.2.7](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.7) (2016-11-21) -[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.6...0.2.7) +## [0.2.8](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.8) (2016-11-21) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.7...0.2.8) + +**Merged pull requests:** + +- Update core-object & mocha. [\#16](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/16) ([lukemelia](https://github.com/lukemelia)) + +## [v0.2.7](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.7) (2016-11-21) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.6...v0.2.7) + +[BREAKING] This release changes the context of `this` within a user-defined config property function from the base plugin itself to the surrounding config object. This behavior was previously inconsistent. **Merged pull requests:** diff --git a/package.json b/package.json index 9784c26..c4e9a6f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-deploy-plugin", - "version": "0.2.7", + "version": "0.2.8", "description": "For building plugins for ember-cli-deploy", "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-plugin", "engines": { From 4a1e622bc244a9d872261535b9547fb81ef3158f Mon Sep 17 00:00:00 2001 From: Aaron Chambers Date: Mon, 21 Nov 2016 22:59:46 +0000 Subject: [PATCH 13/16] Add function to pluginHelper --- index.js | 4 +++ tests/unit/index-nodetest.js | 68 +++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 16a5359..ed3fd1c 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,10 @@ function _pluginHelper() { return cloneDeep(configuredValue.call(this, this.context)); } return cloneDeep(configuredValue); + }.bind(this), + + readConfig: function(property) { + return cloneDeep(this.readConfig(property)); }.bind(this) }; } diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js index c51e94e..173d02b 100644 --- a/tests/unit/index-nodetest.js +++ b/tests/unit/index-nodetest.js @@ -21,7 +21,8 @@ describe('base plugin', function() { }, writeLine: function(message) { this.messages.push(message); - } + }, + logInfoColor: 'blue' }; }); @@ -174,5 +175,70 @@ describe('base plugin', function() { assert.deepEqual(plugin.defaultConfig.distFiles, ['index.html', 'assets/logo.png']); assert.deepEqual(plugin.defaultConfig.jsonBlueprint.link.attributes, ['rel', 'href']); }) + + it('provides the ability to read the plugin config', function() { + var Plugin = Subject.extend({ + defaultConfig: { + port: function() { + return 1234; + }, + host: 'foo.com' + } + }); + + var plugin = new Plugin({ + name: 'build' + }); + + var context = { + ui: mockUi, + config: { + build: { + username: 'bar', + options: function(context, pluginHelper) { + return { + port: pluginHelper.readConfig('port'), + host: pluginHelper.readConfig('host'), + username: pluginHelper.readConfig('username') + }; + } + } + } + }; + + plugin.beforeHook(context); + plugin.configure(context); + + assert.deepEqual(plugin.readConfig('options'), { port: 1234, host: 'foo.com', username: 'bar' }); + }); + + it('doesn\'t mutate the original plugin config', function() { + var Plugin = Subject.extend({ + defaultConfig: { } + }); + + var plugin = new Plugin({ + name: 'build' + }); + + var context = { + ui: mockUi, + config: { + build: { + tags: ['foo'], + options: function(context, pluginHelper) { + var tags = pluginHelper.readConfig('tags'); + tags.push('bar'); + return { tags: tags }; + } + } + } + }; + + plugin.beforeHook(context); + plugin.configure(context); + + assert.deepEqual(plugin.readConfig('options'), { tags: ['foo', 'bar']}); + }); }); }); From 211e6f7072f5413e97de707f651e70eb8635941b Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Mon, 21 Nov 2016 18:24:56 -0500 Subject: [PATCH 14/16] Release 0.2.9 --- CHANGELOG.md | 11 +++++++++-- package.json | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7599a5f..24b5bb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ # Change Log -## [0.2.8](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.8) (2016-11-21) -[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.7...0.2.8) +## [0.2.9](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/0.2.9) (2016-11-21) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.8...0.2.9) + +**Merged pull requests:** + +- Add function to pluginHelper [\#17](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/pull/17) ([achambers](https://github.com/achambers)) + +## [v0.2.8](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/tree/v0.2.8) (2016-11-21) +[Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-plugin/compare/v0.2.7...v0.2.8) **Merged pull requests:** diff --git a/package.json b/package.json index c4e9a6f..32b61fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-deploy-plugin", - "version": "0.2.8", + "version": "0.2.9", "description": "For building plugins for ember-cli-deploy", "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-plugin", "engines": { From 4d573415b32a4ba47702661b824b2aa1aa670760 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Thu, 2 Feb 2017 23:04:15 -0500 Subject: [PATCH 15/16] Minor README updates --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2ba301d..30aa43d 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,9 @@ module.exports = { someKey: 'defaultValue', anotherKey: function(context) { return context.anotherKey; // to use data added to the context by another plugin + }, + capsKey: function(context, pluginHelper) { + return pluginHelper.readConfig('someKey').toUppercase(); // pluginHelper.readConfig returns a clone of the specified config value } }, requiredConfig: ['awesomeApiKey'], // throw an error if this is not configured @@ -56,7 +59,3 @@ module.exports = { return new DeployPlugin(); } }; - -## TODO - -Tests From a72d9fc6f35d5926e96e7debb248701dd39249ec Mon Sep 17 00:00:00 2001 From: Raymond Cohen Date: Mon, 20 Feb 2017 18:21:13 -0500 Subject: [PATCH 16/16] error when creating a plugin without a name --- index.js | 6 ++++++ tests/unit/index-nodetest.js | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/index.js b/index.js index ed3fd1c..c17d781 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,12 @@ var DeployPluginBase = CoreObject.extend({ project: null, pluginConfig: null, defaultConfig: {}, + init: function() { + this._super.init.apply(this, arguments); + if (!this.name) { + throw new Error('Plugin is missing name property'); + } + }, beforeHook: function(context) { this.context = context; this.ui = context.ui; diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js index 173d02b..eadcfb8 100644 --- a/tests/unit/index-nodetest.js +++ b/tests/unit/index-nodetest.js @@ -34,6 +34,14 @@ describe('base plugin', function() { assert.equal(plugin.name, 'test-plugin'); }); + it('errors when no name is set', function() { + var makePluginWithNoName = function() { + new Subject(); + }; + + assert.throws(makePluginWithNoName, /missing name/); + }); + describe('log', function() { it('logs raw', function() {