feat: print package versions in peer dependency issues (#5145)

This commit is contained in:
Zoltan Kochan
2022-08-02 20:00:26 +03:00
committed by GitHub
parent 43cd6aaca3
commit c990a409fe
3 changed files with 18 additions and 11 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/render-peer-issues": minor
"pnpm": minor
---
Print the versions of packages in peer dependency warnings and errors.

View File

@@ -85,14 +85,15 @@ interface PkgNode {
function createTree (pkgNode: PkgNode, pkgs: Array<{ name: string, version: string }>, issueText: string) {
const [pkg, ...rest] = pkgs
if (!pkgNode.dependencies[pkg.name]) {
pkgNode.dependencies[pkg.name] = { dependencies: {}, peerIssues: [] }
const label = `${pkg.name} ${chalk.grey(pkg.version)}`
if (!pkgNode.dependencies[label]) {
pkgNode.dependencies[label] = { dependencies: {}, peerIssues: [] }
}
if (rest.length === 0) {
pkgNode.dependencies[pkg.name].peerIssues.push(issueText)
pkgNode.dependencies[label].peerIssues.push(issueText)
return
}
createTree(pkgNode.dependencies[pkg.name], rest, issueText)
createTree(pkgNode.dependencies[label], rest, issueText)
}
function toArchyData (depName: string, pkgNode: PkgNode): archy.Data {

View File

@@ -2,19 +2,19 @@
exports[`renderPeerIssues() 1`] = `
".
└─┬ xxx
└─┬ xxx 1.0.0
├── ✕ unmet peer bbb@^1.0.0: found 2
└─┬ yyy
└─┬ yyy 1.0.0
├── ✕ missing peer aaa@\\">=1.0.0 <3.0.0\\"
└── ✕ unmet peer ccc@^1.0.0: found 2 in xxx
Peer dependencies that should be installed:
aaa@^1.0.0
packages/0
├─┬ zzz
├─┬ zzz 1.0.0
│ ├── ✕ missing peer ddd@^1.0.0
│ └── ✕ missing peer eee@^1.0.0
└─┬ www
└─┬ www 1.0.0
└── ✕ missing peer eee@^2.0.0
✕ Conflicting peer dependencies:
eee
@@ -25,7 +25,7 @@ Peer dependencies that should be installed:
exports[`renderPeerIssues() format correctly the version ranges with spaces and "*" 1`] = `
".
└─┬ z
└─┬ z 1.0.0
├── ✕ missing peer a@\\"*\\"
└── ✕ missing peer b@\\"1 || 2\\"
Peer dependencies that should be installed:
@@ -35,8 +35,8 @@ Peer dependencies that should be installed:
exports[`renderPeerIssues() optional peer dependencies are printed only if they are in conflict with non-optional peers 1`] = `
".
└─┬ xxx
└─┬ yyy
└─┬ xxx 1.0.0
└─┬ yyy 1.0.0
├── ✕ missing peer aaa@^1.0.0
└── ✕ missing peer aaa@^2.0.0
✕ Conflicting peer dependencies: