-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathprepare.ts
50 lines (40 loc) · 1.91 KB
/
prepare.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
import { ValidatePlatformCommandBase } from "./command-base";
import { PrepareController } from "../controllers/prepare-controller";
import { PrepareDataService } from "../services/prepare-data-service";
export class PrepareCommand extends ValidatePlatformCommandBase implements ICommand {
public allowedParameters = [this.$platformCommandParameter];
public dashedOptions = {
watch: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
hmr: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
};
constructor($options: IOptions,
private $prepareController: PrepareController,
$platformValidationService: IPlatformValidationService,
$projectData: IProjectData,
private $platformCommandParameter: ICommandParameter,
$platformsDataService: IPlatformsDataService,
private $prepareDataService: PrepareDataService,
private $migrateController: IMigrateController) {
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
const platform = args[0];
const prepareData = this.$prepareDataService.getPrepareData(this.$projectData.projectDir, platform, this.$options);
await this.$prepareController.prepare(prepareData);
}
public async canExecute(args: string[]): Promise<boolean> {
const platform = args[0];
const result = await this.$platformCommandParameter.validate(platform) &&
await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
if (!this.$options.force) {
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [platform] });
}
if (!result) {
return false;
}
const canExecuteOutput = await super.canExecuteCommandBase(platform);
return canExecuteOutput;
}
}
$injector.registerCommand("prepare", PrepareCommand);