From ffa84e049a2f49a66e0faa2c0c7a6dfbf1a41f29 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 10:08:50 +0000 Subject: [PATCH 1/3] test(cli): load os doctor suites' oclif Config without the command scan Eight in-process `os doctor` suites called `Doctor.run(argv, { root })`, which makes oclif build the command manifest by importing every compiled command (no oclif.manifest.json ships): 6.6 s of each file's first test. Doctor never reads `this.config`, so a shared helper loads the package's own Config with only `oclif.commands` dropped; hooks still load. Claude-Session: https://claude.ai/code/session_013fXj9gbwakFbBp5U9x4EjF Co-authored-by: Claude --- .../doctor-config-env-overlay.test.ts | 8 ++--- .../commands/doctor-config-load-cause.test.ts | 8 ++--- .../doctor-deprecation-hint-commands.test.ts | 5 ++- .../doctor-ledger-dir-authority.test.ts | 10 ++---- ...doctor-ledger-posture-independence.test.ts | 8 ++--- .../doctor-ledger-read-failure.test.ts | 14 +++----- .../commands/doctor-node-env-default.test.ts | 7 ++-- .../doctor-unexamined-spec-tree.test.ts | 9 ++--- packages/cli/test/helpers/doctor-config.ts | 36 +++++++++++++++++++ 9 files changed, 57 insertions(+), 48 deletions(-) create mode 100644 packages/cli/test/helpers/doctor-config.ts diff --git a/packages/cli/src/commands/doctor-config-env-overlay.test.ts b/packages/cli/src/commands/doctor-config-env-overlay.test.ts index 1fbf8b9e026..4ed75911671 100644 --- a/packages/cli/src/commands/doctor-config-env-overlay.test.ts +++ b/packages/cli/src/commands/doctor-config-env-overlay.test.ts @@ -54,8 +54,8 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor, { readDotenvFiles, withDotenvOverlay, @@ -63,10 +63,6 @@ import Doctor, { environmentSourcesCheck, } from './doctor.js'; -const HERE = path.dirname(fileURLToPath(import.meta.url)); -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(HERE, '..', '..'); - /** * The escape is written as `\x1b`, never as the byte itself: one raw control * character makes `grep` treat the whole file as binary, and a test file no @@ -257,7 +253,7 @@ describe('os doctor, end to end, against a config that reads .env at top level', }) as never); try { - await Doctor.run([], { root: CLI_ROOT }); + await Doctor.run([], await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/src/commands/doctor-config-load-cause.test.ts b/packages/cli/src/commands/doctor-config-load-cause.test.ts index f5b50ebd694..463c6a25f7e 100644 --- a/packages/cli/src/commands/doctor-config-load-cause.test.ts +++ b/packages/cli/src/commands/doctor-config-load-cause.test.ts @@ -52,14 +52,10 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor, { configLoadFailureCheck } from './doctor.js'; -const HERE = path.dirname(fileURLToPath(import.meta.url)); -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(HERE, '..', '..'); - /** * The escape is written as `\x1b`, never as the byte itself: one raw control * character makes `grep` treat the whole file as binary, and a test file no @@ -199,7 +195,7 @@ describe('os doctor, end to end, against a config that cannot be loaded', () => }) as never); try { - await Doctor.run(argv, { root: CLI_ROOT }); + await Doctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts index 7579b9e1a72..46ac86afb7b 100644 --- a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts +++ b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts @@ -61,13 +61,12 @@ import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor from './doctor.js'; const HERE = path.dirname(fileURLToPath(import.meta.url)); /** `packages/cli/src/commands` — where oclif's pattern strategy finds commands. */ const COMMANDS_DIR = HERE; -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(HERE, '..', '..'); const DOCTOR_SRC = path.join(COMMANDS_DIR, 'doctor.ts'); /** @@ -251,7 +250,7 @@ describe('os doctor --scan-deprecations, end to end', () => { }) as never); try { - await Doctor.run(argv, { root: CLI_ROOT }); + await Doctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts b/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts index 6de710a110a..797aae08d8e 100644 --- a/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts +++ b/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts @@ -48,8 +48,8 @@ import { describe, it, expect, beforeAll, afterEach, vi } from 'vitest'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor, { installedPackageLedgerDirAuthorityMissingCheck, installedPackageLedgerSkippedEntriesCheck, @@ -62,10 +62,6 @@ import Doctor, { // where the same shape cost 30 ejected merge-queue builds in one night. import '@objectstack/cloud-connection'; -const HERE = path.dirname(fileURLToPath(import.meta.url)); -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(HERE, '..', '..'); - /** * The escape is written as `\x1b`, never as the byte itself: one raw control * character makes `grep` treat the whole file as binary, and a test file no @@ -258,7 +254,7 @@ describe('os doctor, end to end, against a reader that declares no ledger direct }) as never); try { - await FreshDoctor.run(argv, { root: CLI_ROOT }); + await FreshDoctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { @@ -410,7 +406,7 @@ describe('os doctor, end to end, skipped-entries fix quotes the resolved directo }) as never); try { - await Doctor.run(['--verbose'], { root: CLI_ROOT }); + await Doctor.run(['--verbose'], await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts b/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts index ad443e57eb6..fe4e23864f8 100644 --- a/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts +++ b/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts @@ -65,8 +65,8 @@ import { describe, it, expect, beforeAll, beforeEach, afterEach, vi } from 'vite import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor from './doctor.js'; // [#10126] Pay the first transform of these dist-resolved workspace deps at MODULE @@ -76,10 +76,6 @@ import Doctor from './doctor.js'; // where the same shape cost 30 ejected merge-queue builds in one night. import '@objectstack/cloud-connection'; -const HERE = path.dirname(fileURLToPath(import.meta.url)); -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(HERE, '..', '..'); - /** * The escape is written as `\x1b`, never as the byte itself: one raw control * character makes `grep` treat the whole file as binary, and a test file no @@ -224,7 +220,7 @@ describe('os doctor reports ledger readability under every posture (#5429)', () }) as never); try { - await Doctor.run(argv, { root: CLI_ROOT }); + await Doctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/src/commands/doctor-ledger-read-failure.test.ts b/packages/cli/src/commands/doctor-ledger-read-failure.test.ts index c86ed00b3a0..8cc7ff9f972 100644 --- a/packages/cli/src/commands/doctor-ledger-read-failure.test.ts +++ b/packages/cli/src/commands/doctor-ledger-read-failure.test.ts @@ -86,8 +86,8 @@ import { describe, it, expect, beforeAll, beforeEach, afterEach, vi } from 'vite import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor, { installedPackageLedgerFailureCheck, installedPackageLedgerReaderFailureCheck, @@ -100,10 +100,6 @@ import Doctor, { // where the same shape cost 30 ejected merge-queue builds in one night. import '@objectstack/cloud-connection'; -const HERE = path.dirname(fileURLToPath(import.meta.url)); -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(HERE, '..', '..'); - /** * The escape is written as `\x1b`, never as the byte itself: one raw control * character makes `grep` treat the whole file as binary, and a test file no @@ -439,7 +435,7 @@ describe('os doctor, end to end, against an unreadable installed-package ledger' }) as never); try { - await Doctor.run(argv, { root: CLI_ROOT }); + await Doctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { @@ -765,7 +761,7 @@ describe('the optional package INSTALLED BUT UNLOADABLE is reported (#5644)', () }) as never); try { - await FreshDoctor.run(['--verbose'], { root: CLI_ROOT }); + await FreshDoctor.run(['--verbose'], await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { @@ -837,7 +833,7 @@ describe('the optional package INSTALLED BUT UNLOADABLE is reported (#5644)', () let exitCode: number | undefined; try { - await FreshDoctor.run(['--verbose'], { root: CLI_ROOT }); + await FreshDoctor.run(['--verbose'], await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; exitCode = Number(err.message.split(':')[1]); @@ -931,7 +927,7 @@ describe('the optional package being genuinely ABSENT stays completely silent (# }) as never); try { - await FreshDoctor.run(['--verbose'], { root: CLI_ROOT }); + await FreshDoctor.run(['--verbose'], await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/src/commands/doctor-node-env-default.test.ts b/packages/cli/src/commands/doctor-node-env-default.test.ts index c37e8edf093..9dd0c5b49d2 100644 --- a/packages/cli/src/commands/doctor-node-env-default.test.ts +++ b/packages/cli/src/commands/doctor-node-env-default.test.ts @@ -63,8 +63,8 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor, { nodeEnvCheck, nodeEnvSourcePosture, @@ -73,9 +73,6 @@ import Doctor, { readDotenvFiles, } from './doctor.js'; -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..'); - /** * `chalk` may or may not emit SGR codes depending on TTY detection. * @@ -337,7 +334,7 @@ describe('[#5673] os doctor, end to end — the row reaches the report', () => { }) as never); try { - await Doctor.run(argv, { root: CLI_ROOT }); + await Doctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts b/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts index 661758f2de3..99027ede153 100644 --- a/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts +++ b/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts @@ -66,13 +66,10 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { doctorConfig } from '../../test/helpers/doctor-config.js'; import Doctor, { monorepoTreeSkipNotice } from './doctor.js'; -/** `packages/cli` — the oclif root the real command is loaded against below. */ -const CLI_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..'); - /** * `chalk` may or may not emit SGR codes depending on TTY detection. * @@ -175,7 +172,7 @@ describe('os doctor, end to end, in a user-app cwd with no packages/spec', () => }) as never); try { - await Doctor.run(argv, { root: CLI_ROOT }); + await Doctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { @@ -289,7 +286,7 @@ describe('os doctor, end to end, in a monorepo-shaped cwd — the no-regression }) as never); try { - await Doctor.run(argv, { root: CLI_ROOT }); + await Doctor.run(argv, await doctorConfig()); } catch (err) { if (!(err instanceof Error) || !err.message.startsWith('__PROCESS_EXIT__')) throw err; } finally { diff --git a/packages/cli/test/helpers/doctor-config.ts b/packages/cli/test/helpers/doctor-config.ts new file mode 100644 index 00000000000..1771f851fe5 --- /dev/null +++ b/packages/cli/test/helpers/doctor-config.ts @@ -0,0 +1,36 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The oclif `Config` the in-process `os doctor` suites hand `Doctor.run()`. + * + * `Doctor.run(argv, { root })` makes oclif load a Config from the package root, + * and this package ships no `oclif.manifest.json`, so that load builds the + * command manifest by importing every compiled command under `dist/commands`: + * 6.6 s of each file's first test, measured locally (#23181). `os doctor` + * reads none of it — `doctor.ts` never touches `this.config` — so this Config + * is the package's own `package.json` with only `oclif.commands` dropped. The + * hooks (the `preparse` separator strip) and everything else still load from + * the same manifest, and it loads in tens of milliseconds. + * + * ⛔ Not for a suite that asks the Config for a command (`findCommand`, + * `config.commands`, `runCommand`): this one has none. + */ + +import { readFileSync } from 'node:fs'; +import { resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { Config } from '@oclif/core'; + +/** `packages/cli` — the root a `Doctor.run()` loads its Config from. */ +const CLI_ROOT = resolve(fileURLToPath(import.meta.url), '../../..'); + +let loaded: Promise | undefined; + +/** One Config per test file, loaded on first use. */ +export function doctorConfig(): Promise { + loaded ??= (async () => { + const pjson = JSON.parse(readFileSync(resolve(CLI_ROOT, 'package.json'), 'utf8')); + return Config.load({ root: CLI_ROOT, pjson: { ...pjson, oclif: { ...pjson.oclif, commands: undefined } } }); + })(); + return loaded; +} From 44daefda792f6b651b195b9ad2dcb13d38136d80 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 10:46:39 +0000 Subject: [PATCH 2/3] test(cli): keep the doctor Config helper under src/ so tsc reaches it `tsconfig.json`'s rootDir is `src`, so a `src/` test cannot import from `test/helpers/`. `src/**/__tests__/**` is the place the build already excludes (as `src/utils/__tests__/server-body.ts`). Claude-Session: https://claude.ai/code/session_013fXj9gbwakFbBp5U9x4EjF Co-authored-by: Claude --- .../{test/helpers => src/commands/__tests__}/doctor-config.ts | 2 +- packages/cli/src/commands/doctor-config-env-overlay.test.ts | 2 +- packages/cli/src/commands/doctor-config-load-cause.test.ts | 2 +- .../cli/src/commands/doctor-deprecation-hint-commands.test.ts | 2 +- packages/cli/src/commands/doctor-ledger-dir-authority.test.ts | 2 +- .../cli/src/commands/doctor-ledger-posture-independence.test.ts | 2 +- packages/cli/src/commands/doctor-ledger-read-failure.test.ts | 2 +- packages/cli/src/commands/doctor-node-env-default.test.ts | 2 +- packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) rename packages/cli/{test/helpers => src/commands/__tests__}/doctor-config.ts (99%) diff --git a/packages/cli/test/helpers/doctor-config.ts b/packages/cli/src/commands/__tests__/doctor-config.ts similarity index 99% rename from packages/cli/test/helpers/doctor-config.ts rename to packages/cli/src/commands/__tests__/doctor-config.ts index 1771f851fe5..ed1914c9435 100644 --- a/packages/cli/test/helpers/doctor-config.ts +++ b/packages/cli/src/commands/__tests__/doctor-config.ts @@ -22,7 +22,7 @@ import { fileURLToPath } from 'node:url'; import { Config } from '@oclif/core'; /** `packages/cli` — the root a `Doctor.run()` loads its Config from. */ -const CLI_ROOT = resolve(fileURLToPath(import.meta.url), '../../..'); +const CLI_ROOT = resolve(fileURLToPath(import.meta.url), '../../../..'); let loaded: Promise | undefined; diff --git a/packages/cli/src/commands/doctor-config-env-overlay.test.ts b/packages/cli/src/commands/doctor-config-env-overlay.test.ts index 4ed75911671..f8ce0d0883a 100644 --- a/packages/cli/src/commands/doctor-config-env-overlay.test.ts +++ b/packages/cli/src/commands/doctor-config-env-overlay.test.ts @@ -55,7 +55,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor, { readDotenvFiles, withDotenvOverlay, diff --git a/packages/cli/src/commands/doctor-config-load-cause.test.ts b/packages/cli/src/commands/doctor-config-load-cause.test.ts index 463c6a25f7e..13de651dd48 100644 --- a/packages/cli/src/commands/doctor-config-load-cause.test.ts +++ b/packages/cli/src/commands/doctor-config-load-cause.test.ts @@ -53,7 +53,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor, { configLoadFailureCheck } from './doctor.js'; /** diff --git a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts index 46ac86afb7b..b0cdab1e0a8 100644 --- a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts +++ b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts @@ -61,7 +61,7 @@ import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor from './doctor.js'; const HERE = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts b/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts index 797aae08d8e..6b0262861ef 100644 --- a/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts +++ b/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts @@ -49,7 +49,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor, { installedPackageLedgerDirAuthorityMissingCheck, installedPackageLedgerSkippedEntriesCheck, diff --git a/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts b/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts index fe4e23864f8..41f22a0f54b 100644 --- a/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts +++ b/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts @@ -66,7 +66,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor from './doctor.js'; // [#10126] Pay the first transform of these dist-resolved workspace deps at MODULE diff --git a/packages/cli/src/commands/doctor-ledger-read-failure.test.ts b/packages/cli/src/commands/doctor-ledger-read-failure.test.ts index 8cc7ff9f972..9e326ccbd76 100644 --- a/packages/cli/src/commands/doctor-ledger-read-failure.test.ts +++ b/packages/cli/src/commands/doctor-ledger-read-failure.test.ts @@ -87,7 +87,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor, { installedPackageLedgerFailureCheck, installedPackageLedgerReaderFailureCheck, diff --git a/packages/cli/src/commands/doctor-node-env-default.test.ts b/packages/cli/src/commands/doctor-node-env-default.test.ts index 9dd0c5b49d2..cccd1734125 100644 --- a/packages/cli/src/commands/doctor-node-env-default.test.ts +++ b/packages/cli/src/commands/doctor-node-env-default.test.ts @@ -64,7 +64,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor, { nodeEnvCheck, nodeEnvSourcePosture, diff --git a/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts b/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts index 99027ede153..9a964a09b04 100644 --- a/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts +++ b/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts @@ -67,7 +67,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from '../../test/helpers/doctor-config.js'; +import { doctorConfig } from './__tests__/doctor-config.js'; import Doctor, { monorepoTreeSkipNotice } from './doctor.js'; /** From f0e74dd1ddbedcb0aca4c3529df98028129c6ae4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 24 Oct 2026 11:08:30 +0000 Subject: [PATCH 3/3] test(cli): move the doctor Config helper out of the commands tree `environments.test.ts` walks every `.ts` under `src/commands` as a command source, so a helper there registered a phantom `__tests__ doctor-config` id in its model. `src/utils/__tests__/` already holds the package's other non-test helper and is excluded from the build the same way. Claude-Session: https://claude.ai/code/session_013fXj9gbwakFbBp5U9x4EjF Co-authored-by: Claude --- packages/cli/src/commands/doctor-config-env-overlay.test.ts | 2 +- packages/cli/src/commands/doctor-config-load-cause.test.ts | 2 +- .../cli/src/commands/doctor-deprecation-hint-commands.test.ts | 2 +- packages/cli/src/commands/doctor-ledger-dir-authority.test.ts | 2 +- .../cli/src/commands/doctor-ledger-posture-independence.test.ts | 2 +- packages/cli/src/commands/doctor-ledger-read-failure.test.ts | 2 +- packages/cli/src/commands/doctor-node-env-default.test.ts | 2 +- packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts | 2 +- packages/cli/src/{commands => utils}/__tests__/doctor-config.ts | 0 9 files changed, 8 insertions(+), 8 deletions(-) rename packages/cli/src/{commands => utils}/__tests__/doctor-config.ts (100%) diff --git a/packages/cli/src/commands/doctor-config-env-overlay.test.ts b/packages/cli/src/commands/doctor-config-env-overlay.test.ts index f8ce0d0883a..a01dd70ba2b 100644 --- a/packages/cli/src/commands/doctor-config-env-overlay.test.ts +++ b/packages/cli/src/commands/doctor-config-env-overlay.test.ts @@ -55,7 +55,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor, { readDotenvFiles, withDotenvOverlay, diff --git a/packages/cli/src/commands/doctor-config-load-cause.test.ts b/packages/cli/src/commands/doctor-config-load-cause.test.ts index 13de651dd48..575cd2d42b5 100644 --- a/packages/cli/src/commands/doctor-config-load-cause.test.ts +++ b/packages/cli/src/commands/doctor-config-load-cause.test.ts @@ -53,7 +53,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor, { configLoadFailureCheck } from './doctor.js'; /** diff --git a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts index b0cdab1e0a8..6aeec33d4a6 100644 --- a/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts +++ b/packages/cli/src/commands/doctor-deprecation-hint-commands.test.ts @@ -61,7 +61,7 @@ import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor from './doctor.js'; const HERE = path.dirname(fileURLToPath(import.meta.url)); diff --git a/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts b/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts index 6b0262861ef..8df658f4381 100644 --- a/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts +++ b/packages/cli/src/commands/doctor-ledger-dir-authority.test.ts @@ -49,7 +49,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor, { installedPackageLedgerDirAuthorityMissingCheck, installedPackageLedgerSkippedEntriesCheck, diff --git a/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts b/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts index 41f22a0f54b..db9f76e298d 100644 --- a/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts +++ b/packages/cli/src/commands/doctor-ledger-posture-independence.test.ts @@ -66,7 +66,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor from './doctor.js'; // [#10126] Pay the first transform of these dist-resolved workspace deps at MODULE diff --git a/packages/cli/src/commands/doctor-ledger-read-failure.test.ts b/packages/cli/src/commands/doctor-ledger-read-failure.test.ts index 9e326ccbd76..6a120e5cea8 100644 --- a/packages/cli/src/commands/doctor-ledger-read-failure.test.ts +++ b/packages/cli/src/commands/doctor-ledger-read-failure.test.ts @@ -87,7 +87,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor, { installedPackageLedgerFailureCheck, installedPackageLedgerReaderFailureCheck, diff --git a/packages/cli/src/commands/doctor-node-env-default.test.ts b/packages/cli/src/commands/doctor-node-env-default.test.ts index cccd1734125..77d6ac23678 100644 --- a/packages/cli/src/commands/doctor-node-env-default.test.ts +++ b/packages/cli/src/commands/doctor-node-env-default.test.ts @@ -64,7 +64,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor, { nodeEnvCheck, nodeEnvSourcePosture, diff --git a/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts b/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts index 9a964a09b04..4270b9d1d5a 100644 --- a/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts +++ b/packages/cli/src/commands/doctor-unexamined-spec-tree.test.ts @@ -67,7 +67,7 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import { doctorConfig } from './__tests__/doctor-config.js'; +import { doctorConfig } from '../utils/__tests__/doctor-config.js'; import Doctor, { monorepoTreeSkipNotice } from './doctor.js'; /** diff --git a/packages/cli/src/commands/__tests__/doctor-config.ts b/packages/cli/src/utils/__tests__/doctor-config.ts similarity index 100% rename from packages/cli/src/commands/__tests__/doctor-config.ts rename to packages/cli/src/utils/__tests__/doctor-config.ts