fix(cli): Update package.json name property when init next-monorepo (#7742)

* fix(cli): Update package.json name property when init next-monorepo

* test(cli): Fix failing test

* fix(cli): Remove unnecessary git changes

* chore: add changeset

---------

Co-authored-by: shadcn <m@shadcn.com>
This commit is contained in:
JunHyeok Ha
2025-10-05 19:18:31 +09:00
committed by GitHub
parent e96f9edf02
commit da8fa6aacd
2 changed files with 15 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"shadcn": minor
---
rename monorepo project on init

View File

@@ -236,6 +236,16 @@ async function createMonorepoProject(
await execa(options.packageManager, ["install"], {
cwd: projectPath,
})
// await execa("cd", [cwd])
// 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.
const cwd = process.cwd()
@@ -245,7 +255,6 @@ async function createMonorepoProject(
await execa("git", ["commit", "-m", "Initial commit"], {
cwd: projectPath,
})
// await execa("cd", [cwd])
createSpinner?.succeed("Creating a new Next.js monorepo.")
} catch (error) {