From faa7a67fb30c741c2f2559fc64b34f103aac9d79 Mon Sep 17 00:00:00 2001 From: shadcn Date: Tue, 3 Sep 2024 22:16:59 +0400 Subject: [PATCH] fix(shadcn): init with src (#4731) * fix(shadcn): init with src * chore: add changesets --- .changeset/odd-swans-burn.md | 5 +++++ packages/shadcn/src/utils/updaters/update-files.ts | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/odd-swans-burn.md diff --git a/.changeset/odd-swans-burn.md b/.changeset/odd-swans-burn.md new file mode 100644 index 00000000000..61f93abc9c5 --- /dev/null +++ b/.changeset/odd-swans-burn.md @@ -0,0 +1,5 @@ +--- +"shadcn": patch +--- + +fix routes for src dir diff --git a/packages/shadcn/src/utils/updaters/update-files.ts b/packages/shadcn/src/utils/updaters/update-files.ts index 68eea365c4b..757d15d12dd 100644 --- a/packages/shadcn/src/utils/updaters/update-files.ts +++ b/packages/shadcn/src/utils/updaters/update-files.ts @@ -1,6 +1,7 @@ import { existsSync, promises as fs } from "fs" import path, { basename } from "path" import { Config } from "@/src/utils/get-config" +import { getProjectInfo } from "@/src/utils/get-project-info" import { highlighter } from "@/src/utils/highlighter" import { logger } from "@/src/utils/logger" import { @@ -37,7 +38,12 @@ export async function updateFiles( const filesCreatedSpinner = spinner(`Updating files.`, { silent: options.silent, })?.start() - const baseColor = await getRegistryBaseColor(config.tailwind.baseColor) + + const [projectInfo, baseColor] = await Promise.all([ + getProjectInfo(config.resolvedPaths.cwd), + getRegistryBaseColor(config.tailwind.baseColor), + ]) + const filesCreated = [] const filesUpdated = [] const filesSkipped = [] @@ -52,7 +58,9 @@ export async function updateFiles( let filePath = path.join(targetDir, fileName) if (file.target) { - filePath = path.join(config.resolvedPaths.cwd, file.target) + filePath = projectInfo?.isSrcDir + ? path.join(config.resolvedPaths.cwd, "src", file.target) + : path.join(config.resolvedPaths.cwd, file.target) targetDir = path.dirname(filePath) }