fix: yarn up now updates catalog entries instead of rewriting package…#7085
Open
emiliosheinz wants to merge 1 commit intoyarnpkg:masterfrom
Open
fix: yarn up now updates catalog entries instead of rewriting package…#7085emiliosheinz wants to merge 1 commit intoyarnpkg:masterfrom
emiliosheinz wants to merge 1 commit intoyarnpkg:masterfrom
Conversation
6cd993b to
e931cba
Compare
Author
|
There are a few failing CI checks in this PR that I believe need to be addressed before we can merge. I'd love to help get them green, but I'm not familiar enough with the project's conventions to fix them confidently. Could you point me in the right direction? |
Author
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.
Problem
yarn up <pkg>@<version>was rewritingcatalog:andcatalog:<name>references inpackage.jsonwith resolved version strings (e.g."react": "19.2.4") instead of updating the source-of-truth entry in.yarnrc.yml.Fixes #7084.
Approach
In
executeUpClassic(), before writing to a workspace manifest, the code now checks whether the current dependency range starts withcatalog:. If it does, the update is routed to a separatecatalogUpdatesmap (keyed by catalog name + package name) rather than mutating the manifest.After processing all suggestions, two things happen:
Disk write —
Configuration.updateConfiguration()patches.yarnrc.ymlwith the new ranges. This is the same mechanism used throughout Yarn for config mutations.In-memory update —
configuration.valuesis patched directly so that theinstallWithNewReport()call that follows resolves against the new ranges without needing to re-read the file from disk.The
catalogUpdatesmap deduplicates by${catalogName}\0${entryName}so that packages referenced across multiple workspaces are only written once.Known limitations
Configuration.updateConfiguration()round-trips.yarnrc.ymlthrough Yarn's ownparseSyml/stringifySymlserializer, which has two trade-offs:#comments in.yarnrc.ymlare lost on the firstyarn upthat touches a catalog entry.stringifySymlsorts keys according to a fixed priority list, so the order of entries incatalog:andcatalogs:may change.These are accepted limitations consistent with how every other Yarn command that modifies
.yarnrc.ymlbehaves (e.g.yarn config set). A comment-preserving surgical text editor was prototyped but discarded in favour of consistency with the existing serialization path.