feat: pnpm add option to add new entries to catalogs #9484
Conversation
|
So I did not think it through. We cannot make We need a separate flag for specifying the catalog name. Maybe Alternatively, we could use |
In other words, we can have Do you think there is a problem with this? |
I don't think we should allow this because currently the |
|
I think |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a new CLI option to add catalog entries when installing packages with pnpm. It integrates a new saveCatalog/saveCatalogName option throughout the dependency resolution, installation, and workspace manifest updates, along with corresponding tests and documentation updates.
- Introduced a new flag to save dependencies as catalog entries in package.json and pnpm-workspace.yaml.
- Updated dependency resolution and installation functions to merge new catalog data.
- Added tests and configuration updates to support the new catalog functionality.
Reviewed Changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts | Updated options and added newCatalogs integration for catalogs. |
| pkg-manager/resolve-dependencies/src/resolveDependencies.ts | Propagated and merged new catalog data into the lockfile. |
| pkg-manager/plugin-commands-installation/test/saveCatalog.ts | Added tests for verifying catalog saving behavior. |
| pkg-manager/plugin-commands-installation/src/* | Updated CLI options and docs to support the new catalog feature. |
| pkg-manager/core/src/* | Updated dependency parsing and installation methods to include saveCatalog. |
| config/config/src/* | Added new configuration for save-catalog-name. |
| .changeset/tangy-nails-hide.md | Documented the new CLI options and module version bumps. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
pkg-manager/resolve-dependencies/src/resolveDependencyTree.ts:122
- [nitpick] Consider aligning the naming for the catalog saving option across the codebase, as some modules use 'saveCatalog' while others use 'saveCatalogName'. For clarity, choose a single consistent name.
saveCatalog?: string
Restoring the message from: #9484 (comment)
Restoring the message from: #9484 (comment)
Restoring the message from: #9484 (comment)
Restoring the message from: #9484 (comment)
|
Alternatively, I wouldn't mind just relying on the codemod to find any 2 packages with the same dependency and move said dependency to catalog. This is something I would run periodically for example. Unfortunately, it doesn't behave that way at the moment, see fix: do not move packages that are not shared to catalog by mcous · Pull Request #6 · pnpm/codemod/ |
Resolves #9425
TODO:
catalog:inpackage.json.pnpm-workspace.yaml.pnpm-workspace.yaml.pnpm/pkg-manager/resolve-dependencies/src/index.ts
Line 306 in 3f70b67
pnpm-workspace.yaml: There is 1 unused (possibly because I didn't create the right condition to trigger it) but there is no duplication.pnpm add <pkg>.pnpm add <pkg>@<range>.pnpm add <pkg>@<git>.pnpm add <pkg>@jsr:*.pnpm add <local-pkg>(should not save as catalogs).addDefaultCatalogs.package.json.