Skip to content

provided more information to plugin authors #2605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/definitions/platform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ interface IPlatformService extends NodeJS.EventEmitter {
* @param {string} platformTemplate The name of the platform template.
* @param {IProjectData} projectData DTO with information about the project.
* @param {IPlatformSpecificData} platformSpecificData Platform specific data required for project preparation.
* @param {Array} filesToSync Files about to be synced to device.
* @returns {boolean} true indicates that the platform was prepared.
*/
preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, platformSpecificData: IPlatformSpecificData): Promise<boolean>;
preparePlatform(platform: string, appFilesUpdaterOptions: IAppFilesUpdaterOptions, platformTemplate: string, projectData: IProjectData, platformSpecificData: IPlatformSpecificData, filesToSync?: Array<String>): Promise<boolean>;

/**
* Determines whether a build is necessary. A build is necessary when one of the following is true:
Expand Down
2 changes: 1 addition & 1 deletion lib/services/livesync/platform-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
let batch = this.batch[platform];
await batch.syncFiles(async (filesToSync: string[]) => {
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
await this.$platformService.preparePlatform(this.liveSyncData.platform, appFilesUpdaterOptions, this.$options.platformTemplate, projectData, { provision: this.$options.provision, sdk: this.$options.sdk });
await this.$platformService.preparePlatform(this.liveSyncData.platform, appFilesUpdaterOptions, this.$options.platformTemplate, projectData, { provision: this.$options.provision, sdk: this.$options.sdk }, filesToSync);
let canExecute = this.getCanExecuteAction(this.liveSyncData.platform, this.liveSyncData.appIdentifier);
let deviceFileAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => this.transferFiles(deviceAppData, localToDevicePaths, this.liveSyncData.projectFilesPath, !filePath);
let action = this.getSyncAction(filesToSync, deviceFileAction, afterFileSyncAction, projectData);
Expand Down
7 changes: 4 additions & 3 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
return _.filter(this.$platformsData.platformsNames, p => { return this.isPlatformPrepared(p, projectData); });
}

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

await this.trackProjectType(projectData);
Expand Down Expand Up @@ -229,7 +229,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}
}

await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, platformSpecificData, changesInfo);
await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, platformSpecificData, changesInfo, filesToSync);
this.$projectChangesService.savePrepareInfo(platform, projectData);
} else {
this.$logger.out("Skipping prepare.");
Expand All @@ -256,8 +256,9 @@ export class PlatformService extends EventEmitter implements IPlatformService {
}
}

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

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