mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 16:38:12 +00:00
Align the export-session template asset copy step and build-all cache output with the runtime lookup path so published packages include the HTML export assets at `dist/export-html`. Adds a focused build-all regression assertion for the output path contract. Fixes #90843
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
#!/usr/bin/env tsx
|
|
/**
|
|
* Copy export-html templates from src to dist
|
|
*/
|
|
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { ensureDirectory, logVerboseCopy, resolveBuildCopyContext } from "./lib/copy-assets.ts";
|
|
|
|
const context = resolveBuildCopyContext(import.meta.url);
|
|
|
|
const exportHtmlSrcDir = path.join(
|
|
context.projectRoot,
|
|
"src",
|
|
"auto-reply",
|
|
"reply",
|
|
"export-html",
|
|
);
|
|
const exportHtmlDistDir = path.join(context.projectRoot, "dist", "export-html");
|
|
|
|
function copyExportHtmlTemplates() {
|
|
if (!fs.existsSync(exportHtmlSrcDir)) {
|
|
console.warn(`${context.prefix} Source directory not found:`, exportHtmlSrcDir);
|
|
return;
|
|
}
|
|
|
|
fs.rmSync(exportHtmlDistDir, { recursive: true, force: true });
|
|
ensureDirectory(exportHtmlDistDir);
|
|
let copiedCount = 0;
|
|
|
|
const copyDir = (srcDir: string, distDir: string, relativePrefix = "") => {
|
|
ensureDirectory(distDir);
|
|
for (const file of fs.readdirSync(srcDir)) {
|
|
const srcFile = path.join(srcDir, file);
|
|
const distFile = path.join(distDir, file);
|
|
const relativeName = path.join(relativePrefix, file);
|
|
if (file.endsWith(".test.ts")) {
|
|
continue;
|
|
}
|
|
if (fs.statSync(srcFile).isDirectory()) {
|
|
copyDir(srcFile, distFile, relativeName);
|
|
continue;
|
|
}
|
|
fs.copyFileSync(srcFile, distFile);
|
|
copiedCount += 1;
|
|
logVerboseCopy(context, `Copied ${relativeName}`);
|
|
}
|
|
};
|
|
|
|
copyDir(exportHtmlSrcDir, exportHtmlDistDir);
|
|
|
|
console.log(`${context.prefix} Copied ${copiedCount} export-html assets.`);
|
|
}
|
|
|
|
copyExportHtmlTemplates();
|