fix: preserve catalog protocol when updating project manifest#8285
Merged
fix: preserve catalog protocol when updating project manifest#8285
Conversation
Member
Author
ConsiderationsOne problem I was worried about was After a lot of digging to understand the |
This makes `pnpm add foo@catalog:` preserve the catalog protocol when updating `package.json`. This also fixes a quirk with `pnpm update --latest <name>` when <name> is a catalog'ed dep. The `updateSpec` field is set on all deps if `wantedDependencies` filters to 0. https://github.com/pnpm/pnpm/blob/341656f9b36fd08a138fe31969f21f6a9409b0ea/pkg-manager/resolve-dependencies/src/toResolveImporter.ts#L44-L48
5e1e4b7 to
d33cc86
Compare
pnpm update
zkochan
approved these changes
Jul 7, 2024
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
Running
pnpm updatereverts dependencies using thecatalog:protocol back to their original version ranges. Credit to @KSXGitHub for finding this bug.Note how
@pnpm/registry-mockchanges fromcatalog:to^3.34.0in the video below. (Thepath-existsdependency is actually untouched because it's configured inpnpm.updateConfig.ignoreDependencies.)update.mov
Changes
The
updateProjectManifestfunction is generates aspecsToUpsertarray that determines the values inpackage.jsonafter apnpm update.Updating this function to understand
catalog:protocol dependencies.Now that
updateProjectManifestunderstands how to writecatalog:protocol dependencies, this has the side effect of makingpnpm add foo@catalog:work correctly. 🎉