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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept tag dependencies as valid #704

Merged
merged 1 commit into from
Dec 19, 2021
Merged

Accept tag dependencies as valid #704

merged 1 commit into from
Dec 19, 2021

Conversation

Andarist
Copy link
Member

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2021

馃 Changeset detected

Latest commit: 3281faa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@changesets/get-dependents-graph Minor
@changesets/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 12, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3281faa:

Sandbox Source
Vanilla Configuration

@@ -267,6 +267,37 @@ describe("running version in a simple project", () => {
expect(changesetDir).toContain(".ignored-temporarily.md");
});

it("should not update a dependant that uses a tag as a dependency rage for a package that could otherwise be local", async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test is already passing on the main branch but I have thought that it might be worth it to add it here nevertheless. The only difference is that this will no longer print errors in the console - this is being checked in a unit test for getDependencyGraph so I've skipped rechecking this here.

if (!semver.satisfies(expected, depVersion)) {
const range = getValidRange(depRange);

if ((range && !range.test(expected)) || isProtocolRange(depRange)) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't isProtocolRange(depRange) doing nothing here(and also the other place it's used)? Since if it's a "protocol range" then it's not a valid semver range?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not quite - for instance link: would result in range === null and we might not want to accept it for production dependencies. In general - this code might not be complete, but it's more complete than the previous version. I want to understand the use cases better before allowing for more things.

Some more information can be deduced from #704 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Oh sorry, I was reading this wrong

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

By, tag, you mean a dep with anything other than just a semver range, right?

@Andarist
Copy link
Member Author

By, tag, you mean a dep with anything other than just a semver range, right?

Somewhat, kinda - there is not an obvious way to distinguish a tag from other things. If we take a look at this list we can distinguish such things:

  • semver ranges/versions
  • HTTP URLs, git (so with a protocol)
  • */''/x/X (wildcards)
  • user/repo (special case for GitHub)
  • tags
  • path/path/path (local paths)

We know though that we also have other protocols, like workspace:, link: and even patch: (available at least in Yarn Berry).

So the code in this PR doesn't target tags specifically as I don't ensure that some other categories stay unmatched. However, when I look at this - those categories should probably also stay untouched in the same way. We could add some tests for those - but I'm not sure if it's worth it right now (given my limited time to work on this)

@emmatown
Copy link
Member

Seems strange that we wouldn't error for tags and GitHub repos but would for things that have explicit protocols? Feels like we should just only error when it's a range but it's out of range of the actual version?

@Andarist
Copy link
Member Author

Seems strange that we wouldn't error for tags and GitHub repos but would for things that have explicit protocols? Feels like we should just only error when it's a range but it's out of range of the actual version?

We have an explicit test that disallows link: protocol to be used for production dependencies:

it("should set valid to false if the link protocol is used in a non-dev dep", function() {

Like I've mentioned in other comment of mine here:

In general - this code might not be complete, but it's more complete than the previous version. I want to understand the use cases better before allowing for more things.

I'm unsure how all of the protocol types work with packing - and I assume that this might be different per package manager (I hope that this is not pm-dependent but I assume the worst :P). And I don't have time to investigate this right now - so I've decided to leave the existing behavior untouched and fix what I know that has to be fixed.

@Andarist Andarist merged commit 6f9c9d6 into main Dec 19, 2021
@Andarist Andarist deleted the fix/tag-dependants branch December 19, 2021 08:26
@github-actions github-actions bot mentioned this pull request Dec 19, 2021
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.

None yet

2 participants