Skip to content

Commit fcf0bff

Browse files
authored
test: derive deprecated sdk usage guard (#86403)
1 parent ba2b820 commit fcf0bff

3 files changed

Lines changed: 50 additions & 15 deletions

File tree

scripts/check-deprecated-api-usage.mjs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import fs from "node:fs";
33
import path from "node:path";
44
import { collectDeprecatedInternalConfigApiViolations } from "./lib/deprecated-config-api-guard.mjs";
5+
import { buildDeprecatedPluginSdkModuleSpecifiers } from "./lib/deprecated-plugin-sdk-usage.mjs";
56

67
const repoRoot = process.cwd();
78

@@ -11,6 +12,13 @@ const skippedFilePatterns = [
1112
/\.test\.[cm]?[jt]sx?$/u,
1213
/\.spec\.[cm]?[jt]sx?$/u,
1314
/\.e2e\.[cm]?[jt]sx?$/u,
15+
/\.test-(?:harness|loader|support)\.[cm]?[jt]sx?$/u,
16+
/\.contract-test-support\.[cm]?[jt]sx?$/u,
17+
/(?:^|\/)test-(?:helpers|support)\.[cm]?[jt]sx?$/u,
18+
/(?:^|\/)(?:test-helpers|test-support)\//u,
19+
/^extensions\/test-support\//u,
20+
/^src\/channels\/plugins\/contracts\/test-helpers\//u,
21+
/^src\/plugins\/contracts\/tts-contract-suites\.ts$/u,
1422
/\.d\.ts$/u,
1523
];
1624

@@ -131,21 +139,7 @@ const rules = [
131139
{
132140
id: "plugin-sdk-compat-subpaths",
133141
roots: ["src", "extensions", "packages"],
134-
moduleSpecifiers: [
135-
"openclaw/plugin-sdk/agent-dir-compat",
136-
"openclaw/plugin-sdk/channel-config-schema-legacy",
137-
"openclaw/plugin-sdk/channel-reply-pipeline",
138-
"openclaw/plugin-sdk/channel-runtime",
139-
"openclaw/plugin-sdk/compat",
140-
"openclaw/plugin-sdk/discord",
141-
"openclaw/plugin-sdk/infra-runtime",
142-
"openclaw/plugin-sdk/mattermost",
143-
"openclaw/plugin-sdk/matrix",
144-
"openclaw/plugin-sdk/telegram-account",
145-
"openclaw/plugin-sdk/testing",
146-
"openclaw/plugin-sdk/test-utils",
147-
"openclaw/plugin-sdk/zalouser",
148-
],
142+
moduleSpecifiers: buildDeprecatedPluginSdkModuleSpecifiers(),
149143
message: "use focused non-deprecated plugin SDK subpaths",
150144
},
151145
{
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import deprecatedPublicPluginSdkSubpaths from "./plugin-sdk-deprecated-public-subpaths.json" with { type: "json" };
2+
3+
const DEPRECATED_PLUGIN_SDK_EXTRA_SPECIFIERS = [
4+
"openclaw/plugin-sdk",
5+
"openclaw/plugin-sdk/agent-dir-compat",
6+
"openclaw/plugin-sdk/test-utils",
7+
];
8+
9+
export function buildDeprecatedPluginSdkModuleSpecifiers(
10+
deprecatedSubpaths = deprecatedPublicPluginSdkSubpaths,
11+
) {
12+
return [
13+
...new Set([
14+
...DEPRECATED_PLUGIN_SDK_EXTRA_SPECIFIERS,
15+
...deprecatedSubpaths.map((subpath) => `openclaw/plugin-sdk/${subpath}`),
16+
]),
17+
].toSorted();
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { describe, expect, it } from "vitest";
2+
import { buildDeprecatedPluginSdkModuleSpecifiers } from "../../scripts/lib/deprecated-plugin-sdk-usage.mjs";
3+
import deprecatedPublicPluginSdkSubpaths from "../../scripts/lib/plugin-sdk-deprecated-public-subpaths.json" with { type: "json" };
4+
5+
describe("scripts/check-deprecated-api-usage", () => {
6+
it("bans every curated deprecated public plugin SDK subpath", () => {
7+
const specifiers = new Set(buildDeprecatedPluginSdkModuleSpecifiers());
8+
9+
for (const subpath of deprecatedPublicPluginSdkSubpaths) {
10+
expect(specifiers.has(`openclaw/plugin-sdk/${subpath}`), subpath).toBe(true);
11+
}
12+
});
13+
14+
it("keeps root and private compatibility aliases explicit", () => {
15+
expect(buildDeprecatedPluginSdkModuleSpecifiers()).toEqual(
16+
expect.arrayContaining([
17+
"openclaw/plugin-sdk",
18+
"openclaw/plugin-sdk/agent-dir-compat",
19+
"openclaw/plugin-sdk/test-utils",
20+
]),
21+
);
22+
});
23+
});

0 commit comments

Comments
 (0)