test: move plugin-sdk index and root alias guardrails

This commit is contained in:
Peter Steinberger
2026-04-01 02:50:22 +01:00
parent 016f065d7e
commit f5a23b710c
2 changed files with 8 additions and 5 deletions

View File

@@ -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", () => {

View File

@@ -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) =>