refactor(#182): migrate project-root module to runtime path

This commit is contained in:
Tom Boucher
2026-05-24 21:38:49 -04:00
parent 22e9c1de62
commit c46dfc4a7f
7 changed files with 15 additions and 14 deletions

View File

@@ -3,7 +3,7 @@
/** /**
* GENERATED FILE — DO NOT EDIT. * GENERATED FILE — DO NOT EDIT.
* *
* Source: sdk/src/project-root/index.ts * Source: sdk/src/runtime/project-root.ts
* Regenerate: cd sdk && npm run gen:project-root * Regenerate: cd sdk && npm run gen:project-root
* *
* Project-Root Resolution Module — resolves a project root from a starting * Project-Root Resolution Module — resolves a project root from a starting

View File

@@ -2,7 +2,7 @@
/** /**
* Generator for the Project-Root Resolution Module CJS artifact. * Generator for the Project-Root Resolution Module CJS artifact.
* *
* Imports the compiled ESM output from sdk/dist/project-root/index.js, * Imports the compiled ESM output from sdk/dist/runtime/project-root.js,
* captures findProjectRoot via Function.prototype.toString(), then emits * captures findProjectRoot via Function.prototype.toString(), then emits
* get-shit-done/bin/lib/project-root.generated.cjs. * get-shit-done/bin/lib/project-root.generated.cjs.
* *
@@ -14,14 +14,14 @@ import { writeFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { requireFreshDist } from './_gen-helpers.mjs'; import { requireFreshDist } from './_gen-helpers.mjs';
requireFreshDist('sdk/dist/project-root/index.js', 'sdk/src/project-root/index.ts'); requireFreshDist('sdk/dist/runtime/project-root.js', 'sdk/src/runtime/project-root.ts');
const BANNER = `'use strict'; const BANNER = `'use strict';
/** /**
* GENERATED FILE — DO NOT EDIT. * GENERATED FILE — DO NOT EDIT.
* *
* Source: sdk/src/project-root/index.ts * Source: sdk/src/runtime/project-root.ts
* Regenerate: cd sdk && npm run gen:project-root * Regenerate: cd sdk && npm run gen:project-root
* *
* Project-Root Resolution Module — resolves a project root from a starting * Project-Root Resolution Module — resolves a project root from a starting
@@ -41,7 +41,7 @@ const BANNER = `'use strict';
* duplicating the logic. * duplicating the logic.
*/ */
export async function buildProjectRootCjs() { export async function buildProjectRootCjs() {
const distUrl = new URL('../dist/project-root/index.js', import.meta.url); const distUrl = new URL('../dist/runtime/project-root.js', import.meta.url);
const { findProjectRoot, FIND_PROJECT_ROOT_MAX_DEPTH } = await import(distUrl.href); const { findProjectRoot, FIND_PROJECT_ROOT_MAX_DEPTH } = await import(distUrl.href);
const findProjectRootBody = findProjectRoot.toString(); const findProjectRootBody = findProjectRoot.toString();

View File

@@ -502,9 +502,9 @@ export function planningPaths(projectDir: string, workstream?: string): Planning
} }
// ─── findProjectRoot (multi-repo .planning resolution) ───────────────────── // ─── findProjectRoot (multi-repo .planning resolution) ─────────────────────
// Implementation lives in sdk/src/project-root/index.ts — re-exported here // Implementation lives in sdk/src/runtime/project-root.ts — re-exported here
// so that existing consumers of helpers.ts continue to work unchanged. // so that existing consumers of helpers.ts continue to work unchanged.
export { findProjectRoot } from '../project-root/index.js'; export { findProjectRoot } from '../runtime/project-root.js';
// ─── resolvePathUnderProject ─────────────────────────────────────────────── // ─── resolvePathUnderProject ───────────────────────────────────────────────

View File

@@ -1,5 +1,5 @@
/** /**
* Pinning tests for sdk/src/project-root/index.ts * Pinning tests for sdk/src/runtime/project-root.ts
* *
* These tests pin the behaviour of findProjectRoot before the CJS refactor * These tests pin the behaviour of findProjectRoot before the CJS refactor
* in Cycle 2. They must remain GREEN throughout (never bend the implementation * in Cycle 2. They must remain GREEN throughout (never bend the implementation
@@ -14,7 +14,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdtemp, rm, writeFile, mkdir } from 'node:fs/promises'; import { mkdtemp, rm, writeFile, mkdir } from 'node:fs/promises';
import { join } from 'node:path'; import { join } from 'node:path';
import { tmpdir } from 'node:os'; import { tmpdir } from 'node:os';
import { findProjectRoot } from './index.js'; import { findProjectRoot } from './project-root.js';
describe('findProjectRoot (project-root module)', () => { describe('findProjectRoot (project-root module)', () => {
let workspace: string; let workspace: string;

View File

@@ -10,7 +10,8 @@
* Bounded by FIND_PROJECT_ROOT_MAX_DEPTH ancestors. Sync I/O. * Bounded by FIND_PROJECT_ROOT_MAX_DEPTH ancestors. Sync I/O.
* *
* Source of truth for `findProjectRoot` — the CJS artifact at * Source of truth for `findProjectRoot` — the CJS artifact at
* get-shit-done/bin/lib/project-root.generated.cjs is generated from this file. * get-shit-done/bin/lib/project-root.generated.cjs is generated from
* sdk/src/runtime/project-root.ts.
*/ */
import { dirname, resolve, sep, relative, parse as parsePath } from 'node:path'; import { dirname, resolve, sep, relative, parse as parsePath } from 'node:path';

View File

@@ -53,8 +53,8 @@ const GENERATORS = [
}, },
{ {
script: 'gen-project-root.mjs', script: 'gen-project-root.mjs',
dist: 'sdk/dist/project-root/index.js', dist: 'sdk/dist/runtime/project-root.js',
ts: 'sdk/src/project-root/index.ts', ts: 'sdk/src/runtime/project-root.ts',
}, },
{ {
script: 'gen-workstream-inventory-builder.mjs', script: 'gen-workstream-inventory-builder.mjs',

View File

@@ -2,7 +2,7 @@
/** /**
* CJS parity test — project-root module * CJS parity test — project-root module
* *
* For every fixture from sdk/src/project-root/index.test.ts, asserts that * For every fixture from sdk/src/runtime/project-root.test.ts, asserts that
* both the SDK (ESM, via dynamic import) and the generated CJS artifact * both the SDK (ESM, via dynamic import) and the generated CJS artifact
* return identical paths. This confirms that the generator correctly * return identical paths. This confirms that the generator correctly
* captures the function body and that all dependencies (sep, dirname, * captures the function body and that all dependencies (sep, dirname,
@@ -21,7 +21,7 @@ const { findProjectRoot: findProjectRootCjs } = require('../get-shit-done/bin/li
// SDK ESM — loaded once before all tests via dynamic import // SDK ESM — loaded once before all tests via dynamic import
let findProjectRootSdk; let findProjectRootSdk;
before(async () => { before(async () => {
const mod = await import('../sdk/dist/project-root/index.js'); const mod = await import('../sdk/dist/runtime/project-root.js');
findProjectRootSdk = mod.findProjectRoot; findProjectRootSdk = mod.findProjectRoot;
}); });