Skip to content
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

fix(update-dependencies), resolve dependencies version from "update-dependents" prop of the lane #8903

Merged
merged 1 commit into from
May 21, 2024
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
38 changes: 38 additions & 0 deletions e2e/harmony/snap-from-scope.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,44 @@ export const BasicIdInput = () => {
});
});
});
describe('updating a component in the lane then running update-dependencies command to update the dependents', () => {
let updateDepsOutput: string;
before(() => {
helper.scopeHelper.reInitLocalScope();
helper.scopeHelper.addRemoteScope(helper.scopes.remotePath);
helper.scopeHelper.getClonedRemoteScope(remoteScope);
helper.command.importLane('dev', '-x');
helper.command.snapComponentWithoutBuild('comp3', '--skip-auto-snap --unmodified');
helper.command.export();

const updateRemote = helper.scopeHelper.getNewBareScope('-remote-update');
helper.scopeHelper.addRemoteScope(helper.scopes.remotePath, updateRemote.scopePath);

const data = [
{
componentId: `${helper.scopes.remote}/comp2`,
dependencies: [`${helper.scopes.remote}/comp3`],
},
];
// console.log('updateRemote.scopePath', updateRemote.scopePath);
// console.log(`bit update-dependencies '${JSON.stringify(data)}' --lane ${helper.scopes.remote}/dev`);
try {
updateDepsOutput = helper.command.updateDependencies(
data,
`--lane ${helper.scopes.remote}/dev`,
updateRemote.scopePath
);
} catch (err: any) {
updateDepsOutput = err.message;
}
});
// it's currently failing because comp3 is not in the npm registry, that's fine.
// all we care about here is that it won't fail because it cannot find the version of the dependency
it('should not throw an error saying it cannot find the version of the dependency', () => {
expect(updateDepsOutput).to.not.include('unable to find a version');
expect(updateDepsOutput).to.include('comp3 is not in the npm registry'); // not a mandatory test
});
});
});
describe('updating packages (not components)', () => {
before(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ to bypass this error, use --skip-new-scope-validation flag (not recommended. it
// exact version, expect the entered version to be okay.
return compId;
}
if (this.laneObj) {
// for "update-dependents" feature, we need the components from update-dependents prop of the lane to have get
// the updated versions of the dependencies from the lane.
const fromLane = this.laneObj.getCompHeadIncludeUpdateDependents(compId);
if (fromLane) return compId.changeVersion(fromLane.toString());
}
return this.snapping.getCompIdWithExactVersionAccordingToSemver(compId);
}

Expand Down