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

Function spec

packages/node/src/spec.ts:9–31  ·  view source on GitHub ↗
(ctx: PandaContext, options: SpecOptions)

Source from the content-addressed store, hash-verified

7}
8
9export async function spec(ctx: PandaContext, options: SpecOptions) {
10 const { outdir } = options
11
12 const specs = ctx.getSpec()
13
14 // Use ctx.paths.specs (includes configured outdir) or override with provided outdir
15 const specDir = outdir ? [ctx.config.cwd, outdir] : ctx.paths.specs
16 const specDirPath = ctx.runtime.path.join(...specDir)
17
18 const writeSpec = async (spec: SpecFile) => {
19 await ctx.output.write({
20 id: `spec-${spec.type}` as ArtifactId,
21 dir: specDir,
22 files: [{ file: `${spec.type}.json`, code: JSON.stringify(spec, null, 2) }],
23 })
24 }
25
26 await Promise.all(specs.map(writeSpec))
27
28 const specTypes = specs.map((s) => s.type)
29 logger.info('spec', `Generated ${specTypes.length} spec file(s) → ${specDirPath}`)
30 return specs
31}

Callers 1

mainFunction · 0.90

Calls 1

joinMethod · 0.65

Tested by

no test coverage detected