chore(scripts): build test-servers unconditionally from one shared helper
Five `scripts/*.mjs` consumers each carried their own `ensureTestServer()` that returned early when `test-servers/build` was already on disk. Presence is not freshness: once that directory exists — which it does on any machine that has run the smokes once — an edit to `test-servers/src` was never picked up again, and the smoke went on driving the previously-built fixture. The failure is silent and misattributed. It does not read as "your fixture is stale"; it reads as a product bug in whatever the smoke is checking. `scripts/lib/ensure-test-servers.mjs` is now the one place that build is produced for a script consumer, and it builds unconditionally — memoized once per process per repo root, so pack-and-verify's two asks stay one tsc pass while a fresh run always rebuilds. Callers name the entries they depend on and get one actionable failure message, replacing five that had drifted. pack-and-verify also stops shelling out to `npx tsc`, which is what made it the one script unrunnable on Windows (#1939). `test-servers/tsconfig.json` gains `incremental` so the up-to-date case is cheap: 3.0s cold, 1.6s incremental here. Unconditional emit is still not a clean — `--noCheck` leaves the stale .js of a deleted src file behind — which is unchanged from before and recorded in the helper's header and AGENTS.md. Closes #2111 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JTHVxSu8AUgHRLvo1ntZ8H Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
2b129087a3
commit
e59452ea8c
1 changed files with 391 additions and 164 deletions
|
|
@ -29,12 +29,13 @@
|
|||
* smoke-web-browser.mjs; see its header.
|
||||
*/
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import { join } from "node:path";
|
||||
import { startAnnouncedChild } from "./announced-child.mjs";
|
||||
import { resolveNodeBin } from "./resolve-node-bin.mjs";
|
||||
import {
|
||||
ensureTestServers,
|
||||
testServerEntryPath,
|
||||
} from "./ensure-test-servers.mjs";
|
||||
|
||||
/** The App tool the `mcp-app-http.json` fixture serves. */
|
||||
export const APP_TOOL = "mcp_app_demo";
|
||||
|
|
@ -51,7 +52,7 @@ export const FATAL_CONSOLE =
|
|||
|
||||
/** Path to the composable test server build, relative to the repo root. */
|
||||
export function composableServerPath(repoRoot) {
|
||||
return join(repoRoot, "test-servers", "build", "server-composable.js");
|
||||
return testServerEntryPath(repoRoot, "composable");
|
||||
}
|
||||
|
||||
/** Path to a `test-servers/configs/<name>.json` fixture. */
|
||||
|
|
@ -71,31 +72,15 @@ export function sandboxProxyPageFor(webBuildDir) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build the composable test server bundle if it isn't present yet.
|
||||
*
|
||||
* The root-installed tsc is run via this Node — `npx` is a `.cmd` shim on
|
||||
* Windows that a shell-free spawnSync can't start (ENOENT — #1939).
|
||||
* Build the composable test server bundle. Unconditional per process — see
|
||||
* `ensure-test-servers.mjs` for why presence is not freshness (#2111).
|
||||
*/
|
||||
export function ensureComposableTestServer(repoRoot, label) {
|
||||
const entry = composableServerPath(repoRoot);
|
||||
if (existsSync(entry)) return entry;
|
||||
console.log(`${label} — building test-servers (missing build output)...`);
|
||||
const r = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
resolveNodeBin("typescript", "tsc", repoRoot),
|
||||
"-p",
|
||||
"test-servers",
|
||||
"--noCheck",
|
||||
],
|
||||
{ cwd: repoRoot, stdio: "inherit" },
|
||||
);
|
||||
if (r.status !== 0 || !existsSync(entry)) {
|
||||
throw new Error(
|
||||
"could not build the test servers (test-servers/build/server-composable.js). " +
|
||||
"Run `npm run test-servers:build` from clients/web.",
|
||||
);
|
||||
}
|
||||
const [entry] = ensureTestServers({
|
||||
repoRoot,
|
||||
label,
|
||||
requires: ["composable"],
|
||||
});
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue