Home / Function/ getFrameworkVersion() — ui Function Reference

getFrameworkVersion() — ui Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

packages/shadcn/src/utils/get-project-info.ts lines 174–208

export async function getFrameworkVersion(
  framework: Framework,
  packageJson: ReturnType<typeof getPackageInfo>
) {
  if (!packageJson) {
    return null
  }

  // Only detect Next.js version for now.
  if (!["next-app", "next-pages"].includes(framework.name)) {
    return null
  }

  const version =
    packageJson.dependencies?.next || packageJson.devDependencies?.next

  if (!version) {
    return null
  }

  // Extract full semver (major.minor.patch), handling ^, ~, etc.
  const versionMatch = version.match(/^[\^~]?(\d+\.\d+\.\d+)/)
  if (versionMatch) {
    return versionMatch[1] // e.g., "16.0.0"
  }

  // For ranges like ">=15.0.0 <16.0.0", extract the first version.
  const rangeMatch = version.match(/(\d+\.\d+\.\d+)/)
  if (rangeMatch) {
    return rangeMatch[1]
  }

  // For "latest", "canary", "rc", etc., return the tag as-is.
  return version
}

Subdomains

Called By

Frequently Asked Questions

What does getFrameworkVersion() do?
getFrameworkVersion() is a function in the ui codebase, defined in packages/shadcn/src/utils/get-project-info.ts.
Where is getFrameworkVersion() defined?
getFrameworkVersion() is defined in packages/shadcn/src/utils/get-project-info.ts at line 174.
What calls getFrameworkVersion()?
getFrameworkVersion() 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