Skip to content

Commit

Permalink
fix: askx new --template-url -> the language and deployer selection a… (
Browse files Browse the repository at this point in the history
  • Loading branch information
Chih-Ying authored Apr 2, 2020
1 parent 936e197 commit 1907e07
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/commands/v2new/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ function createNonHostedSkill(cmd, profile, doDebug, userInput, callback) {
return callback(projectErr);
}
Messenger.getInstance().info(`Project for skill "${userInput.skillName}" is successfully created at ${projectFolderPath}\n`);
if (cmd.templateUrl) {
return callback();
}
try {
// 2.load involving M(Model) component (ResourcesConfig & Manifest) from the downloaded skill project with 'default' profile
helper.loadSkillProjectModel(projectFolderPath, 'default');
Expand Down
9 changes: 8 additions & 1 deletion lib/commands/v2new/wizard-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
*/
function collectUserCreationProjectInfo(cmd, callback) {
const userInput = {};
ui.selectSkillCodeLanguage((languageErr, language) => {
_getSkillCodeLanguage(cmd, (languageErr, language) => {
if (languageErr) {
return callback(languageErr);
}
Expand Down Expand Up @@ -62,6 +62,13 @@ function collectUserCreationProjectInfo(cmd, callback) {
});
}

function _getSkillCodeLanguage(cmd, callback) {
if (cmd.templateUrl) {
return callback();
}
ui.selectSkillCodeLanguage((err, res) => callback(err || null, res));
}

/**
* Get template info for non-hosted skill
* @param {Object} cmd command object
Expand Down
19 changes: 19 additions & 0 deletions test/unit/commands/v2new/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,25 @@ describe('Commands new test - command class test', () => {
});
});

it('| load skill project model succeeds, with custom template, expect no error thrown', (done) => {
// setup
const TEST_CMD_TEMPLATE = {
profile: TEST_PROFILE,
templateUrl: 'templateUrl'
};
const TEST_USER_INPUT = {};
wizardHelper.collectUserCreationProjectInfo.callsArgWith(1, null, TEST_USER_INPUT);
helper.downloadTemplateFromGit.callsArgWith(2, null);
// call
instance.handle(TEST_CMD_TEMPLATE, (err) => {
// verify
expect(err).equal(undefined);
expect(errorStub.callCount).equal(0);
expect(infoStub.callCount).equal(2);
done();
});
});

it('| load skill project model fails, expect error thrown', (done) => {
// setup
const TEST_USER_INPUT = {};
Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands/v2new/wizard-helper-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('Commands new test - wizard helper test', () => {
});

it('| Hosted skills do not support custom template, expect throw error', (done) => {
// setup
// setup
const TEST_HOSTED_ERROR = 'No custom template allowed for an Alexa hosted skill.';
ui.selectSkillCodeLanguage.callsArgWith(0, null, TEST_LANGUAGE_RESPONSE);
ui.getDeploymentType.callsArgWith(1, null, TEST_HOSTED_DEPLOYMENT);
Expand Down

0 comments on commit 1907e07

Please sign in to comment.