ui
ui copied to clipboard
fix(cli): recognize package.json files in ancestor directories
I have a monorepo with unusual structure
/ <--- repo root
package.json
tsconfig.json
other-stuff/
server/ <--- nextjs project root
components.json
src/pages/
index.tsx
I'd like to be able to run bunx --bun shadcn@latest add alert-dialog from the //server/ directory.
Without this PR, the package.json in the ancestor directory is not recognized. I get (incorrectly) prompted to create a project, and can't use the shadcn add tool properly.
This change lets the shadcn cli recognize when we're inside a valid node package, not just in the root dir.
I've tested that this works correctly for my project.
As far as I can tell, my directory structure ought to be valid. Other tools accept that we're in a valid package as defined by having some ancestor package.json.
Within this tool, the updateDependencies function is able to work in a subdir, as it uses @antfu/ni to find the package manager, which in turn uses the find-up package that I've switched to here.
@jaredp is attempting to deploy a commit to the shadcn-pro Team on Vercel.
A member of the Team first needs to authorize it.
@shadcn how do I request review?
@jaredp Yeah this is a valid project structure. So the next app is inside server? Can you give me a more detailed tree of your project setup so that I can test this please?
@shadcn yep yep, sorry I didn't get a notification about this
.
├── package.json
├── node_modules
├── bun.lockb
├── bunfig.toml
├── server (the nextjs pages-router app)
│ ├── next.config.js
│ ├── components.json
│ ├── postcss.config.cjs
│ ├── tailwind.config.ts
│ ├── drizzle.config.ts
│ ├── next-env.d.ts
│ ├── public
│ ├── src
│ └── vercel.json
├── chrome-extension
│ ├── code for a chrome extension, which imports some things in ../server
│ └── ...
├── tsconfig.json
└── tsconfig.tsbuildinfo
I have package.json/node_modules and tsconfig.json at the root of the monorepo. There are 2 different apps produced:
- a NextJS app for backend, admin website, and some shared code under
server/. This is where the shadcn components live. - a Chrome extension under
chrome-extension/
@shadcn ping
I'm doing monorepo work. I'll take a look at this again.