updateFiles() — ui Function Reference
Architecture documentation for the updateFiles() function in update-files.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD bc52ca78_0228_54e7_56b2_602b341e2ec4["updateFiles()"] 3efb2c23_7931_d244_b4e1_85acab69298c["update-files.ts"] bc52ca78_0228_54e7_56b2_602b341e2ec4 -->|defined in| 3efb2c23_7931_d244_b4e1_85acab69298c ff8d1a68_3ace_911d_7cb3_0e0a0d30e24f["resolveFilePath()"] bc52ca78_0228_54e7_56b2_602b341e2ec4 -->|calls| ff8d1a68_3ace_911d_7cb3_0e0a0d30e24f 4b6decbf_93a4_8403_9ccd_daf4d79c041f["findCommonRoot()"] bc52ca78_0228_54e7_56b2_602b341e2ec4 -->|calls| 4b6decbf_93a4_8403_9ccd_daf4d79c041f 4455fa61_3128_9c0a_fcab_27989c578bf7["_isNext16Middleware()"] bc52ca78_0228_54e7_56b2_602b341e2ec4 -->|calls| 4455fa61_3128_9c0a_fcab_27989c578bf7 7dc382f5_944d_c67e_f395_05edc855da6a["resolveImports()"] bc52ca78_0228_54e7_56b2_602b341e2ec4 -->|calls| 7dc382f5_944d_c67e_f395_05edc855da6a style bc52ca78_0228_54e7_56b2_602b341e2ec4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/utils/updaters/update-files.ts lines 36–334
export async function updateFiles(
files: RegistryItem["files"],
config: Config,
options: {
overwrite?: boolean
force?: boolean
silent?: boolean
rootSpinner?: ReturnType<typeof spinner>
isRemote?: boolean
isWorkspace?: boolean
path?: string
}
) {
if (!files?.length) {
return {
filesCreated: [],
filesUpdated: [],
filesSkipped: [],
}
}
options = {
overwrite: false,
force: false,
silent: false,
isRemote: false,
isWorkspace: false,
...options,
}
const filesCreatedSpinner = spinner(`Updating files.`, {
silent: options.silent,
})?.start()
const [projectInfo, baseColor] = await Promise.all([
getProjectInfo(config.resolvedPaths.cwd),
config.tailwind.baseColor
? getRegistryBaseColor(config.tailwind.baseColor)
: Promise.resolve(undefined),
])
let filesCreated: string[] = []
let filesUpdated: string[] = []
let filesSkipped: string[] = []
let envVarsAdded: string[] = []
let envFile: string | null = null
for (let index = 0; index < files.length; index++) {
const file = files[index]
if (!file.content) {
continue
}
let filePath = resolveFilePath(file, config, {
isSrcDir: projectInfo?.isSrcDir,
framework: projectInfo?.framework.name,
commonRoot: findCommonRoot(
files.map((f) => f.path),
file.path
),
path: options.path,
fileIndex: index,
})
if (!filePath) {
continue
}
const fileName = basename(file.path)
const targetDir = path.dirname(filePath)
if (!config.tsx) {
filePath = filePath.replace(/\.tsx?$/, (match) =>
match === ".tsx" ? ".jsx" : ".js"
)
}
if (isEnvFile(filePath) && !existsSync(filePath)) {
const alternativeEnvFile = findExistingEnvFile(targetDir)
if (alternativeEnvFile) {
filePath = alternativeEnvFile
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does updateFiles() do?
updateFiles() is a function in the ui codebase, defined in packages/shadcn/src/utils/updaters/update-files.ts.
Where is updateFiles() defined?
updateFiles() is defined in packages/shadcn/src/utils/updaters/update-files.ts at line 36.
What does updateFiles() call?
updateFiles() calls 4 function(s): _isNext16Middleware, findCommonRoot, resolveFilePath, resolveImports.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free