feat: add nameFormatter option to buildDependentsTree for custom display names#10629
feat: add nameFormatter option to buildDependentsTree for custom display names#10629
Conversation
…lay names Allow consumers (e.g. Bit CLI) to provide a nameFormatter callback that reads the package manifest and returns a custom display name. The resolved displayName is carried through the DependentsTree/DependentNode data model and used by all render functions (tree, JSON, parseable). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover displayName behavior across all three output formats (tree, JSON, parseable) and the summary line, verifying that displayName is preferred over name when provided and that name is used as fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds the ability to customize package display names in dependency tree output by introducing an optional nameFormatter callback to buildDependentsTree. The formatter receives package metadata (name, version, manifest) and returns a custom display name, which is then used consistently across all output formats (tree, JSON, parseable).
Changes:
- Added
nameFormatteroption tobuildDependentsTreeanddisplayNamefield toDependentsTree/DependentNodeinterfaces - Updated all render functions to use
displayName ?? namefallback pattern for consistent display - Implemented
resolveDisplayNamehelper to format names for intermediate nodes using the formatter callback
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| reviewing/dependencies-hierarchy/src/buildDependentsTree.ts | Added nameFormatter option, displayName fields to interfaces, and logic to resolve custom display names for tree nodes |
| reviewing/list/src/renderDependentsTree.ts | Updated all render functions (tree, JSON, parseable) to use displayName ?? name for consistent output |
| .changeset/add-name-formatter.md | Added changeset documenting the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test that nameFormatter populates displayName on matched root and intermediate package nodes, that displayName is undefined when nameFormatter is not provided, and that it remains undefined when the formatter returns undefined. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…lay names (#10629) Allow consumers (e.g. Bit CLI) to provide a nameFormatter callback that reads the package manifest and returns a custom display name. The resolved displayName is carried through the DependentsTree/DependentNode data model and used by all render functions (tree, JSON, parseable).
`bit why` now shows a reverse dependency tree. The searched package appears at the root with its dependents as branches, walking back to workspace components. This replaces the previous forward-tree output which was noisy and hard to read for deeply nested dependencies. Also with the complete rewrite of the dependency tree builder we have fixed the out-of-memory errors that were frequent with the why command. The command also became a lot faster. ## Proposed Changes Related PRs: - pnpm/pnpm#10582 - pnpm/pnpm#10586 - pnpm/pnpm#10615 - pnpm/pnpm#10616 - pnpm/pnpm#10627 - pnpm/pnpm#10629 - pnpm/pnpm#10596 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Allow consumers (e.g. Bit CLI) to provide a nameFormatter callback that reads the package manifest and returns a custom display name. The resolved displayName is carried through the DependentsTree/DependentNode data model and used by all render functions (tree, JSON, parseable).