mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
fix(qa): make matrix block streaming deterministic
This commit is contained in:
@@ -1,19 +1,53 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { build } from "esbuild";
|
||||
|
||||
const scriptPath = path.resolve(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"../../../scripts/build-diffs-viewer-runtime.mjs",
|
||||
);
|
||||
const result = spawnSync(process.execPath, [scriptPath, "curated"], { stdio: "inherit" });
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
const extensionRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const repoRoot = path.resolve(extensionRoot, "../..");
|
||||
const outputPath = path.join(extensionRoot, "assets/viewer-runtime.js");
|
||||
|
||||
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
||||
|
||||
const result = await build({
|
||||
entryPoints: [path.join(extensionRoot, "src/viewer-client.ts")],
|
||||
bundle: true,
|
||||
platform: "browser",
|
||||
target: "es2020",
|
||||
format: "esm",
|
||||
minify: true,
|
||||
legalComments: "none",
|
||||
outfile: outputPath,
|
||||
write: false,
|
||||
plugins: [
|
||||
{
|
||||
name: "openclaw-diffs-curated-shiki",
|
||||
setup(buildContext) {
|
||||
buildContext.onResolve({ filter: /^shiki$/ }, () => ({
|
||||
path: path.join(repoRoot, "scripts/diffs-shiki-curated.ts"),
|
||||
}));
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const outputFile = result.outputFiles?.[0];
|
||||
if (!outputFile) {
|
||||
throw new Error("esbuild did not produce extensions/diffs/assets/viewer-runtime.js");
|
||||
}
|
||||
if (result.signal) {
|
||||
console.error(`build-diffs-viewer-runtime exited with signal ${result.signal}`);
|
||||
process.exit(1);
|
||||
|
||||
const runtime = outputFile.text.replace(/[ \t]+$/gm, "");
|
||||
let previousRuntime = null;
|
||||
try {
|
||||
previousRuntime = await fs.readFile(outputPath, "utf8");
|
||||
} catch (error) {
|
||||
if (error?.code !== "ENOENT") {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
if (previousRuntime !== runtime) {
|
||||
await fs.writeFile(outputPath, runtime);
|
||||
}
|
||||
process.exit(result.status ?? 0);
|
||||
|
||||
Reference in New Issue
Block a user