From efb341bd7194d3b40540e868d5d262b97d7a1fe1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 15 Mar 2026 22:08:09 +0100 Subject: [PATCH] test: add test for install summary without updated manifest log Add a reporter test verifying that when packageManifestLogger only emits the initial manifest (as happens during dry runs), the summary correctly shows only root-level changes without false dependency type diffs. Also add changeset for the install summary fix. Co-Authored-By: Claude Opus 4.6 --- .changeset/fix-install-summary.md | 6 ++++ cli/default-reporter/test/index.ts | 48 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 .changeset/fix-install-summary.md diff --git a/.changeset/fix-install-summary.md b/.changeset/fix-install-summary.md new file mode 100644 index 0000000000..30074e08d7 --- /dev/null +++ b/.changeset/fix-install-summary.md @@ -0,0 +1,6 @@ +--- +"@pnpm/resolve-dependencies": patch +"pnpm": patch +--- + +Fixed the install summary in workspaces by setting recursive config before reporter initialization and skipping manifest logging during dry runs. diff --git a/cli/default-reporter/test/index.ts b/cli/default-reporter/test/index.ts index 0fdf77993d..9556dc377a 100644 --- a/cli/default-reporter/test/index.ts +++ b/cli/default-reporter/test/index.ts @@ -38,6 +38,54 @@ const h1 = chalk.cyanBright const EOL = '\n' +test('does not show false dependency changes when updated manifest is not logged', async () => { + const prefix = '/home/jane/project' + const output$ = toOutput$({ + context: { + argv: ['install'], + config: { dir: prefix } as Config, + }, + streamParser: createStreamParser(), + }) + + // During a dry run, only the initial manifest is logged (no updated manifest). + // The summary should only show root-level added packages, not false dependency type changes. + packageManifestLogger.debug({ + initial: { + name: 'foo', + version: '1.0.0', + + dependencies: { + 'is-positive': '^1.0.0', + }, + devDependencies: { + 'is-negative': '^1.0.0', + }, + }, + prefix, + }) + rootLogger.debug({ + added: { + dependencyType: 'prod', + id: 'registry.npmjs.org/is-positive/1.0.0', + name: 'is-positive', + realName: 'is-positive', + version: '1.0.0', + }, + prefix, + }) + summaryLogger.debug({ prefix }) + + expect.assertions(1) + + const output = await firstValueFrom(output$.pipe(take(1), map(normalizeNewline))) + // Should only show the added package, not re-list existing deps as added/removed + expect(output).toBe(EOL + `\ +${h1('dependencies:')} +${ADD} is-positive ${versionColor('1.0.0')} +`) +}) + test('prints summary (of current package only)', async () => { const prefix = '/home/jane/project' const output$ = toOutput$({