-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathremove.js
More file actions
47 lines (42 loc) · 1.57 KB
/
remove.js
File metadata and controls
47 lines (42 loc) · 1.57 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
import inquirer from 'inquirer'
import configRemove from '../../config-remove'
import * as load from '../../util/load'
import reporter from '../../util/reporter'
import merge from 'lodash.merge'
export const command = 'remove --env <env> <VARS=values...>'
export const desc = 'Remove environment variables for alias on AWS'
export function builder (yargs) {
return yargs
.pkgConf('shep', process.cwd())
.boolean('quiet')
.alias('quiet', 'q')
.describe('quiet', 'Don\'t log anything')
.describe('env', 'Specifies which environment to remove variables from. If not provided an interactive menu will display the options')
.example('shep config remove --env beta NEW_VARIABLE', 'Removes NEW_VARIABLE from all functions with beta alias')
}
export async function handler (opts) {
const logger = opts.quiet ? () => {} : reporter()
const inputs = {}
if (!opts.env) {
const envs = await load.envs()
const questions = [
{
name: 'env',
message: 'Environment',
type: 'list',
choices: () => envs
}
]
merge(inputs, await inquirer.prompt(questions.filter((q) => !opts[q.name])))
}
logger({ type: 'start', body: 'Remove environment variables on functions in AWS' })
try {
const versions = await configRemove(merge({}, inputs, opts))
logger({ type: 'done' })
logger(`Removed ${opts.vars.join(', ')} from ${inputs.env || opts.env}`)
versions.forEach(({ FunctionName, Identifier }) => logger(`Updated ${FunctionName} to version ${Identifier.Version}`))
} catch (e) {
logger({ type: 'fail' })
throw e
}
}