Skip to content

Commit d5c4eed

Browse files
committed
refactor: update after review
1 parent e437bd3 commit d5c4eed

File tree

8 files changed

+22
-19
lines changed

8 files changed

+22
-19
lines changed

lib/definitions/platform.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ interface IPlatformService extends IBuildPlatformAction, NodeJS.EventEmitter {
8181
* @param {string} @optional outputPath Directory containing build information and artifacts.
8282
* @returns {Promise<boolean>} true indicates that the application should be installed.
8383
*/
84-
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: boolean, outputPath?: string): Promise<boolean>;
84+
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<boolean>;
8585

8686
/**
8787
* Determines whether the project should undergo the prepare process.
@@ -260,7 +260,7 @@ interface IPlatformData {
260260
projectRoot: string;
261261
normalizedPlatformName: string;
262262
appDestinationDirectoryPath: string;
263-
deviceBuildOutputPath(options: IRelease): string;
263+
getDeviceBuildOutputPath(options: IRelease): string;
264264
emulatorBuildOutputPath?: string;
265265
getValidPackageNames(buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): string[];
266266
frameworkFilesExtensions: string[];

lib/definitions/project.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ interface IPlatformProjectServiceBase {
140140

141141
interface IBuildForDevice {
142142
buildForDevice: boolean;
143-
release: boolean;
143+
}
144+
145+
interface IShouldInstall extends IBuildForDevice, IRelease {
146+
144147
}
145148

146149
interface INativePrepare {

lib/services/android-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
8383
platformProjectService: this,
8484
emulatorServices: this.$androidEmulatorServices,
8585
projectRoot: projectRoot,
86-
deviceBuildOutputPath: (options: IRelease): string => {
86+
getDeviceBuildOutputPath: (options: IRelease): string => {
8787
return this.getDeviceBuildOutputPath(path.join(...deviceBuildOutputArr), projectData, options);
8888
},
8989
getValidPackageNames: (buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): string[] => {

lib/services/ios-project-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
7171
platformProjectService: this,
7272
emulatorServices: this.$iOSEmulatorServices,
7373
projectRoot: projectRoot,
74-
deviceBuildOutputPath: (options: IRelease): string => {
74+
getDeviceBuildOutputPath: (options: IRelease): string => {
7575
return path.join(projectRoot, "build", "device");
7676
},
7777
emulatorBuildOutputPath: path.join(projectRoot, "build", "emulator"),

lib/services/livesync/livesync-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
413413

414414
await this.trackAction(action, platform, options);
415415

416-
const shouldInstall = await this.$platformService.shouldInstall(options.device, options.projectData, options.release, options.deviceBuildInfoDescriptor.outputPath);
416+
const shouldInstall = await this.$platformService.shouldInstall(options.device, options.projectData, options, options.deviceBuildInfoDescriptor.outputPath);
417417
if (shouldInstall) {
418418
await this.$platformService.installApplication(options.device, { release: false }, options.projectData, pathToBuildItem, options.deviceBuildInfoDescriptor.outputPath);
419419
appInstalledOnDeviceResult.appInstalled = true;

lib/services/platform-service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
333333

334334
const platformData = this.$platformsData.getPlatformData(platform, projectData);
335335
const forDevice = !buildConfig || buildConfig.buildForDevice;
336-
outputPath = outputPath || (forDevice ? platformData.deviceBuildOutputPath(buildConfig) : platformData.emulatorBuildOutputPath || platformData.deviceBuildOutputPath(buildConfig));
336+
outputPath = outputPath || (forDevice ? platformData.getDeviceBuildOutputPath(buildConfig) : platformData.emulatorBuildOutputPath || platformData.getDeviceBuildOutputPath(buildConfig));
337337
if (!this.$fs.exists(outputPath)) {
338338
return true;
339339
}
@@ -433,15 +433,15 @@ export class PlatformService extends EventEmitter implements IPlatformService {
433433
this.$fs.writeJson(buildInfoFile, buildInfo);
434434
}
435435

436-
public async shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: boolean, outputPath?: string): Promise<boolean> {
436+
public async shouldInstall(device: Mobile.IDevice, projectData: IProjectData, isRelease: IRelease, outputPath?: string): Promise<boolean> {
437437
const platform = device.deviceInfo.platform;
438438
if (!(await device.applicationManager.isApplicationInstalled(projectData.projectId))) {
439439
return true;
440440
}
441441

442442
const platformData = this.$platformsData.getPlatformData(platform, projectData);
443443
const deviceBuildInfo: IBuildInfo = await this.getDeviceBuildInfo(device, projectData);
444-
const localBuildInfo = this.getBuildInfo(platform, platformData, { buildForDevice: !device.isEmulator, release: false }, outputPath);
444+
const localBuildInfo = this.getBuildInfo(platform, platformData, { buildForDevice: !device.isEmulator, release: isRelease.release }, outputPath);
445445
return !localBuildInfo || !deviceBuildInfo || deviceBuildInfo.buildTime !== localBuildInfo.buildTime;
446446
}
447447

@@ -517,7 +517,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
517517
this.$logger.out("Skipping package build. No changes detected on the native side. This will be fast!");
518518
}
519519

520-
if (deployInfo.deployOptions.forceInstall || shouldBuild || (await this.shouldInstall(device, deployInfo.projectData, buildConfig.release))) {
520+
if (deployInfo.deployOptions.forceInstall || shouldBuild || (await this.shouldInstall(device, deployInfo.projectData, buildConfig))) {
521521
await this.installApplication(device, buildConfig, deployInfo.projectData);
522522
} else {
523523
this.$logger.out("Skipping install.");
@@ -552,12 +552,12 @@ export class PlatformService extends EventEmitter implements IPlatformService {
552552
await this.$devicesService.execute(action, this.getCanExecuteAction(platform, runOptions));
553553
}
554554

555-
private getBuildOutputPath(platform: string, platformData: IPlatformData, options: IBuildForDevice): string {
555+
private getBuildOutputPath(platform: string, platformData: IPlatformData, options: IShouldInstall): string {
556556
if (platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
557-
return options.buildForDevice ? platformData.deviceBuildOutputPath(options) : platformData.emulatorBuildOutputPath;
557+
return options.buildForDevice ? platformData.getDeviceBuildOutputPath(options) : platformData.emulatorBuildOutputPath;
558558
}
559559

560-
return platformData.deviceBuildOutputPath(options);
560+
return platformData.getDeviceBuildOutputPath(options);
561561
}
562562

563563
private async getDeviceBuildInfoFilePath(device: Mobile.IDevice, projectData: IProjectData): Promise<string> {
@@ -577,7 +577,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
577577
}
578578
}
579579

580-
private getBuildInfo(platform: string, platformData: IPlatformData, options: IBuildForDevice, buildOutputPath?: string): IBuildInfo {
580+
private getBuildInfo(platform: string, platformData: IPlatformData, options: IShouldInstall, buildOutputPath?: string): IBuildInfo {
581581
buildOutputPath = buildOutputPath || this.getBuildOutputPath(platform, platformData, options);
582582
const buildInfoFile = path.join(buildOutputPath, buildInfoFileName);
583583
if (this.$fs.exists(buildInfoFile)) {
@@ -767,11 +767,11 @@ export class PlatformService extends EventEmitter implements IPlatformService {
767767
}
768768

769769
public getLatestApplicationPackageForDevice(platformData: IPlatformData, buildConfig: IBuildConfig, outputPath?: string): IApplicationPackage {
770-
return this.getLatestApplicationPackage(outputPath || platformData.deviceBuildOutputPath(buildConfig), platformData.getValidPackageNames({ isForDevice: true, isReleaseBuild: buildConfig.release }));
770+
return this.getLatestApplicationPackage(outputPath || platformData.getDeviceBuildOutputPath(buildConfig), platformData.getValidPackageNames({ isForDevice: true, isReleaseBuild: buildConfig.release }));
771771
}
772772

773773
public getLatestApplicationPackageForEmulator(platformData: IPlatformData, buildConfig: IBuildConfig, outputPath?: string): IApplicationPackage {
774-
return this.getLatestApplicationPackage(outputPath || platformData.emulatorBuildOutputPath || platformData.deviceBuildOutputPath(buildConfig), platformData.getValidPackageNames({ isForDevice: false, isReleaseBuild: buildConfig.release }));
774+
return this.getLatestApplicationPackage(outputPath || platformData.emulatorBuildOutputPath || platformData.getDeviceBuildOutputPath(buildConfig), platformData.getValidPackageNames({ isForDevice: false, isReleaseBuild: buildConfig.release }));
775775
}
776776

777777
private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {

test/platform-commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PlatformData implements IPlatformData {
3535
};
3636
emulatorServices: Mobile.IEmulatorPlatformServices = null;
3737
projectRoot = "";
38-
deviceBuildOutputPath = (buildTypeOption: IRelease) => {
38+
getDeviceBuildOutputPath = (buildTypeOption: IRelease) => {
3939
return "";
4040
}
4141
getValidPackageNames = (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [""];

test/stubs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
304304
platformProjectService: this,
305305
emulatorServices: undefined,
306306
projectRoot: "",
307-
deviceBuildOutputPath: (buildTypeOption: IRelease) => {
307+
getDeviceBuildOutputPath: (buildTypeOption: IRelease) => {
308308
return "";
309309
},
310310
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
@@ -417,7 +417,7 @@ export class PlatformsDataStub extends EventEmitter implements IPlatformsData {
417417
projectRoot: "",
418418
normalizedPlatformName: "",
419419
appDestinationDirectoryPath: "",
420-
deviceBuildOutputPath: (buildTypeOption: IRelease) => {
420+
getDeviceBuildOutputPath: (buildTypeOption: IRelease) => {
421421
return "";
422422
},
423423
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],

0 commit comments

Comments
 (0)