MCPcopy Create free account
hub / github.com/chakra-ui/panda / codegen

Function codegen

packages/node/src/codegen.ts:4–25  ·  view source on GitHub ↗
(ctx: PandaContext, ids?: ArtifactId[])

Source from the content-addressed store, hash-verified

2import type { PandaContext } from './create-context'
3
4export async function codegen(ctx: PandaContext, ids?: ArtifactId[]) {
5 const { default: pLimit } = await import('p-limit')
6 const limit = pLimit(20)
7 if (ctx.config.clean) ctx.output.empty()
8
9 let artifacts = ctx.getArtifacts(ids)
10 if (ctx.hooks['codegen:prepare']) {
11 const results = await ctx.hooks['codegen:prepare']?.({ changed: ids, artifacts })
12 if (results) artifacts = results
13 }
14
15 // limit concurrency since we might output a lot of files
16 const promises = artifacts.map((artifact) => limit(() => ctx.output.write(artifact)))
17 await Promise.allSettled(promises)
18
19 await ctx.hooks['codegen:done']?.({ changed: ids })
20
21 return {
22 box: ctx.initMessage(),
23 msg: ctx.messages.artifactsGenerated(),
24 }
25}

Callers 3

mainFunction · 0.90
emitMethod · 0.90
buildFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected