-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathprepare.ts
83 lines (73 loc) · 2.42 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { ValidatePlatformCommandBase } from "./command-base";
import { PrepareController } from "../controllers/prepare-controller";
import { PrepareDataService } from "../services/prepare-data-service";
import { IProjectData } from "../definitions/project";
import { IOptions, IPlatformValidationService } from "../declarations";
import { IPlatformsDataService } from "../definitions/platform";
import { IMigrateController } from "../definitions/migrate";
import { ICommand, ICommandParameter } from "../common/definitions/commands";
import { OptionType } from "../common/declarations";
import { injector } from "../common/yok";
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);