diff --git a/CHANGELOG.md b/CHANGELOG.md
index b7c4504..c9665b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,15 +13,15 @@ Thank you to all who took the time to contribute!
#### Community Contributions
-- [#1](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/1) Create a tag form the hash of the index.html [@achambers](https://github.com/achambers)
-- [#3](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/3) Updated to be in line with how ember-cli-deploy handles context data [@achambers](https://github.com/achambers)
-- [#4](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/4) Remove dependency on index path [@achambers](https://github.com/achambers)
-- [#5](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/5) Now filePattern is relative to the dist dir stored in `context.distDir` [@achambers](https://github.com/achambers)
-- [#6](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/6) Rename index-hash to file-hash [@lukemelia](https://github.com/lukemelia)
-- [#7](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/7) Change to use `configure` hook instead of `willDeploy` [@achambers](https://github.com/achambers)
-- [#8](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/8) Renamed project and all references to `tags` [@achambers](https://github.com/achambers)
-- [#9](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/9) `configure` primes the config with data from the deployment context [@achambers](https://github.com/achambers)
-- [#10](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/10) Restructure to use ember-cli-deploy-plugin, and complete rename to em… [@lukemelia](https://github.com/lukemelia)
-- [#12](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/12) Update README for v0.5.0 [@achambers](https://github.com/achambers)
+- [#1](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/1) Create a tag form the hash of the index.html [@achambers](https://github.com/achambers)
+- [#3](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/3) Updated to be in line with how ember-cli-deploy handles context data [@achambers](https://github.com/achambers)
+- [#4](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/4) Remove dependency on index path [@achambers](https://github.com/achambers)
+- [#5](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/5) Now filePattern is relative to the dist dir stored in `context.distDir` [@achambers](https://github.com/achambers)
+- [#6](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/6) Rename index-hash to file-hash [@lukemelia](https://github.com/lukemelia)
+- [#7](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/7) Change to use `configure` hook instead of `willDeploy` [@achambers](https://github.com/achambers)
+- [#8](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/8) Renamed project and all references to `tags` [@achambers](https://github.com/achambers)
+- [#9](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/9) `configure` primes the config with data from the deployment context [@achambers](https://github.com/achambers)
+- [#10](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/10) Restructure to use ember-cli-deploy-plugin, and complete rename to em… [@lukemelia](https://github.com/lukemelia)
+- [#12](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/12) Update README for v0.5.0 [@achambers](https://github.com/achambers)
Thank you to all who took the time to contribute!
diff --git a/README.md b/README.md
index 9e469a9..bc25722 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,13 @@
-# ember-cli-deploy-revision-key
+# ember-cli-deploy-revision-data
-> An ember-cli-deploy plugin to generate a unique revision key based on the current build
+> An ember-cli-deploy plugin to generate data about this deploy revision including a unique revision key based on the current build
**WARNING: This plugin is only compatible with ember-cli-deploy versions >= 0.5.0**
-This plugin will generate a unique revision key for the current build. The revision key can be used to uniquely identify the particular version of the application.
+This plugin will generate revison data for the current build. This data can be used by other plugins to understand more about the current revision being deployed.
+The revision key included in the revison data can be used to uniquely identify the particular version of the application.
## What is an ember-cli-deploy plugin?
@@ -22,7 +23,7 @@ To get up and running quickly, do the following:
- Install this plugin
```bash
-$ ember install ember-cli-deploy-revision-key
+$ ember install ember-cli-deploy-revision-data
```
- Run the pipeline
@@ -35,7 +36,7 @@ $ ember deploy
Run the following command in your terminal:
```bash
-ember install ember-cli-deploy-revision-key
+ember install ember-cli-deploy-revision-data
```
## ember-cli-deploy Hooks Implemented
@@ -43,7 +44,7 @@ ember install ember-cli-deploy-revision-key
For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][1].
- `configure`
-- `didBuild`
+- `prepare`
## Configuration Options
@@ -51,18 +52,28 @@ For detailed information on how configuration of plugins works, please refer to
### type
-The type of [Key Generator](#key-generators) to be used.
+The type of [Data Generator](#data-generators) to be used.
*Default:* `'file-hash'`
*Alternatives:* `'git-tag-commit'`, `'version-commit'`
-## Key Generators
+## Data Generators
-Key generators are the strategies used to generate the unique revision key. Currently there is only one Key Generator implementation but we will add more as needed. Some examples of other potential key generators are `GitHash` or `DateTime` generators.
+Data generators are the strategies used to generate information about the revision being deployed. A data generator must return an object which contains a property called `revisionKey` which uniquely identifies the current revision. A generator can add any other data that it deems relevant to the data object that it returns.
### File Hash generator
-This key generator will fingerprint the `index.html` and return an MD5 hash. The generation of the revision key, using this generator, is guaranteed to be idempotent. That is, the same revision key will be generated for the same set of project files. If the project files change in any way, this will be reflected by a change in the revision key.
+This generator contructs a revisionKey from the fingerprint of the `index.html` file.
+
+#### Data fields returned
+
+##### revisionKey
+
+The unique identifier of this build based on the MD5 fingerprint of the `index.html` file. This key is guaranteed to be idempotent. That is, the same revision key will be generated for the same set of project files. If the project files change in any way, this will be reflected by a change in the revision key.
+
+##### timestamp
+
+The timestamp of the current deploy
#### Configuration Options
@@ -86,19 +97,41 @@ The list of built project files. This option should be relative to `distDir` and
### Git Tag Commit generator
-Creates a key based on the most recent git tag and the currently checked-out commit. The tag is the tag identifier, followed by a `+` symbol, followed by the first 8 characters of the commit hash.
+Constructs a revision key based on the most recent git tag and the currently checked-out commit.
+
+#### Data fields returned
+
+##### revisionKey
+
+The unique identifier of this build based on the git tag, followed by a `+` symbol, followed by the first 8 characters of the current commit hash.
For example, if your most recent git tag is `v2.0.3`, and the current commit is `0993043d49f9e0[...]`, this generator will return a revision of `v2.0.3+0993043d`.
+##### timestamp
+
+The timestamp of the current deploy
+
### Version Commit generator
-Similar to the Git Tag Commit generator, but uses the `package.json` version string instead of the git tag. The JSON file containing the version string can be configured with the `versionFile` option.
+Similar to the Git Tag Commit generator but uses the `package.json` version string to construct the revision key instead of the git tag.
+
+#### Data fields returned
+
+##### revisionKey
+
+The unique identifier of this build based on the version in the `package.json`, followed by a `+` symbol, followed by the first 8 characters of the current commit hash.
+
+For example, if your package.json version is `v2.0.3`, and the current commit is `0993043d49f9e0[...]`, this generator will return a revision of `v2.0.3+0993043d`.
+
+##### timestamp
+
+The timestamp of the current deploy
#### Configuration Options
##### versionFile
-The file containing your project's version number. Must be a JSON file with a top-level `version` key. Only used by the `version-commit` key generator.
+The file containing your project's version number. Must be a JSON file with a top-level `version` key.
*Default:* `package.json`
diff --git a/RELEASE.md b/RELEASE.md
index f7d2d21..a9a4610 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -16,7 +16,7 @@ The following steps should navigate you through the release process to ensure as
8. `git push upstream master`
9. `git tag "vx.y.z"`
10. `git push upstream vx.y.z`
-11. `npm publish ./ember-cli-deploy-revision-key-.tgz`
+11. `npm publish ./ember-cli-deploy-revision-data-.tgz`
### Create a github release
diff --git a/bin/changelog b/bin/changelog
index 85e08ff..b180d4b 100755
--- a/bin/changelog
+++ b/bin/changelog
@@ -21,7 +21,7 @@ var compareCommits = Promise.denodeify(github.repos.compareCommits);
var currentVersion = 'v' + require('../package').version;
var user = 'zapnito';
-var repo = 'ember-cli-deploy-revision-key';
+var repo = 'ember-cli-deploy-revision-data';
compareCommits({
user: user,
diff --git a/bin/prepare-release b/bin/prepare-release
index d06a2a1..cac7d9a 100755
--- a/bin/prepare-release
+++ b/bin/prepare-release
@@ -1,7 +1,7 @@
#!/bin/sh
rm -rf node_modules && \
-rm -rf ./ember-cli-deploy-revision-key*.tgz && \
+rm -rf ./ember-cli-deploy-revision-data*.tgz && \
npm cache clear && \
npm i --no-optional && \
npm link --no-optional && \
diff --git a/bower.json b/bower.json
index 41aa884..a3354f6 100644
--- a/bower.json
+++ b/bower.json
@@ -1,5 +1,5 @@
{
- "name": "ember-cli-deploy-revision-key",
+ "name": "ember-cli-deploy-revision-data",
"dependencies": {
"ember": "1.11.1",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
diff --git a/index.js b/index.js
index 5aa30a8..65f0b6a 100644
--- a/index.js
+++ b/index.js
@@ -6,7 +6,7 @@ var Promise = require('ember-cli/lib/ext/promise');
var DeployPluginBase = require('ember-cli-deploy-plugin');
module.exports = {
- name: 'ember-cli-deploy-revision-key',
+ name: 'ember-cli-deploy-revision-data',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
@@ -22,22 +22,22 @@ module.exports = {
},
versionFile: 'package.json',
},
- didBuild: function(context) {
+ prepare: function(context) {
var self = this;
var type = this.readConfig('type');
- var KeyGenerator = require('./lib/key-generators')[type];
- var keyGenerator = new KeyGenerator({
+ var DataGenerator = require('./lib/data-generators')[type];
+ var dataGenerator = new DataGenerator({
plugin: this
});
- this.log('creating revision key using `' + type + '`');
- return keyGenerator.generate()
- .then(function(revisionKey) {
- self.log('generated revision key: `' + revisionKey + '`');
- return revisionKey;
+ this.log('creating revision data using `' + type + '`');
+ return dataGenerator.generate()
+ .then(function(data) {
+ self.log('generated revision data for revision: `' + data.revisionKey + '`');
+ return data;
})
- .then(function(revisionKey) {
- return { revisionKey: revisionKey };
+ .then(function(data) {
+ return { revisionData: data };
})
.catch(this._errorMessage.bind(this));
},
diff --git a/lib/key-generators/file-hash.js b/lib/data-generators/file-hash.js
similarity index 83%
rename from lib/key-generators/file-hash.js
rename to lib/data-generators/file-hash.js
index f37e991..861f528 100644
--- a/lib/key-generators/file-hash.js
+++ b/lib/data-generators/file-hash.js
@@ -29,16 +29,11 @@ module.exports = CoreObject.extend({
return readFile(filePath)
.then(function(contents) {
- return md5Hash(contents.toString());
+ return {
+ revisionKey: md5Hash(contents.toString()),
+ timestamp: new Date().toISOString()
+ };
})
- },
-
- _resolveConfigValue: function(key, config, context) {
- if(typeof config[key] === 'function') {
- return config[key](context);
- }
-
- return config[key];
}
});
diff --git a/lib/key-generators/git-tag-commit.js b/lib/data-generators/git-tag-commit.js
similarity index 83%
rename from lib/key-generators/git-tag-commit.js
rename to lib/data-generators/git-tag-commit.js
index b1741ea..f633450 100644
--- a/lib/key-generators/git-tag-commit.js
+++ b/lib/data-generators/git-tag-commit.js
@@ -18,6 +18,9 @@ module.exports = CoreObject.extend({
return Promise.reject('Could not build revision with tag `' + tag + '` and commit hash `' + sha + '`');
}
- return Promise.resolve(info.tag + '+' + sha);
+ return Promise.resolve({
+ revisionKey: info.tag + '+' + sha,
+ timestamp: new Date().toISOString()
+ });
}
});
diff --git a/lib/key-generators/index.js b/lib/data-generators/index.js
similarity index 100%
rename from lib/key-generators/index.js
rename to lib/data-generators/index.js
diff --git a/lib/key-generators/version-commit.js b/lib/data-generators/version-commit.js
similarity index 88%
rename from lib/key-generators/version-commit.js
rename to lib/data-generators/version-commit.js
index 75a1af0..a5af9ac 100644
--- a/lib/key-generators/version-commit.js
+++ b/lib/data-generators/version-commit.js
@@ -31,7 +31,10 @@ module.exports = CoreObject.extend({
return Promise.reject('Could not build revision with version `' + json.version + '` and commit hash `' + sha + '`');
}
- return json.version + '+' + sha;
+ return {
+ revisionKey: json.version + '+' + sha,
+ timestamp: new Date().toISOString()
+ };
});
}
});
diff --git a/package.json b/package.json
index e38ecfe..0866bbd 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
- "name": "ember-cli-deploy-revision-key",
+ "name": "ember-cli-deploy-revision-data",
"version": "0.1.0-beta.2",
- "description": "An ember-cli-plugin to create a unique revision key for the build",
+ "description": "An ember-cli-deploy plugin to generate data about this deploy revision including a unique revision key based on the current build",
"directories": {
"doc": "doc",
"test": "tests"
@@ -11,7 +11,7 @@
"build": "ember build",
"test": "node tests/runner.js"
},
- "repository": "https://github.com/zapnito/ember-cli-deploy-revision-key",
+ "repository": "https://github.com/zapnito/ember-cli-deploy-revision-data",
"engines": {
"node": ">= 0.10.0"
},
@@ -53,7 +53,6 @@
"rsvp": "^3.0.18"
},
"ember-addon": {
- "configPath": "tests/dummy/config",
- "after": "ember-cli-deploy-json-config"
+ "configPath": "tests/dummy/config"
}
}
diff --git a/tests/unit/index-nodetest.js b/tests/unit/index-nodetest.js
index 3f0221f..80dc2d4 100644
--- a/tests/unit/index-nodetest.js
+++ b/tests/unit/index-nodetest.js
@@ -30,19 +30,19 @@ describe('the index', function() {
});
assert.typeOf(plugin.configure, 'function');
- assert.typeOf(plugin.didBuild, 'function');
+ assert.typeOf(plugin.prepare, 'function');
});
describe('configure hook', function() {
it('resolves if config is ok', function() {
var plugin = subject.createDeployPlugin({
- name: 'revision-key'
+ name: 'revision-data'
});
var context = {
ui: mockUi,
config: {
- "revision-key": {
+ "revision-data": {
type: 'file-hash',
filePattern: 'eeee'
}
@@ -55,13 +55,13 @@ describe('the index', function() {
});
it('warns about missing optional config', function() {
var plugin = subject.createDeployPlugin({
- name: 'revision-key'
+ name: 'revision-data'
});
var context = {
ui: mockUi,
config: {
- "revision-key": {
+ "revision-data": {
}
}
};
@@ -82,13 +82,13 @@ describe('the index', function() {
it('adds default config to the config object', function() {
var plugin = subject.createDeployPlugin({
- name: 'revision-key'
+ name: 'revision-data'
});
var context = {
ui: mockUi,
config: {
- "revision-key": {
+ "revision-data": {
}
}
};
@@ -96,15 +96,15 @@ describe('the index', function() {
plugin.beforeHook(context);
plugin.configure(context);
- assert.isDefined(context.config['revision-key'].type);
- assert.isDefined(context.config['revision-key'].filePattern);
+ assert.isDefined(context.config['revision-data'].type);
+ assert.isDefined(context.config['revision-data'].filePattern);
});
});
- describe('didBuild hook', function() {
- it('returns the revisionKey', function() {
+ describe('prepare hook', function() {
+ it('returns the revisionData', function() {
var plugin = subject.createDeployPlugin({
- name: 'revision-key'
+ name: 'revision-data'
});
var context = {
@@ -112,7 +112,7 @@ describe('the index', function() {
distFiles: ['index.html'],
ui: mockUi,
config: {
- "revision-key": {
+ "revision-data": {
type: 'file-hash',
filePattern: 'index.html',
distDir: function(context) {
@@ -126,9 +126,10 @@ describe('the index', function() {
};
plugin.beforeHook(context);
- return assert.isFulfilled(plugin.didBuild(context))
+ return assert.isFulfilled(plugin.prepare(context))
.then(function(result) {
- assert.equal(result.revisionKey, 'ae1569f72495012cd5e8588e0f2f5d49');
+ assert.equal(result.revisionData.revisionKey, 'ae1569f72495012cd5e8588e0f2f5d49');
+ assert.isNotNull(result.revisionData.timestamp);
});
});
});
diff --git a/tests/unit/lib/key-generators/file-hash-nodetest.js b/tests/unit/lib/data-generators/file-hash-nodetest.js
similarity index 51%
rename from tests/unit/lib/key-generators/file-hash-nodetest.js
rename to tests/unit/lib/data-generators/file-hash-nodetest.js
index 4aeb756..0f6895d 100644
--- a/tests/unit/lib/key-generators/file-hash-nodetest.js
+++ b/tests/unit/lib/data-generators/file-hash-nodetest.js
@@ -2,32 +2,45 @@
var assert = require('ember-cli/tests/helpers/assert');
-describe('the file-hash key generator', function() {
- var KeyGenerator;
+describe('the file-hash data generator', function() {
+ var DataGenerator;
before(function() {
- KeyGenerator = require('../../../../lib/key-generators/file-hash');
+ DataGenerator = require('../../../../lib/data-generators/file-hash');
});
describe('#generate', function() {
- it('generates a hash of the supplied index file', function() {
- var plugin = {
- stubConfig: {
- distDir: 'tests/fixtures',
- distFiles: ['index.html'],
- filePattern: 'index.html'
- },
- readConfig: function(key) { return this.stubConfig[key]; }
- };
+ describe('revisionData', function() {
+ var subject;
- var subject = new KeyGenerator({
- plugin: plugin
- });
+ before(function() {
+ var plugin = {
+ stubConfig: {
+ distDir: 'tests/fixtures',
+ distFiles: ['index.html'],
+ filePattern: 'index.html'
+ },
+ readConfig: function(key) { return this.stubConfig[key]; }
+ };
- return assert.isFulfilled(subject.generate())
- .then(function(hash) {
- assert.equal(hash, 'ae1569f72495012cd5e8588e0f2f5d49');
+ subject = new DataGenerator({
+ plugin: plugin
});
+ });
+
+ it('includes the revisonKey', function() {
+ return assert.isFulfilled(subject.generate())
+ .then(function(revisionData) {
+ assert.equal(revisionData.revisionKey, 'ae1569f72495012cd5e8588e0f2f5d49');
+ });
+ });
+
+ it('includes a timestamp', function() {
+ return assert.isFulfilled(subject.generate())
+ .then(function(revisionData) {
+ assert.isNotNull(revisionData.timestamp);
+ });
+ });
});
it('rejects when the filePattern doesn\'t exist in distFiles', function() {
@@ -40,7 +53,7 @@ describe('the file-hash key generator', function() {
readConfig: function(key) { return this.stubConfig[key]; }
};
- var subject = new KeyGenerator({
+ var subject = new DataGenerator({
plugin: plugin
});
@@ -60,7 +73,7 @@ describe('the file-hash key generator', function() {
readConfig: function(key) { return this.stubConfig[key]; }
};
- var subject = new KeyGenerator({
+ var subject = new DataGenerator({
plugin: plugin
});
diff --git a/tests/unit/lib/key-generators/git-tag-commit-nodetest.js b/tests/unit/lib/data-generators/git-tag-commit-nodetest.js
similarity index 63%
rename from tests/unit/lib/key-generators/git-tag-commit-nodetest.js
rename to tests/unit/lib/data-generators/git-tag-commit-nodetest.js
index 1434e09..de79b64 100644
--- a/tests/unit/lib/key-generators/git-tag-commit-nodetest.js
+++ b/tests/unit/lib/data-generators/git-tag-commit-nodetest.js
@@ -3,12 +3,12 @@
var assert = require('ember-cli/tests/helpers/assert');
var gitRepoInfo = require('git-repo-info');
-describe('the git-tag-commit key generator', function() {
- var KeyGenerator;
+describe('the git-tag-commit data generator', function() {
+ var DataGenerator;
var cwd;
before(function() {
- KeyGenerator = require('../../../../lib/key-generators/git-tag-commit');
+ DataGenerator = require('../../../../lib/data-generators/git-tag-commit');
gitRepoInfo._changeGitDir('dotgit');
});
@@ -24,18 +24,29 @@ describe('the git-tag-commit key generator', function() {
it('concatenates the git tag and the git commit hash', function() {
process.chdir('tests/fixtures/repo');
- var subject = new KeyGenerator();
+ var subject = new DataGenerator();
return assert.isFulfilled(subject.generate())
- .then(function(revision) {
- assert.equal(revision, '2.3.4+41d41f08');
+ .then(function(data) {
+ assert.equal(data.revisionKey, '2.3.4+41d41f08');
+ });
+ });
+
+ it('returns a timestamp', function() {
+ process.chdir('tests/fixtures/repo');
+
+ var subject = new DataGenerator();
+
+ return assert.isFulfilled(subject.generate())
+ .then(function(data) {
+ assert.isNotNull(data.timestamp);
});
});
it('rejects if no repository found', function() {
process.chdir('tests/fixtures/not-a-repo');
- var subject = new KeyGenerator();
+ var subject = new DataGenerator();
return assert.isRejected(subject.generate())
.then(function(error) {
@@ -46,7 +57,7 @@ describe('the git-tag-commit key generator', function() {
it('rejects if no git tag found', function() {
process.chdir('tests/fixtures/tagless-repo');
- var subject = new KeyGenerator();
+ var subject = new DataGenerator();
return assert.isRejected(subject.generate())
.then(function(error) {
diff --git a/tests/unit/lib/key-generators/version-commit-nodetest.js b/tests/unit/lib/data-generators/version-commit-nodetest.js
similarity index 67%
rename from tests/unit/lib/key-generators/version-commit-nodetest.js
rename to tests/unit/lib/data-generators/version-commit-nodetest.js
index 296f118..83e76d9 100644
--- a/tests/unit/lib/key-generators/version-commit-nodetest.js
+++ b/tests/unit/lib/data-generators/version-commit-nodetest.js
@@ -3,12 +3,12 @@
var assert = require('ember-cli/tests/helpers/assert');
var gitRepoInfo = require('git-repo-info');
-describe('the version-commit key generator', function() {
- var KeyGenerator;
+describe('the version-commit data generator', function() {
+ var DataGenerator;
var cwd;
before(function() {
- KeyGenerator = require('../../../../lib/key-generators/version-commit');
+ DataGenerator = require('../../../../lib/data-generators/version-commit');
gitRepoInfo._changeGitDir('dotgit');
});
@@ -31,53 +31,73 @@ describe('the version-commit key generator', function() {
readConfig: function(key) { return this.stubConfig[key]; }
};
- var subject = new KeyGenerator({
+ var subject = new DataGenerator({
plugin: plugin
});
return assert.isFulfilled(subject.generate())
- .then(function(revision) {
- assert.equal(revision, '3.2.1+41d41f08');
+ .then(function(data) {
+ assert.equal(data.revisionKey, '3.2.1+41d41f08');
});
});
- it('rejects if no repository found', function() {
- process.chdir('tests/fixtures/not-a-repo');
+ it('has version source file option', function() {
+ process.chdir('tests/fixtures/repo');
var plugin = {
stubConfig: {
- versionFile: 'package.json'
+ versionFile: 'version.json'
},
readConfig: function(key) { return this.stubConfig[key]; }
};
- var subject = new KeyGenerator({
+ var subject = new DataGenerator({
plugin: plugin
});
- return assert.isRejected(subject.generate())
- .then(function(error) {
- assert.equal(error, 'Could not find git repository');
+ return assert.isFulfilled(subject.generate())
+ .then(function(data) {
+ assert.equal(data.revisionKey, '1.2.3+41d41f08');
});
});
- it('has version source file option', function() {
+ it('returns a timestamp', function() {
process.chdir('tests/fixtures/repo');
var plugin = {
stubConfig: {
- versionFile: 'version.json'
+ versionFile: 'package.json'
},
readConfig: function(key) { return this.stubConfig[key]; }
};
- var subject = new KeyGenerator({
+ var subject = new DataGenerator({
plugin: plugin
});
return assert.isFulfilled(subject.generate())
- .then(function(revision) {
- assert.equal(revision, '1.2.3+41d41f08');
+ .then(function(data) {
+ assert.isNotNull(data.timestamp);
+ });
+ });
+
+ it('rejects if no repository found', function() {
+ process.chdir('tests/fixtures/not-a-repo');
+
+ var plugin = {
+ stubConfig: {
+ versionFile: 'package.json'
+ },
+ readConfig: function(key) { return this.stubConfig[key]; }
+ };
+
+ var subject = new DataGenerator({
+ plugin: plugin
+ });
+
+ return assert.isRejected(subject.generate())
+ .then(function(error) {
+ assert.equal(error, 'Could not find git repository');
});
});
@@ -91,7 +111,7 @@ describe('the version-commit key generator', function() {
readConfig: function(key) { return this.stubConfig[key]; }
};
- var subject = new KeyGenerator({
+ var subject = new DataGenerator({
plugin: plugin
});