-
Notifications
You must be signed in to change notification settings - Fork 5.7k
/
no-service.js
291 lines (267 loc) · 7.41 KB
/
no-service.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
'use strict';
const globalOptions = require('./common-options/global');
const serviceOptions = require('./common-options/service');
const awsServiceOptions = require('./common-options/aws-service');
const commands = (module.exports = new Map());
commands.set('', {
usage: 'Interactive Quickstart',
serviceDependencyMode: 'optional',
hasAwsExtension: true,
options: {
'help-interactive': { usage: 'Show this message', type: 'boolean' },
'template-path': {
usage: 'Template local path for the service.',
},
},
lifecycleEvents: ['initializeService', 'setupAws', 'autoUpdate', 'tabCompletion', 'end'],
});
commands.set('config', {
usage: 'Configure Serverless',
options: {
autoupdate: {
usage: 'Turn on auto update mechanism (turn off via "--no-autoupdate")',
type: 'boolean',
},
},
lifecycleEvents: ['config'],
});
commands.set('config credentials', {
usage: 'Configures a new provider profile for the Serverless Framework',
hasAwsExtension: true,
options: {
provider: {
usage: 'Name of the provider. Supported providers: aws',
required: true,
shortcut: 'p',
},
key: {
usage: 'Access key for the provider',
shortcut: 'k',
required: true,
},
secret: {
usage: 'Secret key for the provider',
shortcut: 's',
required: true,
},
profile: {
usage: 'Name of the profile you wish to create. Defaults to "default"',
shortcut: 'n',
},
overwrite: {
usage: 'Overwrite the existing profile configuration in the credentials file',
shortcut: 'o',
type: 'boolean',
},
},
lifecycleEvents: ['config'],
});
(() => {
const isHidden = process.platform === 'win32';
const noSupportNotice = '<tab> completion is not supported on Windows';
commands.set('config tabcompletion install', {
usage: 'Install a <tab> completion for chosen shell',
isHidden,
noSupportNotice,
options: {
shell: {
usage:
'Shell for which <tab> completion should be installed. ' +
'Supported options: bash (default), zsh, fish ',
shortcut: 's',
},
location: {
usage: 'Custom location for shell config',
shortcut: 'l',
},
},
lifecycleEvents: ['install'],
});
commands.set('config tabcompletion uninstall', {
usage: 'Uninstall a <tab> completion',
isHidden,
noSupportNotice,
lifecycleEvents: ['uninstall'],
});
})();
commands.set('create', {
usage: 'Create new Serverless service',
options: {
'template': {
usage:
'Template for the service. Available templates: ' +
`${require('../../templates/recommended-list/human-readable')}`,
shortcut: 't',
},
'template-url': {
usage: 'Template URL for the service. Supports: GitHub, BitBucket',
shortcut: 'u',
},
'template-path': {
usage: 'Template local path for the service.',
},
'path': {
usage: 'The path where the service should be created (e.g. --path my-service)',
shortcut: 'p',
},
'name': {
usage: 'Name for the service. Overwrites the default name of the created service.',
shortcut: 'n',
},
},
lifecycleEvents: ['create'],
});
commands.set('dashboard', {
usage: 'Open the Serverless dashboard',
lifecycleEvents: ['dashboard'],
});
commands.set('generate-event', {
usage: 'Generate event',
lifecycleEvents: ['generate-event'],
options: {
type: {
usage:
'Specify event type. "aws:apiGateway", "aws:sns", "aws:sqs", "aws:dynamo", ' +
'"aws:kinesis", "aws:cloudWatchLog", "aws:s3", "aws:alexaSmartHome", "aws:alexaSkill", ' +
'"aws:cloudWatch", "aws:iot", "aws:cognitoUserPool","aws:websocket" are supported.',
shortcut: 't',
required: true,
},
body: {
usage: 'Specify the body for the message, request, or stream event.',
shortcut: 'b',
},
},
});
commands.set('help', {
// Shows general "help", so has no specific usage info
serviceDependencyMode: 'optional',
});
commands.set('install', {
usage: 'Install a Serverless service from GitHub or a plugin from the Serverless registry',
options: {
url: {
usage: 'URL of the Serverless service on GitHub',
required: true,
shortcut: 'u',
},
name: {
usage: 'Name for the service',
shortcut: 'n',
},
},
lifecycleEvents: ['install'],
});
commands.set('login', {
usage: 'Login or sign up for Serverless',
lifecycleEvents: ['login'],
});
commands.set('logout', {
usage: 'Logout from Serverless',
lifecycleEvents: ['logout'],
});
commands.set('output get', {
usage: 'Get value of dashboard deployment profile parameter',
serviceDependencyMode: 'optional',
hasAwsExtension: true,
options: {
name: { usage: 'Ouptut name', required: true },
service: { usage: 'Dashboard service' },
},
lifecycleEvents: ['get'],
});
commands.set('output list', {
usage: 'List all dashboard deployment profile parameters',
serviceDependencyMode: 'optional',
hasAwsExtension: true,
options: {
service: { usage: 'Dashboard service' },
},
lifecycleEvents: ['list'],
});
commands.set('param get', {
usage: 'Get value of dashboard service output',
serviceDependencyMode: 'optional',
hasAwsExtension: true,
options: {
name: { usage: 'Ouptut name', required: true },
},
lifecycleEvents: ['get'],
});
commands.set('param list', {
usage: 'List all dashboard deployment profile parameters',
serviceDependencyMode: 'optional',
hasAwsExtension: true,
lifecycleEvents: ['list'],
});
commands.set('plugin list', {
usage: 'Lists all available plugins',
lifecycleEvents: ['list'],
});
commands.set('plugin search', {
usage: 'Search for plugins',
options: {
query: {
usage: 'Search query',
required: true,
shortcut: 'q',
},
},
lifecycleEvents: ['search'],
});
commands.set('slstats', {
usage: 'Enable or disable stats',
options: {
enable: {
usage: 'Enable stats ("--enable")',
shortcut: 'e',
type: 'boolean',
},
disable: {
usage: 'Disable stats ("--disable")',
shortcut: 'd',
type: 'boolean',
},
},
lifecycleEvents: ['slstats'],
});
(() => {
const isHidden = !require('../../utils/isStandaloneExecutable') || process.platform === 'win32';
const noSupportNotice =
"It's applicable only in context of a standalone executable instance " +
'in non Windows environment.';
commands.set('upgrade', {
usage: 'Upgrade Serverless',
isHidden,
noSupportNotice,
options: {
major: {
usage: 'Enable upgrade to a new major release',
type: 'boolean',
},
},
lifecycleEvents: ['upgrade'],
});
commands.set('uninstall', {
usage: 'Uninstall Serverless',
isHidden,
noSupportNotice,
lifecycleEvents: ['uninstall'],
});
})();
for (const [name, schema] of commands) {
if (!schema.options) schema.options = {};
for (const optionSchema of Object.values(schema.options)) {
if (!optionSchema.type) optionSchema.type = 'string';
}
if (schema.serviceDependencyMode) {
Object.assign(schema.options, schema.hasAwsExtension ? awsServiceOptions : serviceOptions);
} else {
Object.assign(schema.options, globalOptions);
}
if (!name) {
// Necessary tweaks for Interactive CLI help
schema.options.help = { ...schema.options.help, usage: 'Show general help info' };
schema.options.version = { ...schema.options.version, shortcut: 'v' };
}
}