diff --git a/src/channels/plugins/contracts/plugins-core.loader.contract.test.ts b/src/channels/plugins/contracts/plugins-core.loader.contract.test.ts index a9642feee9e..d505c7e2c90 100644 --- a/src/channels/plugins/contracts/plugins-core.loader.contract.test.ts +++ b/src/channels/plugins/contracts/plugins-core.loader.contract.test.ts @@ -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((entry) => entry.plugin); + const emptyRegistry = createTestRegistry([]); const demoOutbound: ChannelOutboundAdapter = { diff --git a/src/channels/plugins/load.ts b/src/channels/plugins/load.ts deleted file mode 100644 index 70ebe45a853..00000000000 --- a/src/channels/plugins/load.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { createChannelRegistryLoader } from "./registry-loader.js"; -import type { ChannelId, ChannelPlugin } from "./types.js"; - -const loadPluginFromRegistry = createChannelRegistryLoader((entry) => entry.plugin); - -export async function loadChannelPlugin(id: ChannelId): Promise { - return loadPluginFromRegistry(id); -} diff --git a/src/plugins/bundled-manifest-snapshots.ts b/src/plugins/bundled-manifest-snapshots.ts deleted file mode 100644 index 5e3c0f387bb..00000000000 --- a/src/plugins/bundled-manifest-snapshots.ts +++ /dev/null @@ -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; -}