Skip to content

Commit 91f9b8f

Browse files
committed
fix: execute correctly local build after cloud build from sidekick
Reset prepare info when native platform status is not alreadyPrepared in order to ensure the project will be prepared and all properties of this._prepareInfo will be correctly populated.
1 parent 3bc3814 commit 91f9b8f

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

lib/services/project-changes-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class ProjectChangesService implements IProjectChangesService {
171171

172172
public setNativePlatformStatus(platform: string, projectData: IProjectData, addedPlatform: IAddedNativePlatform): void {
173173
this._prepareInfo = this._prepareInfo || this.getPrepareInfo(platform, projectData);
174-
if (this._prepareInfo) {
174+
if (this._prepareInfo && addedPlatform.nativePlatformStatus === NativePlatformStatus.alreadyPrepared) {
175175
this._prepareInfo.nativePlatformStatus = addedPlatform.nativePlatformStatus;
176176
} else {
177177
this._prepareInfo = {

test/project-changes-service.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,51 @@ describe("Project Changes Service Tests", () => {
187187
assert.deepEqual(actualPrepareInfo, { nativePlatformStatus: Constants.NativePlatformStatus.requiresPrepare });
188188
}
189189
});
190+
191+
it(`shouldn't reset prepare info when native platform status is ${Constants.NativePlatformStatus.alreadyPrepared} and there is existing prepare info`, async () => {
192+
for (const platform of ["ios", "android"]) {
193+
await serviceTest.projectChangesService.checkForChanges({
194+
platform,
195+
projectData: serviceTest.projectData,
196+
projectChangesOptions: {
197+
bundle: false,
198+
release: false,
199+
provision: undefined,
200+
teamId: undefined,
201+
useHotModuleReload: false
202+
}
203+
});
204+
serviceTest.projectChangesService.savePrepareInfo(platform, serviceTest.projectData);
205+
const prepareInfo = serviceTest.projectChangesService.getPrepareInfo(platform, serviceTest.projectData);
206+
207+
serviceTest.projectChangesService.setNativePlatformStatus(platform, serviceTest.projectData, { nativePlatformStatus: Constants.NativePlatformStatus.alreadyPrepared });
208+
209+
const actualPrepareInfo = serviceTest.projectChangesService.getPrepareInfo(platform, serviceTest.projectData);
210+
prepareInfo.nativePlatformStatus = Constants.NativePlatformStatus.alreadyPrepared;
211+
assert.deepEqual(actualPrepareInfo, prepareInfo);
212+
}
213+
});
214+
215+
_.each([Constants.NativePlatformStatus.requiresPlatformAdd, Constants.NativePlatformStatus.requiresPrepare], nativePlatformStatus => {
216+
it(`should reset prepare info when native platform status is ${nativePlatformStatus} and there is existing prepare info`, async () => {
217+
for (const platform of ["ios", "android"]) {
218+
await serviceTest.projectChangesService.checkForChanges({
219+
platform,
220+
projectData: serviceTest.projectData,
221+
projectChangesOptions: {
222+
bundle: false,
223+
release: false,
224+
provision: undefined,
225+
teamId: undefined,
226+
useHotModuleReload: false
227+
}
228+
});
229+
serviceTest.projectChangesService.setNativePlatformStatus(platform, serviceTest.projectData, { nativePlatformStatus: nativePlatformStatus });
230+
231+
const actualPrepareInfo = serviceTest.projectChangesService.getPrepareInfo(platform, serviceTest.projectData);
232+
assert.deepEqual(actualPrepareInfo, { nativePlatformStatus: nativePlatformStatus });
233+
}
234+
});
235+
});
190236
});
191237
});

0 commit comments

Comments
 (0)