mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-29 03:26:25 -04:00
refactor: suggest "pnpm peers check" instead of rendering peer issues tree during install (#11133)
Instead of rendering the full peer dependency issues tree during installation, suggest users run "pnpm peers check" to view the issues. Remove the now-unused @pnpm/installing.render-peer-issues package.
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
"@pnpm/cli.common-cli-options-help": major
|
||||
"@pnpm/config.normalize-registries": major
|
||||
"@pnpm/lockfile.preferred-versions": major
|
||||
"@pnpm/installing.render-peer-issues": major
|
||||
"@pnpm/installing.linking.modules-cleaner": major
|
||||
"@pnpm/pkg-manifest.utils": major
|
||||
"@pnpm/get-release-text": major
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
"@pnpm/cli.common-cli-options-help": major
|
||||
"@pnpm/config.normalize-registries": major
|
||||
"@pnpm/lockfile.preferred-versions": major
|
||||
"@pnpm/installing.render-peer-issues": major
|
||||
"@pnpm/installing.linking.modules-cleaner": major
|
||||
"@pnpm/pkg-manifest.utils": major
|
||||
"@pnpm/fetching.directory-fetcher": major
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
"@pnpm/installing.dedupe.issues-renderer": patch
|
||||
"@pnpm/installing.render-peer-issues": patch
|
||||
---
|
||||
|
||||
Replaced `archy` with `@pnpm/text.tree-renderer` for tree output.
|
||||
|
||||
6
.changeset/suggest-peers-check-command.md
Normal file
6
.changeset/suggest-peers-check-command.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/cli.default-reporter": minor
|
||||
"pnpm": minor
|
||||
---
|
||||
|
||||
During installation, peer dependency issues are no longer rendered as a tree. Instead, users are suggested to run `pnpm peers check` to view the issues.
|
||||
@@ -39,7 +39,6 @@
|
||||
"@pnpm/error": "workspace:*",
|
||||
"@pnpm/installing.dedupe.issues-renderer": "workspace:*",
|
||||
"@pnpm/installing.dedupe.types": "workspace:*",
|
||||
"@pnpm/installing.render-peer-issues": "workspace:*",
|
||||
"@pnpm/types": "workspace:*",
|
||||
"@pnpm/util.lex-comparator": "catalog:",
|
||||
"ansi-diff": "catalog:",
|
||||
|
||||
@@ -3,7 +3,6 @@ import type { Log } from '@pnpm/core-loggers'
|
||||
import type { PnpmError } from '@pnpm/error'
|
||||
import { renderDedupeCheckIssues } from '@pnpm/installing.dedupe.issues-renderer'
|
||||
import type { DedupeCheckIssues } from '@pnpm/installing.dedupe.types'
|
||||
import { renderPeerIssues } from '@pnpm/installing.render-peer-issues'
|
||||
import type { PeerDependencyIssuesByProjects } from '@pnpm/types'
|
||||
import chalk from 'chalk'
|
||||
import { equals } from 'ramda'
|
||||
@@ -460,9 +459,11 @@ function hideSecureInfo (key: string, value: string): string {
|
||||
function reportPeerDependencyIssuesError (
|
||||
err: Error,
|
||||
msg: { issuesByProjects: PeerDependencyIssuesByProjects }
|
||||
): ErrorInfo | null {
|
||||
): ErrorInfo {
|
||||
const hasMissingPeers = getHasMissingPeers(msg.issuesByProjects)
|
||||
const hints: string[] = []
|
||||
const hints: string[] = [
|
||||
'Run "pnpm peers check" to list the peer dependency issues.',
|
||||
]
|
||||
if (hasMissingPeers) {
|
||||
hints.push(`To auto-install peer dependencies, add the following to "pnpm-workspace.yaml" in your project root:
|
||||
|
||||
@@ -472,18 +473,9 @@ function reportPeerDependencyIssuesError (
|
||||
|
||||
strictPeerDependencies: false
|
||||
`)
|
||||
const rendered = renderPeerIssues(msg.issuesByProjects)
|
||||
if (!rendered) {
|
||||
// This should never happen.
|
||||
return {
|
||||
title: err.message,
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: err.message,
|
||||
body: `${rendered}
|
||||
${hints.map((hint) => `hint: ${hint}`).join('\n')}
|
||||
`,
|
||||
body: hints.map((hint) => `hint: ${hint}`).join('\n'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { PeerDependencyIssuesLog } from '@pnpm/core-loggers'
|
||||
import { renderPeerIssues } from '@pnpm/installing.render-peer-issues'
|
||||
import * as Rx from 'rxjs'
|
||||
import { map, take } from 'rxjs/operators'
|
||||
|
||||
@@ -12,13 +11,9 @@ export function reportPeerDependencyIssues (
|
||||
): Rx.Observable<Rx.Observable<{ msg: string }>> {
|
||||
return log$.peerDependencyIssues.pipe(
|
||||
take(1),
|
||||
map((log) => {
|
||||
const renderedPeerIssues = renderPeerIssues(log.issuesByProjects)
|
||||
if (!renderedPeerIssues) {
|
||||
return Rx.NEVER
|
||||
}
|
||||
map(() => {
|
||||
return Rx.of({
|
||||
msg: `${formatWarn('Issues with peer dependencies found')}\n${renderedPeerIssues}`,
|
||||
msg: formatWarn('Issues with peer dependencies found. Run "pnpm peers check" to list them.'),
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ test('print peer dependency issues warning', async () => {
|
||||
expect.assertions(1)
|
||||
|
||||
const output = await firstValueFrom(output$)
|
||||
expect(output).toContain('.')
|
||||
expect(output).toContain('pnpm peers check')
|
||||
})
|
||||
|
||||
test('print peer dependency issues error', async () => {
|
||||
@@ -82,8 +82,6 @@ test('print peer dependency issues error', async () => {
|
||||
|
||||
expect.assertions(1)
|
||||
|
||||
expect.assertions(1)
|
||||
|
||||
const output = await firstValueFrom(output$)
|
||||
expect(output).toContain('.')
|
||||
expect(output).toContain('pnpm peers check')
|
||||
})
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
{
|
||||
"path": "../../installing/dedupe/types"
|
||||
},
|
||||
{
|
||||
"path": "../../installing/render-peer-issues"
|
||||
},
|
||||
{
|
||||
"path": "../meta"
|
||||
}
|
||||
|
||||
@@ -1,422 +0,0 @@
|
||||
# @pnpm/render-peer-issues
|
||||
|
||||
## 1002.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [7c1382f]
|
||||
- Updated dependencies [dee39ec]
|
||||
- @pnpm/types@1000.9.0
|
||||
|
||||
## 1002.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @pnpm/error@1000.0.5
|
||||
|
||||
## 1002.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e792927]
|
||||
- @pnpm/types@1000.8.0
|
||||
|
||||
## 1002.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @pnpm/error@1000.0.4
|
||||
|
||||
## 1002.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1a07b8f]
|
||||
- @pnpm/types@1000.7.0
|
||||
- @pnpm/error@1000.0.3
|
||||
|
||||
## 1002.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- f0c3ed6: Remove filtering of peer dependency issues.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5ec7255]
|
||||
- @pnpm/types@1000.6.0
|
||||
|
||||
## 1001.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 8a9f3a4: `pref` renamed to `bareSpecifier`.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [8a9f3a4]
|
||||
- Updated dependencies [5b73df1]
|
||||
- @pnpm/parse-overrides@1001.0.0
|
||||
- @pnpm/types@1000.5.0
|
||||
|
||||
## 1000.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [750ae7d]
|
||||
- @pnpm/types@1000.4.0
|
||||
|
||||
## 1000.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5f7be64]
|
||||
- Updated dependencies [5f7be64]
|
||||
- @pnpm/types@1000.3.0
|
||||
|
||||
## 1000.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a5e4965]
|
||||
- @pnpm/types@1000.2.1
|
||||
|
||||
## 1000.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [8fcc221]
|
||||
- @pnpm/types@1000.2.0
|
||||
|
||||
## 1000.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3717340: Remove trailing new line from the output.
|
||||
|
||||
## 1000.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- acdf26d: Replace `strip-ansi` with the built-in `util.stripVTControlCharacters` [#9009](https://github.com/pnpm/pnpm/pull/9009).
|
||||
- Updated dependencies [b562deb]
|
||||
- @pnpm/types@1000.1.1
|
||||
- @pnpm/error@1000.0.2
|
||||
- @pnpm/parse-overrides@1000.0.2
|
||||
|
||||
## 1000.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [9591a18]
|
||||
- @pnpm/types@1000.1.0
|
||||
|
||||
## 1000.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @pnpm/error@1000.0.1
|
||||
- @pnpm/parse-overrides@1000.0.1
|
||||
|
||||
## 5.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ee5dde3: Don't fail to render missing peer dependencies, when the parents field is an empty array.
|
||||
- @pnpm/error@6.0.3
|
||||
- @pnpm/parse-overrides@5.1.2
|
||||
|
||||
## 5.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 9ff7724: Fix white text on light background for project name [#8526](https://github.com/pnpm/pnpm/pull/8526).
|
||||
- @pnpm/error@6.0.2
|
||||
- @pnpm/parse-overrides@5.1.1
|
||||
|
||||
## 5.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d500d9f]
|
||||
- @pnpm/types@12.2.0
|
||||
|
||||
## 5.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [7ee59a1]
|
||||
- @pnpm/types@12.1.0
|
||||
|
||||
## 5.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [cb006df]
|
||||
- @pnpm/types@12.0.0
|
||||
|
||||
## 5.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0f0e441]
|
||||
- Updated dependencies [0ef168b]
|
||||
- @pnpm/parse-overrides@5.1.0
|
||||
- @pnpm/types@11.1.0
|
||||
|
||||
## 5.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [dd00eeb]
|
||||
- Updated dependencies
|
||||
- @pnpm/types@11.0.0
|
||||
|
||||
## 5.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [13e55b2]
|
||||
- @pnpm/types@10.1.1
|
||||
|
||||
## 5.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [45f4262]
|
||||
- @pnpm/types@10.1.0
|
||||
|
||||
## 5.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a7aef51]
|
||||
- @pnpm/error@6.0.1
|
||||
- @pnpm/parse-overrides@5.0.1
|
||||
|
||||
## 5.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 43cdd87: Node.js v16 support dropped. Use at least Node.js v18.12.
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- aa33269: Peer dependency rules should only affect reporting, not data in the lockfile.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [7733f3a]
|
||||
- Updated dependencies [3ded840]
|
||||
- Updated dependencies [43cdd87]
|
||||
- Updated dependencies [730929e]
|
||||
- @pnpm/types@10.0.0
|
||||
- @pnpm/error@6.0.0
|
||||
- @pnpm/parse-overrides@5.0.0
|
||||
- @pnpm/matcher@6.0.0
|
||||
|
||||
## 4.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4d34684f1]
|
||||
- @pnpm/types@9.4.2
|
||||
|
||||
## 4.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @pnpm/types@9.4.1
|
||||
|
||||
## 4.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [43ce9e4a6]
|
||||
- @pnpm/types@9.4.0
|
||||
|
||||
## 4.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d774a3196]
|
||||
- @pnpm/types@9.3.0
|
||||
|
||||
## 4.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [aa2ae8fe2]
|
||||
- @pnpm/types@9.2.0
|
||||
|
||||
## 4.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a9e0b7cbf]
|
||||
- @pnpm/types@9.1.0
|
||||
|
||||
## 4.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- eceaa8b8b: Node.js 14 support dropped.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [eceaa8b8b]
|
||||
- @pnpm/types@9.0.0
|
||||
|
||||
## 3.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b77651d14]
|
||||
- @pnpm/types@8.10.0
|
||||
|
||||
## 3.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [702e847c1]
|
||||
- @pnpm/types@8.9.0
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [844e82f3a]
|
||||
- @pnpm/types@8.8.0
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- f884689e0: Require `@pnpm/logger` v5.
|
||||
|
||||
## 2.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d665f3ff7]
|
||||
- @pnpm/types@8.7.0
|
||||
|
||||
## 2.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [156cc1ef6]
|
||||
- @pnpm/types@8.6.0
|
||||
|
||||
## 2.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- c990a409f: Print the versions of packages in peer dependency warnings and errors.
|
||||
|
||||
## 2.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c90798461]
|
||||
- @pnpm/types@8.5.0
|
||||
|
||||
## 2.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [8e5b77ef6]
|
||||
- @pnpm/types@8.4.0
|
||||
|
||||
## 2.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2a34b21ce]
|
||||
- @pnpm/types@8.3.0
|
||||
|
||||
## 2.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [fb5bbfd7a]
|
||||
- @pnpm/types@8.2.0
|
||||
|
||||
## 2.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4d39e4a0c]
|
||||
- @pnpm/types@8.1.0
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [18ba5e2c0]
|
||||
- @pnpm/types@8.0.1
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 542014839: Node.js 12 is not supported.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d504dc380]
|
||||
- Updated dependencies [542014839]
|
||||
- @pnpm/types@8.0.0
|
||||
|
||||
## 1.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b138d048c]
|
||||
- @pnpm/types@7.10.0
|
||||
|
||||
## 1.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [26cd01b88]
|
||||
- @pnpm/types@7.9.0
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- b5734a4a7: When reporting unmet peer dependency issues, if the peer dependency is resolved not from a dependency installed by the user, then print the name of the parent package that has the bad peer dependency installed as a dependency.
|
||||
|
||||

|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b5734a4a7]
|
||||
- @pnpm/types@7.8.0
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6058f76cd: When printing peer dependency issues, print the "\*" range in double quotes. This will make it easier to copy the package resolutions and put them to the end of a `pnpm add` command for execution.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a087f339e: A new line should be between the summary about conflicting peers and non-conflicting ones.
|
||||
- Updated dependencies [6493e0c93]
|
||||
- @pnpm/types@7.7.1
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- ba9b2eba1: Initial release.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ba9b2eba1]
|
||||
- @pnpm/types@7.7.0
|
||||
@@ -1,13 +0,0 @@
|
||||
# @pnpm/render-peer-issues
|
||||
|
||||
> Visualizes peer dependency issues
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
pnpm add @pnpm/render-peer-issues
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"name": "@pnpm/installing.render-peer-issues",
|
||||
"version": "1002.0.5",
|
||||
"description": "Visualizes peer dependency issues",
|
||||
"keywords": [
|
||||
"pnpm",
|
||||
"pnpm11"
|
||||
],
|
||||
"license": "MIT",
|
||||
"funding": "https://opencollective.com/pnpm",
|
||||
"repository": "https://github.com/pnpm/pnpm/tree/main/installing/render-peer-issues",
|
||||
"homepage": "https://github.com/pnpm/pnpm/tree/main/installing/render-peer-issues#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pnpm/pnpm/issues"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"exports": {
|
||||
".": "./lib/index.js"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"!*.map"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "pn compile && pn .test",
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"prepublishOnly": "pn compile",
|
||||
"compile": "tsgo --build && pn lint --fix",
|
||||
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pnpm/error": "workspace:*",
|
||||
"@pnpm/text.tree-renderer": "workspace:*",
|
||||
"@pnpm/types": "workspace:*",
|
||||
"chalk": "catalog:",
|
||||
"cli-columns": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pnpm/installing.render-peer-issues": "workspace:*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.13"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "@pnpm/jest-config"
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
import { renderTree, type TreeNode } from '@pnpm/text.tree-renderer'
|
||||
import type {
|
||||
BadPeerDependencyIssue,
|
||||
PeerDependencyIssuesByProjects,
|
||||
} from '@pnpm/types'
|
||||
import chalk from 'chalk'
|
||||
import cliColumns from 'cli-columns'
|
||||
|
||||
export function renderPeerIssues (
|
||||
peerDependencyIssuesByProjects: PeerDependencyIssuesByProjects,
|
||||
opts?: {
|
||||
width?: number
|
||||
}
|
||||
): string {
|
||||
const projects = {} as Record<string, PkgNode>
|
||||
for (const [projectId, { bad, missing, conflicts, intersections }] of Object.entries(peerDependencyIssuesByProjects)) {
|
||||
projects[projectId] = { dependencies: {}, peerIssues: [] }
|
||||
for (const [peerName, issues] of Object.entries(missing)) {
|
||||
if (
|
||||
!conflicts.includes(peerName) &&
|
||||
intersections[peerName] == null
|
||||
) {
|
||||
continue
|
||||
}
|
||||
for (const issue of issues) {
|
||||
createTree(projects[projectId], issue.parents, `${chalk.red('✕ missing peer')} ${formatNameAndRange(peerName, issue.wantedRange)}`)
|
||||
}
|
||||
}
|
||||
for (const [peerName, issues] of Object.entries(bad)) {
|
||||
for (const issue of issues) {
|
||||
createTree(projects[projectId], issue.parents, formatUnmetPeerMessage({
|
||||
peerName,
|
||||
...issue,
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
const cliColumnsOptions = {
|
||||
newline: '\n ',
|
||||
width: (opts?.width ?? process.stdout.columns) - 2,
|
||||
}
|
||||
return Object.entries(projects)
|
||||
.filter(([, project]) => Object.keys(project.dependencies).length > 0)
|
||||
.sort(([projectKey1], [projectKey2]) => projectKey1.localeCompare(projectKey2))
|
||||
.map(([projectKey, project]) => {
|
||||
const summaries = []
|
||||
const { conflicts, intersections } = peerDependencyIssuesByProjects[projectKey]
|
||||
if (conflicts.length) {
|
||||
summaries.push(
|
||||
chalk.red(`✕ Conflicting peer dependencies:\n ${cliColumns(conflicts, cliColumnsOptions).trimEnd()}`)
|
||||
)
|
||||
}
|
||||
if (Object.keys(intersections).length) {
|
||||
summaries.push(
|
||||
`Peer dependencies that should be installed:\n ${cliColumns(Object.entries(intersections).map(([name, version]) => formatNameAndRange(name, version)), cliColumnsOptions)}`
|
||||
)
|
||||
}
|
||||
const title = chalk.reset(projectKey)
|
||||
const summariesConcatenated = summaries.join('\n')
|
||||
return `${renderTree(toArchyData(title, project))}${summariesConcatenated}`.trimEnd()
|
||||
}).join('\n\n')
|
||||
}
|
||||
|
||||
function formatUnmetPeerMessage (
|
||||
{ foundVersion, peerName, wantedRange, resolvedFrom }: BadPeerDependencyIssue & {
|
||||
peerName: string
|
||||
}
|
||||
) {
|
||||
const nameAndRange = formatNameAndRange(peerName, wantedRange)
|
||||
if (resolvedFrom && resolvedFrom.length > 0) {
|
||||
return `✕ unmet peer ${nameAndRange}: found ${foundVersion} in ${resolvedFrom[resolvedFrom.length - 1].name}`
|
||||
}
|
||||
return `${chalk.yellowBright('✕ unmet peer')} ${nameAndRange}: found ${foundVersion}`
|
||||
}
|
||||
|
||||
function formatNameAndRange (name: string, range: string) {
|
||||
if (range.includes(' ') || range === '*') {
|
||||
return `${name}@"${range}"`
|
||||
}
|
||||
return `${name}@${range}`
|
||||
}
|
||||
|
||||
interface PkgNode {
|
||||
peerIssues: string[]
|
||||
dependencies: Record<string, 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]) {
|
||||
pkgNode.dependencies[label] = { dependencies: {}, peerIssues: [] }
|
||||
}
|
||||
if (rest.length === 0) {
|
||||
pkgNode.dependencies[label].peerIssues.push(issueText)
|
||||
return
|
||||
}
|
||||
createTree(pkgNode.dependencies[label], rest, issueText)
|
||||
}
|
||||
|
||||
function toArchyData (depName: string, pkgNode: PkgNode): TreeNode {
|
||||
const result: Required<TreeNode> = {
|
||||
label: depName,
|
||||
nodes: [],
|
||||
}
|
||||
for (const wantedPeer of pkgNode.peerIssues) {
|
||||
result.nodes.push(wantedPeer)
|
||||
}
|
||||
for (const [depName, node] of Object.entries(pkgNode.dependencies)) {
|
||||
result.nodes.push(toArchyData(depName, node))
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`renderPeerIssues() 1`] = `
|
||||
".
|
||||
└─┬ xxx 1.0.0
|
||||
├── ✕ unmet peer bbb@^1.0.0: found 2
|
||||
└─┬ 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 1.0.0
|
||||
│ ├── ✕ missing peer ddd@^1.0.0
|
||||
│ └── ✕ missing peer eee@^1.0.0
|
||||
└─┬ www 1.0.0
|
||||
└── ✕ missing peer eee@^2.0.0
|
||||
✕ Conflicting peer dependencies:
|
||||
eee
|
||||
Peer dependencies that should be installed:
|
||||
ddd@^1.0.0"
|
||||
`;
|
||||
|
||||
exports[`renderPeerIssues() format correctly the version ranges with spaces and "*" 1`] = `
|
||||
".
|
||||
└─┬ z 1.0.0
|
||||
├── ✕ missing peer a@"*"
|
||||
└── ✕ missing peer b@"1 || 2"
|
||||
Peer dependencies that should be installed:
|
||||
a@"*" b@"1 || 2""
|
||||
`;
|
||||
|
||||
exports[`renderPeerIssues() optional peer dependencies are printed only if they are in conflict with non-optional peers 1`] = `
|
||||
".
|
||||
└─┬ xxx 1.0.0
|
||||
└─┬ yyy 1.0.0
|
||||
├── ✕ missing peer aaa@^1.0.0
|
||||
└── ✕ missing peer aaa@^2.0.0
|
||||
✕ Conflicting peer dependencies:
|
||||
aaa"
|
||||
`;
|
||||
@@ -1,233 +0,0 @@
|
||||
import { stripVTControlCharacters as stripAnsi } from 'node:util'
|
||||
|
||||
import { renderPeerIssues } from '@pnpm/installing.render-peer-issues'
|
||||
|
||||
test('renderPeerIssues()', () => {
|
||||
expect(stripAnsi(renderPeerIssues({
|
||||
'packages/0': {
|
||||
conflicts: ['eee'],
|
||||
intersections: { ddd: '^1.0.0' },
|
||||
bad: {},
|
||||
missing: {
|
||||
ddd: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'zzz',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '^1.0.0',
|
||||
},
|
||||
],
|
||||
eee: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'zzz',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '^1.0.0',
|
||||
},
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'www',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '^2.0.0',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
'.': {
|
||||
missing: {
|
||||
aaa: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'xxx',
|
||||
version: '1.0.0',
|
||||
},
|
||||
{
|
||||
name: 'yyy',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '>=1.0.0 <3.0.0',
|
||||
},
|
||||
],
|
||||
},
|
||||
bad: {
|
||||
bbb: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'xxx',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
foundVersion: '2',
|
||||
resolvedFrom: [],
|
||||
optional: false,
|
||||
wantedRange: '^1.0.0',
|
||||
},
|
||||
],
|
||||
ccc: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'xxx',
|
||||
version: '1.0.0',
|
||||
},
|
||||
{
|
||||
name: 'yyy',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
foundVersion: '2',
|
||||
resolvedFrom: [
|
||||
{
|
||||
name: 'xxx',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '^1.0.0',
|
||||
},
|
||||
],
|
||||
},
|
||||
conflicts: [],
|
||||
intersections: { aaa: '^1.0.0' },
|
||||
},
|
||||
}, { width: 500 }))).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('renderPeerIssues() optional peer dependencies are printed only if they are in conflict with non-optional peers', () => {
|
||||
expect(stripAnsi(renderPeerIssues({
|
||||
'.': {
|
||||
missing: {
|
||||
aaa: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'xxx',
|
||||
version: '1.0.0',
|
||||
},
|
||||
{
|
||||
name: 'yyy',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: true,
|
||||
wantedRange: '^1.0.0',
|
||||
},
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'xxx',
|
||||
version: '1.0.0',
|
||||
},
|
||||
{
|
||||
name: 'yyy',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '^2.0.0',
|
||||
},
|
||||
],
|
||||
bbb: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'xxx',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: true,
|
||||
wantedRange: '^1.0.0',
|
||||
},
|
||||
],
|
||||
},
|
||||
bad: {},
|
||||
conflicts: ['aaa'],
|
||||
intersections: {},
|
||||
},
|
||||
empty: {
|
||||
missing: {},
|
||||
bad: {},
|
||||
conflicts: [],
|
||||
intersections: {},
|
||||
},
|
||||
}, { width: 500 }))).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('renderPeerIssues() format correctly the version ranges with spaces and "*"', () => {
|
||||
expect(stripAnsi(renderPeerIssues({
|
||||
'.': {
|
||||
conflicts: [],
|
||||
intersections: { a: '*', b: '1 || 2' },
|
||||
bad: {},
|
||||
missing: {
|
||||
a: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'z',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '*',
|
||||
},
|
||||
],
|
||||
b: [
|
||||
{
|
||||
parents: [
|
||||
{
|
||||
name: 'z',
|
||||
version: '1.0.0',
|
||||
},
|
||||
],
|
||||
optional: false,
|
||||
wantedRange: '1 || 2',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}, { 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',
|
||||
},
|
||||
},
|
||||
}, {
|
||||
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`)
|
||||
})
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"outDir": "../node_modules/.test.lib",
|
||||
"rootDir": "..",
|
||||
"isolatedModules": true
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"../../../__typings__/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": ".."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"extends": "@pnpm/tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"rootDir": "src"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"../../__typings__/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../core/error"
|
||||
},
|
||||
{
|
||||
"path": "../../core/types"
|
||||
},
|
||||
{
|
||||
"path": "../../text/tree-renderer"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"test/**/*.ts",
|
||||
"../../__typings__/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
28
pnpm-lock.yaml
generated
28
pnpm-lock.yaml
generated
@@ -475,9 +475,6 @@ catalogs:
|
||||
ci-info:
|
||||
specifier: ^4.3.0
|
||||
version: 4.4.0
|
||||
cli-columns:
|
||||
specifier: ^4.0.0
|
||||
version: 4.0.0
|
||||
cli-truncate:
|
||||
specifier: ^5.2.0
|
||||
version: 5.2.0
|
||||
@@ -2126,9 +2123,6 @@ importers:
|
||||
'@pnpm/installing.dedupe.types':
|
||||
specifier: workspace:*
|
||||
version: link:../../installing/dedupe/types
|
||||
'@pnpm/installing.render-peer-issues':
|
||||
specifier: workspace:*
|
||||
version: link:../../installing/render-peer-issues
|
||||
'@pnpm/types':
|
||||
specifier: workspace:*
|
||||
version: link:../../core/types
|
||||
@@ -6220,28 +6214,6 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../../core/logger
|
||||
|
||||
installing/render-peer-issues:
|
||||
dependencies:
|
||||
'@pnpm/error':
|
||||
specifier: workspace:*
|
||||
version: link:../../core/error
|
||||
'@pnpm/text.tree-renderer':
|
||||
specifier: workspace:*
|
||||
version: link:../../text/tree-renderer
|
||||
'@pnpm/types':
|
||||
specifier: workspace:*
|
||||
version: link:../../core/types
|
||||
chalk:
|
||||
specifier: 'catalog:'
|
||||
version: 5.6.2
|
||||
cli-columns:
|
||||
specifier: 'catalog:'
|
||||
version: 4.0.0
|
||||
devDependencies:
|
||||
'@pnpm/installing.render-peer-issues':
|
||||
specifier: workspace:*
|
||||
version: 'link:'
|
||||
|
||||
lockfile/detect-dep-types:
|
||||
dependencies:
|
||||
'@pnpm/deps.path':
|
||||
|
||||
@@ -166,7 +166,6 @@ catalog:
|
||||
can-write-to-dir: ^2.0.0
|
||||
chalk: ^5.6.0
|
||||
ci-info: ^4.3.0
|
||||
cli-columns: ^4.0.0
|
||||
cli-truncate: ^5.2.0
|
||||
cmd-extension: ^2.0.0
|
||||
comver-to-semver: ^2.0.0
|
||||
|
||||
Reference in New Issue
Block a user