-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathadd-platform.ts
72 lines (63 loc) · 1.84 KB
/
add-platform.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { ValidatePlatformCommandBase } from "./command-base";
import { IProjectData } from "../definitions/project";
import {
IOptions,
IPlatformCommandHelper,
IPlatformValidationService,
} from "../declarations";
import { IPlatformsDataService } from "../definitions/platform";
import { ICommandParameter, ICommand } from "../common/definitions/commands";
import { IErrors } from "../common/declarations";
import { injector } from "../common/yok";
export class AddPlatformCommand
extends ValidatePlatformCommandBase
implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor(
$options: IOptions,
private $platformCommandHelper: IPlatformCommandHelper,
$platformValidationService: IPlatformValidationService,
$projectData: IProjectData,
$platformsDataService: IPlatformsDataService,
private $errors: IErrors
) {
super(
$options,
$platformsDataService,
$platformValidationService,
$projectData
);
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
await this.$platformCommandHelper.addPlatforms(
args,
this.$projectData,
this.$options.frameworkPath
);
}
public async canExecute(args: string[]): Promise<boolean> {
if (!args || args.length === 0) {
this.$errors.failWithHelp(
"No platform specified. Please specify a platform to add."
);
}
let canExecute = true;
for (const arg of args) {
this.$platformValidationService.validatePlatform(arg, this.$projectData);
if (
!this.$platformValidationService.isPlatformSupportedForOS(
arg,
this.$projectData
)
) {
this.$errors.fail(
`Applications for platform ${arg} cannot be built on this OS`
);
}
canExecute = await super.canExecuteCommandBase(arg);
}
return canExecute;
}
}
injector.registerCommand("platform|add", AddPlatformCommand);