From 177788c9cc739e9916bcf69df11f6b25103f93d8 Mon Sep 17 00:00:00 2001 From: janoshrubos Date: Tue, 29 Dec 2020 18:05:00 +0100 Subject: [PATCH] feat: vue-ts-template --- lib/commands/create-project.ts | 9 ++++++++ test/project-commands.ts | 40 ++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/lib/commands/create-project.ts b/lib/commands/create-project.ts index 780836a044..2b9c5c9b56 100644 --- a/lib/commands/create-project.ts +++ b/lib/commands/create-project.ts @@ -12,6 +12,8 @@ export class CreateProjectCommand implements ICommand { public allowedParameters: ICommandParameter[] = [this.$stringParameter]; private static BlankTemplateKey = "Blank"; private static BlankTemplateDescription = "A blank app"; + private static BlankTsTemplateKey = "Blank Typescript"; + private static BlankTsTemplateDescription = "A blank typescript app"; private static HelloWorldTemplateKey = "Hello World"; private static HelloWorldTemplateDescription = "A Hello World app"; private static DrawerTemplateKey = "SideDrawer"; @@ -57,6 +59,8 @@ export class CreateProjectCommand implements ICommand { let selectedTemplate: string; if (this.$options.js) { selectedTemplate = constants.JAVASCRIPT_NAME; + } else if (this.$options.vue && this.$options.tsc) { + selectedTemplate = "@nativescript/template-blank-vue-ts"; } else if (this.$options.tsc) { selectedTemplate = constants.TYPESCRIPT_NAME; } else if (this.$options.ng) { @@ -315,6 +319,11 @@ can skip this prompt next time using the --template option, or the --ng, --react value: "@nativescript/template-blank-vue", description: CreateProjectCommand.BlankTemplateDescription, }, + { + key: CreateProjectCommand.BlankTsTemplateKey, + value: "@nativescript/template-blank-vue-ts", + description: CreateProjectCommand.BlankTsTemplateDescription, + }, { key: CreateProjectCommand.DrawerTemplateKey, value: "@nativescript/template-drawer-navigation-vue", diff --git a/test/project-commands.ts b/test/project-commands.ts index 7af1609e70..e0db35ff89 100644 --- a/test/project-commands.ts +++ b/test/project-commands.ts @@ -45,9 +45,13 @@ const expectedFlavorChoices = [ description: "Use NativeScript without any framework", }, ]; -const templateChoises = { +const templateChoices = { helloWorld: { key: "Hello World", description: "A Hello World app" }, blank: { key: "Blank", description: "A blank app" }, + blankTypeScript: { + key: "Blank Typescript", + description: "A blank typescript app", + }, sideDrawer: { key: "SideDrawer", description: @@ -59,14 +63,15 @@ const templateChoises = { }, }; const expectedTemplateChoices = [ - templateChoises.helloWorld, - templateChoises.sideDrawer, - templateChoises.tabs, + templateChoices.helloWorld, + templateChoices.sideDrawer, + templateChoices.tabs, ]; const expectedTemplateChoicesVue = [ - templateChoises.blank, - templateChoises.sideDrawer, - templateChoises.tabs, + templateChoices.blank, + templateChoices.blankTypeScript, + templateChoices.sideDrawer, + templateChoices.tabs, ]; class ProjectServiceMock implements IProjectService { @@ -202,6 +207,27 @@ describe("Project commands tests", () => { assert.isTrue(createProjectCalledWithForce); }); + it("should not fail when using only --vue.", async () => { + options.vue = true; + + await createProjectCommand.execute(dummyArgs); + + assert.isTrue(isProjectCreated); + assert.equal(validateProjectCallsCount, 1); + assert.isTrue(createProjectCalledWithForce); + }); + + it("should not fail when using --vue and --tsc.", async () => { + options.vue = true; + options.tsc = true; + + await createProjectCommand.execute(dummyArgs); + + assert.isTrue(isProjectCreated); + assert.equal(validateProjectCallsCount, 1); + assert.isTrue(createProjectCalledWithForce); + }); + it("should not fail when using only --tsc.", async () => { options.tsc = true;