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

support dual versions #2

Merged
merged 3 commits into from
Feb 3, 2022
Merged

support dual versions #2

merged 3 commits into from
Feb 3, 2022

Conversation

cheesehary
Copy link

@cheesehary cheesehary commented Feb 1, 2022

Support dual package versions. This can be configured in root package.json

errors = externalMismatch.validate(ws.get("pkg-1")!, ws, rootWorkspace, {});
expect(errors.length).toEqual(0);
});

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test case to validate which version is used when adding an unsupported version in the case where 2 or more allowed versions exist.
e.g.

'allowedDependencyVersions' {
     'foo': [
         '^1.0.0',
         '^2.0.0'
      ]
}

yarn add foo@^3.0.0 ... does it clamp to the lowest version number, the highest one, or the most commonly used between the allowed versions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, added a test case, should be the most commonly used one.

@@ -1,4 +1,4 @@
import internalMismatch from "../EXTERNAL_MISMATCH";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting to see the naming discrepancy. Increases the diff, which might be problematic if we did end up sticking to a fork if the contribution to the main lib isn't accepted.

expect(errors.length).toEqual(0);
});

it("should error if the range is the range is outside allowedDependencyVersions and running fix should clamp it to the most commonly used one", () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grammar nit: "if the range is the range is outside" looks like duplication. Rephrase please.

@@ -120,7 +124,7 @@ function weakMemoize<Arg, Ret>(func: (arg: Arg) => Ret): (arg: Arg) => Ret {
export let getMostCommonRangeMap = weakMemoize(function getMostCommonRanges(
allPackages: Map<string, Package>
) {
let dependencyRangesMapping = new Map<string, {[key: string]: number}>();
let dependencyRangesMapping = new Map<string, { [key: string]: number }>();
Copy link

@ReDrUm ReDrUm Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may as well avoid formatting changes that aren't related to the tangible changes of this PR just to reduce diff.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I cleared all those unrelated changes to reduce diff

@@ -15,7 +15,7 @@ type ErrorType = {
};

export default makeCheck<ErrorType>({
validate: (workspace, allWorkspace) => {
validate: (workspace, allWorkspace, rootWorkspace, options) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does rootWorkspace do here? I don't see it referenced further down?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the validate function signature.
let errors = check.validate( workspace, allWorkspaces, rootWorkspace, options );

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh right

if (
mostCommonRange !== undefined &&
mostCommonRange !== range &&
!(allowedVersions && allowedVersions.includes(range)) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to summarise, it'll error anything that isn't most common or in allowedVersions? When fixing it'll fix to most common?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep correct

@marcodejongh marcodejongh self-requested a review February 2, 2022 05:30
@cheesehary cheesehary merged commit 262531b into master Feb 3, 2022
@cheesehary cheesehary deleted the support-dual-versions branch February 3, 2022 00:23
@marcodejongh
Copy link
Collaborator

Dont forget to open a PR back upstream

@ReDrUm
Copy link

ReDrUm commented Feb 4, 2022

Late to the party, but it seems like we may need to evolve this a little further first. There seems to be unexpected changes to the yarn.lock file. See this comment thread https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/18569#comment-277298005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants