Add AST extraction tests, broader ignore patterns, build dist
- ast-extract.ts: Support tree-sitter-python and tree-sitter-go grammar loading (pkg.language fallback) - discover.ts: Add cache directories to default ignore (.cache, tmp, temp, .turbo, .parcel-cache, .eslintcache, .prettiercache) - tests: Add TypeScript AST extraction tests (exports + imports) - Verified on real project: media_library_viewer (196 .pi-map.md files) with accurate React component extraction - Build: npm run build produces clean dist/ output All 16 tests pass.
This commit is contained in:
+17
-15
@@ -1,5 +1,11 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { mkdtempSync, writeFileSync, mkdirSync, rmSync, readFileSync } from "fs";
|
||||
import {
|
||||
mkdtempSync,
|
||||
writeFileSync,
|
||||
mkdirSync,
|
||||
rmSync,
|
||||
readFileSync,
|
||||
} from "fs";
|
||||
import { join } from "path";
|
||||
import { tmpdir } from "os";
|
||||
import { initProject } from "../src/init.js";
|
||||
@@ -19,10 +25,7 @@ describe("integration", () => {
|
||||
|
||||
it("init creates .pi-map.md files", async () => {
|
||||
mkdirSync(join(dir, "src"));
|
||||
writeFileSync(
|
||||
join(dir, "src", "index.ts"),
|
||||
`export function foo() {}\n`,
|
||||
);
|
||||
writeFileSync(join(dir, "src", "index.ts"), `export function foo() {}\n`);
|
||||
await initProject(dir);
|
||||
|
||||
const map = readFileSync(join(dir, "src", ".pi-map.md"), "utf8");
|
||||
@@ -32,14 +35,8 @@ describe("integration", () => {
|
||||
|
||||
it("patch updates a file entry", async () => {
|
||||
mkdirSync(join(dir, "src"));
|
||||
writeFileSync(
|
||||
join(dir, "src", "index.ts"),
|
||||
`export function foo() {}\n`,
|
||||
);
|
||||
writeFileSync(
|
||||
join(dir, "src", "utils.ts"),
|
||||
`export const bar = 1;\n`,
|
||||
);
|
||||
writeFileSync(join(dir, "src", "index.ts"), `export function foo() {}\n`);
|
||||
writeFileSync(join(dir, "src", "utils.ts"), `export const bar = 1;\n`);
|
||||
await initProject(dir);
|
||||
|
||||
// Modify a file
|
||||
@@ -110,10 +107,15 @@ describe("integration", () => {
|
||||
await initProject(dir);
|
||||
|
||||
// Change exports
|
||||
writeFileSync(join(dir, "src", "a.ts"), `export const a = 1;\nexport const c = 3;\n`);
|
||||
writeFileSync(
|
||||
join(dir, "src", "a.ts"),
|
||||
`export const a = 1;\nexport const c = 3;\n`,
|
||||
);
|
||||
|
||||
const result = await validateMaps(dir);
|
||||
expect(result.clean).toBe(false);
|
||||
expect(result.discrepancies.some((d) => d.type === "stale-signature")).toBe(true);
|
||||
expect(result.discrepancies.some((d) => d.type === "stale-signature")).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user