Skip to content

feat(cli): add source maps and Cloudflare to sentry wizard - #2529

Open
sentry-junior[bot] wants to merge 26 commits into
mainfrom
feat/cli-wizard-sourcemaps-cloudflare
Open

sentry-junior[bot] wants to merge 26 commits into
mainfrom
feat/cli-wizard-sourcemaps-cloudflare

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1965 (tracking: #2511). Stacked on #2520.

Ports two sentry-wizard 9.1.0 (@069923d) flows into the sentry wizard picker:

  • Source maps (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), plus utils/vendor/is-unicorn-supported.ts, which now reads env vars through getEnv.
  • Cloudflare (src/cloudflare/ → src/lib/wizard/cloudflare/).

Both are registered in WIZARD_RUNNERS with the upstream entry points. The existing sourcemaps/ci.ts gains the upstream step that asks the user to run the sentry:sourcemaps script 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 sentry CLI from the sentry npm package. They install sentry@^4 as a devDependency instead of @sentry/cli@^2. The wizard itself never needs a sentry-cli binary: src/utils/bash.ts (the get-cli download and sentry-cli --version check) is not ported.

sentry-cli v2 v4
sentry-cli sourcemaps inject / upload sentry sourcemap inject / upload
sentry-cli releases propose-version / new sentry release propose-version / create
--org <org> --project <project> [defaults] in .sentryclirc, or SENTRY_ORG / SENTRY_PROJECT
--url <url> SENTRY_URL
Wrangler upload with --strip-prefix 'dist/..' Wrangler upload with --no-rewrite

The generated commands don't use the hidden --org / --project compat flags:

  • Local runs: the generic and Wrangler flows merge org, project and, on self-hosted Sentry, url into the project's .sentryclirc [defaults], next to the gitignored [auth] token the wizard already writes. Other sections, keys and comments are kept. v4 reads them from there.
  • Self-hosted url: this depends on a CLI fix that's in progress separately. Today v4 rejects a non-SaaS [defaults] url that sits in the same file as the token. The wizard also tells self-hosted users to set SENTRY_URL wherever the script runs.
  • CI: on sentry.io, the CI step lists only SENTRY_AUTH_TOKEN. On self-hosted Sentry, it also lists SENTRY_ORG, SENTRY_PROJECT and SENTRY_URL. Wrangler now counts as a sentry-command tool there, since its token is in .sentryclirc, not .env.sentry-build-plugin. It skips the "run the script in CI" prompt because its post<deploy> script already runs the upload.

The sentry-cli tool 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.

Other differences from upstream

  • tools/nextjs.ts and tools/remix.ts are not ported. Nothing in 9.1.0 reaches them.
  • The redirect to a better-suited wizard (SvelteKit, React Native) calls the CLI's runWizard instead of spawning @sentry/wizard.
  • The Wrangler deploy-script parser no longer splits on shell operators inside quotes or $(…). Without this, rerunning the wizard would split inside the version pipe it adds.
  • Wrangler's sentry release create no longer passes --project, so the project slug stays out of package.json. It depends on release create sends no project unless --project is set #2534, which makes release create default to the resolved project.
  • The formatter, linter and test tsconfig now skip packages/cli/test/lib/wizard/**/fixtures/**, so the Cloudflare fixtures keep their exact upstream bytes.

Follow-ups

Open questions

  1. Wrangler prefix: 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?
    The sentry:sourcemaps npm script is now just sentry sourcemap upload <path>, because the upload injects debug IDs itself.

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 5 commits November 26, 2026 11:48
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>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 27, 2026 11:31pm UTC
sentry-local Ready Ready Preview Nov 27, 2026 11:31pm UTC

Request Review

sentry-junior Bot and others added 2 commits November 26, 2026 13:28
…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.
sentry-junior Bot and others added 2 commits November 26, 2026 18:10
- 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>
sentry-junior Bot and others added 6 commits November 26, 2026 19:01
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>
Comment thread .oxfmtrc.json Resolved
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 27, 2026 16:45
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 27, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

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

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@sentry-junior

sentry-junior Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@BYK both checked against packages/cli/src:

  1. Inject step: yes, it's redundant. Without --no-rewrite, sourcemap upload calls the same injectDirectory() that sourcemap inject uses, with no dry run. That writes the debug IDs into the JS files and maps on disk before it uploads them (commands/sourcemap/upload.ts, lib/sourcemap/inject.ts). So the deployed build carries the IDs either way. The generated script can be just sentry sourcemap upload <path>. That change is in sourcemaps/tools/sentry-cli.ts, which feat(cli): add Nuxt and Angular to sentry wizard #2525 shares byte for byte, so it'll land on both PRs together rather than here alone.
  2. --strip-prefix: you're right, it's a v4 gap. --strip-prefix and --strip-common-prefix only rename the uploaded artifacts. Nothing rewrites the sources inside a map; the only change is turning backslashes into forward slashes. There's no flag that does what v2's --strip-prefix 'dist/..' did. The Wrangler flow uploads with --no-rewrite, so matching is by release plus the ~/ URL, and that part is unaffected. What's lost is the cleanup: frames will likely show the map's own paths, such as ../src/index.ts, instead of src/index.ts.

…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

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ 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.

This branch was successfully deployed

2 active deployments
Preview – sentry-local — 62880e26 Deployed Nov 27, 2026 by vercel[bot]
Preview – cli — 62880e26 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant