-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Contribution
- I'd be willing to implement this feature (contributing guide)
Describe the user story
As a developer, when installing a package into a workspace that uses catalogs, I want pnpm add package@xyz to install the package to catalogs but it's installed to package.json instead. This is not desired when intending to use a catalog only workspace, so manual copy pasting the dependency to catalog follows after installation.
Describe the solution you'd like
A new option to pnpm add like --save-to-catalog where if provided it saves the dependency to the default catalog and updates package.json to use the catalog version. It should also accept an optional name parameter, such that if provided it installs to the named catalog
Describe the drawbacks of your solution
It introduces complexities/questions on the following edge cases
- If the dependency already exists in package.json, it should be updated to point to a catalog version
- It should work with the existing
--save-dev,--save-optional,--save-exact,save-peerand--save-prodoptions as well - If the dependency already exists in the destination catalog, it should be updated in place to the specified version
Describe alternatives you've considered
While the provided pnpm/catalog codemod can be used, it doesn't work for the usecase of installing a new dependency. The new dependency is, more often than not, only used by one package and wouldn't be detected by the codemod.