mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 15:48:06 -05:00
fix: improve how ignored lifecycle scripts are reported (#8899)
This commit is contained in:
5
.changeset/clean-apes-greet.md
Normal file
5
.changeset/clean-apes-greet.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/core-loggers": minor
|
||||
---
|
||||
|
||||
Add new logger for ignored scripts.
|
||||
7
.changeset/mean-cycles-serve.md
Normal file
7
.changeset/mean-cycles-serve.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/default-reporter": minor
|
||||
"@pnpm/build-modules": minor
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Improve how packages with blocked lifecycle scripts are reported during installation. Always print the list of ignored scripts at the end of the output. Include a hint about how to allow the execution of those packages.
|
||||
@@ -137,6 +137,7 @@ export function toOutput$ (
|
||||
const statsPushStream = new Rx.Subject<logs.StatsLog>()
|
||||
const packageImportMethodPushStream = new Rx.Subject<logs.PackageImportMethodLog>()
|
||||
const installCheckPushStream = new Rx.Subject<logs.InstallCheckLog>()
|
||||
const ignoredScriptsPushStream = new Rx.Subject<logs.IgnoredScriptsLog>()
|
||||
const registryPushStream = new Rx.Subject<logs.RegistryLog>()
|
||||
const rootPushStream = new Rx.Subject<logs.RootLog>()
|
||||
const packageManifestPushStream = new Rx.Subject<logs.PackageManifestLog>()
|
||||
@@ -187,6 +188,9 @@ export function toOutput$ (
|
||||
case 'pnpm:install-check':
|
||||
installCheckPushStream.next(log)
|
||||
break
|
||||
case 'pnpm:ignored-scripts':
|
||||
ignoredScriptsPushStream.next(log)
|
||||
break
|
||||
case 'pnpm:registry':
|
||||
registryPushStream.next(log)
|
||||
break
|
||||
@@ -238,6 +242,7 @@ export function toOutput$ (
|
||||
executionTime: Rx.from(executionTimePushStream),
|
||||
hook: Rx.from(hookPushStream),
|
||||
installCheck: Rx.from(installCheckPushStream),
|
||||
ignoredScripts: Rx.from(ignoredScriptsPushStream),
|
||||
lifecycle: Rx.from(lifecyclePushStream),
|
||||
link: Rx.from(linkPushStream),
|
||||
other,
|
||||
|
||||
@@ -33,6 +33,7 @@ export function reporterForClient (
|
||||
context: Rx.Observable<logs.ContextLog>
|
||||
fetchingProgress: Rx.Observable<logs.FetchingProgressLog>
|
||||
executionTime: Rx.Observable<logs.ExecutionTimeLog>
|
||||
ignoredScripts: Rx.Observable<logs.IgnoredScriptsLog>
|
||||
progress: Rx.Observable<logs.ProgressLog>
|
||||
stage: Rx.Observable<logs.StageLog>
|
||||
deprecation: Rx.Observable<logs.DeprecationLog>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import path from 'path'
|
||||
import {
|
||||
type IgnoredScriptsLog,
|
||||
type DeprecationLog,
|
||||
type PackageManifestLog,
|
||||
type RootLog,
|
||||
@@ -37,6 +38,7 @@ export function reportSummary (
|
||||
summary: Rx.Observable<SummaryLog>
|
||||
root: Rx.Observable<RootLog>
|
||||
packageManifest: Rx.Observable<PackageManifestLog>
|
||||
ignoredScripts: Rx.Observable<IgnoredScriptsLog>
|
||||
},
|
||||
opts: {
|
||||
cmd: string
|
||||
@@ -53,11 +55,12 @@ export function reportSummary (
|
||||
|
||||
return Rx.combineLatest(
|
||||
pkgsDiff$,
|
||||
log$.ignoredScripts.pipe(Rx.startWith({ packageNames: undefined })),
|
||||
summaryLog$
|
||||
)
|
||||
.pipe(
|
||||
take(1),
|
||||
map(([pkgsDiff]) => {
|
||||
map(([pkgsDiff, ignoredScripts]) => {
|
||||
let msg = ''
|
||||
for (const depType of ['prod', 'optional', 'peer', 'dev', 'nodeModulesOnly'] as const) {
|
||||
let diffs: PackageDiff[] = Object.values(pkgsDiff[depType as keyof typeof pkgsDiff])
|
||||
@@ -82,6 +85,13 @@ export function reportSummary (
|
||||
msg += EOL
|
||||
}
|
||||
}
|
||||
if (ignoredScripts.packageNames && ignoredScripts.packageNames.length > 0) {
|
||||
msg += EOL
|
||||
msg += `The following dependencies have build scripts that were ignored: ${Array.from(ignoredScripts.packageNames).sort().join(', ')}`
|
||||
msg += EOL
|
||||
msg += 'To allow the execution of build scripts for these packages, add their names to "pnpm.onlyBuiltDependencies" in your "package.json", then run "pnpm rebuild"'
|
||||
msg += EOL
|
||||
}
|
||||
return Rx.of({ msg })
|
||||
})
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ import assert from 'assert'
|
||||
import path from 'path'
|
||||
import util from 'util'
|
||||
import { calcDepState, type DepsStateCache } from '@pnpm/calc-dep-state'
|
||||
import { skippedOptionalDependencyLogger } from '@pnpm/core-loggers'
|
||||
import { skippedOptionalDependencyLogger, ignoredScriptsLogger } from '@pnpm/core-loggers'
|
||||
import { runPostinstallHooks } from '@pnpm/lifecycle'
|
||||
import { linkBins, linkBinsOfPackages } from '@pnpm/link-bins'
|
||||
import { logger } from '@pnpm/logger'
|
||||
@@ -83,12 +83,7 @@ export async function buildModules<T extends string> (
|
||||
)
|
||||
})
|
||||
await runGroups(opts.childConcurrency ?? 4, groups)
|
||||
if (ignoredPkgs.size > 0) {
|
||||
logger.info({
|
||||
message: `The following dependencies have build scripts that were ignored: ${Array.from(ignoredPkgs).sort().join(', ')}`,
|
||||
prefix: opts.lockfileDir,
|
||||
})
|
||||
}
|
||||
ignoredScriptsLogger.debug({ packageNames: Array.from(ignoredPkgs) })
|
||||
}
|
||||
|
||||
async function buildDependency<T extends string> (
|
||||
|
||||
@@ -3,6 +3,7 @@ export * from './deprecationLogger'
|
||||
export * from './fetchingProgressLogger'
|
||||
export * from './hookLogger'
|
||||
export * from './installCheckLogger'
|
||||
export * from './ignoredScriptsLogger'
|
||||
export * from './lifecycleLogger'
|
||||
export * from './linkLogger'
|
||||
export * from './packageImportMethodLogger'
|
||||
|
||||
12
packages/core-loggers/src/ignoredScriptsLogger.ts
Normal file
12
packages/core-loggers/src/ignoredScriptsLogger.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {
|
||||
type LogBase,
|
||||
logger,
|
||||
} from '@pnpm/logger'
|
||||
|
||||
export const ignoredScriptsLogger = logger('ignored-scripts')
|
||||
|
||||
export interface IgnoredScriptsMessage {
|
||||
packageNames: string[]
|
||||
}
|
||||
|
||||
export type IgnoredScriptsLog = { name: 'pnpm:ignored-scripts' } & LogBase & IgnoredScriptsMessage
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
type ExecutionTimeLog,
|
||||
type HookLog,
|
||||
type InstallCheckLog,
|
||||
type IgnoredScriptsLog,
|
||||
type LifecycleLog,
|
||||
type LinkLog,
|
||||
type PackageImportMethodLog,
|
||||
@@ -31,6 +32,7 @@ export type Log =
|
||||
| ExecutionTimeLog
|
||||
| HookLog
|
||||
| InstallCheckLog
|
||||
| IgnoredScriptsLog
|
||||
| LifecycleLog
|
||||
| LinkLog
|
||||
| PackageManifestLog
|
||||
|
||||
Reference in New Issue
Block a user