Repository navigation
fix(cli): Let the React Native wizard finish without a terminal - #2839
Conversation
`sentry wizard reactNative` with every feature flag and stdin at `/dev/null` still stopped with exit code 1: bare React Native projects at "Do you want to run pod install now?" and Expo projects at "Have you successfully sent a test event?". - `--pod-install`/`--no-pod-install` answer the pod install question, which keeps Yes as its default. - The closing test event question is only a confirmation, so it is skipped when stdin is not a terminal. The run then ends with an outro that tells the user to send a test event and check it in Sentry, and sets `user-confirmed-first-error` to `skipped`. - An Expo `metro.config.js` that already has Sentry is its own outcome: logged once, without "Could not patch" or the copy-paste instructions (which also asked a question). - `.env.local` (Expo) and `sentry.properties` (Flutter) are appended to `.gitignore` only when no line lists them yet. The check is shared with `addCliConfigFileToGitIgnore` as `gitignoreHasEntry`. Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Tested Blockers: two questions that this PR doesn't cover still stop a run without a terminal, so check 1 and check 4 exit 1. Both come from shared code that existed before this PR. Everything this PR changes works as described.
Safe to merge? Yes. The new flag, the skipped closing question, the Expo Metro message and the New (not from this PR):
|
There was a problem hiding this comment.
Approving. Everything this PR changes works in the real-project test above:
--pod-install/--no-pod-installanswer thepod installquestion.- The closing question is skipped without a terminal.
- Expo second run: Metro says "already has Sentry configuration" instead of "Could not patch".
.gitignore: entries are checked before appending, including a line with trailing spaces.
Nothing regressed with a terminal, on SwiftPM projects, in Flutter, or in Next.js, which covers the shared .gitignore check. Expo without a terminal now exits 0.
Follow-up, in a separate PR, tracked in #2840: two more questions still stop a run without a terminal.
- Formatters: "Looks like you have Prettier in your project. Do you want to run it on your files?" (
runFormattersinutils/clack/index.ts). It hits every bare React Native app from the template, since the template includes Prettier. With Prettier removed, the bare React Native run exits 0. - Updating: "The @sentry/react-native package is already installed. Do you want to update it to the latest version?" (
installPackage). It hits every second run, in bare React Native and Expo.
Why they're not covered here: both are shared by every JavaScript-based wizard (Next.js, SvelteKit, Nuxt, Angular, Remix, React Router, Cloudflare, sourcemaps), not just React Native. Changing them affects all of those, so it deserves its own PR and review. It also needs a decision this PR shouldn't make:
- Option A: answer flags, such as
--format/--no-formatand--update/--no-update. That's consistent with #2789 and with #2652's rule that an unanswered question stops a run without a terminal. - Option B: safe defaults without a terminal: don't run the formatter, and keep the installed version.
I'd go with flags. The same follow-up can also make --no-pod-install print "Run cd ios && pod install before building", since right now the only output is the flag's own log line.
From the mobile re-test (getsentry/sentry-react-native#7172). Even with every feature flag (
--tracing --profiling --logs --replay --feedback --no-mcp < /dev/null),sentry wizard reactNativeexited 1 at a prompt: bare React Native at "Do you want to runpod installnow?", Expo at "Have you successfully sent a test event?". This lets the React Native and Expo wizards finish without a terminal, which the wizard e2e tests in #2572 need.pod install: new--pod-install/--no-pod-installflag inWIZARD_ANSWER_FLAGS(reactNative only).confirmPodInstallasks throughaskFlagQuestionand keeps Yes as the default.Closing question: it only confirms a setup that is already done, so it is skipped when stdin is not a TTY (
isatty(0), asguardNonInteractiveand auto-login check). Piped stdin that is still open counts as no terminal too. The run then ends with an outro that says Sentry is set up, tells the user to send a test event and check it in Sentry, and links the project's issues page and the sentry-react-native GitHub issues.user-confirmed-first-erroris"skipped". With a terminal, it is asked as before.Expo second run: a
metro.config.jsthat already has Sentry is its own"already-configured"outcome ofpatchMetroInMemory. It is logged once, with no "Could not patch" error and no copy-paste instructions. Those instructions also asked "Did you apply the snippet above?", which would have stopped a run without a terminal too. Parse and write failures still show them, as #2786 does forapp.json..gitignoreduplicates: Expo's.env.local(addToGitignore) and Flutter'ssentry.properties(addProperties) are appended only when no line already is the entry, ignoring surrounding whitespace. The check isgitignoreHasEntryinutils/git.ts.addCliConfigFileToGitIgnorenow uses it as well, so whitespace around the entry counts there too. #2796 also changesaddCliConfigFileToGitIgnore, but in other lines.via Antonis Lilis.
--
View Session [Sentry]