Skip to content

Commit 487b30d

Browse files
committed
refactor: update after review
1 parent 91e6005 commit 487b30d

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
@@ -76,7 +76,7 @@ interface IPlatformService extends NodeJS.EventEmitter {
7676
* @param {string} @optional outputPath Directory containing build information and artifacts.
7777
* @returns {Promise<boolean>} true indicates that the application should be installed.
7878
*/
79-
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: boolean, outputPath?: string): Promise<boolean>;
79+
shouldInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<boolean>;
8080

8181
/**
8282
* Determines whether the project should undergo the prepare process.
@@ -255,7 +255,7 @@ interface IPlatformData {
255255
projectRoot: string;
256256
normalizedPlatformName: string;
257257
appDestinationDirectoryPath: string;
258-
deviceBuildOutputPath(options: IRelease): string;
258+
getDeviceBuildOutputPath(options: IRelease): string;
259259
emulatorBuildOutputPath?: string;
260260
getValidPackageNames(buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): string[];
261261
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
@@ -82,7 +82,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
8282
platformProjectService: this,
8383
emulatorServices: this.$androidEmulatorServices,
8484
projectRoot: projectRoot,
85-
deviceBuildOutputPath: (options: IRelease): string => {
85+
getDeviceBuildOutputPath: (options: IRelease): string => {
8686
return this.getDeviceBuildOutputPath(path.join(...deviceBuildOutputArr), projectData, options);
8787
},
8888
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
@@ -70,7 +70,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
7070
platformProjectService: this,
7171
emulatorServices: this.$iOSEmulatorServices,
7272
projectRoot: projectRoot,
73-
deviceBuildOutputPath: (options: IRelease): string => {
73+
getDeviceBuildOutputPath: (options: IRelease): string => {
7474
return path.join(projectRoot, "build", "device");
7575
},
7676
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
@@ -332,7 +332,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
332332

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

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

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

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

515-
if (deployInfo.deployOptions.forceInstall || shouldBuild || (await this.shouldInstall(device, deployInfo.projectData, buildConfig.release))) {
515+
if (deployInfo.deployOptions.forceInstall || shouldBuild || (await this.shouldInstall(device, deployInfo.projectData, buildConfig))) {
516516
await this.installApplication(device, buildConfig, deployInfo.projectData);
517517
} else {
518518
this.$logger.out("Skipping install.");
@@ -547,12 +547,12 @@ export class PlatformService extends EventEmitter implements IPlatformService {
547547
await this.$devicesService.execute(action, this.getCanExecuteAction(platform, runOptions));
548548
}
549549

550-
private getBuildOutputPath(platform: string, platformData: IPlatformData, options: IBuildForDevice): string {
550+
private getBuildOutputPath(platform: string, platformData: IPlatformData, options: IShouldInstall): string {
551551
if (platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLowerCase()) {
552-
return options.buildForDevice ? platformData.deviceBuildOutputPath(options) : platformData.emulatorBuildOutputPath;
552+
return options.buildForDevice ? platformData.getDeviceBuildOutputPath(options) : platformData.emulatorBuildOutputPath;
553553
}
554554

555-
return platformData.deviceBuildOutputPath(options);
555+
return platformData.getDeviceBuildOutputPath(options);
556556
}
557557

558558
private async getDeviceBuildInfoFilePath(device: Mobile.IDevice, projectData: IProjectData): Promise<string> {
@@ -572,7 +572,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
572572
}
573573
}
574574

575-
private getBuildInfo(platform: string, platformData: IPlatformData, options: IBuildForDevice, buildOutputPath?: string): IBuildInfo {
575+
private getBuildInfo(platform: string, platformData: IPlatformData, options: IShouldInstall, buildOutputPath?: string): IBuildInfo {
576576
buildOutputPath = buildOutputPath || this.getBuildOutputPath(platform, platformData, options);
577577
const buildInfoFile = path.join(buildOutputPath, buildInfoFileName);
578578
if (this.$fs.exists(buildInfoFile)) {
@@ -762,11 +762,11 @@ export class PlatformService extends EventEmitter implements IPlatformService {
762762
}
763763

764764
public getLatestApplicationPackageForDevice(platformData: IPlatformData, buildConfig: IBuildConfig, outputPath?: string): IApplicationPackage {
765-
return this.getLatestApplicationPackage(outputPath || platformData.deviceBuildOutputPath(buildConfig), platformData.getValidPackageNames({ isForDevice: true, isReleaseBuild: buildConfig.release }));
765+
return this.getLatestApplicationPackage(outputPath || platformData.getDeviceBuildOutputPath(buildConfig), platformData.getValidPackageNames({ isForDevice: true, isReleaseBuild: buildConfig.release }));
766766
}
767767

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

772772
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
@@ -294,7 +294,7 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
294294
platformProjectService: this,
295295
emulatorServices: undefined,
296296
projectRoot: "",
297-
deviceBuildOutputPath: (buildTypeOption: IRelease) => {
297+
getDeviceBuildOutputPath: (buildTypeOption: IRelease) => {
298298
return "";
299299
},
300300
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
@@ -392,7 +392,7 @@ export class PlatformsDataStub extends EventEmitter implements IPlatformsData {
392392
projectRoot: "",
393393
normalizedPlatformName: "",
394394
appDestinationDirectoryPath: "",
395-
deviceBuildOutputPath: (buildTypeOption: IRelease) => {
395+
getDeviceBuildOutputPath: (buildTypeOption: IRelease) => {
396396
return "";
397397
},
398398
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],

0 commit comments

Comments
 (0)