fix: make the warning about blocked install scripts more prominent (#9067)

This commit is contained in:
Zoltan Kochan
2025-02-09 01:34:18 +01:00
committed by GitHub
parent c52f55af30
commit 371734043a
6 changed files with 34 additions and 20 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/render-peer-issues": patch
---
Remove trailing new line from the output.

View File

@@ -0,0 +1,8 @@
---
"@pnpm/default-reporter": patch
"@pnpm/core": patch
"@pnpm/crypto.object-hasher": patch
"pnpm": patch
---
Print the warning about blocked installation scripts at the end of the installation output and make it more prominent.

View File

@@ -9,6 +9,7 @@ import {
import { type Config } from '@pnpm/config'
import * as Rx from 'rxjs'
import { map, take } from 'rxjs/operators'
import boxen from 'boxen'
import chalk from 'chalk'
import semver from 'semver'
import { EOL } from '../constants'
@@ -87,7 +88,14 @@ export function reportSummary (
}
if (ignoredScripts.packageNames && ignoredScripts.packageNames.length > 0) {
msg += EOL
msg += `Ignored build scripts: ${Array.from(ignoredScripts.packageNames).sort().join(', ')}. Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.`
msg += boxen(`Ignored build scripts: ${Array.from(ignoredScripts.packageNames).sort().join(', ')}.
Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.`, {
title: 'Warning',
padding: 1,
margin: 0,
borderStyle: 'round',
borderColor: 'yellow',
})
msg += EOL
}
return Rx.of({ msg })

View File

@@ -72,7 +72,7 @@ export function renderPeerIssues (
const { conflicts, intersections } = peerDependencyIssuesByProjects[projectKey]
if (conflicts.length) {
summaries.push(
chalk.red(`✕ Conflicting peer dependencies:\n ${cliColumns(conflicts, cliColumnsOptions)}`)
chalk.red(`✕ Conflicting peer dependencies:\n ${cliColumns(conflicts, cliColumnsOptions).trimEnd()}`)
)
}
if (Object.keys(intersections).length) {
@@ -81,12 +81,9 @@ export function renderPeerIssues (
)
}
const title = chalk.reset(projectKey)
let summariesConcatenated = summaries.join('\n')
if (summariesConcatenated) {
summariesConcatenated += '\n'
}
return `${archy(toArchyData(title, project))}${summariesConcatenated}`
}).join('\n')
const summariesConcatenated = summaries.join('\n')
return `${archy(toArchyData(title, project))}${summariesConcatenated}`.trimEnd()
}).join('\n\n')
}
function formatUnmetPeerMessage (

View File

@@ -8,7 +8,7 @@ exports[`renderPeerIssues() 1`] = `
├── ✕ 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
aaa@^1.0.0
packages/0
├─┬ zzz 1.0.0
@@ -17,17 +17,15 @@ packages/0
└─┬ www 1.0.0
└── ✕ missing peer eee@^2.0.0
✕ Conflicting peer dependencies:
eee
eee
Peer dependencies that should be installed:
ddd@^1.0.0
"
ddd@^1.0.0"
`;
exports[`renderPeerIssues() allowed versions 1`] = `
".
└─┬ aaa 1.0.0
└── ✕ unmet peer @foo/bar@^1.0.0: found 2.0.0
"
└── ✕ unmet peer @foo/bar@^1.0.0: found 2.0.0"
`;
exports[`renderPeerIssues() format correctly the version ranges with spaces and "*" 1`] = `
@@ -36,8 +34,7 @@ exports[`renderPeerIssues() format correctly the version ranges with spaces and
├── ✕ missing peer a@"*"
└── ✕ missing peer b@"1 || 2"
Peer dependencies that should be installed:
a@"*" b@"1 || 2"
"
a@"*" b@"1 || 2""
`;
exports[`renderPeerIssues() optional peer dependencies are printed only if they are in conflict with non-optional peers 1`] = `
@@ -47,6 +44,5 @@ exports[`renderPeerIssues() optional peer dependencies are printed only if they
├── ✕ missing peer aaa@^1.0.0
└── ✕ missing peer aaa@^2.0.0
✕ Conflicting peer dependencies:
aaa
"
aaa"
`;

View File

@@ -1300,13 +1300,13 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
}))
}
summaryLogger.debug({ prefix: opts.lockfileDir })
reportPeerDependencyIssues(peerDependencyIssuesByProjects, {
lockfileDir: opts.lockfileDir,
strictPeerDependencies: opts.strictPeerDependencies,
})
summaryLogger.debug({ prefix: opts.lockfileDir })
// Similar to the sequencing for when the original wanted lockfile is
// copied, the new lockfile passed here should be as close as possible to
// what will eventually be written to disk. Ex: peers should be resolved,