@esposter/shared-node 4.13.0 → 4.14.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
@@ -39,14 +39,15 @@ spawnSync("pnpm", ["install"], { stdio: "inherit" });
39
39
 
40
40
  ## <a name="key-exports">🧩 Key Exports</a>
41
41
 
42
- | Export | Description |
43
- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
44
- | `BENCHMARK_RUN_OPTIONS` (`/bench`) | Run options that every `bench.compare` call passes. They fix the iteration count. |
45
- | `BenchmarkMarkdownReporter` (default export, `/reporter`) | Vitest reporter. Writes `Foo.bench.md` and `Foo.bench.json` beside `Foo.bench.ts`. |
46
- | `spawn`, `spawnSync`, `execFile`, `execFileSync`, `execSync` (`/child-process`) | Node's own child-process functions. Each forces `windowsHide: true`, so a console child never opens a window of its own. |
47
- | `execFileAsync` (`/child-process`) | The promisified `execFile`, with the same window flag. Resolves `{ stdout, stderr }`. |
48
- | `CACHE_ROOT`, `readContentAddressedObject` (`/cache`) | The download cache folder that every checkout shares. A read-through cache for objects named by the hex SHA-256 of their bytes. |
49
- | `writePartialThenMove` (`/cache`) | Writes a file whole. A partial file is written beside the path and renamed onto it once written, and it is removed when either step fails. |
42
+ | Export | Description |
43
+ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
44
+ | `BENCHMARK_RUN_OPTIONS` (`/bench`) | Run options that every `bench.compare` call passes. They fix the iteration count. |
45
+ | `BenchmarkMarkdownReporter` (default export, `/reporter`) | Vitest reporter. Writes `Foo.bench.md` and `Foo.bench.json` beside `Foo.bench.ts`. |
46
+ | `spawn`, `spawnSync`, `execFile`, `execFileSync`, `execSync` (`/child-process`) | Node's own child-process functions. Each forces `windowsHide: true`, so a console child never opens a window of its own. |
47
+ | `execFileAsync` (`/child-process`) | The promisified `execFile`, with the same window flag. Resolves `{ stdout, stderr }`. |
48
+ | `CACHE_ROOT`, `readContentAddressedObject` (`/cache`) | The download cache folder that every checkout shares. A read-through cache for objects named by the hex SHA-256 of their bytes. |
49
+ | `writePartialThenMove` (`/cache`) | Writes a file whole. A partial file is written beside the path and renamed onto it once written, and it is removed when either step fails. |
50
+ | `readWakeRecords`, `getWakeGaps`, `checkIsFullRun`, `WakeRecord` (`/wake-check`) | The live topic wake check's records, one per test file, the watched procedures no record calls, and the rule that a run is whole only when it names no file and no subset flag. |
50
51
 
51
52
  ## <a name="license">⚖️ License</a>
52
53
 
@@ -0,0 +1 @@
1
+ export declare const findRepositoryRoot: (directory: string) => string;
@@ -0,0 +1,12 @@
1
+ import { NotFoundError } from "@esposter/shared";
2
+ import { existsSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ // src/services/findRepositoryRoot.ts
5
+ const WORKSPACE_MANIFEST_NAME = "pnpm-workspace.yaml";
6
+ const findRepositoryRoot = (directory) => {
7
+ if (existsSync(join(directory, WORKSPACE_MANIFEST_NAME))) return directory;
8
+ const parent = dirname(directory);
9
+ if (parent === directory) throw new NotFoundError(WORKSPACE_MANIFEST_NAME, directory);
10
+ return findRepositoryRoot(parent);
11
+ };
12
+ export { findRepositoryRoot };
@@ -0,0 +1,10 @@
1
+ export interface WakeRecord {
2
+ called: string[];
3
+ counts: {
4
+ changed: number;
5
+ reruns: number;
6
+ writes: number;
7
+ };
8
+ file: string;
9
+ watched: string[];
10
+ }
@@ -1,14 +1,13 @@
1
1
  import { CONTENT_CACHE_DIRECTORY } from "./constants.js";
2
2
  import { writePartialThenMove } from "./writePartialThenMove.js";
3
- import { InvalidOperationError, Operation, getResultAsync, noop } from "@esposter/shared";
3
+ import { ASSET_HASH_REGEX, InvalidOperationError, Operation, getResultAsync, noop } from "@esposter/shared";
4
4
  import { createHash } from "node:crypto";
5
5
  import { existsSync } from "node:fs";
6
6
  import { readFile, writeFile } from "node:fs/promises";
7
7
  import { join } from "node:path";
8
8
  // src/services/cache/readContentAddressedObject.ts
9
- const SHA_256_HEX_REGEX = /^[0-9a-f]{64}$/u;
10
9
  const readContentAddressedObject = async (hash, download, directory = CONTENT_CACHE_DIRECTORY) => {
11
- if (!SHA_256_HEX_REGEX.test(hash)) throw new InvalidOperationError(Operation.Read, hash, "is not a SHA-256 hex digest");
10
+ if (!ASSET_HASH_REGEX.test(hash)) throw new InvalidOperationError(Operation.Read, hash, "is not a SHA-256 hex digest");
12
11
  const path = join(directory, hash);
13
12
  if (existsSync(path)) return readFile(path);
14
13
  const bytes = Buffer.from(await download());
@@ -0,0 +1 @@
1
+ export declare const checkIsFullRun: (args: string[]) => boolean;
@@ -0,0 +1,12 @@
1
+ // src/services/wakeCheck/checkIsFullRun.ts
2
+ const SUBSET_FLAGS = [
3
+ "--changed",
4
+ "--related",
5
+ "-t",
6
+ "--testNamePattern",
7
+ "--project",
8
+ "--shard"
9
+ ];
10
+ const checkIsSubsetFlag = (arg) => SUBSET_FLAGS.some((flag) => arg === flag || arg.startsWith(`${flag}=`));
11
+ const checkIsFullRun = (args) => args.every((arg) => arg === "run" || arg.startsWith("-") && !checkIsSubsetFlag(arg));
12
+ export { checkIsFullRun };
@@ -0,0 +1,2 @@
1
+ import { WakeRecord } from "../../models/WakeRecord.js";
2
+ export declare const getWakeGaps: (records: WakeRecord[]) => string[];
@@ -0,0 +1,6 @@
1
+ // src/services/wakeCheck/getWakeGaps.ts
2
+ const getWakeGaps = (records) => {
3
+ const called = new Set(records.flatMap((record) => record.called));
4
+ return (records[0]?.watched ?? []).filter((path) => !called.has(path)).toSorted();
5
+ };
6
+ export { getWakeGaps };
@@ -0,0 +1 @@
1
+ export declare const getWakeRecordDirectory: (root: string) => string;
@@ -0,0 +1,4 @@
1
+ import { join } from "node:path";
2
+ // src/services/wakeCheck/getWakeRecordDirectory.ts
3
+ const getWakeRecordDirectory = (root) => join(root, ".vitest", "wake-check");
4
+ export { getWakeRecordDirectory };
@@ -0,0 +1,2 @@
1
+ import { WakeRecord } from "../../models/WakeRecord.js";
2
+ export declare const readWakeRecords: (root: string) => WakeRecord[];
@@ -0,0 +1,10 @@
1
+ import { getWakeRecordDirectory } from "./getWakeRecordDirectory.js";
2
+ import { jsonDateParse } from "@esposter/shared";
3
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ // src/services/wakeCheck/readWakeRecords.ts
6
+ const readWakeRecords = (root) => {
7
+ const directory = getWakeRecordDirectory(root);
8
+ return existsSync(directory) ? readdirSync(directory).map((name) => jsonDateParse(readFileSync(join(directory, name), "utf8"))) : [];
9
+ };
10
+ export { readWakeRecords };
@@ -0,0 +1,6 @@
1
+ import { WakeRecord } from "./models/WakeRecord.js";
2
+ import { checkIsFullRun } from "./services/wakeCheck/checkIsFullRun.js";
3
+ import { getWakeGaps } from "./services/wakeCheck/getWakeGaps.js";
4
+ import { getWakeRecordDirectory } from "./services/wakeCheck/getWakeRecordDirectory.js";
5
+ import { readWakeRecords } from "./services/wakeCheck/readWakeRecords.js";
6
+ export { type WakeRecord, checkIsFullRun, getWakeGaps, getWakeRecordDirectory, readWakeRecords };
@@ -0,0 +1,5 @@
1
+ import { checkIsFullRun } from "./services/wakeCheck/checkIsFullRun.js";
2
+ import { getWakeGaps } from "./services/wakeCheck/getWakeGaps.js";
3
+ import { getWakeRecordDirectory } from "./services/wakeCheck/getWakeRecordDirectory.js";
4
+ import { readWakeRecords } from "./services/wakeCheck/readWakeRecords.js";
5
+ export { checkIsFullRun, getWakeGaps, getWakeRecordDirectory, readWakeRecords };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esposter/shared-node",
3
- "version": "4.13.0",
3
+ "version": "4.14.0",
4
4
  "description": "Node-only shared tooling: the machine-wide download cache, hidden-window child processes, and benchmark reporting reused across packages.",
5
5
  "keywords": [
6
6
  "benchmark",
@@ -33,7 +33,9 @@
33
33
  "./bench": "./dist/bench.js",
34
34
  "./cache": "./dist/cache.js",
35
35
  "./child-process": "./dist/child-process.js",
36
+ "./find-repository-root": "./dist/find-repository-root.js",
36
37
  "./reporter": "./dist/reporter.js",
38
+ "./wake-check": "./dist/wake-check.js",
37
39
  "./package.json": "./package.json"
38
40
  },
39
41
  "publishConfig": {
@@ -47,11 +49,11 @@
47
49
  "typecheck": "tsrs --fast"
48
50
  },
49
51
  "dependencies": {
50
- "@esposter/shared": "4.13.0",
52
+ "@esposter/shared": "4.14.0",
51
53
  "uuid": "^14.0.3"
52
54
  },
53
55
  "devDependencies": {
54
- "@esposter/configuration": "4.13.0",
56
+ "@esposter/configuration": "4.14.0",
55
57
  "@types/node": "^26.6.6",
56
58
  "tsdown": "^0.23.7"
57
59
  },
@@ -63,5 +65,5 @@
63
65
  "optional": true
64
66
  }
65
67
  },
66
- "gitHead": "d60ae90f266ad504f7c584ccf1103a8a8cbd1f04"
68
+ "gitHead": "4bacc78dfc7a663a424cbb5a51f57f4f8d0fee2e"
67
69
  }