MCPcopy Create free account
hub / github.com/callstackincubator/polygen / printCodegenStats

Function printCodegenStats

packages/polygen-cli/src/actions/codegen.ts:19–40  ·  view source on GitHub ↗
(generatedModule: W2CGeneratedModule)

Source from the content-addressed store, hash-verified

17}
18
19function printCodegenStats(generatedModule: W2CGeneratedModule) {
20 const hglt = chalk.dim;
21 const { imports, exports } = generatedModule;
22
23 function statsOf(set: GeneratedSymbol[]): string {
24 const highlight = chalk.dim;
25 const grouped = Object.groupBy(
26 set,
27 (s) => s.target.kind as GeneratedEntityKind
28 );
29 const countOf = (type: GeneratedEntityKind) => grouped[type]?.length ?? 0;
30 return [
31 `${highlight(countOf('function'))} functions`,
32 `${highlight(countOf('memory'))} memories`,
33 `${highlight(countOf('global'))} globals`,
34 `${highlight(countOf('table'))} tables`,
35 ].join(', ');
36 }
37
38 consola.info(` Found ${hglt(imports.length)} imports (${statsOf(imports)})`);
39 consola.info(` Found ${hglt(exports.length)} exports (${statsOf(exports)})`);
40}
41
42/**
43 * Generates code for a single module.

Callers 1

generateModuleFunction · 0.85

Calls 1

statsOfFunction · 0.85

Tested by

no test coverage detected