MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / writeProject

Function writeProject

__tests__/resolver-pool-pipeline.test.ts:32–54  ·  view source on GitHub ↗

Enough calls for several batches of the pool's size, each file calling into its neighbours and its base class.

(root: string)

Source from the content-addressed store, hash-verified

30
31/** Enough calls for several batches of the pool's size, each file calling into its neighbours and its base class. */
32function writeProject(root: string): void {
33 fs.mkdirSync(path.join(root, 'src'));
34 const files = 12;
35 const methods = 60;
36 for (let f = 0; f < files; f++) {
37 const base = f === 0 ? '' : ` extends Service${f - 1}`;
38 const body: string[] = [];
39 for (let m = 0; m < methods; m++) {
40 const calls = Array.from({ length: 12 }, (_, c) => ` this.method${f}_${(m + c) % methods}();\n this.inherited${Math.max(0, f - 1)}();\n helper${(f + c) % files}();`);
41 body.push(` method${f}_${m}(): void {\n${calls.join('\n')}\n }`);
42 }
43 fs.writeFileSync(path.join(root, 'src', `service${f}.ts`), [
44 ...(f === 0 ? [] : [`import { Service${f - 1} } from './service${f - 1}';`]),
45 ...Array.from({ length: files }, (_, i) => i).filter((i) => i !== f).map((i) => `import { helper${i} } from './service${i}';`),
46 `export function helper${f}(): void {}`,
47 `export class Service${f}${base} {`,
48 ` inherited${f}(): void {}`,
49 ...body,
50 '}',
51 '',
52 ].join('\n'));
53 }
54}
55
56function indexedGraph(root: string, env: NodeJS.ProcessEnv): { graph: string; log: string } {
57 const result = spawnSync(process.execPath, [cli, 'init', '-y', root], {

Callers 1

Calls 4

fromMethod · 0.80
pushMethod · 0.80
mapMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected