Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: askx new --template-url -> the language and deployer selection a… #95

Merged
merged 2 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/commands/v2new/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,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 @@ -224,6 +224,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