get-config.ts — ui Source File
Architecture documentation for get-config.ts, a typescript file in the ui codebase. 10 imports, 6 dependents.
Entity Profile
Dependency Diagram
graph LR 913f04e7_90de_d0b5_5068_4dacd40de96e["get-config.ts"] d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5 2ae56314_aa15_5495_52a2_137787e7b210["constants"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 2ae56314_aa15_5495_52a2_137787e7b210 a3b2545e_3d8c_699d_ef11_6ab18db14666["schema"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> a3b2545e_3d8c_699d_ef11_6ab18db14666 24fd9695_7ceb_b1f6_c84e_e349d5356c12["get-project-info"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 24fd9695_7ceb_b1f6_c84e_e349d5356c12 15e8bad0_00cc_3d96_8e33_2f062120ea7f["highlighter"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 15e8bad0_00cc_3d96_8e33_2f062120ea7f 45db7f11_9c93_4005_b06b_e244ebb11d78["resolve-import"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 45db7f11_9c93_4005_b06b_e244ebb11d78 9f36ba3d_b51d_9338_c630_db74ab728257["cosmiconfig"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 9f36ba3d_b51d_9338_c630_db74ab728257 587e4732_d484_82b5_c4de_af2e9f20d031["fast-glob"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 587e4732_d484_82b5_c4de_af2e9f20d031 67c3fcb7_babc_5ba5_b887_30779f599239["tsconfig-paths"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 67c3fcb7_babc_5ba5_b887_30779f599239 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] 913f04e7_90de_d0b5_5068_4dacd40de96e --> 6802ce19_522d_e5fb_e458_8826d9f6952e 9ef55c05_4ae8_de0d_13ee_4570ec1b1c55["namespaces.test.ts"] 9ef55c05_4ae8_de0d_13ee_4570ec1b1c55 --> 913f04e7_90de_d0b5_5068_4dacd40de96e d51ab9e0_8488_8598_7079_e383487a0885["utils.test.ts"] d51ab9e0_8488_8598_7079_e383487a0885 --> 913f04e7_90de_d0b5_5068_4dacd40de96e 84d5040c_6b1a_ee5d_e967_8ff170c2d22b["transform-cleanup.test.ts"] 84d5040c_6b1a_ee5d_e967_8ff170c2d22b --> 913f04e7_90de_d0b5_5068_4dacd40de96e a6d62398_32bc_ec75_8e5a_d1b6e51a2e3d["get-config.test.ts"] a6d62398_32bc_ec75_8e5a_d1b6e51a2e3d --> 913f04e7_90de_d0b5_5068_4dacd40de96e style 913f04e7_90de_d0b5_5068_4dacd40de96e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import path from "path"
import { BUILTIN_REGISTRIES } from "@/src/registry/constants"
import {
configSchema,
rawConfigSchema,
workspaceConfigSchema,
} from "@/src/schema"
import { getProjectInfo } from "@/src/utils/get-project-info"
import { highlighter } from "@/src/utils/highlighter"
import { resolveImport } from "@/src/utils/resolve-import"
import { cosmiconfig } from "cosmiconfig"
import fg from "fast-glob"
import { loadConfig } from "tsconfig-paths"
import { z } from "zod"
export const DEFAULT_STYLE = "default"
export const DEFAULT_COMPONENTS = "@/components"
export const DEFAULT_UTILS = "@/lib/utils"
export const DEFAULT_TAILWIND_CSS = "app/globals.css"
export const DEFAULT_TAILWIND_CONFIG = "tailwind.config.js"
export const DEFAULT_TAILWIND_BASE_COLOR = "slate"
// TODO: Figure out if we want to support all cosmiconfig formats.
// A simple components.json file would be nice.
export const explorer = cosmiconfig("components", {
searchPlaces: ["components.json"],
})
export type Config = z.infer<typeof configSchema>
export async function getConfig(cwd: string) {
const config = await getRawConfig(cwd)
if (!config) {
return null
}
// Set default icon library if not provided.
if (!config.iconLibrary) {
config.iconLibrary = config.style === "new-york" ? "radix" : "lucide"
}
return await resolveConfigPaths(cwd, config)
}
export async function resolveConfigPaths(
cwd: string,
config: z.infer<typeof rawConfigSchema>
) {
// Merge built-in registries with user registries
config.registries = {
...BUILTIN_REGISTRIES,
...(config.registries || {}),
}
// Read tsconfig.json.
const tsConfig = await loadConfig(cwd)
if (tsConfig.resultType === "failed") {
throw new Error(
// ... (226 more lines)
Domain
Subdomains
Functions
Types
Dependencies
- constants
- cosmiconfig
- fast-glob
- get-project-info
- highlighter
- path
- resolve-import
- schema
- tsconfig-paths
- zod
Imported By
- packages/shadcn/test/utils/get-config.test.ts
- packages/shadcn/test/utils/get-item-target-path.test.ts
- packages/shadcn/src/registry/namespaces.test.ts
- packages/shadcn/src/utils/transformers/transform-cleanup.test.ts
- packages/shadcn/test/utils/updaters/update-files.test.ts
- packages/shadcn/src/registry/utils.test.ts
Source
Frequently Asked Questions
What does get-config.ts do?
get-config.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, TemplateSync subdomain.
What functions are defined in get-config.ts?
get-config.ts defines 9 function(s): createConfig, findCommonRoot, findPackageRoot, getConfig, getRawConfig, getTargetStyleFromConfig, getWorkspaceConfig, isAliasKey, resolveConfigPaths.
What does get-config.ts depend on?
get-config.ts imports 10 module(s): constants, cosmiconfig, fast-glob, get-project-info, highlighter, path, resolve-import, schema, and 2 more.
What files import get-config.ts?
get-config.ts is imported by 6 file(s): get-config.test.ts, get-item-target-path.test.ts, namespaces.test.ts, transform-cleanup.test.ts, update-files.test.ts, utils.test.ts.
Where is get-config.ts in the architecture?
get-config.ts is located at packages/shadcn/src/utils/get-config.ts (domain: FrameworkTooling, subdomain: TemplateSync, directory: packages/shadcn/src/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free