Merge pull request #252 from open-gsd/fix/182-migrate-project-root-module

refactor(#182): migrate project-root resolution module to sdk/src/runtime
This commit is contained in:
Tom Boucher
2026-05-24 21:45:57 -04:00
committed by GitHub
7 changed files with 15 additions and 14 deletions

View File

@@ -3,7 +3,7 @@
/**
* 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
*
* 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.
*
* 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
* 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 { 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';
/**
* 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
*
* Project-Root Resolution Module — resolves a project root from a starting
@@ -41,7 +41,7 @@ const BANNER = `'use strict';
* duplicating the logic.
*/
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 findProjectRootBody = findProjectRoot.toString();

View File

@@ -502,9 +502,9 @@ export function planningPaths(projectDir: string, workstream?: string): Planning
}
// ─── 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.
export { findProjectRoot } from '../project-root/index.js';
export { findProjectRoot } from '../runtime/project-root.js';
// ─── 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
* 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 { join } from 'node:path';
import { tmpdir } from 'node:os';
import { findProjectRoot } from './index.js';
import { findProjectRoot } from './project-root.js';
describe('findProjectRoot (project-root module)', () => {
let workspace: string;

View File

@@ -10,7 +10,8 @@
* Bounded by FIND_PROJECT_ROOT_MAX_DEPTH ancestors. Sync I/O.
*
* 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';

View File

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

View File

@@ -2,7 +2,7 @@
/**
* 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
* return identical paths. This confirms that the generator correctly
* 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
let findProjectRootSdk;
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;
});