-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathcreate-project.ts
50 lines (39 loc) · 1.54 KB
/
create-project.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
///<reference path="../.d.ts"/>
"use strict";
import * as constants from "../constants";
export class ProjectCommandParameter implements ICommandParameter {
constructor(private $errors: IErrors,
private $logger: ILogger,
private $projectNameValidator: IProjectNameValidator) { }
mandatory = true;
validate(value: string): IFuture<boolean> {
return (() => {
if(!value) {
this.$errors.fail("You must specify <App name> when creating a new project.");
}
if (value.toUpperCase() === "APP") {
this.$logger.warn("You cannot build applications named 'app' in Xcode. Consider creating a project with different name.");
}
return this.$projectNameValidator.validate(value);
}).future<boolean>()();
}
}
export class CreateProjectCommand implements ICommand {
constructor(private $projectService: IProjectService,
private $errors: IErrors,
private $logger: ILogger,
private $projectNameValidator: IProjectNameValidator,
private $options: IOptions) { }
public enableHooks = false;
execute(args: string[]): IFuture<void> {
return (() => {
if (this.$options.ng && this.$options.template) {
this.$errors.fail("You cannot use --ng and --template simultaneously.");
}
let selectedTemplate = this.$options.ng ? constants.ANGULAR_NAME : this.$options.template;
this.$projectService.createProject(args[0], selectedTemplate).wait();
}).future<void>()();
}
allowedParameters = [new ProjectCommandParameter(this.$errors, this.$logger, this.$projectNameValidator) ];
}
$injector.registerCommand("create", CreateProjectCommand);