Skip to content

Commit 31781bb

Browse files
authored
provided more information to plugin authors (#2605)
* provided more information to plugin authors plugin authors needed more information on what files have changed during livesync we no provide this information through hookArgs.filesToSync, which is a string array full with all detected changed files * added a comment to explain parameter
1 parent 0d3e921 commit 31781bb

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/definitions/platform.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ interface IPlatformService extends NodeJS.EventEmitter {
4242
* @param {string} platformTemplate The name of the platform template.
4343
* @param {IProjectData} projectData DTO with information about the project.
4444
* @param {IPlatformSpecificData} platformSpecificData Platform specific data required for project preparation.
45+
* @param {Array} filesToSync Files about to be synced to device.
4546
* @returns {boolean} true indicates that the platform was prepared.
4647
*/
47-
preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, platformSpecificData: IPlatformSpecificData): Promise<boolean>;
48+
preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, filesToSync?: Array<String>): Promise<boolean>;
4849

4950
/**
5051
* Determines whether a build is necessary. A build is necessary when one of the following is true:

lib/services/livesync/platform-livesync-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
123123
let batch = this.batch[platform];
124124
await batch.syncFiles(async (filesToSync: string[]) => {
125125
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
126-
await this.$platformService.preparePlatform(this.liveSyncData.platform, appFilesUpdaterOptions, this.$options.platformTemplate, projectData, { provision: this.$options.provision, sdk: this.$options.sdk });
126+
await this.$platformService.preparePlatform(this.liveSyncData.platform, appFilesUpdaterOptions, this.$options.platformTemplate, projectData, { provision: this.$options.provision, sdk: this.$options.sdk }, filesToSync);
127127
let canExecute = this.getCanExecuteAction(this.liveSyncData.platform, this.liveSyncData.appIdentifier);
128128
let deviceFileAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => this.transferFiles(deviceAppData, localToDevicePaths, this.liveSyncData.projectFilesPath, !filePath);
129129
let action = this.getSyncAction(filesToSync, deviceFileAction, afterFileSyncAction, projectData);

lib/services/platform-service.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
192192
return _.filter(this.$platformsData.platformsNames, p => { return this.isPlatformPrepared(p, projectData); });
193193
}
194194

195-
public async preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, platformSpecificData: IPlatformSpecificData): Promise<boolean> {
195+
public async preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, filesToSync?: Array<String>): Promise<boolean> {
196196
this.validatePlatform(platform, projectData);
197197

198198
await this.trackProjectType(projectData);
@@ -231,7 +231,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
231231
}
232232
}
233233

234-
await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, platformSpecificData, changesInfo);
234+
await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, platformSpecificData, changesInfo, filesToSync);
235235
this.$projectChangesService.savePrepareInfo(platform, projectData);
236236
} else {
237237
this.$logger.out("Skipping prepare.");
@@ -258,8 +258,9 @@ export class PlatformService extends EventEmitter implements IPlatformService {
258258
}
259259
}
260260

261+
/* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/
261262
@helpers.hook('prepare')
262-
private async preparePlatformCore(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, changesInfo?: IProjectChangesInfo): Promise<void> {
263+
private async preparePlatformCore(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, changesInfo?: IProjectChangesInfo, filesToSync?: Array<String>): Promise<void> {
263264
this.$logger.out("Preparing project...");
264265

265266
let platformData = this.$platformsData.getPlatformData(platform, projectData);

0 commit comments

Comments
 (0)