|
1 | 1 | export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
|
2 |
| - protected platform: string; |
3 | 2 |
|
4 | 3 | constructor(protected $platformService: IPlatformService,
|
5 | 4 | protected $projectData: IProjectData,
|
6 | 5 | protected $options: IOptions,
|
7 | 6 | protected $devicesService: Mobile.IDevicesService,
|
8 | 7 | private $iosDeviceOperations: IIOSDeviceOperations,
|
9 |
| - private $mobileHelper: Mobile.IMobileHelper) { |
| 8 | + private $mobileHelper: Mobile.IMobileHelper, |
| 9 | + private $platformsData: IPlatformsData) { |
10 | 10 | }
|
11 | 11 |
|
12 |
| - public async getDevicesLiveSyncInfo(args: string[], devices: Mobile.IDevice[]): Promise<IDevicesDescriptorsLiveSyncInfo> { |
| 12 | + public async getDevicesLiveSyncInfo(devices: Mobile.IDevice[], liveSyncService: ILiveSyncService, platform: string): Promise<void> { |
13 | 13 | await this.$devicesService.detectCurrentlyAttachedDevices();
|
| 14 | + |
| 15 | + const workingWithiOSDevices = !platform || this.$mobileHelper.isiOSPlatform(platform); |
| 16 | + const shouldKeepProcessAlive = this.$options.watch || !this.$options.justlaunch; |
| 17 | + if (workingWithiOSDevices && shouldKeepProcessAlive) { |
| 18 | + this.$iosDeviceOperations.setShouldDispose(false); |
| 19 | + } |
| 20 | + |
| 21 | + if (this.$options.release || this.$options.bundle) { |
| 22 | + await this.runInReleaseMode(platform); |
| 23 | + return; |
| 24 | + } |
| 25 | + |
14 | 26 | // Now let's take data for each device:
|
15 | 27 | const deviceDescriptors: ILiveSyncDeviceInfo[] = devices
|
16 | 28 | .map(d => {
|
@@ -40,41 +52,35 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
|
40 | 52 | return info;
|
41 | 53 | });
|
42 | 54 |
|
43 |
| - const workingWithiOSDevices = !this.platform || this.$mobileHelper.isiOSPlatform(this.platform); |
44 |
| - const shouldKeepProcessAlive = this.$options.watch || !this.$options.justlaunch; |
45 |
| - if (workingWithiOSDevices && shouldKeepProcessAlive) { |
46 |
| - this.$iosDeviceOperations.setShouldDispose(false); |
47 |
| - } |
48 |
| - |
49 |
| - // TODO: test it, might have isuues with `tns run` (no args) |
50 |
| - if (this.$options.release || this.$options.bundle) { |
51 |
| - const runPlatformOptions: IRunPlatformOptions = { |
52 |
| - device: this.$options.device, |
53 |
| - emulator: this.$options.emulator, |
54 |
| - justlaunch: this.$options.justlaunch |
55 |
| - }; |
56 |
| - |
57 |
| - const deployOptions = _.merge<IDeployPlatformOptions>({ |
58 |
| - projectDir: this.$projectData.projectDir, |
59 |
| - clean: true, |
60 |
| - }, this.$options.argv); |
61 |
| - |
62 |
| - await this.$platformService.deployPlatform(args[0], this.$options, deployOptions, this.$projectData, this.$options); |
63 |
| - await this.$platformService.startApplication(args[0], runPlatformOptions, this.$projectData.projectId); |
64 |
| - this.$platformService.trackProjectType(this.$projectData); |
65 |
| - } |
66 |
| - |
67 | 55 | const liveSyncInfo: ILiveSyncInfo = {
|
68 | 56 | projectDir: this.$projectData.projectDir,
|
69 | 57 | skipWatcher: !this.$options.watch,
|
70 | 58 | watchAllFiles: this.$options.syncAllFiles,
|
71 | 59 | clean: this.$options.clean
|
72 | 60 | };
|
73 | 61 |
|
74 |
| - return { |
75 |
| - deviceDescriptors, |
76 |
| - liveSyncInfo |
| 62 | + await liveSyncService.liveSync(deviceDescriptors, liveSyncInfo); |
| 63 | + |
| 64 | + } |
| 65 | + |
| 66 | + private async runInReleaseMode(platform: string): Promise<void> { |
| 67 | + const runPlatformOptions: IRunPlatformOptions = { |
| 68 | + device: this.$options.device, |
| 69 | + emulator: this.$options.emulator, |
| 70 | + justlaunch: this.$options.justlaunch |
77 | 71 | };
|
| 72 | + |
| 73 | + const deployOptions = _.merge<IDeployPlatformOptions>({ |
| 74 | + projectDir: this.$projectData.projectDir, |
| 75 | + clean: true, |
| 76 | + }, this.$options.argv); |
| 77 | + |
| 78 | + const availablePlatforms = platform ? [platform] : _.values<string>(this.$platformsData.availablePlatforms); |
| 79 | + for (const currentPlatform of availablePlatforms) { |
| 80 | + await this.$platformService.deployPlatform(currentPlatform, this.$options, deployOptions, this.$projectData, this.$options); |
| 81 | + await this.$platformService.startApplication(currentPlatform, runPlatformOptions, this.$projectData.projectId); |
| 82 | + this.$platformService.trackProjectType(this.$projectData); |
| 83 | + } |
78 | 84 | }
|
79 | 85 | }
|
80 | 86 |
|
|
0 commit comments