-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathlivesync-command-helper.ts
87 lines (73 loc) · 3.25 KB
/
livesync-command-helper.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
export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
constructor(protected $platformService: IPlatformService,
protected $projectData: IProjectData,
protected $options: IOptions,
protected $devicesService: Mobile.IDevicesService,
private $iosDeviceOperations: IIOSDeviceOperations,
private $mobileHelper: Mobile.IMobileHelper,
private $platformsData: IPlatformsData) {
}
public async getDevicesLiveSyncInfo(devices: Mobile.IDevice[], liveSyncService: ILiveSyncService, platform: string): Promise<void> {
await this.$devicesService.detectCurrentlyAttachedDevices({ shouldReturnImmediateResult: false, platform });
const workingWithiOSDevices = !platform || this.$mobileHelper.isiOSPlatform(platform);
const shouldKeepProcessAlive = this.$options.watch || !this.$options.justlaunch;
if (workingWithiOSDevices && shouldKeepProcessAlive) {
this.$iosDeviceOperations.setShouldDispose(false);
}
if (this.$options.release || this.$options.bundle) {
await this.runInReleaseMode(platform);
return;
}
// Now let's take data for each device:
const deviceDescriptors: ILiveSyncDeviceInfo[] = devices
.map(d => {
const info: ILiveSyncDeviceInfo = {
identifier: d.deviceInfo.identifier,
buildAction: async (): Promise<string> => {
const buildConfig: IBuildConfig = {
buildForDevice: !d.isEmulator,
projectDir: this.$options.path,
clean: this.$options.clean,
teamId: this.$options.teamId,
device: this.$options.device,
provision: this.$options.provision,
release: this.$options.release,
keyStoreAlias: this.$options.keyStoreAlias,
keyStorePath: this.$options.keyStorePath,
keyStoreAliasPassword: this.$options.keyStoreAliasPassword,
keyStorePassword: this.$options.keyStorePassword
};
await this.$platformService.buildPlatform(d.deviceInfo.platform, buildConfig, this.$projectData);
const result = await this.$platformService.lastOutputPath(d.deviceInfo.platform, buildConfig, this.$projectData);
return result;
}
};
return info;
});
const liveSyncInfo: ILiveSyncInfo = {
projectDir: this.$projectData.projectDir,
skipWatcher: !this.$options.watch,
watchAllFiles: this.$options.syncAllFiles,
clean: this.$options.clean
};
await liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
}
private async runInReleaseMode(platform: string): Promise<void> {
const runPlatformOptions: IRunPlatformOptions = {
device: this.$options.device,
emulator: this.$options.emulator,
justlaunch: this.$options.justlaunch
};
const deployOptions = _.merge<IDeployPlatformOptions>({
projectDir: this.$projectData.projectDir,
clean: true,
}, this.$options.argv);
const availablePlatforms = platform ? [platform] : _.values<string>(this.$platformsData.availablePlatforms);
for (const currentPlatform of availablePlatforms) {
await this.$platformService.deployPlatform(currentPlatform, this.$options, deployOptions, this.$projectData, this.$options);
await this.$platformService.startApplication(currentPlatform, runPlatformOptions, this.$projectData.projectId);
this.$platformService.trackProjectType(this.$projectData);
}
}
}
$injector.register("liveSyncCommandHelper", LiveSyncCommandHelper);