MCPcopy Create free account
hub / github.com/MigoXLab/coderio / generateCode

Function generateCode

src/nodes/code/index.ts:10–33  ·  view source on GitHub ↗
(state: GraphState)

Source from the content-addressed store, hash-verified

8 * Generates React components from the page structure tree
9 */
10export async function generateCode(state: GraphState) {
11 try {
12 logger.printInfoLog('🚀 Starting Code Generation...');
13
14 // Validate required state fields
15 if (!state.protocol) {
16 throw new Error('No protocol data found');
17 }
18
19 // Load code cache
20 const cache = loadCodeCache(state.workspace);
21
22 // Process the entire node tree (cache is saved incrementally after each component)
23 const totalComponents = await processNode(state, cache);
24
25 // Inject root component to App.tsx (cache is saved after injection)
26 await injectRootComponentToApp(state, cache);
27
28 logger.printSuccessLog(`✨ Code generation completed! Generated ${totalComponents} components`);
29 } catch (error) {
30 const errorMessage = error instanceof Error ? error.message : String(error);
31 throw new Error(`Code generation failed: ${errorMessage}`);
32 }
33}

Callers 1

registerP2CCommandFunction · 0.90

Calls 3

loadCodeCacheFunction · 0.90
processNodeFunction · 0.90
injectRootComponentToAppFunction · 0.90

Tested by

no test coverage detected