( result: ScanResult, outputDir: string )
| 3 | import type { ScanResult, KnowledgeMap, KnowledgeNoteType } from "./types.js"; |
| 4 | |
| 5 | export async function writeOutput( |
| 6 | result: ScanResult, |
| 7 | outputDir: string |
| 8 | ): Promise<string> { |
| 9 | await mkdir(outputDir, { recursive: true }); |
| 10 | |
| 11 | // Compute CRUD groups before formatting |
| 12 | if (result.crudGroups === undefined) { |
| 13 | result.crudGroups = computeCrudGroups(result.routes); |
| 14 | } |
| 15 | |
| 16 | const sections: { name: string; content: string }[] = []; |
| 17 | |
| 18 | if (result.routes.length > 0) { |
| 19 | const content = formatRoutes(result); |
| 20 | sections.push({ name: "routes", content }); |
| 21 | await writeFile(join(outputDir, "routes.md"), content); |
| 22 | } |
| 23 | |
| 24 | if (result.schemas.length > 0) { |
| 25 | const content = formatSchema(result); |
| 26 | sections.push({ name: "schema", content }); |
| 27 | await writeFile(join(outputDir, "schema.md"), content); |
| 28 | } |
| 29 | |
| 30 | if (result.components.length > 0) { |
| 31 | const content = formatComponents(result); |
| 32 | sections.push({ name: "components", content }); |
| 33 | await writeFile(join(outputDir, "components.md"), content); |
| 34 | } |
| 35 | |
| 36 | if (result.libs.length > 0) { |
| 37 | const content = formatLibs(result); |
| 38 | sections.push({ name: "libs", content }); |
| 39 | await writeFile(join(outputDir, "libs.md"), content); |
| 40 | } |
| 41 | |
| 42 | const configContent = formatConfig(result); |
| 43 | if (configContent) { |
| 44 | sections.push({ name: "config", content: configContent }); |
| 45 | await writeFile(join(outputDir, "config.md"), configContent); |
| 46 | } |
| 47 | |
| 48 | if (result.middleware.length > 0) { |
| 49 | const content = formatMiddleware(result); |
| 50 | sections.push({ name: "middleware", content }); |
| 51 | await writeFile(join(outputDir, "middleware.md"), content); |
| 52 | } |
| 53 | |
| 54 | if (result.graph.hotFiles.length > 0) { |
| 55 | const content = formatGraph(result); |
| 56 | sections.push({ name: "graph", content }); |
| 57 | await writeFile(join(outputDir, "graph.md"), content); |
| 58 | } |
| 59 | |
| 60 | if (result.events && result.events.length > 0) { |
| 61 | const content = formatEvents(result); |
| 62 | sections.push({ name: "events", content }); |
no test coverage detected