From ab9eb59e9ceaaeb43a8f748dc61a9f0d5be2dd5e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 7 Mar 2026 14:05:26 +0100 Subject: [PATCH] fix: improve global install output to show clean summary (#10897) Hide the ugly temporary directory path prefix from progress output for global installs (same approach as dlx). Show a proper install summary with "global:" heading instead of the temp directory path. --- .changeset/fix-global-install-output.md | 6 ++++++ cli/default-reporter/src/index.ts | 2 +- cli/default-reporter/src/reporterForClient/pkgsDiff.ts | 8 +++++--- .../src/reporterForClient/reportSummary.ts | 8 ++------ cli/default-reporter/test/index.ts | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 .changeset/fix-global-install-output.md diff --git a/.changeset/fix-global-install-output.md b/.changeset/fix-global-install-output.md new file mode 100644 index 0000000000..7ab0bad235 --- /dev/null +++ b/.changeset/fix-global-install-output.md @@ -0,0 +1,6 @@ +--- +"@pnpm/default-reporter": patch +"pnpm": patch +--- + +Fixed the output of global install to show a clean install summary instead of displaying ugly temporary directory paths in progress output. diff --git a/cli/default-reporter/src/index.ts b/cli/default-reporter/src/index.ts index 52b302bad4..e159e9041f 100644 --- a/cli/default-reporter/src/index.ts +++ b/cli/default-reporter/src/index.ts @@ -275,7 +275,7 @@ export function toOutput$ ( throttleProgress: opts.reportingOptions?.throttleProgress, width: opts.reportingOptions?.outputMaxWidth, hideAddedPkgsProgress: opts.reportingOptions?.hideAddedPkgsProgress, - hideProgressPrefix: opts.reportingOptions?.hideProgressPrefix ?? (cmd === 'dlx'), + hideProgressPrefix: opts.reportingOptions?.hideProgressPrefix ?? (cmd === 'dlx' || opts.context.config?.global === true), hideLifecycleOutput: opts.reportingOptions?.hideLifecycleOutput, hideLifecyclePrefix: opts.reportingOptions?.hideLifecyclePrefix, approveBuildsInstructionText: opts.reportingOptions?.approveBuildsInstructionText, diff --git a/cli/default-reporter/src/reporterForClient/pkgsDiff.ts b/cli/default-reporter/src/reporterForClient/pkgsDiff.ts index 578d73cf7f..916c38f6e1 100644 --- a/cli/default-reporter/src/reporterForClient/pkgsDiff.ts +++ b/cli/default-reporter/src/reporterForClient/pkgsDiff.ts @@ -42,12 +42,12 @@ export function getPkgsDiff ( packageManifest: Rx.Observable }, opts: { - prefix: string + prefix?: string } ): Rx.Observable { const deprecationSet$ = log$.deprecation .pipe( - filter((log) => log.prefix === opts.prefix), + filter((log) => !opts.prefix || log.prefix === opts.prefix), scan((acc, log) => { acc.add(log.pkgId) return acc @@ -55,7 +55,9 @@ export function getPkgsDiff ( startWith(new Set()) ) - const filterPrefix = filter((log: { prefix: string }) => log.prefix === opts.prefix) + const filterPrefix = opts.prefix + ? filter((log: { prefix: string }) => log.prefix === opts.prefix) + : (x: Rx.Observable) => x const pkgsDiff$ = Rx.combineLatest( log$.root.pipe(filterPrefix), deprecationSet$ diff --git a/cli/default-reporter/src/reporterForClient/reportSummary.ts b/cli/default-reporter/src/reporterForClient/reportSummary.ts index 9f5351c8af..affa96805f 100644 --- a/cli/default-reporter/src/reporterForClient/reportSummary.ts +++ b/cli/default-reporter/src/reporterForClient/reportSummary.ts @@ -46,7 +46,7 @@ export function reportSummary ( pnpmConfig?: Config } ): Rx.Observable> { - const pkgsDiff$ = getPkgsDiff(log$, { prefix: opts.cwd }) + const pkgsDiff$ = getPkgsDiff(log$, { prefix: opts.pnpmConfig?.global ? undefined : opts.cwd }) const summaryLog$ = log$.summary.pipe(take(1)) const _printDiffs = printDiffs.bind(null, { cmd: opts.cmd, prefix: opts.cwd, pnpmConfig: opts.pnpmConfig }) @@ -68,11 +68,7 @@ export function reportSummary ( } if (diffs.length > 0) { msg += EOL - if (opts.pnpmConfig?.global) { - msg += chalk.cyanBright(`${opts.cwd}:`) - } else { - msg += chalk.cyanBright(`${propertyByDependencyType[depType] as string}:`) - } + msg += chalk.cyanBright(opts.pnpmConfig?.global ? 'global:' : `${propertyByDependencyType[depType] as string}:`) msg += EOL msg += _printDiffs(diffs, depType) msg += EOL diff --git a/cli/default-reporter/test/index.ts b/cli/default-reporter/test/index.ts index ea6435bc44..7d89eada96 100644 --- a/cli/default-reporter/test/index.ts +++ b/cli/default-reporter/test/index.ts @@ -404,7 +404,7 @@ test('prints summary for global installation', async () => { const output = await firstValueFrom(output$.pipe(take(1), map(normalizeNewline))) expect(output).toBe(EOL + `\ -${h1(`${prefix}:`)} +${h1('global:')} ${ADD} bar ${versionColor('2.0.0')} ${ADD} foo ${versionColor('1.0.0')} ${versionColor('(2.0.0 is available)')} `)