Home / Function/ getTsConfigAliasPrefix() — ui Function Reference

getTsConfigAliasPrefix() — ui Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

packages/shadcn/src/utils/get-project-info.ts lines 287–311

export async function getTsConfigAliasPrefix(cwd: string) {
  const tsConfig = await loadConfig(cwd)

  if (
    tsConfig?.resultType === "failed" ||
    !Object.entries(tsConfig?.paths).length
  ) {
    return null
  }

  // This assume that the first alias is the prefix.
  for (const [alias, paths] of Object.entries(tsConfig.paths)) {
    if (
      paths.includes("./*") ||
      paths.includes("./src/*") ||
      paths.includes("./app/*") ||
      paths.includes("./resources/js/*") // Laravel.
    ) {
      return alias.replace(/\/\*$/, "") ?? null
    }
  }

  // Use the first alias as the prefix.
  return Object.keys(tsConfig?.paths)?.[0].replace(/\/\*$/, "") ?? null
}

Subdomains

Called By

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free