Skip to content

fix: fix cloud deploy command #4810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/common/mobile/mobile-core/devices-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
12 changes: 7 additions & 5 deletions lib/controllers/deploy-controller.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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));
Expand Down
1 change: 0 additions & 1 deletion lib/definitions/run.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ declare global {
}

interface IDeployData {
buildData: IBuildData;
deviceDescriptors: ILiveSyncDeviceDescriptor[];
}

Expand Down
9 changes: 3 additions & 6 deletions lib/helpers/deploy-command-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
11 changes: 3 additions & 8 deletions lib/helpers/livesync-command-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
return { liveSyncInfo, deviceDescriptors };
}

private async runInRelease(platform: string, deviceDescriptors: ILiveSyncDeviceDescriptor[], liveSyncInfo: ILiveSyncInfo): Promise<void> {
private async runInRelease(platform: string, deviceDescriptors: ILiveSyncDeviceDescriptor[]): Promise<void> {
await this.$devicesService.initialize({
platform,
deviceId: this.$options.device,
Expand All @@ -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);
Expand Down