@williamthorsen/nmr-core 0.11.0 → 0.12.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/.meta/changelog.json +44 -0
- package/CHANGELOG.md +32 -0
- package/README.md +18 -3
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/terminal.d.ts +49 -8
- package/dist/esm/terminal.js +39 -16
- package/package.json +7 -5
package/.meta/changelog.json
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"date": "2026-09-18",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "🎉 Features",
|
|
8
|
+
"audience": "all",
|
|
9
|
+
"items": [
|
|
10
|
+
{
|
|
11
|
+
"description": "Give nmr-core's print helpers plain output in pipes and CI logs (#834)",
|
|
12
|
+
"body": "- Stops `printError`, `printSkip`, `printSuccess`, and `reportWriteResult` in `@williamthorsen/nmr-core` from printing emoji into a pipe or a CI log: Each helper now detects a plain or rich style from `CI` and the terminal state of its own stream (stderr for `printError`, stdout for the others), and accepts an optional trailing `OutputStyle` that outranks detection.\n- Adds `resolveStreamStyles`, which resolves a `plain` or `rich` output style separately for stdout and stderr, reading a caller-named flag first, then a caller-named environment variable (`auto`, `plain`, or `rich`), then `CI`, the stream's terminal state, and `TERM`, and which returns a setting that it does not recognize in `invalid` instead of throwing.\n- Re-exports `defineGlyphSet`, `STATUS_GLYPHS`, `wrapToWidth`, `measureGlyphColumn`, and `describeInvalidOutputStyle` from the experimental `/candidate` API of `@williamthorsen/toolbelt.terminal`, so that a package that depends on `@williamthorsen/nmr-core` builds glyph sets and wraps text without declaring that dependency itself.\n- Changes the rich marker of `printSkip` from ⚠️ to 🟠, the `warning` glyph in `STATUS_GLYPHS`; rich `printError` and `printSuccess` output is unchanged.",
|
|
13
|
+
"hash": "0c45461848b6c7bfee5a28be2a1cb2633ccdddfe"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"description": "Give release-kit plain output in pipes and CI logs (#835)",
|
|
17
|
+
"body": "- Adds the `RELEASE_KIT_OUTPUT_STYLE` environment variable, which accepts `auto`, `plain`, or `rich` and outranks the detection from `CI`, the stream's terminal state, and `TERM`; any other value is a usage error that exits with code 1.\n- Changes the emoji in rich output so that none has a different meaning from the one that it has in `nmr`: warnings from ⚠️ to 🟠, skips from ⏭️ to ⏩, the errors of `show-tag-prefixes` from ⛔ to ❌, and the tag marker from 🏷️ to 🔖.\n- Adds a required `style` parameter to `formatValidateOverridesResult`, which the package root exports.",
|
|
18
|
+
"hash": "aae401b4bbcafc7014e4b3804d80528d2d098a30"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"description": "Give nmr plain output in pipes and CI logs (#838)",
|
|
22
|
+
"body": "- Stops `nmr` from printing emoji to a pipe or a CI log: When the output stream is not a terminal or `CI` is set, a verdict reads `PASS`, `FAIL`, `SKIP`, or `NOOP` and a command icon is omitted, so that a log can be searched for a verdict.\n- Adds `--output-style <auto|plain|rich>` to `nmr` and the `NMR_OUTPUT_STYLE` variable, each forcing either style; the flag outranks the variable, a value that names no style exits 1 with a usage error, and neither enters a check-cache key: A rich run and a plain run share a recorded pass.\n- Replaces several rich glyphs, taking the status markers from the set that release-kit and v11y-check print so that one status has one glyph across the three tools: a recalled pass shows ⏩ in place of ⏭️, a skipped empty override shows ⚪ in place of ⛔, a warning and the `--log` refusal show 🟠 in place of ⚠️ and 📭, the `--log` header shows 💾 in place of 📼, and `nmr-ensure-prepublish-hooks` reports ✅ and ❌ in place of ✓ and ✗.",
|
|
23
|
+
"hash": "693b3a7f57def3d299ced240c19bda90f6253bdc"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"version": "0.11.1",
|
|
31
|
+
"date": "2026-09-15",
|
|
32
|
+
"sections": [
|
|
33
|
+
{
|
|
34
|
+
"title": "⚙️ Tooling",
|
|
35
|
+
"audience": "dev",
|
|
36
|
+
"items": [
|
|
37
|
+
{
|
|
38
|
+
"description": "Upgrade eslint-config-typescript to v17 and adopt its ignore lists (#797)",
|
|
39
|
+
"body": "- Declares `vitest` as `catalog:` in every workspace that imports it, with the pnpm catalog pinning 4.1.11, because v17 no longer exempts `vitest` from `n/no-extraneous-import`.\n- Builds the global ignores in `eslint.config.ts` from the published `commonIgnores` and `toolIgnores`, which also exclude `pnpm-lock.yaml` and each `.readyup/manifest.json`, so the `eslint --fix` in `nmr lint` can no longer rewrite a kit manifest and make the next build's `rdy verify` fail.",
|
|
40
|
+
"hash": "b201669444763ad5bef85730b114098ef352e09b"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
2
46
|
{
|
|
3
47
|
"version": "0.11.0",
|
|
4
48
|
"date": "2026-09-08",
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.12.0 — 2026-09-18
|
|
6
|
+
|
|
7
|
+
### 🎉 Features
|
|
8
|
+
|
|
9
|
+
- Give nmr-core's print helpers plain output in pipes and CI logs (#834)
|
|
10
|
+
|
|
11
|
+
- Stops `printError`, `printSkip`, `printSuccess`, and `reportWriteResult` in `@williamthorsen/nmr-core` from printing emoji into a pipe or a CI log: Each helper now detects a plain or rich style from `CI` and the terminal state of its own stream (stderr for `printError`, stdout for the others), and accepts an optional trailing `OutputStyle` that outranks detection.
|
|
12
|
+
- Adds `resolveStreamStyles`, which resolves a `plain` or `rich` output style separately for stdout and stderr, reading a caller-named flag first, then a caller-named environment variable (`auto`, `plain`, or `rich`), then `CI`, the stream's terminal state, and `TERM`, and which returns a setting that it does not recognize in `invalid` instead of throwing.
|
|
13
|
+
- Re-exports `defineGlyphSet`, `STATUS_GLYPHS`, `wrapToWidth`, `measureGlyphColumn`, and `describeInvalidOutputStyle` from the experimental `/candidate` API of `@williamthorsen/toolbelt.terminal`, so that a package that depends on `@williamthorsen/nmr-core` builds glyph sets and wraps text without declaring that dependency itself.
|
|
14
|
+
- Changes the rich marker of `printSkip` from ⚠️ to 🟠, the `warning` glyph in `STATUS_GLYPHS`; rich `printError` and `printSuccess` output is unchanged.
|
|
15
|
+
|
|
16
|
+
- Give release-kit plain output in pipes and CI logs (#835)
|
|
17
|
+
|
|
18
|
+
- Adds the `RELEASE_KIT_OUTPUT_STYLE` environment variable, which accepts `auto`, `plain`, or `rich` and outranks the detection from `CI`, the stream's terminal state, and `TERM`; any other value is a usage error that exits with code 1.
|
|
19
|
+
- Changes the emoji in rich output so that none has a different meaning from the one that it has in `nmr`: warnings from ⚠️ to 🟠, skips from ⏭️ to ⏩, the errors of `show-tag-prefixes` from ⛔ to ❌, and the tag marker from 🏷️ to 🔖.
|
|
20
|
+
- Adds a required `style` parameter to `formatValidateOverridesResult`, which the package root exports.
|
|
21
|
+
|
|
22
|
+
- Give nmr plain output in pipes and CI logs (#838)
|
|
23
|
+
|
|
24
|
+
- Stops `nmr` from printing emoji to a pipe or a CI log: When the output stream is not a terminal or `CI` is set, a verdict reads `PASS`, `FAIL`, `SKIP`, or `NOOP` and a command icon is omitted, so that a log can be searched for a verdict.
|
|
25
|
+
- Adds `--output-style <auto|plain|rich>` to `nmr` and the `NMR_OUTPUT_STYLE` variable, each forcing either style; the flag outranks the variable, a value that names no style exits 1 with a usage error, and neither enters a check-cache key: A rich run and a plain run share a recorded pass.
|
|
26
|
+
- Replaces several rich glyphs, taking the status markers from the set that release-kit and v11y-check print so that one status has one glyph across the three tools: a recalled pass shows ⏩ in place of ⏭️, a skipped empty override shows ⚪ in place of ⛔, a warning and the `--log` refusal show 🟠 in place of ⚠️ and 📭, the `--log` header shows 💾 in place of 📼, and `nmr-ensure-prepublish-hooks` reports ✅ and ❌ in place of ✓ and ✗.
|
|
27
|
+
|
|
28
|
+
## 0.11.1 — 2026-09-15
|
|
29
|
+
|
|
30
|
+
### ⚙️ Tooling
|
|
31
|
+
|
|
32
|
+
- Upgrade eslint-config-typescript to v17 and adopt its ignore lists (#797)
|
|
33
|
+
|
|
34
|
+
- Declares `vitest` as `catalog:` in every workspace that imports it, with the pnpm catalog pinning 4.1.11, because v17 no longer exempts `vitest` from `n/no-extraneous-import`.
|
|
35
|
+
- Builds the global ignores in `eslint.config.ts` from the published `commonIgnores` and `toolIgnores`, which also exclude `pnpm-lock.yaml` and each `.readyup/manifest.json`, so the `eslint --fix` in `nmr lint` can no longer rewrite a kit manifest and make the next build's `rdy verify` fail.
|
|
36
|
+
|
|
5
37
|
## 0.11.0 — 2026-09-08
|
|
6
38
|
|
|
7
39
|
### 🎉 Features
|
package/README.md
CHANGED
|
@@ -5,13 +5,28 @@ Shared utilities for node-monorepo-tools packages.
|
|
|
5
5
|
This package serves as the shared library foundation for the monorepo. For the nmr CLI tool, see [`@williamthorsen/nmr`](../nmr).
|
|
6
6
|
|
|
7
7
|
<!-- section:release-notes -->
|
|
8
|
-
## Release notes — v0.
|
|
8
|
+
## Release notes — v0.12.0 (2026-09-18)
|
|
9
9
|
|
|
10
10
|
### 🎉 Features
|
|
11
11
|
|
|
12
|
-
-
|
|
12
|
+
- Give nmr-core's print helpers plain output in pipes and CI logs (#834)
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
- Stops `printError`, `printSkip`, `printSuccess`, and `reportWriteResult` in `@williamthorsen/nmr-core` from printing emoji into a pipe or a CI log: Each helper now detects a plain or rich style from `CI` and the terminal state of its own stream (stderr for `printError`, stdout for the others), and accepts an optional trailing `OutputStyle` that outranks detection.
|
|
15
|
+
- Adds `resolveStreamStyles`, which resolves a `plain` or `rich` output style separately for stdout and stderr, reading a caller-named flag first, then a caller-named environment variable (`auto`, `plain`, or `rich`), then `CI`, the stream's terminal state, and `TERM`, and which returns a setting that it does not recognize in `invalid` instead of throwing.
|
|
16
|
+
- Re-exports `defineGlyphSet`, `STATUS_GLYPHS`, `wrapToWidth`, `measureGlyphColumn`, and `describeInvalidOutputStyle` from the experimental `/candidate` API of `@williamthorsen/toolbelt.terminal`, so that a package that depends on `@williamthorsen/nmr-core` builds glyph sets and wraps text without declaring that dependency itself.
|
|
17
|
+
- Changes the rich marker of `printSkip` from ⚠️ to 🟠, the `warning` glyph in `STATUS_GLYPHS`; rich `printError` and `printSuccess` output is unchanged.
|
|
18
|
+
|
|
19
|
+
- Give release-kit plain output in pipes and CI logs (#835)
|
|
20
|
+
|
|
21
|
+
- Adds the `RELEASE_KIT_OUTPUT_STYLE` environment variable, which accepts `auto`, `plain`, or `rich` and outranks the detection from `CI`, the stream's terminal state, and `TERM`; any other value is a usage error that exits with code 1.
|
|
22
|
+
- Changes the emoji in rich output so that none has a different meaning from the one that it has in `nmr`: warnings from ⚠️ to 🟠, skips from ⏭️ to ⏩, the errors of `show-tag-prefixes` from ⛔ to ❌, and the tag marker from 🏷️ to 🔖.
|
|
23
|
+
- Adds a required `style` parameter to `formatValidateOverridesResult`, which the package root exports.
|
|
24
|
+
|
|
25
|
+
- Give nmr plain output in pipes and CI logs (#838)
|
|
26
|
+
|
|
27
|
+
- Stops `nmr` from printing emoji to a pipe or a CI log: When the output stream is not a terminal or `CI` is set, a verdict reads `PASS`, `FAIL`, `SKIP`, or `NOOP` and a command icon is omitted, so that a log can be searched for a verdict.
|
|
28
|
+
- Adds `--output-style <auto|plain|rich>` to `nmr` and the `NMR_OUTPUT_STYLE` variable, each forcing either style; the flag outranks the variable, a value that names no style exits 1 with a usage error, and neither enters a check-cache key: A rich run and a plain run share a recorded pass.
|
|
29
|
+
- Replaces several rich glyphs, taking the status markers from the set that release-kit and v11y-check print so that one status has one glyph across the three tools: a recalled pass shows ⏩ in place of ⏭️, a skipped empty override shows ⚪ in place of ⛔, a warning and the `--log` refusal show 🟠 in place of ⚠️ and 📭, the `--log` header shows 💾 in place of 📼, and `nmr-ensure-prepublish-hooks` reports ✅ and ❌ in place of ✓ and ✗.
|
|
15
30
|
<!-- /section:release-notes -->
|
|
16
31
|
|
|
17
32
|
## Installation
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { hashWorkingTree, readHeadSha } from './hashWorkingTree.js';
|
|
|
9
9
|
export type { FlagDefinition, FlagSchema, ParseArgsOptions, ParsedArgs, ParsedFlags, ParseErrorKind, } from './parseArgs.js';
|
|
10
10
|
export { parseArgs, parseArgsOrExit, ParseError } from './parseArgs.js';
|
|
11
11
|
export { readPackageVersion } from './readPackageVersion.js';
|
|
12
|
-
export {
|
|
12
|
+
export type { GlyphSet, InvalidOutputStyle, OutputStyle, ResolveStreamStylesOptions, StatusGlyphName, StreamStyleResolution, StreamStyles, } from './terminal.js';
|
|
13
|
+
export { defineGlyphSet, describeInvalidOutputStyle, formatErrorLine, formatGlyphLine, formatStatusLine, measureGlyphColumn, printError, printSkip, printStep, printSuccess, reportError, reportWriteResult, resolveStreamStyles, STATUS_GLYPHS, wrapToWidth, } from './terminal.js';
|
|
13
14
|
export type { WriteOutcome, WriteResult } from './writeFileWithCheck.js';
|
|
14
15
|
export { writeFileWithCheck } from './writeFileWithCheck.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -6,5 +6,5 @@ export { hasErrnoCode } from "./hasErrnoCode.js";
|
|
|
6
6
|
export { hashWorkingTree, readHeadSha } from "./hashWorkingTree.js";
|
|
7
7
|
export { parseArgs, parseArgsOrExit, ParseError } from "./parseArgs.js";
|
|
8
8
|
export { readPackageVersion } from "./readPackageVersion.js";
|
|
9
|
-
export { formatErrorLine, printError, printSkip, printStep, printSuccess, reportError, reportWriteResult, } from "./terminal.js";
|
|
9
|
+
export { defineGlyphSet, describeInvalidOutputStyle, formatErrorLine, formatGlyphLine, formatStatusLine, measureGlyphColumn, printError, printSkip, printStep, printSuccess, reportError, reportWriteResult, resolveStreamStyles, STATUS_GLYPHS, wrapToWidth, } from "./terminal.js";
|
|
10
10
|
export { writeFileWithCheck } from "./writeFileWithCheck.js";
|
package/dist/esm/terminal.d.ts
CHANGED
|
@@ -1,24 +1,65 @@
|
|
|
1
1
|
import type { Writable } from 'node:stream';
|
|
2
|
+
import { type GlyphSet, type InvalidOutputStyle, type OutputStyle, type StatusGlyphName } from '@williamthorsen/toolbelt.terminal/candidate';
|
|
2
3
|
import type { WriteResult } from './writeFileWithCheck.js';
|
|
4
|
+
export type { GlyphSet, InvalidOutputStyle, OutputStyle, StatusGlyphName, } from '@williamthorsen/toolbelt.terminal/candidate';
|
|
5
|
+
export { defineGlyphSet, describeInvalidOutputStyle, measureGlyphColumn, STATUS_GLYPHS, wrapToWidth, } from '@williamthorsen/toolbelt.terminal/candidate';
|
|
6
|
+
export interface ResolveStreamStylesOptions {
|
|
7
|
+
/** Raw arguments in which to find `flag`; read only when `flag` is given. */
|
|
8
|
+
readonly argv?: readonly string[] | undefined;
|
|
9
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
10
|
+
/** The environment variable holding the caller's standing preference: `auto`, `plain`, or `rich`. */
|
|
11
|
+
readonly envVar: string;
|
|
12
|
+
/** The flag naming a style for one invocation, leading dashes included; it outranks `envVar`. */
|
|
13
|
+
readonly flag?: string | undefined;
|
|
14
|
+
readonly stderrIsTty: boolean;
|
|
15
|
+
readonly stdoutIsTty: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface StreamStyleResolution {
|
|
18
|
+
/** The first value of `flag` or `envVar` that names no setting; resolution continues with the next source. */
|
|
19
|
+
readonly invalid?: InvalidOutputStyle | undefined;
|
|
20
|
+
readonly styles: StreamStyles;
|
|
21
|
+
}
|
|
22
|
+
export interface StreamStyles {
|
|
23
|
+
readonly stderr: OutputStyle;
|
|
24
|
+
readonly stdout: OutputStyle;
|
|
25
|
+
}
|
|
3
26
|
/**
|
|
4
27
|
* Renders the canonical `Error: <message>` line (without a trailing newline) — the single
|
|
5
28
|
* definition of this shape. Use it where the line is a value rather than a write target,
|
|
6
29
|
* e.g. a command that returns its message for the caller to print.
|
|
7
30
|
*/
|
|
8
31
|
export declare function formatErrorLine(message: string): string;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Renders a glyph from `glyphs` and a message, omitting the separating space when the glyph's variant is
|
|
34
|
+
* empty, which is what a set declares for a name whose message always opens on a word.
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatGlyphLine<Name extends string>(glyphs: GlyphSet<Name>, style: OutputStyle, name: Name, message: string): string;
|
|
37
|
+
/** Renders a status marker and a message, padding the marker so that messages align across statuses. */
|
|
38
|
+
export declare function formatStatusLine(style: OutputStyle, status: StatusGlyphName, message: string): string;
|
|
39
|
+
/** Prints an error message to stderr, in the style detected for stderr unless one is given. */
|
|
40
|
+
export declare function printError(message: string, style?: OutputStyle): void;
|
|
41
|
+
/** Prints a skip/warning message to stdout, in the style detected for stdout unless one is given. */
|
|
42
|
+
export declare function printSkip(message: string, style?: OutputStyle): void;
|
|
13
43
|
/** Prints a step label with a right-arrow prefix. */
|
|
14
44
|
export declare function printStep(message: string): void;
|
|
15
|
-
/** Prints a success message
|
|
16
|
-
export declare function printSuccess(message: string): void;
|
|
45
|
+
/** Prints a success message to stdout, in the style detected for stdout unless one is given. */
|
|
46
|
+
export declare function printSuccess(message: string, style?: OutputStyle): void;
|
|
17
47
|
/**
|
|
18
48
|
* Writes the canonical `Error: <message>` line to a stream (stderr by default) — the single
|
|
19
49
|
* sanctioned door for this output shape. Pass an injected stream for in-process CLIs that
|
|
20
50
|
* route output through a `Writable` rather than touching `process.stderr` directly.
|
|
21
51
|
*/
|
|
22
52
|
export declare function reportError(message: string, stream?: Writable): void;
|
|
23
|
-
/**
|
|
24
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Prints a terminal message for a write result based on its outcome: a failure to stderr, every
|
|
55
|
+
* other outcome to stdout. Each message takes its own stream's style from `styles`; without
|
|
56
|
+
* `styles`, it takes the style detected for that stream.
|
|
57
|
+
*/
|
|
58
|
+
export declare function reportWriteResult(result: WriteResult, dryRun: boolean, styles?: StreamStyles): void;
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the style of each output stream: the flag when one is named, else the named environment
|
|
61
|
+
* variable, else detection from `CI`, the stream's terminal state, and `TERM`. Never throws; a value
|
|
62
|
+
* that names no setting is returned in `invalid`, for the caller to report with
|
|
63
|
+
* `describeInvalidOutputStyle`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveStreamStyles(options: ResolveStreamStylesOptions): StreamStyleResolution;
|
package/dist/esm/terminal.js
CHANGED
|
@@ -1,58 +1,81 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
+
import { detectOutputStyle, measureGlyphColumn, resolveOutputStyle, STATUS_GLYPHS, } from '@williamthorsen/toolbelt.terminal/candidate';
|
|
3
|
+
export { defineGlyphSet, describeInvalidOutputStyle, measureGlyphColumn, STATUS_GLYPHS, wrapToWidth, } from '@williamthorsen/toolbelt.terminal/candidate';
|
|
2
4
|
export function formatErrorLine(message) {
|
|
3
5
|
return `Error: ${message}`;
|
|
4
6
|
}
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
+
export function formatGlyphLine(glyphs, style, name, message) {
|
|
8
|
+
const { text } = glyphs[style][name];
|
|
9
|
+
return text === '' ? message : `${text} ${message}`;
|
|
7
10
|
}
|
|
8
|
-
export function
|
|
9
|
-
|
|
11
|
+
export function formatStatusLine(style, status, message) {
|
|
12
|
+
const glyphs = STATUS_GLYPHS[style];
|
|
13
|
+
const glyph = glyphs[status];
|
|
14
|
+
const padding = ' '.repeat(measureGlyphColumn(glyphs) - glyph.width);
|
|
15
|
+
return `${glyph.text}${padding} ${message}`;
|
|
16
|
+
}
|
|
17
|
+
export function printError(message, style = detectStreamStyle(process.stderr)) {
|
|
18
|
+
process.stderr.write(` ${formatStatusLine(style, 'failed', message)}\n`);
|
|
19
|
+
}
|
|
20
|
+
export function printSkip(message, style = detectStreamStyle(process.stdout)) {
|
|
21
|
+
console.info(` ${formatStatusLine(style, 'warning', message)}`);
|
|
10
22
|
}
|
|
11
23
|
export function printStep(message) {
|
|
12
24
|
console.info(`\n> ${message}`);
|
|
13
25
|
}
|
|
14
|
-
export function printSuccess(message) {
|
|
15
|
-
console.info(`
|
|
26
|
+
export function printSuccess(message, style = detectStreamStyle(process.stdout)) {
|
|
27
|
+
console.info(` ${formatStatusLine(style, 'passed', message)}`);
|
|
16
28
|
}
|
|
17
29
|
export function reportError(message, stream = process.stderr) {
|
|
18
30
|
stream.write(`${formatErrorLine(message)}\n`);
|
|
19
31
|
}
|
|
20
|
-
export function reportWriteResult(result, dryRun) {
|
|
32
|
+
export function reportWriteResult(result, dryRun, styles) {
|
|
33
|
+
const style = styles?.stdout;
|
|
21
34
|
switch (result.outcome) {
|
|
22
35
|
case 'created':
|
|
23
36
|
if (dryRun) {
|
|
24
|
-
printSuccess(`[dry-run] Would create ${result.filePath}
|
|
37
|
+
printSuccess(`[dry-run] Would create ${result.filePath}`, style);
|
|
25
38
|
}
|
|
26
39
|
else {
|
|
27
|
-
printSuccess(`Created ${result.filePath}
|
|
40
|
+
printSuccess(`Created ${result.filePath}`, style);
|
|
28
41
|
}
|
|
29
42
|
break;
|
|
30
43
|
case 'overwritten':
|
|
31
44
|
if (dryRun) {
|
|
32
|
-
printSuccess(`[dry-run] Would overwrite ${result.filePath}
|
|
45
|
+
printSuccess(`[dry-run] Would overwrite ${result.filePath}`, style);
|
|
33
46
|
}
|
|
34
47
|
else {
|
|
35
|
-
printSuccess(`Overwrote ${result.filePath}
|
|
48
|
+
printSuccess(`Overwrote ${result.filePath}`, style);
|
|
36
49
|
}
|
|
37
50
|
break;
|
|
38
51
|
case 'up-to-date':
|
|
39
|
-
printSuccess(`${result.filePath} (up to date)
|
|
52
|
+
printSuccess(`${result.filePath} (up to date)`, style);
|
|
40
53
|
break;
|
|
41
54
|
case 'skipped':
|
|
42
55
|
if (result.error) {
|
|
43
|
-
printSkip(`${result.filePath} (could not read for comparison: ${result.error})
|
|
56
|
+
printSkip(`${result.filePath} (could not read for comparison: ${result.error})`, style);
|
|
44
57
|
}
|
|
45
58
|
else {
|
|
46
|
-
printSkip(`${result.filePath} (already exists)
|
|
59
|
+
printSkip(`${result.filePath} (already exists)`, style);
|
|
47
60
|
}
|
|
48
61
|
break;
|
|
49
62
|
case 'failed':
|
|
50
63
|
if (result.error) {
|
|
51
|
-
printError(`Failed to write ${result.filePath}: ${result.error}
|
|
64
|
+
printError(`Failed to write ${result.filePath}: ${result.error}`, styles?.stderr);
|
|
52
65
|
}
|
|
53
66
|
else {
|
|
54
|
-
printError(`Failed to write ${result.filePath}
|
|
67
|
+
printError(`Failed to write ${result.filePath}`, styles?.stderr);
|
|
55
68
|
}
|
|
56
69
|
break;
|
|
57
70
|
}
|
|
58
71
|
}
|
|
72
|
+
export function resolveStreamStyles(options) {
|
|
73
|
+
const { argv = [], env, envVar, flag, stderrIsTty, stdoutIsTty } = options;
|
|
74
|
+
const stderr = resolveOutputStyle({ argv, env, envVar, flag, isTty: stderrIsTty });
|
|
75
|
+
const stdout = resolveOutputStyle({ argv, env, envVar, flag, isTty: stdoutIsTty });
|
|
76
|
+
const styles = { stderr: stderr.style, stdout: stdout.style };
|
|
77
|
+
return stdout.invalid === undefined ? { styles } : { invalid: stdout.invalid, styles };
|
|
78
|
+
}
|
|
79
|
+
function detectStreamStyle(stream) {
|
|
80
|
+
return detectOutputStyle({ env: process.env, isTty: stream.isTTY === true });
|
|
81
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@williamthorsen/nmr-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared utilities for node-monorepo-tools packages",
|
|
6
6
|
"keywords": [
|
|
@@ -34,12 +34,14 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@williamthorsen/toolbelt.errors": "0.
|
|
37
|
+
"@williamthorsen/toolbelt.errors": "0.8.1",
|
|
38
|
+
"@williamthorsen/toolbelt.terminal": "0.2.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@williamthorsen/toolbelt.filesystem": "0.
|
|
41
|
-
"@williamthorsen/toolbelt.testing": "0.
|
|
42
|
-
"@williamthorsen/toolbelt.vitest": "0.
|
|
41
|
+
"@williamthorsen/toolbelt.filesystem": "0.9.1",
|
|
42
|
+
"@williamthorsen/toolbelt.testing": "0.6.1",
|
|
43
|
+
"@williamthorsen/toolbelt.vitest": "0.10.1",
|
|
44
|
+
"vitest": "4.1.11"
|
|
43
45
|
},
|
|
44
46
|
"engines": {
|
|
45
47
|
"node": ">=24"
|