mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-20 05:31:30 +00:00
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import tsdownConfig from "../../tsdown.config.ts";
|
|
|
|
type TsdownConfigEntry = {
|
|
entry?: Record<string, string> | string[];
|
|
outDir?: string;
|
|
};
|
|
|
|
function asConfigArray(config: unknown): TsdownConfigEntry[] {
|
|
return Array.isArray(config) ? (config as TsdownConfigEntry[]) : [config as TsdownConfigEntry];
|
|
}
|
|
|
|
function entryKeys(config: TsdownConfigEntry): string[] {
|
|
if (!config.entry || Array.isArray(config.entry)) {
|
|
return [];
|
|
}
|
|
return Object.keys(config.entry);
|
|
}
|
|
|
|
describe("tsdown config", () => {
|
|
it("keeps core, plugin runtime, plugin-sdk, bundled plugins, and bundled hooks in one dist graph", () => {
|
|
const configs = asConfigArray(tsdownConfig);
|
|
const distGraphs = configs.filter((config) => {
|
|
const keys = entryKeys(config);
|
|
return (
|
|
keys.includes("index") ||
|
|
keys.includes("plugins/runtime/index") ||
|
|
keys.includes("plugin-sdk/index") ||
|
|
keys.includes("extensions/openai/index") ||
|
|
keys.includes("bundled/boot-md/handler")
|
|
);
|
|
});
|
|
|
|
expect(distGraphs).toHaveLength(1);
|
|
expect(entryKeys(distGraphs[0])).toEqual(
|
|
expect.arrayContaining([
|
|
"index",
|
|
"plugins/runtime/index",
|
|
"plugin-sdk/compat",
|
|
"plugin-sdk/index",
|
|
"extensions/openai/index",
|
|
"bundled/boot-md/handler",
|
|
]),
|
|
);
|
|
});
|
|
|
|
it("does not emit plugin-sdk or hooks from a separate dist graph", () => {
|
|
const configs = asConfigArray(tsdownConfig);
|
|
|
|
expect(configs.some((config) => config.outDir === "dist/plugin-sdk")).toBe(false);
|
|
expect(
|
|
configs.some((config) =>
|
|
Array.isArray(config.entry)
|
|
? config.entry.some((entry) => entry.includes("src/hooks/"))
|
|
: false,
|
|
),
|
|
).toBe(false);
|
|
});
|
|
});
|