mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 21:20:23 +00:00
test: move plugin-sdk index and root alias guardrails
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildPluginSdkPackageExports } from "./entrypoints.js";
|
||||
import { buildPluginSdkPackageExports } from "../../plugin-sdk/entrypoints.js";
|
||||
|
||||
const pluginSdkIndexPath = fileURLToPath(new URL("../../plugin-sdk/index.ts", import.meta.url));
|
||||
|
||||
async function collectRuntimeExports(filePath: string, seen = new Set<string>()) {
|
||||
const normalizedPath = path.resolve(filePath);
|
||||
@@ -43,7 +46,7 @@ async function collectRuntimeExports(filePath: string, seen = new Set<string>())
|
||||
}
|
||||
|
||||
async function readIndexRuntimeExports() {
|
||||
return await collectRuntimeExports(path.join(import.meta.dirname, "index.ts"));
|
||||
return await collectRuntimeExports(pluginSdkIndexPath);
|
||||
}
|
||||
|
||||
describe("plugin-sdk exports", () => {
|
||||
@@ -6,10 +6,10 @@ import vm from "node:vm";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const rootSdk = require("./root-alias.cjs") as Record<string, unknown>;
|
||||
const rootAliasPath = fileURLToPath(new URL("./root-alias.cjs", import.meta.url));
|
||||
const rootAliasPath = fileURLToPath(new URL("../../plugin-sdk/root-alias.cjs", import.meta.url));
|
||||
const rootSdk = require(rootAliasPath) as Record<string, unknown>;
|
||||
const rootAliasSource = fs.readFileSync(rootAliasPath, "utf-8");
|
||||
const packageJsonPath = fileURLToPath(new URL("../../package.json", import.meta.url));
|
||||
const packageJsonPath = fileURLToPath(new URL("../../../package.json", import.meta.url));
|
||||
|
||||
type EmptySchema = {
|
||||
safeParse: (value: unknown) =>
|
||||
Reference in New Issue
Block a user