Skip to content

Commit 915ffc7

Browse files
committed
Renamed KeyGenerators to DataGenerators
1 parent ecc820c commit 915ffc7

File tree

10 files changed

+68
-43
lines changed

10 files changed

+68
-43
lines changed

README.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# ember-cli-deploy-revision-data
22

3-
> An ember-cli-deploy plugin to generate a unique revision key based on the current build
3+
> An ember-cli-deploy plugin to generate data about this deploy revision including a unique revision key based on the current build
44
55
<hr/>
66
**WARNING: This plugin is only compatible with ember-cli-deploy versions >= 0.5.0**
77
<hr/>
88

9-
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.
9+
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.
10+
The revision key included in the revison data can be used to uniquely identify the particular version of the application.
1011

1112
## What is an ember-cli-deploy plugin?
1213

@@ -51,18 +52,28 @@ For detailed information on how configuration of plugins works, please refer to
5152

5253
### type
5354

54-
The type of [Key Generator](#key-generators) to be used.
55+
The type of [Data Generator](#data-generators) to be used.
5556

5657
*Default:* `'file-hash'`
5758
*Alternatives:* `'git-tag-commit'`, `'version-commit'`
5859

59-
## Key Generators
60+
## Data Generators
6061

61-
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.
62+
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.
6263

6364
### File Hash generator
6465

65-
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.
66+
This generator contructs a revisionKey from the fingerprint of the `index.html` file.
67+
68+
#### Data fields returned
69+
70+
##### revisionKey
71+
72+
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.
73+
74+
##### timestamp
75+
76+
The timestamp of the current deploy
6677

6778
#### Configuration Options
6879

@@ -86,19 +97,41 @@ The list of built project files. This option should be relative to `distDir` and
8697

8798
### Git Tag Commit generator
8899

89-
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.
100+
Constructs a revision key based on the most recent git tag and the currently checked-out commit.
101+
102+
#### Data fields returned
103+
104+
##### revisionKey
105+
106+
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.
90107

91108
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`.
92109

110+
##### timestamp
111+
112+
The timestamp of the current deploy
113+
93114
### Version Commit generator
94115

95-
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.
116+
Similar to the Git Tag Commit generator but uses the `package.json` version string to construct the revision key instead of the git tag.
117+
118+
#### Data fields returned
119+
120+
##### revisionKey
121+
122+
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.
123+
124+
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`.
125+
126+
##### timestamp
127+
128+
The timestamp of the current deploy
96129

97130
#### Configuration Options
98131

99132
##### versionFile
100133

101-
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.
134+
The file containing your project's version number. Must be a JSON file with a top-level `version` key.
102135

103136
*Default:* `package.json`
104137

@@ -119,4 +152,4 @@ The following properties are expected to be present on the deployment `context`
119152

120153
[1]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"
121154
[2]: https://github.com/zapnito/ember-cli-deploy-build "ember-cli-deploy-build"
122-
[3]: https://github.com/ember-cli/ember-cli-deploy "ember-cli-deploy"
155+
[3]: https://github.com/ember-cli/ember-cli-deploy "ember-cli-deploy"

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ module.exports = {
2525
didBuild: function(context) {
2626
var self = this;
2727
var type = this.readConfig('type');
28-
var KeyGenerator = require('./lib/key-generators')[type];
29-
var keyGenerator = new KeyGenerator({
28+
var DataGenerator = require('./lib/data-generators')[type];
29+
var dataGenerator = new DataGenerator({
3030
plugin: this
3131
});
3232

33-
this.log('creating revision key using `' + type + '`');
34-
return keyGenerator.generate()
33+
this.log('creating revision data using `' + type + '`');
34+
return dataGenerator.generate()
3535
.then(function(revisionKey) {
36-
self.log('generated revision key: `' + revisionKey + '`');
36+
self.log('generated revision ata for revision: `' + revisionKey + '`');
3737
return revisionKey;
3838
})
3939
.then(function(revisionKey) {

lib/key-generators/file-hash.js renamed to lib/data-generators/file-hash.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ module.exports = CoreObject.extend({
3131
.then(function(contents) {
3232
return md5Hash(contents.toString());
3333
})
34-
},
35-
36-
_resolveConfigValue: function(key, config, context) {
37-
if(typeof config[key] === 'function') {
38-
return config[key](context);
39-
}
40-
41-
return config[key];
4234
}
4335
});
4436

File renamed without changes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ember-cli-deploy-revision-data",
33
"version": "0.1.0-beta.2",
4-
"description": "An ember-cli-plugin to create a unique revision key for the build",
4+
"description": "An ember-cli-deploy plugin to generate data about this deploy revision including a unique revision key based on the current build",
55
"directories": {
66
"doc": "doc",
77
"test": "tests"

tests/unit/lib/key-generators/file-hash-nodetest.js renamed to tests/unit/lib/data-generators/file-hash-nodetest.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
var assert = require('ember-cli/tests/helpers/assert');
44

5-
describe('the file-hash key generator', function() {
6-
var KeyGenerator;
5+
describe('the file-hash data generator', function() {
6+
var DataGenerator;
77

88
before(function() {
9-
KeyGenerator = require('../../../../lib/key-generators/file-hash');
9+
DataGenerator = require('../../../../lib/data-generators/file-hash');
1010
});
1111

1212
describe('#generate', function() {
@@ -20,7 +20,7 @@ describe('the file-hash key generator', function() {
2020
readConfig: function(key) { return this.stubConfig[key]; }
2121
};
2222

23-
var subject = new KeyGenerator({
23+
var subject = new DataGenerator({
2424
plugin: plugin
2525
});
2626

@@ -40,7 +40,7 @@ describe('the file-hash key generator', function() {
4040
readConfig: function(key) { return this.stubConfig[key]; }
4141
};
4242

43-
var subject = new KeyGenerator({
43+
var subject = new DataGenerator({
4444
plugin: plugin
4545
});
4646

@@ -60,7 +60,7 @@ describe('the file-hash key generator', function() {
6060
readConfig: function(key) { return this.stubConfig[key]; }
6161
};
6262

63-
var subject = new KeyGenerator({
63+
var subject = new DataGenerator({
6464
plugin: plugin
6565
});
6666

tests/unit/lib/key-generators/git-tag-commit-nodetest.js renamed to tests/unit/lib/data-generators/git-tag-commit-nodetest.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
var assert = require('ember-cli/tests/helpers/assert');
44
var gitRepoInfo = require('git-repo-info');
55

6-
describe('the git-tag-commit key generator', function() {
7-
var KeyGenerator;
6+
describe('the git-tag-commit data generator', function() {
7+
var DataGenerator;
88
var cwd;
99

1010
before(function() {
11-
KeyGenerator = require('../../../../lib/key-generators/git-tag-commit');
11+
DataGenerator = require('../../../../lib/data-generators/git-tag-commit');
1212
gitRepoInfo._changeGitDir('dotgit');
1313
});
1414

@@ -24,7 +24,7 @@ describe('the git-tag-commit key generator', function() {
2424
it('concatenates the git tag and the git commit hash', function() {
2525
process.chdir('tests/fixtures/repo');
2626

27-
var subject = new KeyGenerator();
27+
var subject = new DataGenerator();
2828

2929
return assert.isFulfilled(subject.generate())
3030
.then(function(revision) {
@@ -35,7 +35,7 @@ describe('the git-tag-commit key generator', function() {
3535
it('rejects if no repository found', function() {
3636
process.chdir('tests/fixtures/not-a-repo');
3737

38-
var subject = new KeyGenerator();
38+
var subject = new DataGenerator();
3939

4040
return assert.isRejected(subject.generate())
4141
.then(function(error) {
@@ -46,7 +46,7 @@ describe('the git-tag-commit key generator', function() {
4646
it('rejects if no git tag found', function() {
4747
process.chdir('tests/fixtures/tagless-repo');
4848

49-
var subject = new KeyGenerator();
49+
var subject = new DataGenerator();
5050

5151
return assert.isRejected(subject.generate())
5252
.then(function(error) {

tests/unit/lib/key-generators/version-commit-nodetest.js renamed to tests/unit/lib/data-generators/version-commit-nodetest.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
var assert = require('ember-cli/tests/helpers/assert');
44
var gitRepoInfo = require('git-repo-info');
55

6-
describe('the version-commit key generator', function() {
7-
var KeyGenerator;
6+
describe('the version-commit data generator', function() {
7+
var DataGenerator;
88
var cwd;
99

1010
before(function() {
11-
KeyGenerator = require('../../../../lib/key-generators/version-commit');
11+
DataGenerator = require('../../../../lib/data-generators/version-commit');
1212
gitRepoInfo._changeGitDir('dotgit');
1313
});
1414

@@ -31,7 +31,7 @@ describe('the version-commit key generator', function() {
3131
readConfig: function(key) { return this.stubConfig[key]; }
3232
};
3333

34-
var subject = new KeyGenerator({
34+
var subject = new DataGenerator({
3535
plugin: plugin
3636
});
3737

@@ -51,7 +51,7 @@ describe('the version-commit key generator', function() {
5151
readConfig: function(key) { return this.stubConfig[key]; }
5252
};
5353

54-
var subject = new KeyGenerator({
54+
var subject = new DataGenerator({
5555
plugin: plugin
5656
});
5757

@@ -71,7 +71,7 @@ describe('the version-commit key generator', function() {
7171
readConfig: function(key) { return this.stubConfig[key]; }
7272
};
7373

74-
var subject = new KeyGenerator({
74+
var subject = new DataGenerator({
7575
plugin: plugin
7676
});
7777

@@ -91,7 +91,7 @@ describe('the version-commit key generator', function() {
9191
readConfig: function(key) { return this.stubConfig[key]; }
9292
};
9393

94-
var subject = new KeyGenerator({
94+
var subject = new DataGenerator({
9595
plugin: plugin
9696
});
9797

0 commit comments

Comments
 (0)