fix(scripts): catch namespace plugin sdk wildcard exports

This commit is contained in:
Vincent Koc 2026-06-23 10:35:28 +02:00
parent c061373ede
commit a59b2f2958
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -9,7 +9,7 @@ const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."
const extensionsRoot = path.join(repoRoot, "extensions");
const WILDCARD_PLUGIN_SDK_REEXPORT_PATTERN =
/^\s*export\s+(?:type\s+)?\*\s+from\s+["']openclaw\/plugin-sdk\//u;
/^\s*export\s+(?:type\s+)?\*\s+(?:as\s+[$\w]+\s+)?from\s+["']openclaw\/plugin-sdk\//u;
async function listExtensionApiFiles(rootDir = extensionsRoot) {
const entries = await fs.readdir(rootDir, { withFileTypes: true });

View file

@ -8,13 +8,17 @@ describe("check-plugin-sdk-wildcard-reexports", () => {
findPluginSdkWildcardReexports(
[
'export * from "openclaw/plugin-sdk/foo";',
'export * as sdk from "openclaw/plugin-sdk/foo";',
'export type * from "openclaw/plugin-sdk/bar";',
'export type * as sdkTypes from "openclaw/plugin-sdk/bar";',
'export { named } from "openclaw/plugin-sdk/foo";',
].join("\n"),
),
).toEqual([
{ line: 1, text: 'export * from "openclaw/plugin-sdk/foo";' },
{ line: 2, text: 'export type * from "openclaw/plugin-sdk/bar";' },
{ line: 2, text: 'export * as sdk from "openclaw/plugin-sdk/foo";' },
{ line: 3, text: 'export type * from "openclaw/plugin-sdk/bar";' },
{ line: 4, text: 'export type * as sdkTypes from "openclaw/plugin-sdk/bar";' },
]);
});
@ -25,6 +29,7 @@ describe("check-plugin-sdk-wildcard-reexports", () => {
'export { named } from "openclaw/plugin-sdk/foo";',
'export type { Named } from "openclaw/plugin-sdk/foo";',
'export * from "./src/runtime-api.js";',
'export * as runtime from "./src/runtime-api.js";',
].join("\n"),
),
).toStrictEqual([]);