From e5eb03214a5dee57ba9205e50a85ff7f08c773f3 Mon Sep 17 00:00:00 2001 From: fatme Date: Fri, 5 Jul 2019 16:13:26 +0300 Subject: [PATCH 1/4] fix: fix cloud deploy command Currently `tns cloud deploy` command starts local build as the provided buildAction through deviceDescriptor is not executed from deployController. --- lib/controllers/deploy-controller.ts | 8 +++++--- lib/helpers/deploy-command-helper.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/controllers/deploy-controller.ts b/lib/controllers/deploy-controller.ts index 1574926ea4..8f9497617e 100644 --- a/lib/controllers/deploy-controller.ts +++ b/lib/controllers/deploy-controller.ts @@ -1,16 +1,18 @@ 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 executeAction = async (device: Mobile.IDevice) => { - const packageFilePath = await this.$buildController.prepareAndBuild({ ...buildData, buildForDevice: !device.isEmulator }); + await this.$prepareController.prepare(buildData); + const deviceDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier); + const packageFilePath = await deviceDescriptor.buildAction(); await this.$deviceInstallAppService.installOnDevice(device, { ...buildData, buildForDevice: !device.isEmulator }, packageFilePath); }; diff --git a/lib/helpers/deploy-command-helper.ts b/lib/helpers/deploy-command-helper.ts index ffc6ac0a89..607c3e8c77 100644 --- a/lib/helpers/deploy-command-helper.ts +++ b/lib/helpers/deploy-command-helper.ts @@ -36,7 +36,7 @@ export class DeployCommandHelper { 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, d.deviceInfo.platform, buildData, this.$projectData); const info: ILiveSyncDeviceDescriptor = { identifier: d.deviceInfo.identifier, From 5db1afc240d13827ccbbfce3af8f24d3c5bb4fa1 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Fri, 5 Jul 2019 17:58:36 +0300 Subject: [PATCH 2/4] fix: pass correct data to build controller from deploy command --- lib/helpers/deploy-command-helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers/deploy-command-helper.ts b/lib/helpers/deploy-command-helper.ts index 607c3e8c77..25f9feb78b 100644 --- a/lib/helpers/deploy-command-helper.ts +++ b/lib/helpers/deploy-command-helper.ts @@ -36,7 +36,7 @@ export class DeployCommandHelper { const buildAction = additionalOptions && additionalOptions.buildPlatform ? additionalOptions.buildPlatform.bind(additionalOptions.buildPlatform, d.deviceInfo.platform, buildData, this.$projectData) : - this.$buildController.build.bind(this.$buildController, d.deviceInfo.platform, buildData, this.$projectData); + this.$buildController.build.bind(this.$buildController, buildData); const info: ILiveSyncDeviceDescriptor = { identifier: d.deviceInfo.identifier, From fe3a348e186eae4cae33002ace9391c8db39441c Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Fri, 5 Jul 2019 17:58:55 +0300 Subject: [PATCH 3/4] fix: print full error with stacktrace when action on device fails --- lib/common/mobile/mobile-core/devices-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } } From 1672adcbebae01f3fa77367f738fa6370902c200 Mon Sep 17 00:00:00 2001 From: fatme Date: Mon, 8 Jul 2019 10:36:43 +0300 Subject: [PATCH 4/4] fix: fix deploy with provision Currently buildData is provided through deviceDescriptor so no need to provide it as a separate argument. --- lib/controllers/deploy-controller.ts | 6 +++--- lib/definitions/run.d.ts | 1 - lib/helpers/deploy-command-helper.ts | 7 ++----- lib/helpers/livesync-command-helper.ts | 11 +++-------- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/controllers/deploy-controller.ts b/lib/controllers/deploy-controller.ts index 8f9497617e..8c51ac20c3 100644 --- a/lib/controllers/deploy-controller.ts +++ b/lib/controllers/deploy-controller.ts @@ -7,13 +7,13 @@ export class DeployController { ) { } public async deploy(data: IDeployData): Promise { - const { buildData, deviceDescriptors } = data; + const { deviceDescriptors } = data; const executeAction = async (device: Mobile.IDevice) => { - await this.$prepareController.prepare(buildData); 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, { ...buildData, buildForDevice: !device.isEmulator }, packageFilePath); + 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 25f9feb78b..2ebc056765 100644 --- a/lib/helpers/deploy-command-helper.ts +++ b/lib/helpers/deploy-command-helper.ts @@ -32,7 +32,7 @@ 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) : @@ -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);