diff --git a/lib/common/mobile/mobile-core/devices-service.ts b/lib/common/mobile/mobile-core/devices-service.ts index 347f5d5c52..ea8a843657 100644 --- a/lib/common/mobile/mobile-core/devices-service.ts +++ b/lib/common/mobile/mobile-core/devices-service.ts @@ -444,7 +444,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi } } catch (err) { err.deviceIdentifier = device.deviceInfo.identifier; - this.$logger.trace(`Error while executing action on device ${device.deviceInfo.identifier}. The error is ${err}`); + this.$logger.trace(`Error while executing action on device ${device.deviceInfo.identifier}. The error is`, err); errors.push(err); } } diff --git a/lib/controllers/deploy-controller.ts b/lib/controllers/deploy-controller.ts index 1574926ea4..8c51ac20c3 100644 --- a/lib/controllers/deploy-controller.ts +++ b/lib/controllers/deploy-controller.ts @@ -1,17 +1,19 @@ export class DeployController { constructor( - private $buildController: IBuildController, private $deviceInstallAppService: IDeviceInstallAppService, - private $devicesService: Mobile.IDevicesService + private $devicesService: Mobile.IDevicesService, + private $prepareController: IPrepareController ) { } public async deploy(data: IDeployData): Promise { - const { buildData, deviceDescriptors } = data; + const { deviceDescriptors } = data; const executeAction = async (device: Mobile.IDevice) => { - const packageFilePath = await this.$buildController.prepareAndBuild({ ...buildData, buildForDevice: !device.isEmulator }); - await this.$deviceInstallAppService.installOnDevice(device, { ...buildData, buildForDevice: !device.isEmulator }, packageFilePath); + const deviceDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier); + await this.$prepareController.prepare(deviceDescriptor.buildData); + const packageFilePath = await deviceDescriptor.buildAction(); + await this.$deviceInstallAppService.installOnDevice(device, { ...deviceDescriptor.buildData, buildForDevice: !device.isEmulator }, packageFilePath); }; await this.$devicesService.execute(executeAction, (device: Mobile.IDevice) => _.some(deviceDescriptors, deviceDescriptor => deviceDescriptor.identifier === device.deviceInfo.identifier)); diff --git a/lib/definitions/run.d.ts b/lib/definitions/run.d.ts index 3dfe93169a..f0b9091065 100644 --- a/lib/definitions/run.d.ts +++ b/lib/definitions/run.d.ts @@ -8,7 +8,6 @@ declare global { } interface IDeployData { - buildData: IBuildData; deviceDescriptors: ILiveSyncDeviceDescriptor[]; } diff --git a/lib/helpers/deploy-command-helper.ts b/lib/helpers/deploy-command-helper.ts index ffc6ac0a89..2ebc056765 100644 --- a/lib/helpers/deploy-command-helper.ts +++ b/lib/helpers/deploy-command-helper.ts @@ -32,11 +32,11 @@ export class DeployCommandHelper { projectDir: this.$projectData.projectDir }); - const buildData = this.$buildDataService.getBuildData(this.$projectData.projectDir, d.deviceInfo.platform, { ...this.$options, outputPath, buildForDevice: !d.isEmulator }); + const buildData = this.$buildDataService.getBuildData(this.$projectData.projectDir, d.deviceInfo.platform, { ...this.$options.argv, outputPath, buildForDevice: !d.isEmulator, skipWatcher: !this.$options.watch }); const buildAction = additionalOptions && additionalOptions.buildPlatform ? additionalOptions.buildPlatform.bind(additionalOptions.buildPlatform, d.deviceInfo.platform, buildData, this.$projectData) : - this.$buildController.prepareAndBuild.bind(this.$buildController, d.deviceInfo.platform, buildData, this.$projectData); + this.$buildController.build.bind(this.$buildController, buildData); const info: ILiveSyncDeviceDescriptor = { identifier: d.deviceInfo.identifier, @@ -50,10 +50,7 @@ export class DeployCommandHelper { return info; }); - await this.$deployController.deploy({ - buildData: this.$buildDataService.getBuildData(this.$projectData.projectDir, platform, { ...this.$options.argv, skipWatcher: !this.$options.watch }), - deviceDescriptors - }); + await this.$deployController.deploy({ deviceDescriptors }); } } $injector.register("deployCommandHelper", DeployCommandHelper); diff --git a/lib/helpers/livesync-command-helper.ts b/lib/helpers/livesync-command-helper.ts index ea2fbc1e5d..fcc6d26076 100644 --- a/lib/helpers/livesync-command-helper.ts +++ b/lib/helpers/livesync-command-helper.ts @@ -100,7 +100,7 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper { const { liveSyncInfo, deviceDescriptors } = await this.executeLiveSyncOperationCore(devices, platform, additionalOptions); if (this.$options.release) { - await this.runInRelease(platform, deviceDescriptors, liveSyncInfo); + await this.runInRelease(platform, deviceDescriptors); return; } @@ -160,7 +160,7 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper { return { liveSyncInfo, deviceDescriptors }; } - private async runInRelease(platform: string, deviceDescriptors: ILiveSyncDeviceDescriptor[], liveSyncInfo: ILiveSyncInfo): Promise { + private async runInRelease(platform: string, deviceDescriptors: ILiveSyncDeviceDescriptor[]): Promise { await this.$devicesService.initialize({ platform, deviceId: this.$options.device, @@ -169,12 +169,7 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper { sdk: this.$options.sdk }); - const buildData = this.$buildDataService.getBuildData(liveSyncInfo.projectDir, platform, { ...this.$options.argv, clean: true, watch: false }); - - await this.$deployController.deploy({ - buildData, - deviceDescriptors - }); + await this.$deployController.deploy({ deviceDescriptors }); for (const deviceDescriptor of deviceDescriptors) { const device = this.$devicesService.getDeviceByIdentifier(deviceDescriptor.identifier);