Skip to content

fix(shadcn): skip app index update when app/page.tsx is missing - #11588

Open
HariomPtdr wants to merge 1 commit into
shadcn-ui:mainfrom
HariomPtdr:fix/app-index-missing-page
Open

fix(shadcn): skip app index update when app/page.tsx is missing#11588
HariomPtdr wants to merge 1 commit into
shadcn-ui:mainfrom
HariomPtdr:fix/app-index-missing-page

Conversation

@HariomPtdr

Copy link
Copy Markdown

updateAppIndex guards on the index file existing:

if (!(await fs.stat(indexPath)).isFile()) {
  return
}

fs.stat rejects with ENOENT on a missing path rather than resolving, so this early return is unreachable — a missing app/page.tsx throws instead of being skipped. The error propagates to the catch in add.ts and surfaces through handleError as a raw ENOENT, after the component has already been written.

The rest of the codebase already uses the tolerant idiom for exactly this case — migrate-radix.ts, migrate-rtl.ts and migrate-icons.ts all do await fs.stat(fullPath).catch(() => null). This is the only fs.stat call site in packages/shadcn that doesn't, so this change just brings it in line.

I wasn't able to reach the throw from the CLI today: updateAppIndex only runs after createProject scaffolds a fresh Next.js app from a v0 chat URL, and that template always writes app/page.tsx. So this is a latent bug rather than one users are currently hitting — happy to close it if you'd rather leave the guard as is.

update-app-index.ts had no test file, so this also adds one covering the missing-file and directory cases alongside the happy path.

Testing

  • The new should not throw when app/page.tsx does not exist test fails with ENOENT on main and passes with the fix.
  • Full packages/shadcn suite: 1778 passed. Two pre-existing failures are unrelated to this change and environmental in my checkout (github-cli.test.ts asserts a stack trace doesn't contain "private", and my clone lives under /private/tmp; resolver.test.ts fails to collect because I installed with --filter/--ignore-scripts).

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@HariomPtdr is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

`fs.stat` throws ENOENT on a missing path, so the `isFile()` guard in
`updateAppIndex` could never return early as intended -- a missing
`app/page.tsx` crashed `add` instead of being skipped.

Use the `.catch(() => null)` idiom already used by the migration
helpers, and add the missing test coverage for this module.
@HariomPtdr
HariomPtdr force-pushed the fix/app-index-missing-page branch from 01be00c to 2666fc6 Compare August 21, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant