UNPKG

1.23 kBJavaScriptView Raw
1var utils = require('./utils')
2var inquirer = require('inquirer')
3
4module.exports = function(yargs) {
5 yargs.command('select', 'Selects an existing AWS region to be used for creating lambda functions and API resources', function (yargs) {
6 module.exports.select(utils.end)
7 })
8 .command('show', 'Shows the current selected AWS region', function(yargs) {
9 module.exports.show(utils.end)
10 })
11 .wrap(yargs.terminalWidth())
12 .help('help')
13 .argv
14}
15
16module.exports.show = function(callback) {
17 utils.requiresRegion()
18 var config = utils.readConfig()
19 console.log(config.region)
20}
21
22module.exports.select = function(callback) {
23 // For available regions
24 // see http://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region
25 // and http://docs.aws.amazon.com/general/latest/gr/rande.html#lambda_region
26 var question = {
27 name: 'region',
28 type: 'list',
29 choices: ['us-east-1', 'us-west-2', 'eu-west-1', 'ap-northeast-1'],
30 message: 'Choose a region',
31 }
32 inquirer.prompt([question], function(answers) {
33 var config = utils.readConfig()
34 config.region = answers.region
35 utils.writeConfig(config)
36 console.log('Updated region configuration successfully')
37 callback()
38 })
39}