mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-18 13:30:48 +00:00
refactor(plugins): derive compat provider ids from manifests
This commit is contained in:
@@ -5,11 +5,16 @@ import { discoverOpenClawPlugins } from "../src/plugins/discovery.js";
|
||||
// Match exact monolithic-root specifier in any code path:
|
||||
// imports/exports, require/dynamic import, and test mocks (vi.mock/jest.mock).
|
||||
const ROOT_IMPORT_PATTERN = /["']openclaw\/plugin-sdk["']/;
|
||||
const LEGACY_ROUTING_IMPORT_PATTERN = /["']openclaw\/plugin-sdk\/routing["']/;
|
||||
|
||||
function hasMonolithicRootImport(content: string): boolean {
|
||||
return ROOT_IMPORT_PATTERN.test(content);
|
||||
}
|
||||
|
||||
function hasLegacyRoutingImport(content: string): boolean {
|
||||
return LEGACY_ROUTING_IMPORT_PATTERN.test(content);
|
||||
}
|
||||
|
||||
function isSourceFile(filePath: string): boolean {
|
||||
if (filePath.endsWith(".d.ts")) {
|
||||
return false;
|
||||
@@ -77,7 +82,8 @@ function main() {
|
||||
filesToCheck.add(sharedFile);
|
||||
}
|
||||
|
||||
const offenders: string[] = [];
|
||||
const monolithicOffenders: string[] = [];
|
||||
const legacyRoutingOffenders: string[] = [];
|
||||
for (const entryFile of filesToCheck) {
|
||||
let content = "";
|
||||
try {
|
||||
@@ -86,19 +92,35 @@ function main() {
|
||||
continue;
|
||||
}
|
||||
if (hasMonolithicRootImport(content)) {
|
||||
offenders.push(entryFile);
|
||||
monolithicOffenders.push(entryFile);
|
||||
}
|
||||
if (hasLegacyRoutingImport(content)) {
|
||||
legacyRoutingOffenders.push(entryFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (offenders.length > 0) {
|
||||
console.error("Bundled plugin source files must not import monolithic openclaw/plugin-sdk.");
|
||||
for (const file of offenders.toSorted()) {
|
||||
const relative = path.relative(process.cwd(), file) || file;
|
||||
console.error(`- ${relative}`);
|
||||
if (monolithicOffenders.length > 0 || legacyRoutingOffenders.length > 0) {
|
||||
if (monolithicOffenders.length > 0) {
|
||||
console.error("Bundled plugin source files must not import monolithic openclaw/plugin-sdk.");
|
||||
for (const file of monolithicOffenders.toSorted()) {
|
||||
const relative = path.relative(process.cwd(), file) || file;
|
||||
console.error(`- ${relative}`);
|
||||
}
|
||||
}
|
||||
if (legacyRoutingOffenders.length > 0) {
|
||||
console.error(
|
||||
"Bundled plugin source files must not import legacy openclaw/plugin-sdk/routing.",
|
||||
);
|
||||
for (const file of legacyRoutingOffenders.toSorted()) {
|
||||
const relative = path.relative(process.cwd(), file) || file;
|
||||
console.error(`- ${relative}`);
|
||||
}
|
||||
}
|
||||
if (monolithicOffenders.length > 0 || legacyRoutingOffenders.length > 0) {
|
||||
console.error(
|
||||
"Use openclaw/plugin-sdk/<channel> for channel plugins, /core for shared routing and startup surfaces, or /compat for broader internals.",
|
||||
);
|
||||
}
|
||||
console.error(
|
||||
"Use openclaw/plugin-sdk/<channel> for channel plugins, /core for startup surfaces, or /compat for broader internals.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user