-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathprepare.ts
47 lines (40 loc) · 1.72 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
import { ValidatePlatformCommandBase } from "./command-base";
export class PrepareCommand extends ValidatePlatformCommandBase implements ICommand {
public allowedParameters = [this.$platformCommandParameter];
constructor($options: IOptions,
$platformService: IPlatformService,
$projectData: IProjectData,
private $platformCommandParameter: ICommandParameter,
$platformsData: IPlatformsData,
private $workflowService: IWorkflowService) {
super($options, $platformsData, $platformService, $projectData);
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, skipWarnings: true });
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
bundle: !!this.$options.bundle,
release: this.$options.release,
useHotModuleReload: this.$options.hmr
};
const platformInfo: IPreparePlatformInfo = {
platform: args[0],
appFilesUpdaterOptions,
platformTemplate: this.$options.platformTemplate,
projectData: this.$projectData,
config: this.$options,
env: this.$options.env
};
await this.$platformService.preparePlatform(platformInfo);
}
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
const platform = args[0];
const result = await this.$platformCommandParameter.validate(platform) && await this.$platformService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
if (!result) {
return false;
}
const canExecuteOutput = await super.canExecuteCommandBase(platform);
return canExecuteOutput;
}
}
$injector.registerCommand("prepare", PrepareCommand);