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).
- **`pnpm why` now shows a reverse dependency tree.** The searched package appears at the root with its dependants as branches, walking back to workspace roots. This replaces the previous forward-tree output which was noisy and hard to read for deeply nested dependencies.
- **Replaced `archy` with a new `@pnpm/text.tree-renderer` package** that renders trees using box-drawing characters (├──, └──, │) and supports grouped sections, dim connectors, and deduplication markers.
- **Show peer dependency hash suffixes** in `pnpm list` and `pnpm why` output to distinguish between different peer-dep variants of the same package.
- **Improved `pnpm list` visual output:** bold importer nodes, dimmed workspace paths, dependency grouping, package count summary, and deterministic sort order.
- **Added `--long` support to `pnpm why`** and the ability to read package manifests from the CAS store.
- **Deduplicated shared code** between `list` and `why` commands into a common module, and reused `getPkgInfo` in the why tree builder.
* fix: support alias resolution in pnpm why with npm:
protocol
* refactor: make alias required instead of optional
* refactor: reorder field to put alias first
* fix: get correct path info in dependencies hierarchy tree
* chore: test case for build dependencies hierarchy
* docs: update changeset
* chore: test cases
* fix: show full path in dependencies hierarchy tree
* refactor(dependencies-hierarchy): remove keypath argument from getTree
The `keypath` argument is an internal implementation detail of `getTree`
used to detect cycles in the package graph. Removing this from the call
signature of `getTree` since it exposes an implementation detail.
The start of a `getTree` call always passed in the starting node as the
initial value anyway.
```ts
const getChildrenTree = getTree.bind(null, { ... })
getChildrenTree([relativeId], relativeId)
```
It's simpler for that to happen in the first call to `getTreeHelper`
internally and better ensures the keypath is created correctly. A future
refactor makes construction of the keypath more involved.
* refactor(dependencies-hierarchy): remove refToRelative call in getPkgInfo
This removes an extra `refToRelative` call in `getPkgInfo`. The result
of this call wasn't used within the function and was simply passed back
to the caller.
Callers of `getPkgInfo` were checking the result of `refToRelative`,
from `getPkgInfo`'s return object only to call `refToRelative` again.
Calling `refToRelative` directly simplifies code a bit. We can remove an
unnecessary cast and an if statement.
* refactor(dependencies-hierarchy): create enum for getTree nodes
* feature(dependencies-hierarchy): traverse through workspace packages
This updates `pnpm list` and `pnpm why` to traverse through `link:`
packages by simply. This is done by simply implementing a new TreeNodeId
enum variant.
* test(dependencies-hierarchy): test transitive workspace package listing
* refactor(dependencies-hierarchy): create interface for GetPkgInfoOpts
A future commit adds new fields to `getPkgInfo`'s options. The dedicated
interface makes it easier to describe these new options with a JSDoc.
* fix(dependencies-hierarchy): fix path for link: deps in projects
This was a bug before the changes in this pull request. The bug was not
user facing since `pnpm list --json` doesn't print this computed path.
* fix(dependencies-hierarchy): print version paths rel to starting project
* feat(list): add --only-projects flag
* refactor: change description of --only-projects
Co-authored-by: Zoltan Kochan <z@kochan.io>