Skip to content

fix: save correct .nsprepareinfo file on cloud commands #4719

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
Jun 13, 2019
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
2 changes: 1 addition & 1 deletion lib/controllers/prepare-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class PrepareController extends EventEmitter {
result = { hasNativeChanges, platform: prepareData.platform.toLowerCase() };
}

this.$projectChangesService.savePrepareInfo(platformData);
await this.$projectChangesService.savePrepareInfo(platformData, projectData, prepareData);

this.$logger.info(`Project successfully prepared (${prepareData.platform.toLowerCase()})`);

Expand Down
2 changes: 1 addition & 1 deletion lib/services/platform/add-platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AddPlatformService implements IAddPlatformService {
platformData.platformProjectService.ensureConfigurationFileInAppResources(projectData);
await platformData.platformProjectService.interpolateData(projectData);
platformData.platformProjectService.afterCreateProject(platformData.projectRoot, projectData);
this.$projectChangesService.setNativePlatformStatus(platformData, { nativePlatformStatus: NativePlatformStatus.requiresPrepare });
await this.$projectChangesService.setNativePlatformStatus(platformData, projectData, { nativePlatformStatus: NativePlatformStatus.requiresPrepare });
}
}
$injector.register("addPlatformService", AddPlatformService);
2 changes: 1 addition & 1 deletion lib/services/platform/prepare-native-platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class PrepareNativePlatformService implements IPrepareNativePlatformServi
}

platformData.platformProjectService.interpolateConfigurationFile(projectData);
this.$projectChangesService.setNativePlatformStatus(platformData, { nativePlatformStatus: NativePlatformStatus.alreadyPrepared });
await this.$projectChangesService.setNativePlatformStatus(platformData, projectData, { nativePlatformStatus: NativePlatformStatus.alreadyPrepared });

return hasChanges;
}
Expand Down
10 changes: 7 additions & 3 deletions lib/services/project-changes-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,16 @@ export class ProjectChangesService implements IProjectChangesService {
return prepareInfo;
}

public savePrepareInfo(platformData: IPlatformData): void {
public async savePrepareInfo(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise<void> {
if (!this._prepareInfo) {
await this.ensurePrepareInfo(platformData, projectData, prepareData);
}

const prepareInfoFilePath = this.getPrepareInfoFilePath(platformData);
this.$fs.writeJson(prepareInfoFilePath, this._prepareInfo);
}

public setNativePlatformStatus(platformData: IPlatformData, addedPlatform: IAddedNativePlatform): void {
public async setNativePlatformStatus(platformData: IPlatformData, projectData: IProjectData, addedPlatform: IAddedNativePlatform): Promise<void> {
this._prepareInfo = this._prepareInfo || this.getPrepareInfo(platformData);
if (this._prepareInfo && addedPlatform.nativePlatformStatus === NativePlatformStatus.alreadyPrepared) {
this._prepareInfo.nativePlatformStatus = addedPlatform.nativePlatformStatus;
Expand All @@ -151,7 +155,7 @@ export class ProjectChangesService implements IProjectChangesService {
};
}

this.savePrepareInfo(platformData);
await this.savePrepareInfo(platformData, projectData, null);
}

private async ensurePrepareInfo(platformData: IPlatformData, projectData: IProjectData, prepareData: PrepareData): Promise<boolean> {
Expand Down
4 changes: 2 additions & 2 deletions lib/services/webpack/webpack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ declare global {
checkForChanges(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise<IProjectChangesInfo>;
getPrepareInfoFilePath(platformData: IPlatformData): string;
getPrepareInfo(platformData: IPlatformData): IPrepareInfo;
savePrepareInfo(platformData: IPlatformData): void;
setNativePlatformStatus(platformData: IPlatformData, addedPlatform: IAddedNativePlatform): void;
savePrepareInfo(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise<void>;
setNativePlatformStatus(platformData: IPlatformData, projectData: IProjectData, addedPlatform: IAddedNativePlatform): void;
currentChanges: IProjectChangesInfo;
}

Expand Down
10 changes: 5 additions & 5 deletions test/project-changes-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ describe("Project Changes Service Tests", () => {
});

describe("setNativePlatformStatus", () => {
it("creates prepare info and sets only the native platform status when there isn't an existing prepare info", () => {
it("creates prepare info and sets only the native platform status when there isn't an existing prepare info", async () => {
for (const platform of ["ios", "android"]) {
serviceTest.projectChangesService.setNativePlatformStatus(serviceTest.getPlatformData(platform), { nativePlatformStatus: Constants.NativePlatformStatus.requiresPrepare });
await serviceTest.projectChangesService.setNativePlatformStatus(serviceTest.getPlatformData(platform), serviceTest.projectData, { nativePlatformStatus: Constants.NativePlatformStatus.requiresPrepare });

const actualPrepareInfo = serviceTest.projectChangesService.getPrepareInfo(serviceTest.getPlatformData(platform));

Expand All @@ -183,10 +183,10 @@ describe("Project Changes Service Tests", () => {
it(`shouldn't reset prepare info when native platform status is ${Constants.NativePlatformStatus.alreadyPrepared} and there is existing prepare info`, async () => {
for (const platform of ["ios", "android"]) {
await serviceTest.projectChangesService.checkForChanges(serviceTest.getPlatformData(platform), serviceTest.projectData, <any>{});
serviceTest.projectChangesService.savePrepareInfo(serviceTest.getPlatformData(platform));
await serviceTest.projectChangesService.savePrepareInfo(serviceTest.getPlatformData(platform), serviceTest.projectData, null);
const prepareInfo = serviceTest.projectChangesService.getPrepareInfo(serviceTest.getPlatformData(platform));

serviceTest.projectChangesService.setNativePlatformStatus(serviceTest.getPlatformData(platform), { nativePlatformStatus: Constants.NativePlatformStatus.alreadyPrepared });
await serviceTest.projectChangesService.setNativePlatformStatus(serviceTest.getPlatformData(platform), serviceTest.projectData, { nativePlatformStatus: Constants.NativePlatformStatus.alreadyPrepared });

const actualPrepareInfo = serviceTest.projectChangesService.getPrepareInfo(serviceTest.getPlatformData(platform));
prepareInfo.nativePlatformStatus = Constants.NativePlatformStatus.alreadyPrepared;
Expand All @@ -198,7 +198,7 @@ describe("Project Changes Service Tests", () => {
it(`should reset prepare info when native platform status is ${nativePlatformStatus} and there is existing prepare info`, async () => {
for (const platform of ["ios", "android"]) {
await serviceTest.projectChangesService.checkForChanges(serviceTest.getPlatformData(platform), serviceTest.projectData, <any>{});
serviceTest.projectChangesService.setNativePlatformStatus(serviceTest.getPlatformData(platform), { nativePlatformStatus: nativePlatformStatus });
await serviceTest.projectChangesService.setNativePlatformStatus(serviceTest.getPlatformData(platform), serviceTest.projectData, { nativePlatformStatus: nativePlatformStatus });

const actualPrepareInfo = serviceTest.projectChangesService.getPrepareInfo(serviceTest.getPlatformData(platform));
assert.deepEqual(actualPrepareInfo, { nativePlatformStatus: nativePlatformStatus });
Expand Down
4 changes: 2 additions & 2 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ export class ProjectChangesService implements IProjectChangesService {
return null;
}

public savePrepareInfo(platformData: IPlatformData): void {
public async savePrepareInfo(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise<void> {
}

public getPrepareInfoFilePath(platformData: IPlatformData): string {
Expand All @@ -760,7 +760,7 @@ export class ProjectChangesService implements IProjectChangesService {
return <IProjectChangesInfo>{};
}

public setNativePlatformStatus(platformData: IPlatformData, addedPlatform: IAddedNativePlatform): void {
public async setNativePlatformStatus(platformData: IPlatformData, projectData: IProjectData, addedPlatform: IAddedNativePlatform): Promise<void> {
return;
}
}
Expand Down