@williamthorsen/nmr-core 0.9.2 → 0.10.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
CHANGED
|
@@ -4,7 +4,15 @@ Shared utilities for node-monorepo-tools packages.
|
|
|
4
4
|
|
|
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
|
-
<!-- section:release-notes
|
|
7
|
+
<!-- section:release-notes -->
|
|
8
|
+
## Release notes — v0.10.0 (2026-08-13)
|
|
9
|
+
|
|
10
|
+
### 🎉 Features
|
|
11
|
+
|
|
12
|
+
- Print a retained run with nmr --log (#669)
|
|
13
|
+
|
|
14
|
+
Adds `nmr --log <command>`, which prints what the last recorded pass wrote instead of running the command again. The whole transcript, up to a limit of 256 KiB, is now saved for any passing command that is not writing straight to a terminal; `--log` prints it under a header giving the instant, the duration, and the command chain that succeeded. The log of a composite is the sum of its constituents' excerpts. If a change disqualifies the recording, `--log` instead reports the change.
|
|
15
|
+
<!-- /section:release-notes -->
|
|
8
16
|
|
|
9
17
|
## Installation
|
|
10
18
|
|
|
@@ -10,6 +10,7 @@ export interface CacheEntryRef extends CacheDirRef {
|
|
|
10
10
|
export declare function readCacheEntry(entryPath: string): Promise<string | undefined>;
|
|
11
11
|
export declare function readJsonCacheEntry<T>(entryPath: string, isValidEntry: (value: unknown) => value is T): Promise<T | undefined>;
|
|
12
12
|
export declare function removeCacheDir(ref: CacheDirRef): Promise<void>;
|
|
13
|
+
export declare function removeCacheEntry(entryPath: string): Promise<void>;
|
|
13
14
|
export declare function resolveCacheDir(ref: CacheDirRef): string;
|
|
14
15
|
export declare function resolveCacheEntryPath(ref: CacheEntryRef): string;
|
|
15
16
|
export declare function writeCacheEntry(entryPath: string, content: string): Promise<void>;
|
package/dist/esm/cache-store.js
CHANGED
|
@@ -28,6 +28,9 @@ export async function readJsonCacheEntry(entryPath, isValidEntry) {
|
|
|
28
28
|
export async function removeCacheDir(ref) {
|
|
29
29
|
await rm(resolveCacheDir(ref), { force: true, recursive: true });
|
|
30
30
|
}
|
|
31
|
+
export async function removeCacheEntry(entryPath) {
|
|
32
|
+
await rm(entryPath, { force: true });
|
|
33
|
+
}
|
|
31
34
|
export function resolveCacheDir(ref) {
|
|
32
35
|
const absoluteScopeDir = path.resolve(ref.scopeDir);
|
|
33
36
|
const home = findNearestNodeModulesHost(absoluteScopeDir) ?? absoluteScopeDir;
|
|
@@ -2,6 +2,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { existsSync, lstatSync, readFileSync, readlinkSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
+
import { describeError } from '@williamthorsen/toolbelt.errors';
|
|
5
6
|
import { GIT_OUTPUT_LIMIT } from "./gitOutputLimit.js";
|
|
6
7
|
const HASH_FORMAT = 'nmr-working-tree-v1';
|
|
7
8
|
const PRECEDING_FIELD_COUNTS = {
|
|
@@ -101,9 +102,6 @@ function collectChangedPaths(statusOutput) {
|
|
|
101
102
|
}
|
|
102
103
|
return { ok: true, paths };
|
|
103
104
|
}
|
|
104
|
-
function describeError(error) {
|
|
105
|
-
return error instanceof Error ? error.message : String(error);
|
|
106
|
-
}
|
|
107
105
|
function digestBuffer(buffer) {
|
|
108
106
|
return createHash('sha256').update(buffer).digest('hex');
|
|
109
107
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const PACKAGE_NAME = "@williamthorsen/nmr-core";
|
|
2
2
|
export type { CacheDirRef, CacheEntryRef } from './cache-store.js';
|
|
3
|
-
export { readCacheEntry, readJsonCacheEntry, removeCacheDir, resolveCacheDir, resolveCacheEntryPath, writeCacheEntry, } from './cache-store.js';
|
|
3
|
+
export { readCacheEntry, readJsonCacheEntry, removeCacheDir, removeCacheEntry, resolveCacheDir, resolveCacheEntryPath, writeCacheEntry, } from './cache-store.js';
|
|
4
4
|
export { findPackageRoot } from './findPackageRoot.js';
|
|
5
5
|
export { GIT_OUTPUT_LIMIT } from './gitOutputLimit.js';
|
|
6
6
|
export type { WorkingTreeHashResult } from './hashWorkingTree.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const PACKAGE_NAME = '@williamthorsen/nmr-core';
|
|
2
|
-
export { readCacheEntry, readJsonCacheEntry, removeCacheDir, resolveCacheDir, resolveCacheEntryPath, writeCacheEntry, } from "./cache-store.js";
|
|
2
|
+
export { readCacheEntry, readJsonCacheEntry, removeCacheDir, removeCacheEntry, resolveCacheDir, resolveCacheEntryPath, writeCacheEntry, } from "./cache-store.js";
|
|
3
3
|
export { findPackageRoot } from "./findPackageRoot.js";
|
|
4
4
|
export { GIT_OUTPUT_LIMIT } from "./gitOutputLimit.js";
|
|
5
5
|
export { hashWorkingTree, readHeadSha } from "./hashWorkingTree.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
|
+
import { describeError } from '@williamthorsen/toolbelt.errors';
|
|
3
4
|
function normalizeTrailingWhitespace(content) {
|
|
4
5
|
return content
|
|
5
6
|
.split('\n')
|
|
@@ -18,7 +19,7 @@ export function writeFileWithCheck(filePath, content, options) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
catch (error) {
|
|
21
|
-
const message =
|
|
22
|
+
const message = describeError(error);
|
|
22
23
|
return { filePath, outcome: 'skipped', error: message };
|
|
23
24
|
}
|
|
24
25
|
return { filePath, outcome: 'skipped' };
|
|
@@ -31,14 +32,14 @@ export function writeFileWithCheck(filePath, content, options) {
|
|
|
31
32
|
mkdirSync(dirname(filePath), { recursive: true });
|
|
32
33
|
}
|
|
33
34
|
catch (error) {
|
|
34
|
-
const message =
|
|
35
|
+
const message = describeError(error);
|
|
35
36
|
return { filePath, outcome: 'failed', error: message };
|
|
36
37
|
}
|
|
37
38
|
try {
|
|
38
39
|
writeFileSync(filePath, content, 'utf8');
|
|
39
40
|
}
|
|
40
41
|
catch (error) {
|
|
41
|
-
const message =
|
|
42
|
+
const message = describeError(error);
|
|
42
43
|
return { filePath, outcome: 'failed', error: message };
|
|
43
44
|
}
|
|
44
45
|
return { filePath, outcome };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@williamthorsen/nmr-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared utilities for node-monorepo-tools packages",
|
|
6
6
|
"keywords": [
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"author": "William Thorsen <william@thorsen.dev> (https://github.com/williamthorsen)",
|
|
22
|
+
"sideEffects": false,
|
|
22
23
|
"type": "module",
|
|
23
24
|
"exports": {
|
|
24
25
|
".": {
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
"files": [
|
|
31
32
|
"dist"
|
|
32
33
|
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@williamthorsen/toolbelt.errors": "0.4.0"
|
|
36
|
+
},
|
|
33
37
|
"engines": {
|
|
34
38
|
"node": ">=24"
|
|
35
39
|
},
|