Skip to content

Commit 67ab245

Browse files
committed
Merge pull request #16 from achambers/construct-revision-data
Return revision metadata instead of just revisionKey
2 parents 4cd269e + f53a982 commit 67ab245

16 files changed

+194
-116
lines changed

CHANGELOG.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ Thank you to all who took the time to contribute!
1313

1414
#### Community Contributions
1515

16-
- [#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)
17-
- [#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)
18-
- [#4](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/4) Remove dependency on index path [@achambers](https://github.com/achambers)
19-
- [#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)
20-
- [#6](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/6) Rename index-hash to file-hash [@lukemelia](https://github.com/lukemelia)
21-
- [#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)
22-
- [#8](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/8) Renamed project and all references to `tags` [@achambers](https://github.com/achambers)
23-
- [#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)
24-
- [#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)
25-
- [#12](https://github.com/zapnito/ember-cli-deploy-revision-key/pull/12) Update README for v0.5.0 [@achambers](https://github.com/achambers)
16+
- [#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)
17+
- [#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)
18+
- [#4](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/4) Remove dependency on index path [@achambers](https://github.com/achambers)
19+
- [#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)
20+
- [#6](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/6) Rename index-hash to file-hash [@lukemelia](https://github.com/lukemelia)
21+
- [#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)
22+
- [#8](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/8) Renamed project and all references to `tags` [@achambers](https://github.com/achambers)
23+
- [#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)
24+
- [#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)
25+
- [#12](https://github.com/zapnito/ember-cli-deploy-revision-data/pull/12) Update README for v0.5.0 [@achambers](https://github.com/achambers)
2626

2727
Thank you to all who took the time to contribute!

README.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
# ember-cli-deploy-revision-key
1+
# 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

@@ -22,7 +23,7 @@ To get up and running quickly, do the following:
2223
- Install this plugin
2324

2425
```bash
25-
$ ember install ember-cli-deploy-revision-key
26+
$ ember install ember-cli-deploy-revision-data
2627
```
2728

2829
- Run the pipeline
@@ -35,34 +36,44 @@ $ ember deploy
3536
Run the following command in your terminal:
3637

3738
```bash
38-
ember install ember-cli-deploy-revision-key
39+
ember install ember-cli-deploy-revision-data
3940
```
4041

4142
## ember-cli-deploy Hooks Implemented
4243

4344
For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][1].
4445

4546
- `configure`
46-
- `didBuild`
47+
- `prepare`
4748

4849
## Configuration Options
4950

5051
For detailed information on how configuration of plugins works, please refer to the [Plugin Documentation][1].
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

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The following steps should navigate you through the release process to ensure as
1616
8. `git push upstream master`
1717
9. `git tag "vx.y.z"`
1818
10. `git push upstream vx.y.z`
19-
11. `npm publish ./ember-cli-deploy-revision-key-<version>.tgz`
19+
11. `npm publish ./ember-cli-deploy-revision-data-<version>.tgz`
2020

2121
### Create a github release
2222

bin/changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var compareCommits = Promise.denodeify(github.repos.compareCommits);
2121
var currentVersion = 'v' + require('../package').version;
2222

2323
var user = 'zapnito';
24-
var repo = 'ember-cli-deploy-revision-key';
24+
var repo = 'ember-cli-deploy-revision-data';
2525

2626
compareCommits({
2727
user: user,

bin/prepare-release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
rm -rf node_modules && \
4-
rm -rf ./ember-cli-deploy-revision-key*.tgz && \
4+
rm -rf ./ember-cli-deploy-revision-data*.tgz && \
55
npm cache clear && \
66
npm i --no-optional && \
77
npm link --no-optional && \

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "ember-cli-deploy-revision-key",
2+
"name": "ember-cli-deploy-revision-data",
33
"dependencies": {
44
"ember": "1.11.1",
55
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",

index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Promise = require('ember-cli/lib/ext/promise');
66
var DeployPluginBase = require('ember-cli-deploy-plugin');
77

88
module.exports = {
9-
name: 'ember-cli-deploy-revision-key',
9+
name: 'ember-cli-deploy-revision-data',
1010

1111
createDeployPlugin: function(options) {
1212
var DeployPlugin = DeployPluginBase.extend({
@@ -22,22 +22,22 @@ module.exports = {
2222
},
2323
versionFile: 'package.json',
2424
},
25-
didBuild: function(context) {
25+
prepare: 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()
35-
.then(function(revisionKey) {
36-
self.log('generated revision key: `' + revisionKey + '`');
37-
return revisionKey;
33+
this.log('creating revision data using `' + type + '`');
34+
return dataGenerator.generate()
35+
.then(function(data) {
36+
self.log('generated revision data for revision: `' + data.revisionKey + '`');
37+
return data;
3838
})
39-
.then(function(revisionKey) {
40-
return { revisionKey: revisionKey };
39+
.then(function(data) {
40+
return { revisionData: data };
4141
})
4242
.catch(this._errorMessage.bind(this));
4343
},

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,11 @@ module.exports = CoreObject.extend({
2929

3030
return readFile(filePath)
3131
.then(function(contents) {
32-
return md5Hash(contents.toString());
32+
return {
33+
revisionKey: md5Hash(contents.toString()),
34+
timestamp: new Date().toISOString()
35+
};
3336
})
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];
4237
}
4338
});
4439

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ module.exports = CoreObject.extend({
1818
return Promise.reject('Could not build revision with tag `' + tag + '` and commit hash `' + sha + '`');
1919
}
2020

21-
return Promise.resolve(info.tag + '+' + sha);
21+
return Promise.resolve({
22+
revisionKey: info.tag + '+' + sha,
23+
timestamp: new Date().toISOString()
24+
});
2225
}
2326
});
File renamed without changes.

0 commit comments

Comments
 (0)