import { readdirSync, readFileSync, statSync } from "node:fs"; import { join, resolve } from "node:path"; import { describe, expect, it } from "@suaveplan/testing/runner"; const pkgRoot = resolve(__dirname, ".."); const srcRoot = join(pkgRoot, "src"); function walk(dir: string): string[] { const out: string[] = []; for (const entry of readdirSync(dir)) { const full = join(dir, entry); const st = statSync(full); if (st.isDirectory()) out.push(...walk(full)); else out.push(full); } return out; } describe("@suaveplan/api-secrets-vault dep graph + layout", () => { it("package.json carries the required @suaveplan/* runtime deps", { timeout: 5000, }, () => { const pkg = JSON.parse( readFileSync(join(pkgRoot, "package.json"), "utf8") ) as { dependencies: Record }; const suaveplan = Object.keys(pkg.dependencies) .filter((k) => k.startsWith("@suaveplan/")) .sort(); expect(suaveplan).toEqual([ "@suaveplan/api-secrets", "@suaveplan/api-types", "@suaveplan/error", "@suaveplan/events", "@suaveplan/logger", "@suaveplan/vault", ]); }); it("zero peerDependencies", { timeout: 5000 }, () => { const pkg = JSON.parse( readFileSync(join(pkgRoot, "package.json"), "utf8") ) as { peerDependencies?: Record }; expect(Object.keys(pkg.peerDependencies ?? {})).toEqual([]); }); it("every src file uses default-import z (no named { z })", { timeout: 5000, }, () => { const bad: string[] = []; for (const file of walk(srcRoot)) { if (!file.endsWith(".ts")) continue; const src = readFileSync(file, "utf8"); if (/import\s*\{\s*z\s*\}\s*from\s*["']zod["']/.test(src)) { bad.push(file); } } expect(bad).toEqual([]); }); it("no static-analysis suppression comments in src/", { timeout: 5000, }, () => { const bad: string[] = []; for (const file of walk(srcRoot)) { if (!file.endsWith(".ts")) continue; const src = readFileSync(file, "utf8"); if (/biome-ignore|eslint-disable|@ts-(ignore|nocheck)/.test(src)) { bad.push(file); } } expect(bad).toEqual([]); }); it("package.json exposes the documented subpath exports", { timeout: 5000, }, () => { const pkg = JSON.parse( readFileSync(join(pkgRoot, "package.json"), "utf8") ) as { exports: Record }; const subpaths = Object.keys(pkg.exports) .filter((k) => k !== "./package.json" && k !== ".") .sort(); expect(subpaths).toEqual([ "./adapter", "./allowlist", "./error-codes", "./from-vault", "./otel", "./types", "./watcher", ]); }); });