import { readdirSync, readFileSync, statSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "@suaveplan/testing/runner"; const pkgRoot = fileURLToPath(new URL("..", import.meta.url)); function walk(dir: string, out: string[] = []): string[] { for (const name of readdirSync(dir)) { const full = join(dir, name); const st = statSync(full); if (st.isDirectory()) walk(full, out); else if (full.endsWith(".ts") || full.endsWith(".tsx")) out.push(full); } return out; } describe("package shape", () => { it("package.json declares no @suaveplan/* runtime deps", { timeout: 5000, }, () => { const pkg = JSON.parse( readFileSync(join(pkgRoot, "package.json"), "utf8") ) as { dependencies?: Record; peerDependencies?: Record; }; const runtime = Object.keys(pkg.dependencies ?? {}); for (const k of runtime) { expect(k.startsWith("@suaveplan/")).toBe(false); } const peer = Object.keys(pkg.peerDependencies ?? {}); for (const k of peer) { // peerDependencies may declare @suaveplan/types (types-only) but no // other @suaveplan/* runtime package. if (k.startsWith("@suaveplan/")) { expect(k).toBe("@suaveplan/types"); } } }); it("no direct vitest or bun:test imports in src/", { timeout: 5000, }, () => { const srcRoot = join(pkgRoot, "src"); const files = walk(srcRoot); for (const f of files) { const text = readFileSync(f, "utf8"); const lines = text.split("\n"); for (const line of lines) { const m = line.match(/from\s+["'](vitest|bun:test)["']/u); expect(m).toBeNull(); } } }); });