diff --git a/.gitignore b/.gitignore index 8edbca0b..59ec9d62 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ coverage # MAC OS .DS_Store - diff --git a/README.md b/README.md index 575f01ed..427a4fbf 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

Alexa Skills Kit Command Line interface

- +

diff --git a/lib/commands/init/helper.js b/lib/commands/init/helper.js index 9ebc0476..e12a7ce0 100644 --- a/lib/commands/init/helper.js +++ b/lib/commands/init/helper.js @@ -7,6 +7,7 @@ const CliWarn = require('@src/exceptions/cli-warn'); const AskResources = require('@src/model/resources-config/ask-resources'); const AskStates = require('@src/model/resources-config/ask-states'); const ResourcesConfig = require('@src/model/resources-config'); +const stringUtils = require('@src/utils/string-utils'); const CONSTANTS = require('@src/utils/constants'); const Messenger = require('@src/view/messenger'); @@ -177,8 +178,13 @@ function _assembleAskResources(userInput, profile) { function bootstrapSkillInfra(rootPath, profile, doDebug, callback) { const askResourcesFilePath = path.join(rootPath, CONSTANTS.FILE_PATH.ASK_RESOURCES_JSON_CONFIG); new ResourcesConfig(askResourcesFilePath); - // bootstrap after deployer gets selected const deployerType = ResourcesConfig.getInstance().getSkillInfraType(profile); + if (!stringUtils.isNonBlankString(deployerType)) { + return process.nextTick(() => { + callback(); + }); + } + // bootstrap after deployer gets selected const ddFolderPath = deployerType.startsWith('@ask-cli/') ? deployerType.replace('@ask-cli/', '') : deployerType; const deployerPath = path.join(rootPath, CONSTANTS.FILE_PATH.SKILL_INFRASTRUCTURE.INFRASTRUCTURE, ddFolderPath); fs.ensureDirSync(deployerPath); diff --git a/lib/controllers/authorization-controller/index.js b/lib/controllers/authorization-controller/index.js index 07eb083d..7a670316 100644 --- a/lib/controllers/authorization-controller/index.js +++ b/lib/controllers/authorization-controller/index.js @@ -152,8 +152,9 @@ module.exports = class AuthorizationController { } if (requestUrl.startsWith('/cb?error')) { response.statusCode = 403; - response.end(`Error: ${requestQuery.error}\nError description: ${requestQuery.error_description}`); - callback(messages.ASK_SIGN_IN_FAILURE_MESSAGE); + const errorMessage = `Error: ${requestQuery.error}\nReason: ${requestQuery.error_description}`; + response.end(messages.ASK_SIGN_IN_FAILURE_MESSAGE(errorMessage)); + callback(errorMessage); } } } diff --git a/lib/controllers/authorization-controller/messages.js b/lib/controllers/authorization-controller/messages.js index c58e3beb..0b2b1da8 100644 --- a/lib/controllers/authorization-controller/messages.js +++ b/lib/controllers/authorization-controller/messages.js @@ -5,6 +5,52 @@ module.exports.PORT_OCCUPIED_WARN_MESSAGE = '[Warn]: 9090 port on localhost has + 'ask-cli cannot start a local server for receiving authorization code.\nPlease either abort any processes running on port 9090\n' + 'or add `--no-browser` flag to the command as an alternative approach.'; -module.exports.ASK_SIGN_IN_SUCCESS_MESSAGE = 'Sign in was successful. Close browser and return to the command line interface.'; +module.exports.ASK_SIGN_IN_SUCCESS_MESSAGE = ` + + + ask-cli Login with Amazon + + + +

+ +

+

+ Sign in was successful. Close browser and return to the command line interface to continue the configure process. +

+ + +`; + +module.exports.ASK_SIGN_IN_FAILURE_MESSAGE = (error) => ` + + + ask-cli Login with Amazon + + + +

+ +

+

+ ${error} +

+ + +`; module.exports.ASK_ENV_VARIABLES_ERROR_MESSAGE = 'Could not find either of the environment variables: ASK_ACCESS_TOKEN, ASK_REFRESH_TOKEN'; diff --git a/package.json b/package.json index d23841c5..0c739ba1 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "eslint-config-airbnb-base": "^14.0.0", "eslint-plugin-import": "^2.20.1", "gulp": "^3.9.1", - "husky": "^4.2.1", + "husky": "^4.2.3", "mocha": "^3.2.0", "nyc": "^13.3.0", "proxyquire": "^1.7.11", diff --git a/test/unit/controller/authorization-controller/index-test.js b/test/unit/controller/authorization-controller/index-test.js index 2595938d..025a7934 100644 --- a/test/unit/controller/authorization-controller/index-test.js +++ b/test/unit/controller/authorization-controller/index-test.js @@ -446,11 +446,12 @@ describe('Controller test - Authorization controller test', () => { // call authorizationController._listenResponseFromLWA(TEST_PORT, (err) => { // verify + const EXPECTED_ERR_MESSAGE = `Error: ${requestQuery.query.error}\nReason: ${requestQuery.query.error_description}`; expect(spinnerTerminateStub.callCount).eq(1); expect(serverDestroyStub.callCount).eq(1); expect(endStub.callCount).eq(1); - expect(endStub.args[0][0]).eq(`Error: ${requestQuery.query.error}\nError description: ${requestQuery.query.error_description}`); - expect(err).eq(messages.ASK_SIGN_IN_FAILURE_MESSAGE); + expect(endStub.args[0][0].includes(EXPECTED_ERR_MESSAGE)).equal(true); + expect(err).eq(EXPECTED_ERR_MESSAGE); done(); }); });