chore(vendor): import pi 0.85.1
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
1 parent
5ebc7018c3
commit
4def357d09
1669 files changed
+397627
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { readdir, readFile } from "node:fs/promises";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
const packageDirectory = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const sourceDirectory = resolve(packageDirectory, "src");
|
||||
const IMPORT_SPECIFIER = /(?:import|export)\s+(?:type\s+)?(?:[^;]*?\sfrom\s*)?["']([^"']+)["']/gu;
|
||||
|
||||
describe("package boundary", () => {
|
||||
test("does not depend on Pi packages or files outside Chord", async () => {
|
||||
const manifest = JSON.parse(await readFile(resolve(packageDirectory, "package.json"), "utf8")) as {
|
||||
dependencies?: Record<string, string>;
|
||||
};
|
||||
expect(Object.keys(manifest.dependencies ?? {}).filter((name) => name.startsWith("@earendil-works/pi-"))).toEqual(
|
||||
[],
|
||||
);
|
||||
|
||||
const paths = (await readdir(sourceDirectory, { recursive: true })).filter((path) => path.endsWith(".ts")).sort();
|
||||
const violations: string[] = [];
|
||||
for (const path of paths) {
|
||||
const file = resolve(sourceDirectory, path);
|
||||
const source = await readFile(file, "utf8");
|
||||
for (const match of source.matchAll(IMPORT_SPECIFIER)) {
|
||||
const specifier = match[1]!;
|
||||
if (specifier.startsWith("@earendil-works/pi-")) violations.push(`${path}: ${specifier}`);
|
||||
if (specifier.startsWith(".") && !resolve(dirname(file), specifier).startsWith(`${sourceDirectory}/`)) {
|
||||
violations.push(`${path}: ${specifier}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(violations).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user