Files
T
DongHyeonkaandClaude Opus 5.5 f0d3953ef2 fix(build): render product index before entry points (R-0)
src/.generated is gitignored, but no entry point rendered it, so a fresh
checkout failed check:architecture, check:types:app/node/test, unit and
component tests, verify:documentation, dev and build.

- run-vitest renders the index before starting Vitest (all vitest suites)
- package scripts that load src (dev, build, storybook, architecture,
  app/node/test type checks, the five fixtures that reach the index,
  verify:documentation) render it first; CI runs these scripts by name
- tests/unit/product-index-entrypoints.test.ts guards the wiring

Verified from a fresh state (src/.generated removed before each gate):
architecture, types app/node/test, lint, unit 1781/1781, component 132/132,
verify:documentation, build, dev (HTTP 200), check:ci all pass;
fixture route-runtime still fails with its expected TS2740.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 11:52:34 +09:00

80 lines
2.0 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { existsSync } from "node:fs";
import { fileURLToPath } from "node:url";
function assertSupportedNode(): void {
const [majorText = "0", minorText = "0"] = process.versions.node.split(".");
const major = Number(majorText);
const minor = Number(minorText);
if (major !== 24 || minor < 11) {
process.stderr.write(
[
`Unsupported Node.js runtime for tests: ${process.versions.node}`,
"Required by package.json: >=24.11.0 <25.0.0",
"Use the repository-supported Node.js runtime before running a test suite.",
"",
].join("\n"),
);
process.exit(1);
}
}
assertSupportedNode();
const vitestEntry = fileURLToPath(
new URL("../node_modules/vitest/vitest.mjs", import.meta.url),
);
if (!existsSync(vitestEntry)) {
process.stderr.write(
"Vitest is not installed. Run the repository package installation first.\n",
);
process.exit(1);
}
const testEnvironment: NodeJS.ProcessEnv = {
...process.env,
NODE_ENV: "test",
};
for (const key of [
"npm_config_userconfig",
"npm_config_prefix",
"npm_config_globalconfig",
"NPM_CONFIG_USERCONFIG",
"NPM_CONFIG_PREFIX",
"NPM_CONFIG_GLOBALCONFIG",
]) {
delete testEnvironment[key];
}
// src/.generated is gitignored; every suite imports the product index, so a
// fresh checkout must render it before Vitest resolves the module graph.
const generated = spawnSync(
process.execPath,
[fileURLToPath(new URL("./generate-product-feature-index.ts", import.meta.url))],
{ stdio: "inherit", env: testEnvironment },
);
if (generated.status !== 0) {
process.stderr.write("Product feature index generation failed.\n");
process.exit(generated.status ?? 1);
}
const result = spawnSync(
process.execPath,
[vitestEntry, ...process.argv.slice(2)],
{
stdio: "inherit",
env: testEnvironment,
},
);
if (result.error) {
throw result.error;
}
if (result.signal) {
process.stderr.write(`Vitest terminated by signal ${result.signal}.\n`);
process.exit(1);
}
process.exit(result.status ?? 1);