From 0c7750c735f08ffda63559a817653276a1837afe Mon Sep 17 00:00:00 2001 From: ChihYing Date: Tue, 7 Apr 2020 16:11:25 -0700 Subject: [PATCH] fix: askx new -> change the representation layer for deployers (#106) --- docs/concepts/Alexa-Hosted-Skill-Commands.md | 4 ++-- docs/concepts/New-Command.md | 6 +++--- lib/commands/v2new/ui.js | 4 ++-- lib/utils/constants.js | 3 +++ test/unit/commands/v2new/ui-test.js | 15 +++++++++------ 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/docs/concepts/Alexa-Hosted-Skill-Commands.md b/docs/concepts/Alexa-Hosted-Skill-Commands.md index b0054d72..fa08ac4e 100644 --- a/docs/concepts/Alexa-Hosted-Skill-Commands.md +++ b/docs/concepts/Alexa-Hosted-Skill-Commands.md @@ -23,8 +23,8 @@ Users will be asked the following questions to create a new skill: * Prompts user for `programming language` * Select programming language * AHS supports Python3.7 and Node10.x -* Prompts user for `deploy delegate` to deploy skill infrastructure - * Select `@ask-cli/hosted-skill-deployer` +* Prompts user for a method to host your skill's backend resources + * Select `Alexa-hosted skills` * Prompts user for `skill name` * Leave empty to use the default skill name `Hello World Skill` * Prompts user for a `folder name` for the skill project diff --git a/docs/concepts/New-Command.md b/docs/concepts/New-Command.md index af2172f1..3e49c4b9 100644 --- a/docs/concepts/New-Command.md +++ b/docs/concepts/New-Command.md @@ -21,15 +21,15 @@ ## DEPLOYERS: -* **Alexa Hosted deployer** +* **Alexa-hosted skills** * Dependency: SMAPI * Description: Create an `Alexa hosted skill`, clone the skill project, and provide git-ready environment to deploy the skill. -* **AWS CloudFormation** +* **AWS with CloudFormation** * Dependency: AWS-SDK * Description: Upload local code to Amazon S3, and use `AWS CloudFormation` to configure AWS resources required for the skill. * **AWS Lambda** * Dependency: AWS-SDK - * Description: Creat an AWS IAM Role with basic permissions to access `AWS Lambda`. Update the configuration and upload the local code to an AWS Lambda function. + * Description: Create an AWS IAM Role with basic permissions to access `AWS Lambda`. Update the configuration and upload the local code to an AWS Lambda function. diff --git a/lib/commands/v2new/ui.js b/lib/commands/v2new/ui.js index 5be20618..74cbdd14 100644 --- a/lib/commands/v2new/ui.js +++ b/lib/commands/v2new/ui.js @@ -104,7 +104,7 @@ function confirmUsingUnofficialTemplate(callback) { function getDeploymentType(deployType, callback) { const deployDelegateChoices = R.values(deployType).map( - (deployer) => `${deployer.NAME}\n ${chalk.gray(deployer.DESCRIPTION)}` + (deployer) => `${deployer.OPTION_NAME}\n ${chalk.gray(deployer.DESCRIPTION)}` ); deployDelegateChoices.push(new inquirer.Separator()); deployDelegateChoices.push(SKIP_DEPLOY_DELEGATE_SELECTION); @@ -116,7 +116,7 @@ function getDeploymentType(deployType, callback) { pageSize: 30, filter: input => input.replace(/\n.*/g, '') }]).then((answer) => { - callback(null, answer.deployDelegate); + callback(null, R.find(R.propEq('OPTION_NAME', answer.deployDelegate))(R.values(deployType)).NAME); }).catch((error) => { callback(error); }); diff --git a/lib/utils/constants.js b/lib/utils/constants.js index 29d2efd5..178d59cc 100644 --- a/lib/utils/constants.js +++ b/lib/utils/constants.js @@ -5,14 +5,17 @@ module.exports.METRICS = { module.exports.DEPLOYER_TYPE = { HOSTED: { + OPTION_NAME: 'Alexa-hosted skills', NAME: '@ask-cli/hosted-skill-deployer', DESCRIPTION: 'Host your skill code by Alexa (free).' }, CFN: { + OPTION_NAME: 'AWS with CloudFormation', NAME: '@ask-cli/cfn-deployer', DESCRIPTION: 'Host your skill code with AWS services and provision with AWS CloudFormation (requires AWS account)' }, LAMBDA: { + OPTION_NAME: 'AWS Lambda', NAME: '@ask-cli/lambda-deployer', DESCRIPTION: 'Host your skill code on AWS Lambda (requires AWS account).' } diff --git a/test/unit/commands/v2new/ui-test.js b/test/unit/commands/v2new/ui-test.js index 35ede7a1..5ecbabcb 100644 --- a/test/unit/commands/v2new/ui-test.js +++ b/test/unit/commands/v2new/ui-test.js @@ -27,7 +27,8 @@ describe('Commands new - UI test', () => { const TEST_LANGUAGE = 'language'; const TEST_TEMPLATE_NAME = 'templateName'; const TEST_CONFIRMATION = 'confirmation'; - const TEST_DEPLOY_DELEGATE = 'deployDelegate'; + const TEST_DEPLOYMENT_OPTION_NAME = 'HOSTED_OPTION_NAME'; + const TEST_DEPLOYMENT_NAME = 'HOSTED_NAME'; const TEST_TEMPLATES_MAP = { template1: { url: 'templateUrl1', @@ -39,10 +40,12 @@ describe('Commands new - UI test', () => { }; const TEST_DEPLOYMENT_MAP = { HOSTED: { - NAME: 'HOSTED_NAME', + OPTION_NAME: TEST_DEPLOYMENT_OPTION_NAME, + NAME: TEST_DEPLOYMENT_NAME, DESCRIPTION: 'HOSTED_DESCRIPTION' }, CFN: { + OPTION_NAME: 'CFN_OPTION_NAME', NAME: 'CFN_NAME', DESCRIPTION: 'CFN_DESCRIPTION' } @@ -52,8 +55,8 @@ describe('Commands new - UI test', () => { `template2\t\t ${chalk.gray('')}` ]; const TEST_DEPLOYMENT_CHOICES_WITH_SEP = [ - `HOSTED_NAME\n ${chalk.gray('HOSTED_DESCRIPTION')}`, - `CFN_NAME\n ${chalk.gray('CFN_DESCRIPTION')}`, + `${TEST_DEPLOYMENT_OPTION_NAME}\n ${chalk.gray('HOSTED_DESCRIPTION')}`, + `CFN_OPTION_NAME\n ${chalk.gray('CFN_DESCRIPTION')}`, new inquirer.Separator(), ui.SKIP_DEPLOY_DELEGATE_SELECTION ]; @@ -371,7 +374,7 @@ describe('Commands new - UI test', () => { it('| confirmation entered by user is retrieved correctly', (done) => { // setup - inquirer.prompt.resolves({ deployDelegate: TEST_DEPLOY_DELEGATE }); + inquirer.prompt.resolves({ deployDelegate: TEST_DEPLOYMENT_OPTION_NAME }); // call ui.getDeploymentType(TEST_DEPLOYMENT_MAP, (err, response) => { // verify @@ -382,7 +385,7 @@ describe('Commands new - UI test', () => { }); expect(inquirer.prompt.args[0][0][0].filter('a \n \n b')).equal('a '); expect(err).equal(null); - expect(response).equal(TEST_DEPLOY_DELEGATE); + expect(response).equal(TEST_DEPLOYMENT_NAME); done(); }); });