From 53bba6b2246426e09f38199dc1501f4d8c5c4208 Mon Sep 17 00:00:00 2001 From: farfromrefuge Date: Fri, 1 Dec 2023 10:28:51 +0100 Subject: [PATCH] feat: new `syncChangedDataOnDevices`. also send the changed files in `IFilesChangeEventData` so that hooks can know what files have changed # Conflicts: # lib/controllers/prepare-controller.ts --- lib/controllers/prepare-controller.ts | 2 +- lib/controllers/run-controller.ts | 15 ++++++++++++--- lib/services/project-changes-service.ts | 3 ++- lib/services/webpack/webpack.d.ts | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/controllers/prepare-controller.ts b/lib/controllers/prepare-controller.ts index 8c22fe3e61..b465765ce4 100644 --- a/lib/controllers/prepare-controller.ts +++ b/lib/controllers/prepare-controller.ts @@ -289,7 +289,7 @@ export class PrepareController extends EventEmitter { data.platform.toLowerCase() === platformData.platformNameLowerCase ) { if (this.isFileWatcherPaused()) return; - this.emitPrepareEvent({ ...data, hasNativeChanges: false }); + this.emitPrepareEvent({ ...data, files: data.files || [], hasNativeChanges: false }); } }; diff --git a/lib/controllers/run-controller.ts b/lib/controllers/run-controller.ts index b05805884b..bc650077ea 100644 --- a/lib/controllers/run-controller.ts +++ b/lib/controllers/run-controller.ts @@ -12,7 +12,7 @@ import * as util from "util"; import * as _ from "lodash"; import { IProjectDataService, IProjectData } from "../definitions/project"; import { IBuildController } from "../definitions/build"; -import { IPlatformsDataService } from "../definitions/platform"; +import { IPlatformData, IPlatformsDataService } from "../definitions/platform"; import { IDebugController } from "../definitions/debug"; import { IPluginsService } from "../definitions/plugins"; import { @@ -23,6 +23,7 @@ import { } from "../common/declarations"; import { IInjector } from "../common/definitions/yok"; import { injector } from "../common/yok"; +import { hook } from "../common/helpers"; export class RunController extends EventEmitter implements IRunController { private prepareReadyEventHandler: any = null; @@ -95,17 +96,23 @@ export class RunController extends EventEmitter implements IRunController { const changesInfo = await this.$projectChangesService.checkForChanges( platformData, projectData, - prepareData + prepareData, + data ); if (changesInfo.hasChanges) { await this.syncChangedDataOnDevices( data, projectData, + platformData, liveSyncInfo ); } } else { - await this.syncChangedDataOnDevices(data, projectData, liveSyncInfo); + const platformData = this.$platformsDataService.getPlatformData( + data.platform, + projectData + ); + await this.syncChangedDataOnDevices(data, projectData, platformData, liveSyncInfo); } }; @@ -623,9 +630,11 @@ export class RunController extends EventEmitter implements IRunController { ); } + @hook("syncChangedDataOnDevices") private async syncChangedDataOnDevices( data: IFilesChangeEventData, projectData: IProjectData, + platformData: IPlatformData, liveSyncInfo: ILiveSyncInfo ): Promise { const successfullySyncedMessageFormat = `Successfully synced application %s on device %s.`; diff --git a/lib/services/project-changes-service.ts b/lib/services/project-changes-service.ts index edb9b2593d..5785167ee5 100644 --- a/lib/services/project-changes-service.ts +++ b/lib/services/project-changes-service.ts @@ -74,7 +74,8 @@ export class ProjectChangesService implements IProjectChangesService { public async checkForChanges( platformData: IPlatformData, projectData: IProjectData, - prepareData: IPrepareData + prepareData: IPrepareData, + filesChangedData?: IFilesChangeEventData ): Promise { this._changesInfo = new ProjectChangesInfo(); const isNewPrepareInfo = await this.ensurePrepareInfo( diff --git a/lib/services/webpack/webpack.d.ts b/lib/services/webpack/webpack.d.ts index e3a8dddd8b..606b3efbb5 100644 --- a/lib/services/webpack/webpack.d.ts +++ b/lib/services/webpack/webpack.d.ts @@ -42,7 +42,8 @@ declare global { checkForChanges( platformData: IPlatformData, projectData: IProjectData, - prepareData: IPrepareData + prepareData: IPrepareData, + filesChangedData?: IFilesChangeEventData ): Promise; getPrepareInfoFilePath(platformData: IPlatformData): string; getPrepareInfo(platformData: IPlatformData): IPrepareInfo;