Zoltan Kochan bf1937bebf fix: render NDJSON output cleanly through @pnpm/default-reporter (#403)
* fix(cli): canonicalize `--dir` so reporter `prefix` matches subprocess `process.cwd()`

`pacquet --reporter=ndjson` piped into `@pnpm/cli.default-reporter`
emitted every progress / stats line with a `.   |   ` path prefix
because the bunyan-envelope `prefix` field was the literal `"."`
(derived from the manifest's parent of `./package.json`). The reporter
compares each event's `prefix` to its own `cwd` (an absolute,
canonicalized path from `process.cwd()`), and the mismatch routed every
log through `zoomOut`.

Canonicalize `--dir` once at the top of `CliArgs::run`, mirroring pnpm's
`config/reader/src/index.ts:270` where
`cwd = fs.realpathSync(betterPathResolve(cliOptions.dir ...))` becomes
`pnpmConfig.dir` and is threaded into every event's `prefix` as
`lockfileDir`. Ports the same realpath behavior to pacquet so a
default-reporter subprocess and pacquet agree on the project root.

Side effect: `pacquet init` now derives the package `name` from the
working-directory basename (matching pnpm) instead of leaving it as
`""` — the `.` parent had no `file_name`. Snapshot updated.

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix(tarball): emit `pnpm:fetching-progress started` with one-indexed `attempt`

The default reporter's `reportBigTarballsProgress` filters started
events with `log.attempt === 1` so a transient retry doesn't reset the
"Downloading <pkg>: …/<size>" progress line. Pacquet's loop counter is
zero-indexed and was being passed straight through, so every started
event was emitted with `attempt: 0` and the reporter silently dropped
the entire channel — no big-tarball progress lines ever rendered.

Pnpm's underlying `node-retry` `op.attempt(cb)` callback hands `cb` a
1-indexed counter, which `packageRequester` forwards verbatim into the
log. Match that wire shape by emitting `attempt + 1` at the
fetching-progress site, mirroring the same `+ 1` adjustment already
present at the neighbouring `pnpm:request-retry` emit.

Updates the recording-fake test to assert `[1, 2]` (one-indexed) and
fixes a stray `attempt: 0` in the reporter serialization test.

* test(cli): add NDJSON `prefix` regression test, refine review nits

Addresses three review comments on #403:

* Add an integration test (`install_emits_canonical_prefix_in_ndjson_events`)
  that runs `pacquet --reporter=ndjson install` and asserts every
  event's `prefix` is the canonicalized workspace path — never `"."`.
  Pins the user-visible regression: the original failure mode was the
  default-reporter subprocess prepending `<prefix> | ` to every progress
  / stats line because the emitted `"."` never matched its own
  `process.cwd()`.
* Reword the canonicalize-failure context to reference the `--dir`
  argument explicitly so a stat / permission failure points the user at
  the flag they passed.
* Restore the `assertion_line` field on
  `init__should_create_package_json.snap` so its metadata matches the
  surrounding insta snapshots.

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-08 01:41:35 +02:00
Description
No description provided
MIT 294 MiB
Languages
Rust 61.2%
TypeScript 38.3%
JavaScript 0.4%