Repository navigation
Conversation
`sentry wizard reactNative` printed "Could not find main App file" on a
fresh bare React Native app and a fresh Expo app, so it never added
`Sentry.init` or `Sentry.wrap`.
The lookup pattern `{.,./src,./app}/+(@(App|_layout).…)` came from
upstream, where `glob` ran it. `tinyglobby` matches nothing for a `.`
inside braces, so the pattern found no file, even a root `App.tsx`.
The Expo SDK 58 template also puts its layout at `src/app/_layout.tsx`,
which the pattern never covered.
Search `.`, `src`, `app`, then `src/app` with one glob each. A new test
runs the lookup against the real filesystem for the template layouts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the React Native app-file discovery changes.
No open issues 🎉
What changed in this PR
Fixes React Native wizard app-file discovery after the switch to tinyglobby, allowing automatic Sentry setup for standard React Native and Expo layouts.
Changes:
- Searches supported directories individually with explicit precedence, adding
src/appfor newer Expo templates. - Adds real-filesystem tests covering supported layouts, directory precedence, and ignored paths.
| File | Description |
|---|---|
packages/cli/test/lib/wizard/react-native/main-app-file.test.ts |
Adds discovery regression tests using the real glob helper. |
packages/cli/src/lib/wizard/react-native/javascript.ts |
Replaces the combined directory glob with ordered lookups and adds src/app support. |
Review effort: Balanced
This branch was successfully deployed
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.
Summary
Fixes getsentry/sentry-react-native#7149.
sentry wizard reactNativeprints "Could not find main App file" on a fresh bare React Native app and on a fresh Expo app. It then shows theSentry.initandSentry.wrapsnippets to paste by hand, and never adds them.Root cause
getMainAppFilePath()uses upstream's pattern{.,./src,./app}/+(@(App|_layout).@(j|t|cj|mj)s?(x)). Upstream ran it withglob; the port runs it withtinyglobby(Port sentry-wizard into the CLI assentry wizard#2511).tinyglobbyhandles the extglobs, but matches nothing for a.inside braces ({.,src}/App.tsxfinds no file,./App.tsxdoes). So the pattern found nothing, even a rootApp.tsx.src/app/_layout.tsx, outside.,src, andapp.The existing test mocks
getFirstMatchedPath, so the pattern itself was never run.Key Changes
getMainAppFilePath()globs{App,_layout}.{js,jsx,ts,tsx,cjs,mjs}in.,src,app, thensrc/app, one directory at a time; the first match wins. This keeps upstream's priority, addssrc/applast, and makes the order deterministic. It dropscjsx/mjsx, which aren't React Native entry files.test/lib/wizard/react-native/main-app-file.test.tsruns the lookup against the real filesystem andtinyglobby, in a temporary directory per layout: the bare RN 0.88 rootApp.tsx, Expo SDK 58'ssrc/app/_layout.tsx,app/_layout.tsx,src/App.js,App.jsx, andsrc/app/_layout.js. It also checks the order and thatnode_modulesandlib/are ignored. Against the old lookup, 7 of its 8 tests fail.Verification
src,test) andpnpm run lintpass.sentry wizard <org>/<project> reactNative, default answers):@react-native-community/cli init): "Added Sentry.init to App.tsx" and "Added Sentry.wrap to App.tsx". The app typechecks with no errors.create-expo-app): "Added Sentry.init to src/app/_layout.tsx" and "Added Sentry.wrap to src/app/_layout.tsx" (export default Sentry.wrap(function TabLayout() {…})).🤖 Generated with Claude Code