Initial Commit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const pkgJson = JSON.parse(
|
||||
readFileSync(resolve(here, "..", "package.json"), "utf8")
|
||||
) as {
|
||||
dependencies: Record<string, string>;
|
||||
devDependencies: Record<string, string>;
|
||||
};
|
||||
|
||||
describe("api-tenant-provider dependency graph", () => {
|
||||
it("declares the expected runtime deps", { timeout: 5000 }, () => {
|
||||
const deps = Object.keys(pkgJson.dependencies).sort();
|
||||
expect(deps).toEqual([
|
||||
"@suaveplan/api-types",
|
||||
"@suaveplan/error",
|
||||
"@suaveplan/types",
|
||||
"tslib",
|
||||
"zod",
|
||||
]);
|
||||
});
|
||||
|
||||
it("uses workspace:^ for every @suaveplan/* runtime dep", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
for (const [name, range] of Object.entries(pkgJson.dependencies)) {
|
||||
if (name.startsWith("@suaveplan/")) {
|
||||
expect(range).toBe("workspace:^");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("does NOT depend on @suaveplan/api-host or @suaveplan/api-router", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
// Stage-1 contract package — must not see the host or router.
|
||||
expect(pkgJson.dependencies["@suaveplan/api-host"]).toBeUndefined();
|
||||
expect(pkgJson.dependencies["@suaveplan/api-router"]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const srcRoot = resolve(here, "..", "src");
|
||||
|
||||
function walk(dir: string): string[] {
|
||||
const out: string[] = [];
|
||||
for (const name of readdirSync(dir)) {
|
||||
const full = join(dir, name);
|
||||
const st = statSync(full);
|
||||
if (st.isDirectory()) out.push(...walk(full));
|
||||
else if (full.endsWith(".ts")) out.push(full);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
describe("zod import discipline", () => {
|
||||
it("every src file uses default-import z (never named { z })", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const offenders: string[] = [];
|
||||
for (const file of walk(srcRoot)) {
|
||||
const text = readFileSync(file, "utf8");
|
||||
// Named-form: import { z } from "zod"
|
||||
if (/import\s*\{\s*z\s*\}\s*from\s*["']zod["']/.test(text)) {
|
||||
offenders.push(file);
|
||||
}
|
||||
}
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user