Repository navigation
feat(cli): add source maps and Cloudflare to sentry wizard - #2529
sentry-junior[bot] wants to merge 26 commits into
Conversation
Start moving getsentry/sentry-wizard into the CLI as `sentry wizard`. This adds the command with the `@sentry/wizard` integrations and flags (`-i`, `--url`, `--org`, `--project`, `--saas`, `--spotlight`, and the rest), the shared wizard helpers, and the Next.js flow. The other integrations report that they are not available in this version yet. The wizard logs in with the CLI's own login: a stored `sentry auth login` session, an agent handoff, or the device flow, instead of the `account/settings/wizard/<hash>` browser flow. It then picks or creates the project, reads its DSN, and creates an org auth token for source map uploads. Telemetry goes through the CLI's client. `sentry init` stays the agent setup guide; its help now points to `sentry wizard` for the interactive setup. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Port `ast-utils` and `url` from getsentry/sentry-wizard into `src/lib/wizard/utils/`. The SvelteKit, Remix, React Router, Angular, Nuxt, source maps, Cloudflare, React Native and Android wizards all use them, so they land once here and the platform PRs that follow build on them in parallel. `ast-utils` edits recast ASTs, so recast and ast-types become direct dev dependencies; both already came in through magicast. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
`sentry wizard` logs in with the CLI's login, which has no sign-up or partner step, so `--signup`, `--promo-code` and `--coming-from` no longer do anything. Passing one now fails with a message that points to https://sentry.io/signup/ instead of being accepted silently. `promoCode` and `comingFrom` leave `WizardOptions`, the welcome banner and `setupCI`, which loses its Vercel partner branch. The help text and the docs say which `@sentry/wizard` flags were removed. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…st-helpers Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Port the source maps wizard (all build tools) and the Cloudflare Workers wizard from sentry-wizard 9.1.0 into `sentry wizard`, with their tests, and register `sourcemaps` and `cloudflare` in WIZARD_RUNNERS. The generated projects now use the v4 `sentry` CLI instead of sentry-cli v2: the wizard installs the `sentry` npm package and writes `sentry sourcemap inject/upload` and `sentry release create` scripts. `.sentryclirc` stays, since v4 still reads it. A self-hosted URL is passed in `SENTRY_URL`, which replaced the sentry-cli `--url` flag. `sourcemaps/ci.ts` gains the step that asks to run the `sentry:sourcemaps` script in CI. The Cloudflare test fixtures keep their upstream bytes, so the formatter, linter and test typecheck skip wizard fixtures. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…sourcemaps-cloudflare Picks up the removed sign-up and partner flags. The source maps and Cloudflare wizards no longer pass `promoCode` to `printWelcome`, and `setupCI` loses the `comingFrom` argument. The `sourcemaps/ci.ts` conflict is resolved to the shared version from #2525. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Generated `sentry` commands no longer pass the hidden `--org` and `--project` compat flags. The generic and Wrangler source maps flows merge `org` and `project` into the project's `.sentryclirc` `[defaults]`, next to the existing `[auth] token` and any other keys, and v4 reads them from there. Wrangler's `sentry:sourcemaps` script drops the `SENTRY_URL=` prefix and the flags from `sentry release create` and `sentry sourcemap upload`. The self-hosted URL is not written to the file. v4 only trusts a non-SaaS `[defaults] url` when the token's host or a stored login vouches for it, and a token from the same file does not, so the upload would be refused. Self-hosted users are told to set `SENTRY_URL` instead. `setupCI` gets the upload target, so the CI step lists `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, `SENTRY_PROJECT` and, for self-hosted, `SENTRY_URL`. Wrangler counts as a `sentry`-command tool there (its token lives in `.sentryclirc`), but skips the "run the script in CI" prompt, since its `post<deploy>` script already runs it. `sentry@^4` is installed as a devDependency. `sourcemaps/ci.ts`, `sourcemaps/tools/sentry-cli.ts`, `angular.ts`, `types.ts` and `abort-if-sportlight-not-supported.ts` now match #2525, apart from exporting `addOrgAndProjectToSentryCliRc` for Wrangler, the devDependency install, and the Wrangler CI case. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
The Cloudflare wizard fixtures are upstream sentry-wizard Worker sources that `wrap-worker` and `update-wrangler-config` tests read and compare as text. The test tsconfig excludes them, so the tsconfig policy check needs them in its list of files no type check covers on purpose.
- Skip the `.sentryclirc` URL check, like `sentry init`: the wizard picks its instance (`--url`, `--saas` or a prompt) before it logs in. - Use the stored login's instance for `sentryUrl` when none was chosen, and log in again when the stored login is for another instance. - Link self-hosted users to `/settings/<org>/auth-tokens/`. - Leave an unparseable MCP config alone (show the copy-paste fallback), and let a cancel inside the MCP setup stop the wizard. - Resolve `catalog:` and `catalog:default` against both pnpm default catalog forms. - Find an existing `SENTRY_AUTH_TOKEN` after the comment header of `.env.sentry-build-plugin`, so re-runs don't add a second one. - Run Windows formatters with Node in the standalone binary, where `process.execPath` is `sentry`. - Ask before updating an `@sentry/nextjs` listed in devDependencies, and treat an unknown SDK version as the `^11` the wizard installs. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…st-helpers Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
On self-hosted Sentry, the generic and Wrangler source maps flows now write `url` to `.sentryclirc` `[defaults]` next to `org` and `project`. v4 rejects that URL from the same file as the token today. The trust check fix is separate, and the generated script depends on it. The CI step on sentry.io now lists only `SENTRY_AUTH_TOKEN`. On self-hosted Sentry it also lists `SENTRY_ORG`, `SENTRY_PROJECT` and `SENTRY_URL`. The wizard docs fragment says the same. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Address review feedback on the shared wizard helpers: - Enable unicorn/no-array-for-each repo-wide and convert every .forEach call site to for...of, including getLastRequireIndex. - Add buildProjectIssuesUrl to lib/sentry-urls.ts, built on getOrgBaseUrl like buildEventSearchUrl, and delete the wizard-specific wizard/utils/url.ts. - Move findFile into lib/dsn/fs-utils.ts and build it on isRegularFile, so a directory or FIFO with a matching name is skipped. It is async now. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
`sentry wizard [<org>/<project>] [<integration>]` replaces the `@sentry/wizard` flags, with the target first like other commands. - The integration is a positional, one at a time. A bare integration id is never read as a target, and a single bare word is always read as an integration, so a project or org spelled like one is written `my-org/nextjs`, `nextjs/` or `/nextjs`. - The target parses with the CLI's org/project grammar and resolves after login with `resolveOrgOptionalTarget`, like other commands. Without one the org and project pickers run, with no detection. - `-f/--force` is the only flag. It sets both `forceInstall` and `ignoreGitChanges`. - The instance comes from `SENTRY_URL` or the stored login, so the SaaS/self-hosted prompt, `--url`, `--saas` and `skipRcUrlCheck` go. - Spotlight mode follows `SENTRY_SPOTLIGHT`, telemetry follows `isTelemetryEnabled()`, and debug output goes through the CLI logger (`--verbose`, `--log-level`). - Every other `@sentry/wizard` flag and `SENTRY_WIZARD_*` variable is gone, hidden ones included, with `disableTelemetryForRun` and `rejectRemovedFlags`. A test pins the wizard's own flags to `force`, and `check:env-coverage` (part of `ci:policy`) fails when any file under `src/` names `SENTRY_WIZARD_`. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Re-export buildProjectIssuesUrl from lib/sentry-web-urls.ts through withSentryBaseUrl(getApiBaseUrl()), like the other user-facing link builders, so self-hosted and regional logins get links on the host they are authenticated against. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…eat/cli-wizard-shared-ast-helpers Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…izard base Merges origin/feat/cli-wizard-shared-ast-helpers at f0a48de (#2520, the chart-app fix and #2519's positional rework) and fixes what it breaks: - `runWizard` no longer takes `debug`, so the redirect to another wizard drops it. - `wizard/utils/url.ts` is gone. The source maps outro links to the project's issues with `buildProjectIssuesUrl` from `lib/sentry-web-urls`. - `findFile` now comes from `lib/dsn/fs-utils` and is async, so the tsc, Vite and webpack tools await it. - The new `no-array-for-each` lint rule: two `forEach` loops become `for...of`. - The wizard docs fragment keeps the base's flag table and the source maps paragraph from this branch. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Takes `sourcemaps/tools/sentry-cli.ts`, `sourcemaps/tools/angular.ts` and their tests from #2525 (370f74d) unchanged, so both PRs carry the same copies. This brings in the Angular snippet that sets `sourceMap` in the production configuration and the `forceInstall` option for the `sentry` install. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Fixes bugs carried over from sentry-wizard 9.1.0 that Warden and Bugbot found on review, without changing how the flows work: - Cloudflare: offer the data collection prompt when the installed SDK version is unknown, using the `^11` range the wizard installs - Cloudflare: stop the TOML `main` match at the closing quote - Vite: recognize quoted `build` and `sourcemap` keys, using the shared `getObjectProperty` helper - Webpack: link the webpack docs when creating a new config - Create React App: name the `GENERATE_SOURCEMAP` variable, and detect CRA from `react-scripts` - Wrangler: exit when the user keeps an existing `sentry:sourcemaps` script, as the prompt says, and read `--outdir` values after several spaces
…emaps-cloudflare # Conflicts: # packages/cli/src/lib/wizard/run.ts # packages/cli/src/lib/wizard/utils/abort-if-sportlight-not-supported.ts # packages/cli/test/tsconfig.json
BYK
left a comment
There was a problem hiding this comment.
Inject before upload: the generic flow keeps the inject step before upload, as upstream did. But v4 upload already injects debug IDs unless --no-rewrite is set. Should the inject step go?
I think so as it looks useless?
v4's --strip-prefix strips uploaded file paths, not the sources inside the maps. So v2's --strip-prefix 'dist/..' was dropped, and the upload relies on release and URL matching. Is that enough?
Looks like a capability gap on v4 to me. Am I right?
|
@BYK both checked against
|
…cript `sentry sourcemap upload` already injects missing debug IDs into the files on disk before it uploads them, the same way `sentry sourcemap inject` does, so the script ran injection twice. Run only the upload.
…emaps-cloudflare # Conflicts: # packages/cli/src/lib/wizard/run.ts # packages/cli/test/tsconfig.json
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 62880e2. Configure here.

Part of #1965 (tracking: #2511). Stacked on #2520.
Ports two sentry-wizard 9.1.0 (@069923d) flows into the
sentry wizardpicker:src/sourcemaps/→src/lib/wizard/sourcemaps/): every tool (webpack, Vite, Rollup, esbuild, tsc, Create React App, Angular, Wrangler, and the generic "I use another tool" flow), plusutils/vendor/is-unicorn-supported.ts, which now reads env vars throughgetEnv.src/cloudflare/→src/lib/wizard/cloudflare/).Both are registered in
WIZARD_RUNNERSwith the upstream entry points. The existingsourcemaps/ci.tsgains the upstream step that asks the user to run thesentry:sourcemapsscript in CI. There is no second copy of that file.The webpack, Vite and tsc tools and the Cloudflare config/worker edits still use magicast/recast. #2510 removes them after v4.
sentry-cli v2 → v4
Generated projects use the v4
sentryCLI from thesentrynpm package. They installsentry@^4as a devDependency instead of@sentry/cli@^2. The wizard itself never needs asentry-clibinary:src/utils/bash.ts(theget-clidownload andsentry-cli --versioncheck) is not ported.sentry-cli sourcemaps inject/uploadsentry sourcemap inject/uploadsentry-cli releases propose-version/newsentry release propose-version/create--org <org> --project <project>[defaults]in.sentryclirc, orSENTRY_ORG/SENTRY_PROJECT--url <url>SENTRY_URL--strip-prefix 'dist/..'--no-rewriteThe generated commands don't use the hidden
--org/--projectcompat flags:org,projectand, on self-hosted Sentry,urlinto the project's.sentryclirc[defaults], next to the gitignored[auth] tokenthe wizard already writes. Other sections, keys and comments are kept. v4 reads them from there.url: this depends on a CLI fix that's in progress separately. Today v4 rejects a non-SaaS[defaults] urlthat sits in the same file as the token. The wizard also tells self-hosted users to setSENTRY_URLwherever the script runs.SENTRY_AUTH_TOKEN. On self-hosted Sentry, it also listsSENTRY_ORG,SENTRY_PROJECTandSENTRY_URL. Wrangler now counts as asentry-command tool there, since its token is in.sentryclirc, not.env.sentry-build-plugin. It skips the "run the script in CI" prompt because itspost<deploy>script already runs the upload.The
sentry-clitool id and file name stay, so telemetry tags still line up with sentry-wizard's.Overlap with the other wizard PRs
File paths match upstream, so this and the parallel ports reconcile with a merge.
sourcemaps/ci.ts,sourcemaps/tools/sentry-cli.ts,tools/angular.ts,tools/types.ts,utils/abort-if-sportlight-not-supported.ts, and thesentry-cli,ciandsentryclirc-filetests match its head. This PR supersedes these lines of it:tools/sentry-cli.ts:addOrgAndProjectToSentryCliRcis exported, so Wrangler writes[defaults]the same way.tools/sentry-cli.ts: thesentry@^4install passesdevDependency: true. It's a build-time tool.ci.ts:"wrangler"joinsCLI_BASED_FLOW_TOOLS, and the npm-script CI step is skipped for it. The reasons are in the CI bullet above.tools/types.ts: adds theSourceMapUploadToolConfigurationFunctiontype that the bundler tools use.abort-if-sportlight-not-supported.ts. This PR takes feat(cli): add Nuxt and Angular to sentry wizard #2525's copy, whose JSDoc differs from feat(cli): add SvelteKit, Remix and React Router to sentry wizard #2526's by one line.Other differences from upstream
tools/nextjs.tsandtools/remix.tsare not ported. Nothing in 9.1.0 reaches them.runWizardinstead of spawning@sentry/wizard.$(…). Without this, rerunning the wizard would split inside the version pipe it adds.sentry release createno longer passes--project, so the project slug stays out ofpackage.json. It depends on release create sends no project unless --project is set #2534, which makesrelease createdefault to the resolved project.packages/cli/test/lib/wizard/**/fixtures/**, so the Cloudflare fixtures keep their exact upstream bytes.Follow-ups
remix/remix-wizard.tsthere writes.env.sentry-build-pluginand links to the manual steps, becauseconfigureVitePluginwasn't ported yet. Once both land, swap that back toconfigureVitePluginfromsourcemaps/tools/vite.ts. Its path and signature match upstream, so the change is one line.sentry release propose-version(| head -n 1), because a hint line follows the version on stdout. Tracked in Command hints print to stdout when output is piped #2531.Open questions
--strip-prefixstrips uploaded file paths, not the sources inside the maps. So v2's--strip-prefix 'dist/..'was dropped, and the upload relies on release and URL matching. Is that enough?The
sentry:sourcemapsnpm script is now justsentry sourcemap upload <path>, because the upload injects debug IDs itself.via @BYK.
--
View Session [Sentry]