fix(plugin-npm): resolve "*" to prereleases when no stable version exists#7205
Open
arpitjain099 wants to merge 1 commit into
Open
fix(plugin-npm): resolve "*" to prereleases when no stable version exists#7205arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
…ists A stable "*" range never matches a prerelease, so a package whose only published versions are prereleases fails to resolve with YN0082 (no candidates found). When the requested range is exactly "*" and nothing matched, retry the version selection with includePrerelease so the package can still be installed until a stable release is published. The retry is scoped strictly to the "*" case, so every other range keeps its current semver behavior. Closes yarnpkg#6469 Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's the problem this PR addresses?
Installing a package whose only published versions are prereleases fails with
YN0082: No candidates foundwhen the range is*. The reported case is@microsoft/kiota-abstractions@npm:*, where every registry version is a prerelease. A stable*never matching a prerelease is correct semver, but it leaves these packages uninstallable until a stable release exists.In #6469 @arcanis agreed with retrying using
includePrereleasewhen the range is*and nothing matched, rather than treating*aslatest:Closes #6469.
How did you fix it?
Pulled the version matching out of
NpmSemverResolver.getCandidatesinto aselectMatchingVersionshelper. It matches as before, and only when the range is exactly*and the normal match is empty does it retry withnew semver.Range('*', {includePrerelease: true}). Any other range (say^1.0.0) keeps its current behavior and still won't pick up prereleases.Tests in
NpmSemverResolver.test.ts: with the fix removed the prerelease-only*case returns[], and with it the prereleases come back;^1.0.0against a prerelease-only set stays[], and a*against a set with stable versions still ignores prereleases.yarn jest packages/plugin-npm/tests/NpmSemverResolver.test.tspasses.One thing left out on purpose:
getSatisfyinguses the same default-range filter, so a prerelease locked this way could fail to re-satisfy*on a later resolution. That felt like a separate change from the install path here, so I held off, but happy to follow up if you want it covered too.Checklist