@pnpm/cli.default-reporter 1100.0.9 → 1100.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/bin/pnpm-render.mjs +7 -0
- package/lib/cli.d.ts +1 -0
- package/lib/cli.js +50 -0
- package/package.json +14 -10
package/README.md
CHANGED
|
@@ -28,6 +28,24 @@ try {
|
|
|
28
28
|
}
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
## `pnpm-render` bin
|
|
32
|
+
|
|
33
|
+
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.
|
|
34
|
+
|
|
35
|
+
For example, [pacquet](https://github.com/pnpm/pacquet) emits the same wire format under `--reporter=ndjson` (to stderr), so its output can be piped through `pnpm-render`:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
pacquet install --reporter=ndjson 2>&1 >/dev/null | pnpm-render
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The redirect (`2>&1 >/dev/null`) is needed because pacquet writes the NDJSON stream to stderr.
|
|
42
|
+
|
|
43
|
+
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:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pacquet add lodash --reporter=ndjson 2>&1 >/dev/null | pnpm-render add
|
|
47
|
+
```
|
|
48
|
+
|
|
31
49
|
## Style Guide
|
|
32
50
|
|
|
33
51
|
1. Never use blue or grey as font color as they are hard to read in many consoles.
|
package/lib/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCli(argv: readonly string[]): Promise<void>;
|
package/lib/cli.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import readline from 'node:readline';
|
|
3
|
+
import { initDefaultReporter } from './index.js';
|
|
4
|
+
export async function runCli(argv) {
|
|
5
|
+
const cmd = argv[0] ?? 'install';
|
|
6
|
+
const emitter = new EventEmitter();
|
|
7
|
+
const streamParser = {
|
|
8
|
+
on: (event, reporter) => {
|
|
9
|
+
emitter.on(event, reporter);
|
|
10
|
+
},
|
|
11
|
+
removeListener: (event, reporter) => {
|
|
12
|
+
emitter.removeListener(event, reporter);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const close = initDefaultReporter({
|
|
16
|
+
streamParser,
|
|
17
|
+
context: { argv: [cmd] },
|
|
18
|
+
reportingOptions: {
|
|
19
|
+
throttleProgress: 200,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
// initDefaultReporter registers its 'data' listener via setTimeout(0); wait
|
|
23
|
+
// a tick so events emitted from the readline loop below aren't dropped.
|
|
24
|
+
await new Promise((resolve) => {
|
|
25
|
+
setTimeout(resolve, 0);
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
29
|
+
for await (const line of rl) {
|
|
30
|
+
if (!line)
|
|
31
|
+
continue;
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = JSON.parse(line);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// Guard against valid JSON that isn't a log object (e.g. `null`,
|
|
40
|
+
// numbers, strings) — the reporter dispatches on `log.name`.
|
|
41
|
+
if (parsed == null || typeof parsed !== 'object')
|
|
42
|
+
continue;
|
|
43
|
+
emitter.emit('data', parsed);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=cli.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/cli.default-reporter",
|
|
3
|
-
"version": "1100.0
|
|
3
|
+
"version": "1100.1.0",
|
|
4
4
|
"description": "The default reporter of pnpm",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -22,33 +22,37 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"lib",
|
|
25
|
-
"!*.map"
|
|
25
|
+
"!*.map",
|
|
26
|
+
"bin"
|
|
26
27
|
],
|
|
28
|
+
"bin": {
|
|
29
|
+
"pnpm-render": "bin/pnpm-render.mjs"
|
|
30
|
+
},
|
|
27
31
|
"dependencies": {
|
|
28
32
|
"@pnpm/util.lex-comparator": "^3.0.2",
|
|
29
33
|
"ansi-diff": "^1.2.0",
|
|
30
34
|
"boxen": "npm:@zkochan/boxen@5.1.2",
|
|
31
|
-
"chalk": "^5.6.
|
|
35
|
+
"chalk": "^5.6.2",
|
|
32
36
|
"cli-truncate": "^5.2.0",
|
|
33
37
|
"normalize-path": "^3.0.0",
|
|
34
38
|
"pretty-bytes": "^7.1.0",
|
|
35
|
-
"pretty-ms": "^9.
|
|
39
|
+
"pretty-ms": "^9.3.0",
|
|
36
40
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
37
41
|
"rxjs": "^7.8.2",
|
|
38
|
-
"semver": "^7.7.
|
|
42
|
+
"semver": "^7.7.4",
|
|
39
43
|
"stacktracey": "^2.2.0",
|
|
40
44
|
"string-length": "^7.0.1",
|
|
41
45
|
"@pnpm/cli.meta": "1100.0.2",
|
|
46
|
+
"@pnpm/config.reader": "1101.2.2",
|
|
42
47
|
"@pnpm/core-loggers": "1100.0.1",
|
|
43
|
-
"@pnpm/deps.inspection.peers-issues-renderer": "1100.0.0",
|
|
44
48
|
"@pnpm/error": "1100.0.0",
|
|
45
49
|
"@pnpm/installing.dedupe.issues-renderer": "1100.0.1",
|
|
50
|
+
"@pnpm/deps.inspection.peers-issues-renderer": "1100.0.0",
|
|
46
51
|
"@pnpm/installing.dedupe.types": "1100.0.1",
|
|
47
|
-
"@pnpm/types": "1101.0.0"
|
|
48
|
-
"@pnpm/config.reader": "1101.2.0"
|
|
52
|
+
"@pnpm/types": "1101.0.0"
|
|
49
53
|
},
|
|
50
54
|
"peerDependencies": {
|
|
51
|
-
"@pnpm/logger": "
|
|
55
|
+
"@pnpm/logger": "^1001.0.1"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
58
|
"@jest/globals": "30.3.0",
|
|
@@ -58,7 +62,7 @@
|
|
|
58
62
|
"ghooks": "2.0.4",
|
|
59
63
|
"load-json-file": "^7.0.1",
|
|
60
64
|
"normalize-newline": "5.0.0",
|
|
61
|
-
"@pnpm/cli.default-reporter": "1100.0
|
|
65
|
+
"@pnpm/cli.default-reporter": "1100.1.0",
|
|
62
66
|
"@pnpm/logger": "1100.0.0"
|
|
63
67
|
},
|
|
64
68
|
"engines": {
|