Skip to content

Commit

Permalink
fix: askx new -> change the representation layer for deployers (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chih-Ying authored Apr 7, 2020
1 parent c58453c commit 0c7750c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/concepts/Alexa-Hosted-Skill-Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/concepts/New-Command.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.



Expand Down
4 changes: 2 additions & 2 deletions lib/commands/v2new/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
});
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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).'
}
Expand Down
15 changes: 9 additions & 6 deletions test/unit/commands/v2new/ui-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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'
}
Expand All @@ -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
];
Expand Down Expand Up @@ -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
Expand All @@ -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();
});
});
Expand Down

0 comments on commit 0c7750c

Please sign in to comment.