mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:20:43 +00:00
refactor(plugin-sdk): narrow config runtime imports
This commit is contained in:
@@ -66,6 +66,7 @@ function isProductionExtensionFile(relPath) {
|
||||
relPath.includes(".test-d.") ||
|
||||
relPath.includes(".test-harness.") ||
|
||||
relPath.includes(".test-shared.") ||
|
||||
relPath.endsWith(".test-support.ts") ||
|
||||
relPath.endsWith("-test-helpers.ts") ||
|
||||
relPath.endsWith("-test-support.ts")
|
||||
) {
|
||||
@@ -155,6 +156,26 @@ function pushDeprecatedRuntimeApiViolations(violations, files) {
|
||||
}
|
||||
}
|
||||
|
||||
function pushBroadConfigRuntimeBarrelViolations(violations, files) {
|
||||
const staticImportPattern =
|
||||
/\b(?:import|export)\s+(?:type\s+)?\{[\s\S]*?\}\s+from\s+["']openclaw\/plugin-sdk\/config-runtime["']/g;
|
||||
const dynamicImportPattern =
|
||||
/\b(?:const|let|var)\s+\{[\s\S]*?\}\s*=\s*(?:await\s+)?import\(["']openclaw\/plugin-sdk\/config-runtime["']\)/g;
|
||||
const typeQueryPattern =
|
||||
/\b(?:typeof\s+)?import\(["']openclaw\/plugin-sdk\/config-runtime["']\)\.[A-Za-z_$][\w$]*/g;
|
||||
|
||||
for (const { filePath, relPath } of files) {
|
||||
const source = readFileSync(filePath, "utf8");
|
||||
for (const pattern of [staticImportPattern, dynamicImportPattern, typeQueryPattern]) {
|
||||
for (const line of findMatchLineNumbers(source, pattern)) {
|
||||
violations.push(
|
||||
`${relPath}:${line} use narrow plugin-sdk config subpaths instead of openclaw/plugin-sdk/config-runtime`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function collectDeprecatedInternalConfigApiViolations({
|
||||
repoRoot = DEFAULT_REPO_ROOT,
|
||||
} = {}) {
|
||||
@@ -177,6 +198,7 @@ export function collectDeprecatedInternalConfigApiViolations({
|
||||
.map((filePath) => ({ filePath, relPath: repoRelative(repoRoot, filePath) }))
|
||||
.filter(({ relPath }) => isProductionExtensionFile(relPath));
|
||||
pushDeprecatedRuntimeApiViolations(violations, productionExtensionFiles);
|
||||
pushBroadConfigRuntimeBarrelViolations(violations, productionExtensionFiles);
|
||||
|
||||
for (const { filePath, relPath } of productionExtensionFiles) {
|
||||
const source = readFileSync(filePath, "utf8");
|
||||
@@ -215,6 +237,15 @@ export function collectDeprecatedInternalConfigApiViolations({
|
||||
violations,
|
||||
repoFiles.filter(({ relPath }) => !isCompatConfigApiFile(relPath)),
|
||||
);
|
||||
pushBroadConfigRuntimeBarrelViolations(
|
||||
violations,
|
||||
repoFiles.filter(
|
||||
({ relPath }) =>
|
||||
!isTestOrHarnessFile(relPath) &&
|
||||
!isCompatConfigApiFile(relPath) &&
|
||||
!relPath.startsWith("test/"),
|
||||
),
|
||||
);
|
||||
|
||||
for (const { filePath, relPath } of repoFiles.filter(
|
||||
({ relPath }) => !isCompatConfigApiFile(relPath),
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
"approval-reply-runtime",
|
||||
"approval-runtime",
|
||||
"config-runtime",
|
||||
"config-types",
|
||||
"plugin-config-runtime",
|
||||
"config-mutation",
|
||||
"cron-store-runtime",
|
||||
"config-schema",
|
||||
"reply-runtime",
|
||||
"reply-dedupe",
|
||||
@@ -51,6 +55,8 @@
|
||||
"infra-runtime",
|
||||
"runtime-config-snapshot",
|
||||
"runtime-group-policy",
|
||||
"model-session-runtime",
|
||||
"talk-config-runtime",
|
||||
"ssrf-policy",
|
||||
"ssrf-runtime",
|
||||
"media-runtime",
|
||||
|
||||
Reference in New Issue
Block a user