mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 08:10:26 +00:00
refactor(plugins): decouple bundled plugin runtime loading
This commit is contained in:
@@ -2,14 +2,15 @@ import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import ts from "typescript";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { loadRuntimeApiExportTypesViaJiti } from "../../../test/helpers/extensions/jiti-runtime-api.ts";
|
||||
import { bundledPluginRoot } from "../../../test/helpers/bundled-plugin-paths.js";
|
||||
import { loadRuntimeApiExportTypesViaJiti } from "../../../test/helpers/plugins/jiti-runtime-api.ts";
|
||||
import {
|
||||
createPluginSetupWizardConfigure,
|
||||
createTestWizardPrompter,
|
||||
runSetupWizardConfigure,
|
||||
type WizardPrompter,
|
||||
} from "../../../test/helpers/extensions/setup-wizard.js";
|
||||
import { createStartAccountContext } from "../../../test/helpers/extensions/start-account-context.js";
|
||||
} from "../../../test/helpers/plugins/setup-wizard.js";
|
||||
import { createStartAccountContext } from "../../../test/helpers/plugins/start-account-context.js";
|
||||
import type { OpenClawConfig, PluginRuntime, ResolvedLineAccount } from "../api.js";
|
||||
import { linePlugin } from "./channel.js";
|
||||
import { clearLineRuntime, setLineRuntime } from "./runtime.js";
|
||||
@@ -28,13 +29,14 @@ vi.mock("@line/bot-sdk", () => ({
|
||||
|
||||
const lineConfigure = createPluginSetupWizardConfigure(linePlugin);
|
||||
let probeLineBot: typeof import("./probe.js").probeLineBot;
|
||||
const LINE_SRC_PREFIX = `../../${bundledPluginRoot("line")}/src/`;
|
||||
|
||||
function normalizeModuleSpecifier(specifier: string): string | null {
|
||||
if (specifier.startsWith("./src/")) {
|
||||
return specifier;
|
||||
}
|
||||
if (specifier.startsWith("../../extensions/line/src/")) {
|
||||
return `./src/${specifier.slice("../../extensions/line/src/".length)}`;
|
||||
if (specifier.startsWith(LINE_SRC_PREFIX)) {
|
||||
return `./src/${specifier.slice(LINE_SRC_PREFIX.length)}`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user