mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
refactor(deadcode): remove orphaned plugin wrappers
This commit is contained in:
@@ -7,10 +7,12 @@ import {
|
||||
createOutboundTestPlugin,
|
||||
createTestRegistry,
|
||||
} from "../../../test-utils/channel-plugins.js";
|
||||
import { loadChannelPlugin } from "../load.js";
|
||||
import { loadChannelOutboundAdapter } from "../outbound/load.js";
|
||||
import { createChannelRegistryLoader } from "../registry-loader.js";
|
||||
import type { ChannelOutboundAdapter, ChannelPlugin } from "../types.js";
|
||||
|
||||
const loadChannelPlugin = createChannelRegistryLoader<ChannelPlugin>((entry) => entry.plugin);
|
||||
|
||||
const emptyRegistry = createTestRegistry([]);
|
||||
|
||||
const demoOutbound: ChannelOutboundAdapter = {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { createChannelRegistryLoader } from "./registry-loader.js";
|
||||
import type { ChannelId, ChannelPlugin } from "./types.js";
|
||||
|
||||
const loadPluginFromRegistry = createChannelRegistryLoader<ChannelPlugin>((entry) => entry.plugin);
|
||||
|
||||
export async function loadChannelPlugin(id: ChannelId): Promise<ChannelPlugin | undefined> {
|
||||
return loadPluginFromRegistry(id);
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { resolveBundledPluginsDir } from "./bundled-dir.js";
|
||||
import {
|
||||
loadPluginManifest,
|
||||
resolvePackageExtensionEntries,
|
||||
type PackageManifest,
|
||||
type PluginManifest,
|
||||
} from "./manifest.js";
|
||||
|
||||
export type BundledPluginManifestSnapshot = {
|
||||
dirName: string;
|
||||
manifest: PluginManifest;
|
||||
};
|
||||
|
||||
const bundledPluginManifestSnapshotCache = new Map<
|
||||
string,
|
||||
readonly BundledPluginManifestSnapshot[]
|
||||
>();
|
||||
|
||||
export function clearBundledPluginManifestSnapshotCache(): void {
|
||||
bundledPluginManifestSnapshotCache.clear();
|
||||
}
|
||||
|
||||
function readPackageManifest(pluginDir: string): PackageManifest | undefined {
|
||||
const packagePath = path.join(pluginDir, "package.json");
|
||||
if (!fs.existsSync(packagePath)) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(packagePath, "utf-8")) as PackageManifest;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function listBundledPluginManifestSnapshots(params?: {
|
||||
bundledDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): readonly BundledPluginManifestSnapshot[] {
|
||||
const bundledDir = params?.bundledDir ?? resolveBundledPluginsDir(params?.env ?? process.env);
|
||||
if (!bundledDir || !fs.existsSync(bundledDir)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const cacheKey = path.resolve(bundledDir);
|
||||
const cached = bundledPluginManifestSnapshotCache.get(cacheKey);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const entries: BundledPluginManifestSnapshot[] = [];
|
||||
for (const dirName of fs
|
||||
.readdirSync(bundledDir, { withFileTypes: true })
|
||||
.filter((entry) => entry.isDirectory())
|
||||
.map((entry) => entry.name)
|
||||
.toSorted((left, right) => left.localeCompare(right))) {
|
||||
const pluginDir = path.join(bundledDir, dirName);
|
||||
if (resolvePackageExtensionEntries(readPackageManifest(pluginDir)).status !== "ok") {
|
||||
continue;
|
||||
}
|
||||
const manifestResult = loadPluginManifest(pluginDir, false);
|
||||
if (!manifestResult.ok) {
|
||||
continue;
|
||||
}
|
||||
entries.push({
|
||||
dirName,
|
||||
manifest: manifestResult.manifest,
|
||||
});
|
||||
}
|
||||
|
||||
const snapshots = Object.freeze(entries);
|
||||
bundledPluginManifestSnapshotCache.set(cacheKey, snapshots);
|
||||
return snapshots;
|
||||
}
|
||||
Reference in New Issue
Block a user