mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
fix(plugins): share capability vitest shim aliases
This commit is contained in:
24
src/plugins/bundled-capability-runtime.test.ts
Normal file
24
src/plugins/bundled-capability-runtime.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildVitestCapabilityShimAliasMap } from "./bundled-capability-runtime.js";
|
||||
|
||||
describe("buildVitestCapabilityShimAliasMap", () => {
|
||||
it("keeps scoped and unscoped capability shim aliases aligned", () => {
|
||||
const aliasMap = buildVitestCapabilityShimAliasMap();
|
||||
|
||||
expect(aliasMap["openclaw/plugin-sdk/llm-task"]).toBe(
|
||||
aliasMap["@openclaw/plugin-sdk/llm-task"],
|
||||
);
|
||||
expect(aliasMap["openclaw/plugin-sdk/config-runtime"]).toBe(
|
||||
aliasMap["@openclaw/plugin-sdk/config-runtime"],
|
||||
);
|
||||
expect(aliasMap["openclaw/plugin-sdk/media-runtime"]).toBe(
|
||||
aliasMap["@openclaw/plugin-sdk/media-runtime"],
|
||||
);
|
||||
expect(aliasMap["openclaw/plugin-sdk/provider-onboard"]).toBe(
|
||||
aliasMap["@openclaw/plugin-sdk/provider-onboard"],
|
||||
);
|
||||
expect(aliasMap["openclaw/plugin-sdk/speech-core"]).toBe(
|
||||
aliasMap["@openclaw/plugin-sdk/speech-core"],
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -25,6 +25,41 @@ import type { OpenClawPluginDefinition, OpenClawPluginModule } from "./types.js"
|
||||
|
||||
const log = createSubsystemLogger("plugins");
|
||||
|
||||
const CAPABILITY_VITEST_SHIM_ALIASES = [
|
||||
{
|
||||
subpath: "llm-task",
|
||||
target: new URL("./capability-runtime-vitest-shims/llm-task.ts", import.meta.url),
|
||||
},
|
||||
{
|
||||
subpath: "config-runtime",
|
||||
target: new URL("./capability-runtime-vitest-shims/config-runtime.ts", import.meta.url),
|
||||
},
|
||||
{
|
||||
subpath: "media-runtime",
|
||||
target: new URL("./capability-runtime-vitest-shims/media-runtime.ts", import.meta.url),
|
||||
},
|
||||
{
|
||||
subpath: "provider-onboard",
|
||||
target: new URL("../plugin-sdk/provider-onboard.ts", import.meta.url),
|
||||
},
|
||||
{
|
||||
subpath: "speech-core",
|
||||
target: new URL("./capability-runtime-vitest-shims/speech-core.ts", import.meta.url),
|
||||
},
|
||||
] as const;
|
||||
|
||||
export function buildVitestCapabilityShimAliasMap(): Record<string, string> {
|
||||
return Object.fromEntries(
|
||||
CAPABILITY_VITEST_SHIM_ALIASES.flatMap(({ subpath, target }) => {
|
||||
const targetPath = fileURLToPath(target);
|
||||
return [
|
||||
[`openclaw/plugin-sdk/${subpath}`, targetPath],
|
||||
[`@openclaw/plugin-sdk/${subpath}`, targetPath],
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function applyVitestCapabilityAliasOverrides(params: {
|
||||
aliasMap: Record<string, string>;
|
||||
pluginSdkResolution?: PluginSdkResolutionPreference;
|
||||
@@ -44,36 +79,7 @@ function applyVitestCapabilityAliasOverrides(params: {
|
||||
// Capability contract loads only need a narrow SDK slice. Keep those
|
||||
// helpers on a tiny source graph so Vitest does not pull the dist chunk
|
||||
// bundle that also drags Matrix/WhatsApp code into these tests.
|
||||
"openclaw/plugin-sdk/llm-task": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/llm-task.ts", import.meta.url),
|
||||
),
|
||||
"@openclaw/plugin-sdk/llm-task": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/llm-task.ts", import.meta.url),
|
||||
),
|
||||
"openclaw/plugin-sdk/config-runtime": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/config-runtime.ts", import.meta.url),
|
||||
),
|
||||
"@openclaw/plugin-sdk/config-runtime": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/config-runtime.ts", import.meta.url),
|
||||
),
|
||||
"openclaw/plugin-sdk/media-runtime": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/media-runtime.ts", import.meta.url),
|
||||
),
|
||||
"@openclaw/plugin-sdk/media-runtime": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/media-runtime.ts", import.meta.url),
|
||||
),
|
||||
"openclaw/plugin-sdk/provider-onboard": fileURLToPath(
|
||||
new URL("../plugin-sdk/provider-onboard.ts", import.meta.url),
|
||||
),
|
||||
"@openclaw/plugin-sdk/provider-onboard": fileURLToPath(
|
||||
new URL("../plugin-sdk/provider-onboard.ts", import.meta.url),
|
||||
),
|
||||
"openclaw/plugin-sdk/speech-core": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/speech-core.ts", import.meta.url),
|
||||
),
|
||||
"@openclaw/plugin-sdk/speech-core": fileURLToPath(
|
||||
new URL("./capability-runtime-vitest-shims/speech-core.ts", import.meta.url),
|
||||
),
|
||||
...buildVitestCapabilityShimAliasMap(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user