Home / Function/ getProjectConfig() — ui Function Reference

getProjectConfig() — ui Function Reference

Architecture documentation for the getProjectConfig() function in get-project-info.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  4f6514c5_4180_5c4d_78ff_976a7528790f["getProjectConfig()"]
  6a5c3afa_2e3e_bbfc_2351_1976d5a184fe["get-project-info.ts"]
  4f6514c5_4180_5c4d_78ff_976a7528790f -->|defined in| 6a5c3afa_2e3e_bbfc_2351_1976d5a184fe
  90d4c1a4_553f_c7f8_7665_87d6136bf243["getProjectInfo()"]
  4f6514c5_4180_5c4d_78ff_976a7528790f -->|calls| 90d4c1a4_553f_c7f8_7665_87d6136bf243
  style 4f6514c5_4180_5c4d_78ff_976a7528790f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/get-project-info.ts lines 349–396

export async function getProjectConfig(
  cwd: string,
  defaultProjectInfo: ProjectInfo | null = null
): Promise<Config | null> {
  // Check for existing component config.
  const [existingConfig, projectInfo] = await Promise.all([
    getConfig(cwd),
    !defaultProjectInfo
      ? getProjectInfo(cwd)
      : Promise.resolve(defaultProjectInfo),
  ])

  if (existingConfig) {
    return existingConfig
  }

  if (
    !projectInfo ||
    !projectInfo.tailwindCssFile ||
    (projectInfo.tailwindVersion === "v3" && !projectInfo.tailwindConfigFile)
  ) {
    return null
  }

  const config: z.infer<typeof rawConfigSchema> = {
    $schema: "https://ui.shadcn.com/schema.json",
    rsc: projectInfo.isRSC,
    tsx: projectInfo.isTsx,
    style: "new-york",
    tailwind: {
      config: projectInfo.tailwindConfigFile ?? "",
      baseColor: "zinc",
      css: projectInfo.tailwindCssFile,
      cssVariables: true,
      prefix: "",
    },
    iconLibrary: "lucide",
    aliases: {
      components: `${projectInfo.aliasPrefix}/components`,
      ui: `${projectInfo.aliasPrefix}/components/ui`,
      hooks: `${projectInfo.aliasPrefix}/hooks`,
      lib: `${projectInfo.aliasPrefix}/lib`,
      utils: `${projectInfo.aliasPrefix}/lib/utils`,
    },
  }

  return await resolveConfigPaths(cwd, config)
}

Subdomains

Frequently Asked Questions

What does getProjectConfig() do?
getProjectConfig() is a function in the ui codebase, defined in packages/shadcn/src/utils/get-project-info.ts.
Where is getProjectConfig() defined?
getProjectConfig() is defined in packages/shadcn/src/utils/get-project-info.ts at line 349.
What does getProjectConfig() call?
getProjectConfig() calls 1 function(s): getProjectInfo.

Analyze Your Own Codebase

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

Try Supermodel Free