Skip to content

Commit 12f657f

Browse files
author
Vladimir Enchev
committed
create --tsc option added + tests
1 parent 5e5c839 commit 12f657f

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

lib/commands/create-project.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ export class CreateProjectCommand implements ICommand {
1010

1111
execute(args: string[]): IFuture<void> {
1212
return (() => {
13-
if (this.$options.ng && this.$options.template) {
14-
this.$errors.fail("You cannot use --ng and --template simultaneously.");
13+
if ((this.$options.tsc || this.$options.ng) && this.$options.template) {
14+
this.$errors.fail("You cannot use --ng or --tsc options together with --template.");
1515
}
1616

17-
let selectedTemplate = this.$options.ng ? constants.ANGULAR_NAME : this.$options.template;
17+
let selectedTemplate: string;
18+
if (this.$options.tsc) {
19+
selectedTemplate = constants.TYPESCRIPT_NAME;
20+
} else if (this.$options.ng) {
21+
selectedTemplate = constants.ANGULAR_NAME;
22+
} else {
23+
selectedTemplate = this.$options.template;
24+
}
1825

1926
this.$projectService.createProject(args[0], selectedTemplate).wait();
2027
}).future<void>()();

lib/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ class ItunesConnectApplicationTypesClass implements IiTunesConnectApplicationTyp
4444
export let ItunesConnectApplicationTypes = new ItunesConnectApplicationTypesClass();
4545

4646
export let ANGULAR_NAME = "angular";
47+
export let TYPESCRIPT_NAME = "TypeScript";

lib/declarations.ts

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ interface IOptions extends ICommonOptions {
8282
keyStorePath: string;
8383
linkTo: string;
8484
ng: boolean;
85+
tsc: boolean;
8586
bundle: boolean;
8687
platformTemplate: string;
8788
port: Number;

lib/options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class Options extends commonOptionsLibPath.OptionsBase {
3333
baseConfig: { type: OptionType.String },
3434
platformTemplate: { type: OptionType.String },
3535
ng: {type: OptionType.Boolean },
36+
tsc: {type: OptionType.Boolean },
3637
bundle: {type: OptionType.Boolean },
3738
all: {type: OptionType.Boolean },
3839
teamId: { type: OptionType.String }

test/project-commands.ts

+33
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ describe("Project commands tests", () => {
6565
assert.isTrue(isProjectCreated);
6666
});
6767

68+
it("should not fail when using only --tsc.", () => {
69+
options.ng = true;
70+
71+
createProjectCommand.execute(dummyArgs).wait();
72+
73+
assert.isTrue(isProjectCreated);
74+
});
75+
6876
it("should not fail when using only --template.", () => {
6977
options.template = "ng";
7078

@@ -81,6 +89,14 @@ describe("Project commands tests", () => {
8189
assert.deepEqual(selectedTemplateName, constants.ANGULAR_NAME);
8290
});
8391

92+
it("should set the template name correctly when used --tsc.", () => {
93+
options.tsc = true;
94+
95+
createProjectCommand.execute(dummyArgs).wait();
96+
97+
assert.deepEqual(selectedTemplateName, constants.TYPESCRIPT_NAME);
98+
});
99+
84100
it("should not set the template name when --ng is not used.", () => {
85101
options.ng = false;
86102

@@ -89,6 +105,14 @@ describe("Project commands tests", () => {
89105
assert.isUndefined(selectedTemplateName);
90106
});
91107

108+
it("should not set the template name when --tsc is not used.", () => {
109+
options.tsc = false;
110+
111+
createProjectCommand.execute(dummyArgs).wait();
112+
113+
assert.isUndefined(selectedTemplateName);
114+
});
115+
92116
it("should fail when --ng and --template are used simultaneously.", () => {
93117
options.ng = true;
94118
options.template = "ng";
@@ -97,5 +121,14 @@ describe("Project commands tests", () => {
97121
createProjectCommand.execute(dummyArgs).wait();
98122
});
99123
});
124+
125+
it("should fail when --tsc and --template are used simultaneously.", () => {
126+
options.tsc = true;
127+
options.template = "tsc";
128+
129+
assert.throws(() => {
130+
createProjectCommand.execute(dummyArgs).wait();
131+
});
132+
});
100133
});
101134
});

0 commit comments

Comments
 (0)