Skip to content

Commit 05441d0

Browse files
author
Frank Schmid
committed
Fixes #17 Show master alias information on "serverless info" command
1 parent 8313087 commit 05441d0

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

lib/listAliases.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ module.exports = {
7171
console.log(chalk.yellow('aliases:'));
7272

7373
return BbPromise.join(
74-
BbPromise.bind(this).then(this.aliasStackLoadAliasTemplates),
74+
BbPromise.bind(this).then(() => {
75+
return this.aliasStackGetAliasStackNames()
76+
.mapSeries(stack => this.aliasStackLoadTemplate(stack));
77+
}),
7578
this.listGetApiId(this._provider.naming.getStackName())
7679
)
7780
.spread((aliasStackTemplates, apiId) => {

lib/stackInformation.js

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,50 @@ module.exports = {
3636

3737
},
3838

39-
/**
40-
* Load all deployed alias stack templates excluding the current alias.
41-
*/
42-
aliasStackLoadAliasTemplates() {
39+
aliasStackGetAliasStackNames() {
4340

4441
const params = {
4542
ExportName: `${this._provider.naming.getStackName()}-ServerlessAliasReference`
4643
};
4744

48-
return this._provider.request('CloudFormation', // eslint-disable-line lodash/prefer-lodash-method
45+
return this._provider.request('CloudFormation',
4946
'listImports',
5047
params,
5148
this._options.stage,
5249
this._options.region)
53-
.then(cfData => BbPromise.resolve(cfData.Imports))
54-
.filter(stack => stack !== `${this._provider.naming.getStackName()}-${this._alias}`)
55-
.mapSeries(stack => {
50+
.then(cfData => BbPromise.resolve(cfData.Imports));
5651

57-
const importParams = {
58-
StackName: stack,
59-
TemplateStage: 'Original' // We need the original references to look up the version resources.
60-
};
52+
},
6153

62-
return this._provider.request('CloudFormation',
63-
'getTemplate',
64-
importParams,
65-
this._options.stage,
66-
this._options.region)
67-
.then(cfData => {
68-
return BbPromise.resolve(JSON.parse(cfData.TemplateBody));
69-
})
70-
.catch(err => {
71-
return BbPromise.reject(new Error(`Unable to retrieve current stack information: ${err.statusCode}`));
72-
});
54+
aliasStackLoadTemplate(stackName, processed) {
55+
56+
const params = {
57+
StackName: stackName,
58+
TemplateStage: processed ? 'Processed' : 'Original'
59+
};
60+
61+
return this._provider.request('CloudFormation',
62+
'getTemplate',
63+
params,
64+
this._options.stage,
65+
this._options.region)
66+
.then(cfData => {
67+
return BbPromise.resolve(JSON.parse(cfData.TemplateBody));
7368
})
69+
.catch(err => {
70+
return BbPromise.reject(new Error(`Unable to retrieve template for ${stackName}: ${err.statusCode}`));
71+
});
72+
73+
},
74+
75+
/**
76+
* Load all deployed alias stack templates excluding the current alias.
77+
*/
78+
aliasStackLoadAliasTemplates() {
79+
80+
return this.aliasStackGetAliasStackNames() // eslint-disable-line lodash/prefer-lodash-method
81+
.filter(stack => stack !== `${this._provider.naming.getStackName()}-${this._alias}`)
82+
.mapSeries(stack => this.aliasStackLoadTemplate(stack))
7483
.catch(err => {
7584
if (err.statusCode === 400) {
7685
// The export is not yet there. Can happen on the very first alias stack deployment.

0 commit comments

Comments
 (0)