From acfefd08cf81d74f7e4f112ca3f20b37e34091a7 Mon Sep 17 00:00:00 2001 From: "Eslam A. Hefnawy" Date: Fri, 18 Dec 2015 13:25:01 +0200 Subject: [PATCH] made region select more robust --- lib/ServerlessPlugin.js | 4 ++-- lib/actions/DashDeploy.js | 2 +- lib/actions/EnvGet.js | 2 +- lib/actions/EnvList.js | 2 +- lib/actions/EnvSet.js | 2 +- lib/actions/EnvUnset.js | 2 +- lib/actions/RegionCreate.js | 2 +- lib/actions/ResourcesDeploy.js | 2 +- lib/actions/StageCreate.js | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ServerlessPlugin.js b/lib/ServerlessPlugin.js index d92a05e2e..d3ce6fc56 100644 --- a/lib/ServerlessPlugin.js +++ b/lib/ServerlessPlugin.js @@ -263,7 +263,7 @@ class ServerlessPlugin { * CLI: Prompt Select Region */ - cliPromptSelectRegion(message, addAllRegions, region, stage) { + cliPromptSelectRegion(message, addAllRegions, existing, region, stage) { let _this = this; @@ -288,7 +288,7 @@ class ServerlessPlugin { return BbPromise.reject(new SError('Stage ' + stage + ' does not exist in your project', SError.errorCodes.UNKNOWN)); } - if (addAllRegions) { + if (existing) { // list only regions in stage regionChoices = []; diff --git a/lib/actions/DashDeploy.js b/lib/actions/DashDeploy.js index 25147ed2c..cf4f947a6 100644 --- a/lib/actions/DashDeploy.js +++ b/lib/actions/DashDeploy.js @@ -134,7 +134,7 @@ module.exports = function(SPlugin, serverlessPath) { }) }) .then(function() { - return _this.cliPromptSelectRegion('Choose a Region in this Stage: ', true, _this.evt.region, _this.evt.stage) + return _this.cliPromptSelectRegion('Choose a Region in this Stage: ', false, true, _this.evt.region, _this.evt.stage) .then(region => { _this.evt.region = region; }) diff --git a/lib/actions/EnvGet.js b/lib/actions/EnvGet.js index cd3c210c4..a797c2697 100644 --- a/lib/actions/EnvGet.js +++ b/lib/actions/EnvGet.js @@ -130,7 +130,7 @@ module.exports = function(SPlugin, serverlessPath) { }) }) .then(function(){ - return _this.cliPromptSelectRegion('Select a region to get env var from: ', true, _this.evt.region, _this.evt.stage) + return _this.cliPromptSelectRegion('Select a region to get env var from: ', true, true, _this.evt.region, _this.evt.stage) .then(region => { _this.evt.region = region; BbPromise.resolve(); diff --git a/lib/actions/EnvList.js b/lib/actions/EnvList.js index 7862d924a..cb53d60b8 100644 --- a/lib/actions/EnvList.js +++ b/lib/actions/EnvList.js @@ -116,7 +116,7 @@ module.exports = function(SPlugin, serverlessPath) { BbPromise.resolve(); }) .then(function(){ - return _this.cliPromptSelectRegion('Select a region to list env vars from: ', true, _this.evt.region, _this.evt.stage) + return _this.cliPromptSelectRegion('Select a region to list env vars from: ', true, true, _this.evt.region, _this.evt.stage) .then(region => { _this.evt.region = region; BbPromise.resolve(); diff --git a/lib/actions/EnvSet.js b/lib/actions/EnvSet.js index 6d4b834b4..ec42fd5b6 100644 --- a/lib/actions/EnvSet.js +++ b/lib/actions/EnvSet.js @@ -143,7 +143,7 @@ module.exports = function(SPlugin, serverlessPath) { }) }) .then(function(){ - return _this.cliPromptSelectRegion('Select a region to set env var in: ', true, _this.evt.region, _this.evt.stage) + return _this.cliPromptSelectRegion('Select a region to set env var in: ', true, true, _this.evt.region, _this.evt.stage) .then(region => { _this.evt.region = region; BbPromise.resolve(); diff --git a/lib/actions/EnvUnset.js b/lib/actions/EnvUnset.js index 285cd2664..2ceb1bc66 100644 --- a/lib/actions/EnvUnset.js +++ b/lib/actions/EnvUnset.js @@ -130,7 +130,7 @@ module.exports = function(SPlugin, serverlessPath) { }) }) .then(function(){ - return _this.cliPromptSelectRegion('Select a region to unset env var from: ', true, _this.evt.region, _this.evt.stage) + return _this.cliPromptSelectRegion('Select a region to unset env var from: ', true, true, _this.evt.region, _this.evt.stage) .then(region => { _this.evt.region = region; BbPromise.resolve(); diff --git a/lib/actions/RegionCreate.js b/lib/actions/RegionCreate.js index 4e39cef59..c5422e5f0 100644 --- a/lib/actions/RegionCreate.js +++ b/lib/actions/RegionCreate.js @@ -126,7 +126,7 @@ module.exports = function(SPlugin, serverlessPath) { BbPromise.resolve(); }) .then(function(){ - return _this.cliPromptSelectRegion('Select a new region for your existing stage: ', false, _this.evt.region, _this.evt.stage) + return _this.cliPromptSelectRegion('Select a new region for your existing stage: ', false, false, _this.evt.region, _this.evt.stage) .then(region => { _this.evt.region = region; BbPromise.resolve(); diff --git a/lib/actions/ResourcesDeploy.js b/lib/actions/ResourcesDeploy.js index a4653a702..25ecb2bfb 100644 --- a/lib/actions/ResourcesDeploy.js +++ b/lib/actions/ResourcesDeploy.js @@ -113,7 +113,7 @@ module.exports = function(SPlugin, serverlessPath) { BbPromise.resolve(); }) .then(function(){ - return _this.cliPromptSelectRegion('Which region are you deploying to: ', false, _this.evt.region, false) + return _this.cliPromptSelectRegion('Which region are you deploying to: ', false, true, _this.evt.region, _this.evt.stage) .then(region => { _this.evt.region = region; BbPromise.resolve(); diff --git a/lib/actions/StageCreate.js b/lib/actions/StageCreate.js index 63ca83930..01d48c489 100644 --- a/lib/actions/StageCreate.js +++ b/lib/actions/StageCreate.js @@ -143,7 +143,7 @@ module.exports = function(SPlugin, serverlessPath) { BbPromise.resolve(); }) .then(function(){ - return _this.cliPromptSelectRegion('Select a region for your new stage: ', false, _this.evt.region, false) + return _this.cliPromptSelectRegion('Select a region for your new stage: ', false, false, _this.evt.region, false) .then(region => { _this.evt.region = region; BbPromise.resolve();