createViteProject() — ui Function Reference
Architecture documentation for the createViteProject() function in create-project.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD bc16475b_7b3b_d826_a651_6590edfd95f4["createViteProject()"] f570a109_148e_1b68_ffd0_6e7f2f8ca03d["create-project.ts"] bc16475b_7b3b_d826_a651_6590edfd95f4 -->|defined in| f570a109_148e_1b68_ffd0_6e7f2f8ca03d ee4c31b0_cc12_35da_90d1_168cb9e6c7f0["createProject()"] ee4c31b0_cc12_35da_90d1_168cb9e6c7f0 -->|calls| bc16475b_7b3b_d826_a651_6590edfd95f4 style bc16475b_7b3b_d826_a651_6590edfd95f4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/utils/create-project.ts lines 294–363
async function createViteProject(
projectPath: string,
options: {
packageManager: string
}
) {
const createSpinner = spinner(
`Creating a new Vite project. This may take a few minutes.`
).start()
try {
// Get the template.
const templatePath = path.join(os.tmpdir(), `shadcn-template-${Date.now()}`)
await fs.ensureDir(templatePath)
const response = await fetch(GITHUB_TEMPLATE_URL)
if (!response.ok) {
throw new Error(`Failed to download template: ${response.statusText}`)
}
// Write the tar file.
const tarPath = path.resolve(templatePath, "template.tar.gz")
await fs.writeFile(tarPath, Buffer.from(await response.arrayBuffer()))
await execa("tar", [
"-xzf",
tarPath,
"-C",
templatePath,
"--strip-components=2",
"ui-main/templates/vite-app",
])
const extractedPath = path.resolve(templatePath, "vite-app")
await fs.move(extractedPath, projectPath)
await fs.remove(templatePath)
// Remove pnpm-lock.yaml if using a different package manager.
if (options.packageManager !== "pnpm") {
const lockFilePath = path.join(projectPath, "pnpm-lock.yaml")
if (fs.existsSync(lockFilePath)) {
await fs.remove(lockFilePath)
}
}
// Run install.
await execa(options.packageManager, ["install"], {
cwd: projectPath,
})
// Write project name to the package.json.
const packageJsonPath = path.join(projectPath, "package.json")
if (fs.existsSync(packageJsonPath)) {
const packageJsonContent = await fs.readFile(packageJsonPath, "utf8")
const packageJson = JSON.parse(packageJsonContent)
packageJson.name = projectPath.split("/").pop()
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2))
}
// Try git init.
await execa("git", ["--version"], { cwd: projectPath })
await execa("git", ["init"], { cwd: projectPath })
await execa("git", ["add", "-A"], { cwd: projectPath })
await execa("git", ["commit", "-m", "Initial commit"], {
cwd: projectPath,
})
createSpinner?.succeed("Creating a new Vite project.")
} catch (error) {
createSpinner?.fail("Something went wrong creating a new Vite project.")
handleError(error)
}
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does createViteProject() do?
createViteProject() is a function in the ui codebase, defined in packages/shadcn/src/utils/create-project.ts.
Where is createViteProject() defined?
createViteProject() is defined in packages/shadcn/src/utils/create-project.ts at line 294.
What calls createViteProject()?
createViteProject() is called by 1 function(s): createProject.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free