feat: wip for init

This commit is contained in:
shadcn
2026-02-12 11:37:35 +04:00
parent 4dbc5581a5
commit a12dd019d3
21 changed files with 1860 additions and 1668 deletions

View File

@@ -9,6 +9,7 @@ import { TEMP_DIR } from "./setup"
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const FIXTURES_DIR = path.join(__dirname, "../../fixtures")
const SHADCN_CLI_PATH = path.join(__dirname, "../../../shadcn/dist/index.js")
const TEMPLATES_DIR = path.join(__dirname, "../../../../templates")
export function getRegistryUrl() {
return process.env.REGISTRY_URL || "http://localhost:4000/r"
@@ -32,6 +33,7 @@ export async function runCommand(
options?: {
env?: Record<string, string>
input?: string
timeout?: number
}
) {
try {
@@ -45,7 +47,7 @@ export async function runCommand(
},
input: options?.input,
reject: false,
timeout: 30000,
timeout: options?.timeout ?? 30000,
})
const result = await childProcess
@@ -69,14 +71,18 @@ export async function npxShadcn(
args: string[],
{
debug = false,
timeout,
}: {
debug?: boolean
timeout?: number
} = {}
) {
const result = await runCommand(cwd, args, {
env: {
REGISTRY_URL: getRegistryUrl(),
SHADCN_TEMPLATE_DIR: TEMPLATES_DIR,
},
timeout,
})
if (debug) {