Files
pnpm/cli/default-reporter/README.md
Zoltan Kochan 6836547017 feat(default-reporter): add pnpm-render bin to render NDJSON from stdin (#11530)
- Adds a `pnpm-render` bin to `@pnpm/cli.default-reporter` that reads pnpm-shaped NDJSON from stdin and pipes it through the default reporter, so external tools that emit `pnpm:*` log records can reuse pnpm's renderer.
- Optional first positional arg sets the command name (defaults to `install`), e.g. `pnpm-render add` for piping output from `pacquet add`.

## Motivation

[Pacquet](https://github.com/pnpm/pacquet) emits pnpm-shaped `--reporter=ndjson` output for forward-compatibility with pnpm's renderer, but there was no way to actually render it. With this bin:

```sh
pacquet install --reporter=ndjson 2>&1 >/dev/null | pnpm-render
```

(pacquet writes NDJSON to stderr, so the redirect is needed.)
2026-05-08 01:56:54 +02:00

1.6 KiB

@pnpm/cli.default-reporter

The default reporter of pnpm

Installation

pnpm add @pnpm/cli.default-reporter

Usage

import { streamParser } from '@pnpm/logger'
import { initDefaultReporter } from '@pnpm/cli.default-reporter'

const stopReporting = initDefaultReporter({
  context: {
    argv: [],
  },
  streamParser,
})

try {
  // calling some pnpm APIs
} finally {
  stopReporting()
}

pnpm-render bin

Installing this package exposes a pnpm-render bin that reads pnpm-shaped NDJSON from stdin and renders it through the default reporter. This lets external tools that emit pnpm:* log records reuse pnpm's renderer.

For example, pacquet emits the same wire format under --reporter=ndjson (to stderr), so its output can be piped through pnpm-render:

pacquet install --reporter=ndjson 2>&1 >/dev/null | pnpm-render

The redirect (2>&1 >/dev/null) is needed because pacquet writes the NDJSON stream to stderr.

An optional first positional argument sets the command name (defaults to install); pass it to match the verb the producer is running so command-specific renderers behave correctly:

pacquet add lodash --reporter=ndjson 2>&1 >/dev/null | pnpm-render add

Style Guide

  1. Never use blue or grey as font color as they are hard to read in many consoles.
    1. Use dim instead of grey
    2. Use cyan bright instead of blue
  2. Don't hide the CLI cursor. (It is easier to never hide but it is really needed only when scripts are running.)
  3. Don't use green and yellow to distinct something.

License

MIT