-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathrun.ts
96 lines (79 loc) · 3.69 KB
/
run.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
84
85
86
87
88
89
90
91
92
93
94
95
96
export class RunCommandBase {
constructor(protected $platformService: IPlatformService,
protected $usbLiveSyncService: ILiveSyncService,
protected $projectData: IProjectData,
protected $options: IOptions,
protected $emulatorPlatformService: IEmulatorPlatformService) {
this.$projectData.initializeProjectData();
}
public async executeCore(args: string[]): Promise<void> {
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
const deployOptions: IDeployPlatformOptions = {
clean: this.$options.clean,
device: this.$options.device,
emulator: this.$options.emulator,
projectDir: this.$options.path,
platformTemplate: this.$options.platformTemplate,
release: this.$options.release,
provision: this.$options.provision,
teamId: this.$options.teamId,
keyStoreAlias: this.$options.keyStoreAlias,
keyStoreAliasPassword: this.$options.keyStoreAliasPassword,
keyStorePassword: this.$options.keyStorePassword,
keyStorePath: this.$options.keyStorePath
};
await this.$platformService.deployPlatform(args[0], appFilesUpdaterOptions, deployOptions, this.$projectData, { provision: this.$options.provision, sdk: this.$options.sdk });
if (this.$options.bundle) {
this.$options.watch = false;
}
if (this.$options.release) {
const deployOpts: IRunPlatformOptions = {
device: this.$options.device,
emulator: this.$options.emulator,
justlaunch: this.$options.justlaunch,
};
return this.$platformService.startApplication(args[0], deployOpts, this.$projectData);
}
return this.$usbLiveSyncService.liveSync(args[0], this.$projectData);
}
}
export class RunIosCommand extends RunCommandBase implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor($platformService: IPlatformService,
private $platformsData: IPlatformsData,
$usbLiveSyncService: ILiveSyncService,
$projectData: IProjectData,
$options: IOptions,
$emulatorPlatformService: IEmulatorPlatformService) {
super($platformService, $usbLiveSyncService, $projectData, $options, $emulatorPlatformService);
}
public async execute(args: string[]): Promise<void> {
return this.executeCore([this.$platformsData.availablePlatforms.iOS]);
}
public async canExecute(args: string[]): Promise<boolean> {
return args.length === 0 && await this.$platformService.validateOptions(this.$options.provision, this.$projectData, this.$platformsData.availablePlatforms.iOS);
}
}
$injector.registerCommand("run|ios", RunIosCommand);
export class RunAndroidCommand extends RunCommandBase implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor($platformService: IPlatformService,
private $platformsData: IPlatformsData,
$usbLiveSyncService: ILiveSyncService,
$projectData: IProjectData,
$options: IOptions,
$emulatorPlatformService: IEmulatorPlatformService,
private $errors: IErrors) {
super($platformService, $usbLiveSyncService, $projectData, $options, $emulatorPlatformService);
}
public async execute(args: string[]): Promise<void> {
return this.executeCore([this.$platformsData.availablePlatforms.Android]);
}
public async canExecute(args: string[]): Promise<boolean> {
if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) {
this.$errors.fail("When producing a release build, you need to specify all --key-store-* options.");
}
return args.length === 0 && await this.$platformService.validateOptions(this.$options.provision, this.$projectData, this.$platformsData.availablePlatforms.Android);
}
}
$injector.registerCommand("run|android", RunAndroidCommand);