@williamthorsen/nmr 0.30.0 → 0.31.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/.readyup/kits/default.js +27 -16
- package/.readyup/manifest.json +2 -2
- package/README.md +299 -62
- package/agents/guidance/rulebooks/nmr.md +4 -2
- package/bin/nmr-report-catalog.js +11 -0
- package/dist/esm/UserError.d.ts +3 -0
- package/dist/esm/UserError.js +6 -0
- package/dist/esm/check-cache.d.ts +36 -1
- package/dist/esm/check-cache.js +91 -23
- package/dist/esm/cli-build.js +2 -1
- package/dist/esm/cli-clean.js +2 -1
- package/dist/esm/cli-ensure-prepublish-hooks.js +2 -1
- package/dist/esm/cli-report-catalog.d.ts +1 -0
- package/dist/esm/cli-report-catalog.js +11 -0
- package/dist/esm/cli-report-overrides.js +2 -1
- package/dist/esm/cli-taze.js +2 -1
- package/dist/esm/cli.js +2 -1
- package/dist/esm/commands/report-catalog.d.ts +1 -0
- package/dist/esm/commands/report-catalog.js +34 -0
- package/dist/esm/commands/report-overrides.js +22 -7
- package/dist/esm/commands/taze.js +2 -1
- package/dist/esm/config.d.ts +1 -0
- package/dist/esm/config.js +66 -18
- package/dist/esm/default-scripts.d.ts +5 -1
- package/dist/esm/default-scripts.js +13 -10
- package/dist/esm/defineConfig.d.ts +1 -1
- package/dist/esm/help.js +3 -1
- package/dist/esm/helpers/clampToBytes.d.ts +2 -0
- package/dist/esm/helpers/clampToBytes.js +20 -0
- package/dist/esm/helpers/createBoundedBuffer.js +1 -4
- package/dist/esm/helpers/deriveExcerpt.d.ts +1 -0
- package/dist/esm/helpers/deriveExcerpt.js +30 -0
- package/dist/esm/helpers/duration.js +16 -9
- package/dist/esm/helpers/package-json.d.ts +11 -4
- package/dist/esm/helpers/package-json.js +51 -22
- package/dist/esm/helpers/readStringValues.d.ts +1 -0
- package/dist/esm/helpers/readStringValues.js +8 -0
- package/dist/esm/helpers/transcript.d.ts +5 -0
- package/dist/esm/helpers/transcript.js +59 -0
- package/dist/esm/recording.d.ts +65 -0
- package/dist/esm/recording.js +96 -0
- package/dist/esm/replay-assembly.d.ts +9 -0
- package/dist/esm/replay-assembly.js +26 -0
- package/dist/esm/report-format.d.ts +18 -0
- package/dist/esm/report-format.js +25 -0
- package/dist/esm/reportCliFailure.d.ts +2 -0
- package/dist/esm/reportCliFailure.js +11 -0
- package/dist/esm/resolve-scripts.d.ts +1 -1
- package/dist/esm/resolver.d.ts +9 -1
- package/dist/esm/resolver.js +26 -17
- package/dist/esm/runCli.js +339 -74
- package/dist/esm/runner.d.ts +9 -3
- package/dist/esm/runner.js +25 -4
- package/dist/esm/scripts.d.ts +1 -1
- package/dist/esm/steps.d.ts +9 -2
- package/dist/esm/steps.js +117 -4
- package/dist/esm/types.d.ts +11 -2
- package/dist/esm/verbosity.d.ts +15 -4
- package/dist/esm/verbosity.js +32 -12
- package/dist/esm/verdict.d.ts +29 -0
- package/dist/esm/verdict.js +150 -0
- package/dist/esm/workspace.d.ts +2 -0
- package/dist/esm/workspace.js +20 -3
- package/package.json +12 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { reportError } from '@williamthorsen/nmr-core';
|
|
2
|
+
import { describeError } from '@williamthorsen/toolbelt.errors';
|
|
3
|
+
import { UserError } from "./UserError.js";
|
|
4
|
+
export function reportCliFailure(error, stderr) {
|
|
5
|
+
if (error instanceof UserError) {
|
|
6
|
+
reportError(error.message, stderr);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const detail = error instanceof Error && error.stack !== undefined ? error.stack : describeError(error);
|
|
10
|
+
stderr.write(`${detail}\n`);
|
|
11
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ScriptRegistry } from './default-scripts.js';
|
|
2
|
-
export type { ScriptRegistry, ScriptValue } from './default-scripts.js';
|
|
2
|
+
export type { ScriptRegistry, ScriptValue, StepSpec } from './default-scripts.js';
|
|
3
3
|
export declare function getDefaultWorkspaceScripts(): ScriptRegistry;
|
|
4
4
|
export declare function getDefaultRootScripts(): ScriptRegistry;
|
package/dist/esm/resolver.d.ts
CHANGED
|
@@ -3,8 +3,16 @@ import type { Step } from './steps.js';
|
|
|
3
3
|
import type { NmrConfig } from './types.js';
|
|
4
4
|
export declare function applyDevBin(command: string, devBin: Record<string, string> | undefined, monorepoRoot: string): string;
|
|
5
5
|
export declare function applyDevBinToSteps(steps: readonly Step[], devBin: Record<string, string> | undefined, monorepoRoot: string): readonly Step[];
|
|
6
|
+
export type ScriptOrigin = {
|
|
7
|
+
tier: 'registry';
|
|
8
|
+
key: string;
|
|
9
|
+
} | {
|
|
10
|
+
tier: 'package';
|
|
11
|
+
file: string;
|
|
12
|
+
key: string;
|
|
13
|
+
};
|
|
6
14
|
export interface ResolvedScript {
|
|
7
|
-
|
|
15
|
+
origin: ScriptOrigin;
|
|
8
16
|
steps: readonly Step[];
|
|
9
17
|
}
|
|
10
18
|
export declare function expandScript(script: ScriptValue, workspaceRoot: boolean): readonly Step[];
|
package/dist/esm/resolver.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { parsePackageJson, readScriptRecord, resolvePackageJsonPath } from "./helpers/package-json.js";
|
|
3
4
|
import { isObject } from "./helpers/type-guards.js";
|
|
4
5
|
import { getDefaultRootScripts, getDefaultWorkspaceScripts } from "./resolve-scripts.js";
|
|
5
6
|
import { composeNmrStep } from "./steps.js";
|
|
@@ -41,26 +42,24 @@ export function expandScript(script, workspaceRoot) {
|
|
|
41
42
|
if (typeof script === 'string') {
|
|
42
43
|
return [{ kind: 'opaque', command: script }];
|
|
43
44
|
}
|
|
44
|
-
return script.map((element) =>
|
|
45
|
+
return script.map((element) => typeof element === 'string'
|
|
46
|
+
? composeNmrStep(element, workspaceRoot)
|
|
47
|
+
: composeNmrStep(element.run, workspaceRoot, element.declinesArgs));
|
|
45
48
|
}
|
|
46
49
|
export function describeScript(script) {
|
|
47
|
-
return typeof script === 'string' ? script : `[${script.join(', ')}]`;
|
|
50
|
+
return typeof script === 'string' ? script : `[${script.map(describeElement).join(', ')}]`;
|
|
51
|
+
}
|
|
52
|
+
function describeElement(element) {
|
|
53
|
+
if (typeof element === 'string') {
|
|
54
|
+
return element;
|
|
55
|
+
}
|
|
56
|
+
return element.declinesArgs === true ? `${element.run} (no args)` : element.run;
|
|
48
57
|
}
|
|
49
58
|
export function readPackageJsonScripts(packageDir) {
|
|
59
|
+
const file = resolvePackageJsonPath(packageDir);
|
|
60
|
+
let raw;
|
|
50
61
|
try {
|
|
51
|
-
|
|
52
|
-
const parsed = JSON.parse(raw);
|
|
53
|
-
if (!isObject(parsed))
|
|
54
|
-
return undefined;
|
|
55
|
-
const scripts = parsed['scripts'];
|
|
56
|
-
if (!isObject(scripts))
|
|
57
|
-
return undefined;
|
|
58
|
-
const result = {};
|
|
59
|
-
for (const [key, val] of Object.entries(scripts)) {
|
|
60
|
-
if (typeof val === 'string')
|
|
61
|
-
result[key] = val;
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
62
|
+
raw = readFileSync(file, 'utf8');
|
|
64
63
|
}
|
|
65
64
|
catch (error) {
|
|
66
65
|
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
@@ -68,6 +67,13 @@ export function readPackageJsonScripts(packageDir) {
|
|
|
68
67
|
}
|
|
69
68
|
throw error;
|
|
70
69
|
}
|
|
70
|
+
const parsed = parsePackageJson(raw, file);
|
|
71
|
+
if (!isObject(parsed))
|
|
72
|
+
return undefined;
|
|
73
|
+
const scripts = parsed['scripts'];
|
|
74
|
+
if (!isObject(scripts))
|
|
75
|
+
return undefined;
|
|
76
|
+
return readScriptRecord(packageDir, scripts);
|
|
71
77
|
}
|
|
72
78
|
export function buildWorkspaceRegistry(config) {
|
|
73
79
|
return {
|
|
@@ -91,7 +97,10 @@ export function resolveScript(commandName, registry, packageDir, workspaceRoot)
|
|
|
91
97
|
if (pkgScripts && Object.hasOwn(pkgScripts, commandName)) {
|
|
92
98
|
const override = pkgScripts[commandName];
|
|
93
99
|
if (override !== undefined && !isSelfReferential(override, commandName)) {
|
|
94
|
-
return {
|
|
100
|
+
return {
|
|
101
|
+
origin: { tier: 'package', file: resolvePackageJsonPath(packageDir), key: commandName },
|
|
102
|
+
steps: [{ kind: 'opaque', command: override }],
|
|
103
|
+
};
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
106
|
}
|
|
@@ -102,5 +111,5 @@ export function resolveScript(commandName, registry, packageDir, workspaceRoot)
|
|
|
102
111
|
if (registryEntry === undefined) {
|
|
103
112
|
return undefined;
|
|
104
113
|
}
|
|
105
|
-
return {
|
|
114
|
+
return { origin: { tier: 'registry', key: commandName }, steps: expandScript(registryEntry, workspaceRoot) };
|
|
106
115
|
}
|