chore(harness): centralize storybook and release entrypoints

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-03-24 18:00:20 +08:00
parent 5d02bf9df4
commit 002a0b6e7b
3 changed files with 65 additions and 3 deletions
+62
View File
@@ -0,0 +1,62 @@
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { spawn } from "node:child_process";
import { repoRoot } from "./core.mjs";
const docsRoot = path.join(repoRoot, "apps", "docs");
const finalOutputDir = path.join(repoRoot, ".artifacts", "storybook-static");
const tempRootDir = path.join(repoRoot, ".artifacts", "storybook-builds");
async function run(command, args, options = {}) {
await new Promise((resolve, reject) => {
const child = spawn(command, args, {
cwd: repoRoot,
stdio: "inherit",
...options
});
child.on("error", reject);
child.on("exit", (code) => {
if (code === 0) {
resolve();
return;
}
reject(new Error(`${command} ${args.join(" ")} exited with code ${code ?? "unknown"}`));
});
});
}
async function main() {
await fs.mkdir(tempRootDir, { recursive: true });
const tempDir = await fs.mkdtemp(path.join(tempRootDir, `${os.hostname().replace(/[^a-zA-Z0-9_-]/g, "-")}-`));
try {
await run(
"pnpm",
[
"exec",
"storybook",
"build",
"--disable-telemetry",
"--output-dir",
tempDir
],
{
cwd: docsRoot,
env: process.env
}
);
await fs.rm(finalOutputDir, { recursive: true, force: true });
await fs.rename(tempDir, finalOutputDir);
} catch (error) {
await fs.rm(tempDir, { recursive: true, force: true });
throw error;
}
}
await main();