Home / Function/ preFlightBuild() — ui Function Reference

preFlightBuild() — ui Function Reference

Architecture documentation for the preFlightBuild() function in preflight-build.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  0d19b7fc_3a19_2220_a30c_f74d31064267["preFlightBuild()"]
  4dac1431_8d6a_f958_0884_e5d642f3cb8b["preflight-build.ts"]
  0d19b7fc_3a19_2220_a30c_f74d31064267 -->|defined in| 4dac1431_8d6a_f958_0884_e5d642f3cb8b
  style 0d19b7fc_3a19_2220_a30c_f74d31064267 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/preflights/preflight-build.ts lines 9–46

export async function preFlightBuild(
  options: z.infer<typeof buildOptionsSchema>
) {
  const errors: Record<string, boolean> = {}

  const resolvePaths = {
    cwd: options.cwd,
    registryFile: path.resolve(options.cwd, options.registryFile),
    outputDir: path.resolve(options.cwd, options.outputDir),
  }

  // Ensure registry file exists.
  if (!fs.existsSync(resolvePaths.registryFile)) {
    errors[ERRORS.BUILD_MISSING_REGISTRY_FILE] = true
  }

  // Create output directory if it doesn't exist.
  await fs.mkdir(resolvePaths.outputDir, { recursive: true })

  if (Object.keys(errors).length > 0) {
    if (errors[ERRORS.BUILD_MISSING_REGISTRY_FILE]) {
      logger.break()
      logger.error(
        `The path ${highlighter.info(
          resolvePaths.registryFile
        )} does not exist.`
      )
    }

    logger.break()
    process.exit(1)
  }

  return {
    errors,
    resolvePaths,
  }
}

Subdomains

Frequently Asked Questions

What does preFlightBuild() do?
preFlightBuild() is a function in the ui codebase, defined in packages/shadcn/src/preflights/preflight-build.ts.
Where is preFlightBuild() defined?
preFlightBuild() is defined in packages/shadcn/src/preflights/preflight-build.ts at line 9.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free