mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-12 02:57:44 -04:00
5
.changeset/chatty-garlics-change.md
Normal file
5
.changeset/chatty-garlics-change.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/render-peer-issues": patch
|
||||
---
|
||||
|
||||
Don't fail to render missing peer dependencies, when the parents field is an empty array.
|
||||
6
.changeset/many-peas-switch.md
Normal file
6
.changeset/many-peas-switch.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Fix `Cannot read properties of undefined (reading 'name')` that is printed while trying to render the missing peer dependencies warning message [#8538](https://github.com/pnpm/pnpm/issues/8538).
|
||||
@@ -114,6 +114,11 @@ interface PkgNode {
|
||||
}
|
||||
|
||||
function createTree (pkgNode: PkgNode, pkgs: Array<{ name: string, version: string }>, issueText: string): void {
|
||||
if (pkgs.length === 0) {
|
||||
// This will happen if incorrect data is passed to the reporter.
|
||||
// It is better to print something instead of crashing.
|
||||
pkgs = [{ name: '<unknown>', version: '<unknown>' }]
|
||||
}
|
||||
const [pkg, ...rest] = pkgs
|
||||
const label = `${pkg.name} ${chalk.grey(pkg.version)}`
|
||||
if (!pkgNode.dependencies[label]) {
|
||||
|
||||
@@ -382,3 +382,33 @@ test('renderPeerIssues() format correctly the version ranges with spaces and "*"
|
||||
},
|
||||
}, { width: 500 }))).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('renderPeerIssues() do not fail if the parents array is empty', () => {
|
||||
expect(stripAnsi(renderPeerIssues({
|
||||
'.': {
|
||||
missing: {
|
||||
foo: [
|
||||
{
|
||||
parents: [],
|
||||
optional: false,
|
||||
wantedRange: '>=1.0.0 <3.0.0',
|
||||
},
|
||||
],
|
||||
},
|
||||
bad: {},
|
||||
conflicts: [],
|
||||
intersections: {
|
||||
foo: '^1.0.0',
|
||||
},
|
||||
},
|
||||
}, {
|
||||
rules: {
|
||||
ignoreMissing: [],
|
||||
},
|
||||
width: 500,
|
||||
})).trim()).toBe(`.
|
||||
└─┬ <unknown> <unknown>
|
||||
└── ✕ missing peer foo@">=1.0.0 <3.0.0"
|
||||
Peer dependencies that should be installed:
|
||||
foo@^1.0.0`)
|
||||
})
|
||||
|
||||
@@ -437,7 +437,10 @@ async function resolvePeersOfNode<T extends PartialResolvedPackage> (
|
||||
if (ctx.peerDependencyIssues.missing[peerName] == null) {
|
||||
ctx.peerDependencyIssues.missing[peerName] = []
|
||||
}
|
||||
const { parents } = getLocationFromParentNodeIds(ctx)
|
||||
const { parents } = getLocationFromParentNodeIds({
|
||||
dependenciesTree: ctx.dependenciesTree,
|
||||
parentNodeIds,
|
||||
})
|
||||
ctx.peerDependencyIssues.missing[peerName].push({
|
||||
optional,
|
||||
parents,
|
||||
|
||||
@@ -533,3 +533,18 @@ test('installation fails when the stored package name and version do not match t
|
||||
|
||||
await execPnpm(['install', '--config.strict-store-pkg-content-check=false', ...settings])
|
||||
})
|
||||
|
||||
// Covers https://github.com/pnpm/pnpm/issues/8538
|
||||
test('do not fail to render peer dependencies warning, when cache was hit during peer resolution', () => {
|
||||
prepare({
|
||||
dependencies: {
|
||||
'@udecode/plate-ui-table': '18.15.0',
|
||||
'@udecode/plate-ui-toolbar': '18.15.0',
|
||||
},
|
||||
})
|
||||
|
||||
const result = execPnpmSync(['install', '--config.auto-install-peers=false'])
|
||||
|
||||
expect(result.status).toBe(0)
|
||||
expect(result.stdout.toString()).toContain('Issues with peer dependencies found')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user