MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / createTempMapProject

Function createTempMapProject

tests/codebase-map.test.ts:47–78  ·  view source on GitHub ↗
(options: TempProjectOptions = {})

Source from the content-addressed store, hash-verified

45};
46
47async function createTempMapProject(options: TempProjectOptions = {}): Promise<string> {
48 const tempParent = await fs.mkdtemp(path.join(os.tmpdir(), 'codebase-map-project-'));
49 const projectName = options.projectName ?? 'temp-map-project';
50 const rootPath = path.join(tempParent, projectName);
51 const ctxDir = path.join(rootPath, CODEBASE_CONTEXT_DIRNAME);
52
53 await fs.mkdir(ctxDir, { recursive: true });
54 await fs.writeFile(
55 path.join(ctxDir, INTELLIGENCE_FILENAME),
56 JSON.stringify(
57 {
58 patterns: options.patterns ?? {},
59 goldenFiles: options.goldenFiles ?? []
60 },
61 null,
62 2
63 ),
64 'utf-8'
65 );
66 await fs.writeFile(
67 path.join(ctxDir, KEYWORD_INDEX_FILENAME),
68 JSON.stringify({ chunks: options.chunks ?? [] }, null, 2),
69 'utf-8'
70 );
71 await fs.writeFile(
72 path.join(ctxDir, RELATIONSHIPS_FILENAME),
73 JSON.stringify({ graph: options.graph ?? {} }, null, 2),
74 'utf-8'
75 );
76
77 return rootPath;
78}
79
80async function removeTempMapProject(rootPath: string): Promise<void> {
81 await fs.rm(path.dirname(rootPath), { recursive: true, force: true });

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected