From ed427db5f25a76457f6c6d4a6192560cffd8f67f Mon Sep 17 00:00:00 2001 From: fatme Date: Mon, 23 Jul 2018 11:48:31 +0300 Subject: [PATCH] Skip local prepare when executing cloud build from sidekick and no project's file is changed --- lib/services/platform-service.ts | 44 ++++++++++++------------- lib/services/project-changes-service.ts | 6 ++-- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 6b73941bd5..4f3800be28 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -197,10 +197,27 @@ export class PlatformService extends EventEmitter implements IPlatformService { return shouldPrepareInfo.changesInfo.hasChanges || requiresNativePrepare; } - private async getChangesInfo(platformInfo: IPreparePlatformInfo): Promise { - const platformData = this.$platformsData.getPlatformData(platformInfo.platform, platformInfo.projectData); + private async getChangesInfo(preparePlatformInfo: IPreparePlatformInfo): Promise { + await this.initialPrepare(preparePlatformInfo); - return this.initialPrepare(platformInfo.platform, platformData, platformInfo.appFilesUpdaterOptions, platformInfo.platformTemplate, platformInfo.projectData, platformInfo.config, platformInfo.nativePrepare, platformInfo); + const { platform, appFilesUpdaterOptions, projectData, config, nativePrepare } = preparePlatformInfo; + const bundle = appFilesUpdaterOptions.bundle; + const nativePlatformStatus = (nativePrepare && nativePrepare.skipNativePrepare) ? constants.NativePlatformStatus.requiresPlatformAdd : constants.NativePlatformStatus.requiresPrepare; + const changesInfo = await this.$projectChangesService.checkForChanges({ + platform, + projectData, + projectChangesOptions: { + bundle, + release: appFilesUpdaterOptions.release, + provision: config.provision, + teamId: config.teamId, + nativePlatformStatus, + skipModulesNativeCheck: preparePlatformInfo.skipModulesNativeCheck + } + }); + + this.$logger.trace("Changes info in prepare platform:", changesInfo); + return changesInfo; } public async preparePlatform(platformInfo: IPreparePlatformInfo): Promise { @@ -252,7 +269,8 @@ export class PlatformService extends EventEmitter implements IPlatformService { } } - private async initialPrepare(platform: string, platformData: IPlatformData, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions, nativePrepare?: INativePrepare, skipNativeCheckOptions?: ISkipNativeCheckOptional): Promise { + private async initialPrepare(preparePlatformInfo: IPreparePlatformInfo) { + const { platform, appFilesUpdaterOptions, platformTemplate, projectData, config, nativePrepare } = preparePlatformInfo; this.validatePlatform(platform, projectData); await this.trackProjectType(projectData); @@ -266,24 +284,6 @@ export class PlatformService extends EventEmitter implements IPlatformService { } await this.ensurePlatformInstalled(platform, platformTemplate, projectData, config, appFilesUpdaterOptions, nativePrepare); - - const bundle = appFilesUpdaterOptions.bundle; - const nativePlatformStatus = (nativePrepare && nativePrepare.skipNativePrepare) ? constants.NativePlatformStatus.requiresPlatformAdd : constants.NativePlatformStatus.requiresPrepare; - const changesInfo = await this.$projectChangesService.checkForChanges({ - platform, - projectData, - projectChangesOptions: { - bundle, - release: appFilesUpdaterOptions.release, - provision: config.provision, - teamId: config.teamId, - nativePlatformStatus, - skipModulesNativeCheck: skipNativeCheckOptions.skipModulesNativeCheck - } - }); - - this.$logger.trace("Changes info in prepare platform:", changesInfo); - return changesInfo; } /* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/ diff --git a/lib/services/project-changes-service.ts b/lib/services/project-changes-service.ts index 7c92087431..4432348a84 100644 --- a/lib/services/project-changes-service.ts +++ b/lib/services/project-changes-service.ts @@ -99,8 +99,10 @@ export class ProjectChangesService implements IProjectChangesService { } } - const projectService = platformData.platformProjectService; - await projectService.checkForChanges(this._changesInfo, projectChangesOptions, projectData); + if (checkForChangesOpts.projectChangesOptions.nativePlatformStatus !== NativePlatformStatus.requiresPlatformAdd) { + const projectService = platformData.platformProjectService; + await projectService.checkForChanges(this._changesInfo, projectChangesOptions, projectData); + } if (projectChangesOptions.bundle !== this._prepareInfo.bundle || projectChangesOptions.release !== this._prepareInfo.release) { this._changesInfo.appFilesChanged = true;