mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:10:45 +00:00
Merged via squash.
Prepared head SHA: b5db59b8fe
Co-authored-by: frankekn <4488090+frankekn@users.noreply.github.com>
Co-authored-by: frankekn <4488090+frankekn@users.noreply.github.com>
Reviewed-by: @frankekn
82 lines
2.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { collectBuiltBundledPluginStagedRuntimeDependencyErrors } from "../../scripts/lib/bundled-plugin-root-runtime-mirrors.mjs";
|
|
import { createScriptTestHarness } from "./test-helpers.js";
|
|
|
|
const { createTempDir } = createScriptTestHarness();
|
|
|
|
function writeJson(root: string, relativePath: string, value: unknown) {
|
|
const fullPath = path.join(root, relativePath);
|
|
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
|
fs.writeFileSync(fullPath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
}
|
|
|
|
describe("collectBuiltBundledPluginStagedRuntimeDependencyErrors", () => {
|
|
it("flags built staged plugins whose dist node_modules are missing runtime deps", () => {
|
|
const repoRoot = createTempDir("openclaw-runtime-contracts-");
|
|
|
|
writeJson(repoRoot, "dist/extensions/diffs/package.json", {
|
|
name: "@openclaw/diffs",
|
|
dependencies: {
|
|
"@pierre/diffs": "^0.1.0",
|
|
},
|
|
openclaw: {
|
|
bundle: {
|
|
stageRuntimeDependencies: true,
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(
|
|
collectBuiltBundledPluginStagedRuntimeDependencyErrors({
|
|
bundledPluginsDir: path.join(repoRoot, "dist/extensions"),
|
|
}),
|
|
).toEqual([
|
|
"built bundled plugin 'diffs' is missing staged runtime dependency '@pierre/diffs: ^0.1.0' under dist/extensions/diffs/node_modules.",
|
|
]);
|
|
});
|
|
|
|
it("accepts built staged plugins when their staged runtime deps are present", () => {
|
|
const repoRoot = createTempDir("openclaw-runtime-contracts-");
|
|
|
|
writeJson(repoRoot, "dist/extensions/diffs/package.json", {
|
|
name: "@openclaw/diffs",
|
|
dependencies: {
|
|
"@pierre/diffs": "^0.1.0",
|
|
},
|
|
openclaw: {
|
|
bundle: {
|
|
stageRuntimeDependencies: true,
|
|
},
|
|
},
|
|
});
|
|
writeJson(repoRoot, "dist/extensions/diffs/node_modules/@pierre/diffs/package.json", {
|
|
name: "@pierre/diffs",
|
|
version: "0.1.0",
|
|
});
|
|
|
|
expect(
|
|
collectBuiltBundledPluginStagedRuntimeDependencyErrors({
|
|
bundledPluginsDir: path.join(repoRoot, "dist/extensions"),
|
|
}),
|
|
).toEqual([]);
|
|
});
|
|
|
|
it("keeps the WhatsApp bundled plugin opted into staged runtime dependencies", () => {
|
|
const packageJson = JSON.parse(
|
|
fs.readFileSync(path.join(process.cwd(), "extensions/whatsapp/package.json"), "utf8"),
|
|
) as {
|
|
dependencies?: Record<string, string>;
|
|
openclaw?: {
|
|
bundle?: {
|
|
stageRuntimeDependencies?: boolean;
|
|
};
|
|
};
|
|
};
|
|
|
|
expect(packageJson.dependencies?.["@whiskeysockets/baileys"]).toBe("7.0.0-rc.9");
|
|
expect(packageJson.openclaw?.bundle?.stageRuntimeDependencies).toBe(true);
|
|
});
|
|
});
|