fix(shadcn): skip app index update when app/page.tsx is missing - #11588
Open
HariomPtdr wants to merge 1 commit into
Open
fix(shadcn): skip app index update when app/page.tsx is missing#11588HariomPtdr wants to merge 1 commit into
HariomPtdr wants to merge 1 commit into
Conversation
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
force-pushed
the
fix/app-index-missing-page
branch
from
August 21, 2026 19:45
01be00c to
2666fc6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
updateAppIndexguards on the index file existing:fs.statrejects withENOENTon a missing path rather than resolving, so this early return is unreachable — a missingapp/page.tsxthrows instead of being skipped. The error propagates to thecatchinadd.tsand surfaces throughhandleErroras a rawENOENT, 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.tsandmigrate-icons.tsall doawait fs.stat(fullPath).catch(() => null). This is the onlyfs.statcall site inpackages/shadcnthat doesn't, so this change just brings it in line.I wasn't able to reach the throw from the CLI today:
updateAppIndexonly runs aftercreateProjectscaffolds a fresh Next.js app from a v0 chat URL, and that template always writesapp/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.tshad no test file, so this also adds one covering the missing-file and directory cases alongside the happy path.Testing
should not throw when app/page.tsx does not existtest fails withENOENTonmainand passes with the fix.packages/shadcnsuite: 1778 passed. Two pre-existing failures are unrelated to this change and environmental in my checkout (github-cli.test.tsasserts a stack trace doesn't contain"private", and my clone lives under/private/tmp;resolver.test.tsfails to collect because I installed with--filter/--ignore-scripts).