forked from serverless/serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectCreate.js
More file actions
88 lines (77 loc) · 2.53 KB
/
ProjectCreate.js
File metadata and controls
88 lines (77 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'use strict';
/**
* Action: ProjectCreate
* - Takes new project data from user and sets a new default "dev" stage
* - Validates the received data
* - Generates scaffolding for the new project in CWD
* - Creates a CF template
* - Creates CF stack by default, unless noExeCf option is set to true
* - Generates project JSON files
*
* Options:
* - name (String) a name for new project
* - profile (String) an AWS profile to create the project in. Must be available in ~/.aws/credentials
* - region (String) the first region for your new project
* - noExeCf: (Boolean) Don't execute CloudFormation
*/
let SUtils;
module.exports = function(S) {
const SUtils = S.utils,
BbPromise = require('bluebird');
class ProjectCreate extends S.classes.Plugin {
static getName() {
return 'serverless.core.' + this.name;
}
registerActions() {
S.addAction(this.createProject.bind(this), {
handler: 'projectCreate',
description: 'Creates scaffolding for a new Serverless project',
context: 'project',
contextAction: 'create',
options: [
{
option: 'name',
shortcut: 'n',
description: 'A new name for this Serverless project'
}, {
option: 'stage',
shortcut: 's',
description: 'Initial project stage'
}, {
option: 'region',
shortcut: 'r',
description: 'Initial Lambda supported AWS region'
}, {
option: 'notificationEmail',
shortcut: 'e',
description: 'email to use for AWS alarms'
}, {
option: 'profile',
shortcut: 'p',
description: 'AWS profile that is set in your aws config file'
}, {
option: 'noExeCf',
shortcut: 'c',
description: 'Optional - Don\'t execute CloudFormation, just generate it. Default: false'
}
]
});
return BbPromise.resolve();
}
/**
* Action
*/
createProject(evt) {
return S.actions.projectInit({
options: {
name: evt.options.name,
stage: evt.options.stage,
region: evt.options.region,
profile: evt.options.profile,
noExeCf: evt.options.noExeCf ? true : false
}
});
}
}
return( ProjectCreate );
};