mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
fix(build): stamp runtime postbuild artifacts
This commit is contained in:
@@ -4,11 +4,17 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import process from "node:process";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { resolveGitHead, writeBuildStamp as writeDistBuildStamp } from "./build-stamp.mjs";
|
||||
import {
|
||||
BUNDLED_PLUGIN_PATH_PREFIX,
|
||||
BUNDLED_PLUGIN_ROOT_DIR,
|
||||
} from "./lib/bundled-plugin-paths.mjs";
|
||||
import {
|
||||
BUILD_STAMP_FILE,
|
||||
RUNTIME_POSTBUILD_STAMP_FILE,
|
||||
resolveGitHead,
|
||||
writeBuildStamp as writeDistBuildStamp,
|
||||
writeRuntimePostBuildStamp as writeDistRuntimePostBuildStamp,
|
||||
} from "./lib/local-build-metadata.mjs";
|
||||
import { runRuntimePostBuild } from "./runtime-postbuild.mjs";
|
||||
|
||||
const buildScript = "scripts/tsdown-build.mjs";
|
||||
@@ -17,12 +23,14 @@ const compilerArgs = [buildScript, "--no-clean"];
|
||||
const runNodeSourceRoots = ["src", BUNDLED_PLUGIN_ROOT_DIR];
|
||||
const runNodeConfigFiles = ["tsconfig.json", "package.json", "tsdown.config.ts"];
|
||||
export const runNodeWatchedPaths = [...runNodeSourceRoots, ...runNodeConfigFiles];
|
||||
const runtimePostBuildStampFile = ".runtime-postbuildstamp";
|
||||
const runtimePostBuildWatchedPaths = [
|
||||
"scripts/copy-bundled-plugin-metadata.mjs",
|
||||
"scripts/copy-plugin-sdk-root-alias.mjs",
|
||||
"scripts/lib",
|
||||
"scripts/lib/local-build-metadata.mjs",
|
||||
"scripts/lib/local-build-metadata-paths.mjs",
|
||||
"scripts/npm-runner.mjs",
|
||||
"scripts/runtime-postbuild-stamp.mjs",
|
||||
"scripts/runtime-postbuild-shared.mjs",
|
||||
"scripts/runtime-postbuild.mjs",
|
||||
"scripts/stage-bundled-plugin-runtime-deps.mjs",
|
||||
@@ -756,20 +764,11 @@ const syncRuntimeArtifacts = async (deps) => {
|
||||
|
||||
const writeRuntimePostBuildStamp = (deps) => {
|
||||
try {
|
||||
deps.fs.mkdirSync(path.dirname(deps.runtimePostBuildStampPath), { recursive: true });
|
||||
const head = resolveGitHead(deps);
|
||||
deps.fs.writeFileSync(
|
||||
deps.runtimePostBuildStampPath,
|
||||
`${JSON.stringify(
|
||||
{
|
||||
syncedAt: Date.now(),
|
||||
...(head ? { head } : {}),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
writeDistRuntimePostBuildStamp({
|
||||
cwd: deps.cwd,
|
||||
fs: deps.fs,
|
||||
spawnSync: deps.spawnSync,
|
||||
});
|
||||
} catch (error) {
|
||||
logRunner(
|
||||
`Failed to write runtime postbuild stamp: ${error?.message ?? "unknown error"}`,
|
||||
@@ -827,8 +826,8 @@ export async function runNodeMain(params = {}) {
|
||||
|
||||
deps.distRoot = path.join(deps.cwd, "dist");
|
||||
deps.distEntry = path.join(deps.distRoot, "/entry.js");
|
||||
deps.buildStampPath = path.join(deps.distRoot, ".buildstamp");
|
||||
deps.runtimePostBuildStampPath = path.join(deps.distRoot, runtimePostBuildStampFile);
|
||||
deps.buildStampPath = path.join(deps.distRoot, BUILD_STAMP_FILE);
|
||||
deps.runtimePostBuildStampPath = path.join(deps.distRoot, RUNTIME_POSTBUILD_STAMP_FILE);
|
||||
deps.sourceRoots = runNodeSourceRoots.map((sourceRoot) => ({
|
||||
name: sourceRoot,
|
||||
path: path.join(deps.cwd, sourceRoot),
|
||||
|
||||
Reference in New Issue
Block a user