Skip to content

Commit 38dd1e4

Browse files
committed
Merge pull request #27 from achambers/use-revision-data-object
Reference revisionKey from new revisionData object
2 parents aa1e493 + 7d1df83 commit 38dd1e4

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ The prefix to be used for the Redis key under which file will be uploaded to Red
113113

114114
### revisionKey
115115

116-
The unique revision number for the version of the file being uploaded to Redis. The Redis key will be a combination of the `keyPrefix` and the `revisionKey`. By default this option will use either the `revisionKey` passed in from the command line or the `revisionKey` property from the deployment context.
116+
The unique revision number for the version of the file being uploaded to Redis. The Redis key will be a combination of the `keyPrefix` and the `revisionKey`. By default this option will use either the `revisionKey` passed in from the command line or the `revisionData.revisionKey` property from the deployment context.
117117

118-
*Default:* `context.commandLineArgs.revisionKey || context.revisionKey`
118+
*Default:* `context.commandLineArgs.revisionKey || context.revisionData.revisionKey`
119119

120120
### allowOverwrite
121121

@@ -131,15 +131,15 @@ The Redis client to be used to upload files to the Redis store. By default this
131131

132132
### didDeployMessage
133133

134-
A message that will be displayed after the file has been successfully uploaded to Redis. By default this message will only display if the revision for `revisionKey` of the deployment context has been activated.
134+
A message that will be displayed after the file has been successfully uploaded to Redis. By default this message will only display if the revision for `revisionData.revisionKey` of the deployment context has been activated.
135135

136136
*Default:*
137137

138138
```javascript
139-
if (context.revisionKey && !context.activatedRevisionKey) {
140-
return "Deployed but did not activate revision " + context.revisionKey + ". "
139+
if (context.revisionData.revisionKey && !context.revisionData.activatedRevisionKey) {
140+
return "Deployed but did not activate revision " + context.revisionData.revisionKey + ". "
141141
+ "To activate, run: "
142-
+ "ember deploy:activate " + context.revisionKey + " --environment=" + context.deployEnvironment + "\n";
142+
+ "ember deploy:activate " + context.revisionData.revisionKey + " --environment=" + context.deployEnvironment + "\n";
143143
}
144144
```
145145

@@ -213,7 +213,7 @@ The following properties are expected to be present on the deployment `context`
213213

214214
- `distDir` (provided by [ember-cli-deploy-build][4])
215215
- `project.name()` (provided by [ember-cli-deploy][5])
216-
- `revisionKey` (provided by [ember-cli-deploy-revision-key][6])
216+
- `revisionData.revisionKey` (provided by [ember-cli-deploy-revision-data][6])
217217
- `commandLineArgs.revisionKey` (provided by [ember-cli-deploy][5])
218218
- `deployEnvironment` (provided by [ember-cli-deploy][5])
219219

@@ -226,4 +226,4 @@ The following properties are expected to be present on the deployment `context`
226226
[3]: https://www.npmjs.com/package/redis "Redis Client"
227227
[4]: https://github.com/zapnito/ember-cli-deploy-build "ember-cli-deploy-build"
228228
[5]: https://github.com/ember-cli/ember-cli-deploy "ember-cli-deploy"
229-
[6]: https://github.com/zapnito/ember-cli-deploy-revision-key "ember-cli-deploy-revision-key"
229+
[6]: https://github.com/zapnito/ember-cli-deploy-revision-data "ember-cli-deploy-revision-data"

index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ module.exports = {
2929
return context.project.name() + ':index';
3030
},
3131
didDeployMessage: function(context){
32-
if (context.revisionKey && !context.activatedRevisionKey) {
33-
return "Deployed but did not activate revision " + context.revisionKey + ". "
32+
var revisionKey = context.revisionData && context.revisionData.revisionKey;
33+
var activatedRevisionKey = context.revisionData && context.revisionData.activatedRevisionKey;
34+
if (revisionKey && !activatedRevisionKey) {
35+
return "Deployed but did not activate revision " + revisionKey + ". "
3436
+ "To activate, run: "
35-
+ "ember deploy:activate " + context.deployTarget + " --revision=" + context.revisionKey + "\n";
37+
+ "ember deploy:activate " + context.deployTarget + " --revision=" + revisionKey + "\n";
3638
}
3739
},
3840
revisionKey: function(context) {
39-
return context.commandOptions.revision || context.revisionKey;
41+
return context.commandOptions.revision || (context.revisionData && context.revisionData.revisionKey);
4042
},
4143
redisDeployClient: function(context) {
4244
var redisOptions = this.pluginConfig;
@@ -76,15 +78,17 @@ module.exports = {
7678

7779
activate: function(/* context */) {
7880
var redisDeployClient = this.readConfig('redisDeployClient');
79-
var revisionKey = this.readConfig('revisionKey');
80-
var keyPrefix = this.readConfig('keyPrefix');
81+
var revisionKey = this.readConfig('revisionKey');
82+
var keyPrefix = this.readConfig('keyPrefix');
8183

8284
this.log('Activating revision `' + revisionKey + '`');
8385
return Promise.resolve(redisDeployClient.activate(keyPrefix, revisionKey))
8486
.then(this.log.bind(this, '✔ Activated revision `' + revisionKey + '`', {}))
8587
.then(function(){
8688
return {
87-
activatedRevisionKey: revisionKey
89+
revisionData: {
90+
activatedRevisionKey: revisionKey
91+
}
8892
};
8993
})
9094
.catch(this._errorMessage.bind(this));

tests/unit/index-nodetest.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ describe('redis plugin', function() {
109109
config: {
110110
redis: config
111111
},
112-
revisionKey: 'something-else'
112+
revisionData: {
113+
revisionKey: 'something-else'
114+
}
113115
};
114116

115117
plugin.beforeHook(context);
@@ -135,7 +137,9 @@ describe('redis plugin', function() {
135137
commandOptions: {
136138
revision: 'abcd'
137139
},
138-
revisionKey: 'something-else'
140+
revisionData: {
141+
revisionKey: 'something-else'
142+
}
139143
};
140144

141145
plugin.beforeHook(context);
@@ -160,7 +164,9 @@ describe('redis plugin', function() {
160164
redis: config
161165
},
162166
commandOptions: { },
163-
revisionKey: 'something-else'
167+
revisionData: {
168+
revisionKey: 'something-else'
169+
}
164170
};
165171

166172
plugin.beforeHook(context);
@@ -380,7 +386,7 @@ describe('redis plugin', function() {
380386
return assert.isFulfilled(plugin.activate(context))
381387
.then(function(result) {
382388
assert.ok(activateCalled);
383-
assert.equal(result.activatedRevisionKey, '123abc');
389+
assert.equal(result.revisionData.activatedRevisionKey, '123abc');
384390
});
385391
});
386392

@@ -438,12 +444,11 @@ describe('redis plugin', function() {
438444
},
439445
project: stubProject,
440446
config: {
441-
redis: {
442-
revisionKey: '123abc',
443-
activatedRevisionKey: null
444-
}
447+
redis: { }
445448
},
446-
revisionKey: '123abc',
449+
revisionData: {
450+
revisionKey: '123abc',
451+
}
447452
};
448453
plugin.beforeHook(context);
449454
plugin.configure(context);

0 commit comments

Comments
 (0)