Skip to content

feat: add nameFormatter option to buildDependentsTree for custom display names#10629

Merged
zkochan merged 3 commits intov10from
v10-name-formatter
Feb 15, 2026
Merged

feat: add nameFormatter option to buildDependentsTree for custom display names#10629
zkochan merged 3 commits intov10from
v10-name-formatter

Conversation

@zkochan
Copy link
Member

@zkochan zkochan commented Feb 15, 2026

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).

…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>
@zkochan zkochan requested a review from Copilot February 15, 2026 20:55
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 nameFormatter option to buildDependentsTree and displayName field to DependentsTree/DependentNode interfaces
  • Updated all render functions to use displayName ?? name fallback pattern for consistent display
  • Implemented resolveDisplayName helper 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>
@zkochan zkochan requested a review from Copilot February 15, 2026 21:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zkochan zkochan merged commit 301d0de into v10 Feb 15, 2026
13 of 15 checks passed
zkochan added a commit that referenced this pull request Feb 15, 2026
…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).
zkochan added a commit to teambit/bit that referenced this pull request Feb 17, 2026
`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants