mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-31 06:19:44 +02:00
57 lines
2.2 KiB
JavaScript
57 lines
2.2 KiB
JavaScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
import { copyBundledPluginMetadata } from "./copy-bundled-plugin-metadata.mjs";
|
|
import { copyPluginSdkRootAlias } from "./copy-plugin-sdk-root-alias.mjs";
|
|
import { stageBundledPluginRuntimeDeps } from "./stage-bundled-plugin-runtime-deps.mjs";
|
|
import { stageBundledPluginRuntime } from "./stage-bundled-plugin-runtime.mjs";
|
|
import { writeOfficialChannelCatalog } from "./write-official-channel-catalog.mjs";
|
|
|
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
|
|
/**
|
|
* Copy static (non-transpiled) runtime assets that are referenced by their
|
|
* source-relative path inside bundled extension code.
|
|
*
|
|
* Each entry: { src: repo-root-relative source, dest: dist-relative dest }
|
|
*/
|
|
export const STATIC_EXTENSION_ASSETS = [
|
|
// acpx MCP proxy — co-deployed alongside the acpx index bundle so that
|
|
// `path.resolve(dirname(import.meta.url), "mcp-proxy.mjs")` resolves correctly
|
|
// at runtime (see extensions/acpx/src/runtime-internals/mcp-agent-command.ts).
|
|
{
|
|
src: "extensions/acpx/src/runtime-internals/mcp-proxy.mjs",
|
|
dest: "dist/extensions/acpx/mcp-proxy.mjs",
|
|
},
|
|
];
|
|
|
|
export function copyStaticExtensionAssets(params = {}) {
|
|
const rootDir = params.rootDir ?? ROOT;
|
|
const assets = params.assets ?? STATIC_EXTENSION_ASSETS;
|
|
const fsImpl = params.fs ?? fs;
|
|
const warn = params.warn ?? console.warn;
|
|
for (const { src, dest } of assets) {
|
|
const srcPath = path.join(rootDir, src);
|
|
const destPath = path.join(rootDir, dest);
|
|
if (fsImpl.existsSync(srcPath)) {
|
|
fsImpl.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
fsImpl.copyFileSync(srcPath, destPath);
|
|
} else {
|
|
warn(`[runtime-postbuild] static asset not found, skipping: ${src}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
export function runRuntimePostBuild(params = {}) {
|
|
copyPluginSdkRootAlias(params);
|
|
copyBundledPluginMetadata(params);
|
|
writeOfficialChannelCatalog(params);
|
|
stageBundledPluginRuntimeDeps(params);
|
|
stageBundledPluginRuntime(params);
|
|
copyStaticExtensionAssets();
|
|
}
|
|
|
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
|
|
runRuntimePostBuild();
|
|
}
|