pnpm/__fixtures__/workspace-with-nested-works...
Brandon Cheng 395a33a50c
feat: traverse through workspace packages in `why` and `list` commands (#5863)
* 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>
2023-01-03 15:28:20 +02:00
..
packages feat: traverse through workspace packages in `why` and `list` commands (#5863) 2023-01-03 15:28:20 +02:00
package.json feat: traverse through workspace packages in `why` and `list` commands (#5863) 2023-01-03 15:28:20 +02:00
pnpm-lock.yaml feat: traverse through workspace packages in `why` and `list` commands (#5863) 2023-01-03 15:28:20 +02:00
pnpm-workspace.yaml feat: traverse through workspace packages in `why` and `list` commands (#5863) 2023-01-03 15:28:20 +02:00