mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:20:44 +00:00
fix(plugins): localize bundled runtime deps to extensions (#67099)
* fix(plugins): localize bundled runtime deps to extensions * fix(plugins): move staged runtime deps out of root * fix(packaging): harden prepack and runtime dep staging * fix(packaging): preserve optional runtime dep staging * Update CHANGELOG.md * fix(packaging): harden runtime staging filesystem writes * fix(docker): ship preinstall warning in bootstrap layers * fix(packaging): exclude staged plugin node_modules from npm pack
This commit is contained in:
@@ -5,8 +5,6 @@ import { existsSync, readdirSync } from "node:fs";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { formatErrorMessage } from "../src/infra/errors.ts";
|
||||
import { writePackageDistInventory } from "../src/infra/package-dist-inventory.ts";
|
||||
|
||||
const skipPrepackPreparedEnv = "OPENCLAW_PREPACK_PREPARED";
|
||||
const requiredPreparedPathGroups = [
|
||||
["dist/index.js", "dist/index.mjs"],
|
||||
["dist/control-ui/index.html"],
|
||||
@@ -22,14 +20,6 @@ function normalizeFiles(files: Iterable<string>): Set<string> {
|
||||
return new Set(Array.from(files, (file) => file.replace(/\\/g, "/")));
|
||||
}
|
||||
|
||||
export function shouldSkipPrepack(env = process.env): boolean {
|
||||
const raw = env[skipPrepackPreparedEnv];
|
||||
if (!raw) {
|
||||
return false;
|
||||
}
|
||||
return !/^(0|false)$/i.test(raw);
|
||||
}
|
||||
|
||||
export function collectPreparedPrepackErrors(
|
||||
files: Iterable<string>,
|
||||
assetPaths: Iterable<string>,
|
||||
@@ -83,9 +73,7 @@ function ensurePreparedArtifacts(): void {
|
||||
const preparedFiles = collectPreparedFilePaths();
|
||||
const errors = collectPreparedPrepackErrors(preparedFiles.files, preparedFiles.assets);
|
||||
if (errors.length === 0) {
|
||||
console.error(
|
||||
`prepack: using prepared artifacts from ${skipPrepackPreparedEnv}; skipping rebuild.`,
|
||||
);
|
||||
console.error("prepack: using existing prepared artifacts.");
|
||||
return;
|
||||
}
|
||||
for (const error of errors) {
|
||||
@@ -97,7 +85,7 @@ function ensurePreparedArtifacts(): void {
|
||||
}
|
||||
|
||||
console.error(
|
||||
`prepack: ${skipPrepackPreparedEnv}=1 requires an existing build and Control UI bundle. Run \`pnpm build && pnpm ui:build\` first or unset ${skipPrepackPreparedEnv}.`,
|
||||
"prepack: requires an existing build and Control UI bundle. Run `pnpm build && pnpm ui:build` before packing or publishing.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -123,14 +111,9 @@ async function writeDistInventory(): Promise<void> {
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const pnpmCommand = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
|
||||
if (shouldSkipPrepack()) {
|
||||
ensurePreparedArtifacts();
|
||||
await writeDistInventory();
|
||||
runBuildSmoke();
|
||||
return;
|
||||
}
|
||||
run(pnpmCommand, ["build"]);
|
||||
run(pnpmCommand, ["ui:build"]);
|
||||
ensurePreparedArtifacts();
|
||||
await writeDistInventory();
|
||||
runBuildSmoke();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user