Skip to content

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

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

sentry-junior[bot] wants to merge 22 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?
  2. 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?

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 5:05pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 27, 2026 5:05pm 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>
…already runs it

When the production build script already ends with `sentry:sourcemaps`,
`addSentryCommandToBuildCommand` left `addedToBuildCommand` false, so
`setupNpmScriptInCI` still asked for a separate CI step and the upload
would run twice. That branch now sets the flag too.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Takes `sourcemaps/tools/sentry-cli.ts` and its test from
#2525 (f5ca46e) as they are, so both PRs carry the same
copy. Its `.sentryclirc` writer is `addUploadTargetToSentryCliRc`, so the
Wrangler tool and the `.sentryclirc` defaults test call it by that name.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@vercel
vercel Bot temporarily deployed to Preview – sentry-local November 27, 2026 00:52 Inactive
Base automatically changed from feat/cli-wizard-shared-ast-helpers to main November 27, 2026 14:04
…emaps-cloudflare

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>

# Conflicts:
#	apps/cli-docs/src/fragments/commands/wizard.md
#	packages/cli/src/lib/wizard/run.ts
#	packages/cli/src/lib/wizard/sourcemaps/ci.ts
#	packages/cli/src/lib/wizard/utils/project-data.ts
#	packages/cli/test/lib/wizard/utils/project-data.test.ts
#	scripts/tsconfig-policy.test.mjs
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.

Cursor Bugbot has reviewed your changes using default effort and found 5 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 5bad502. Configure here.

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
Comment on lines +307 to +310
await showCopyPasteInstructions({
codeSnippet: oldDeployCommand,
filename: "package.json",
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Failed deploy-command rewrite shows the unmodified script as the fix

When the deploy script cannot be rewritten, the manual instructions paste the original command instead of the required wrangler deploy flags, so users cannot recover the setup from the prompt.

Evidence
  • The !newDeployCommand branch warns the user to modify the script manually, then calls showCopyPasteInstructions with codeSnippet: oldDeployCommand.
  • That snippet is the unchanged package.json script, not a command with --outdir, --upload-source-maps, or --var SENTRY_RELEASE:....
  • The missing-script branch immediately above correctly shows the flagged wrangler deploy snippet, so this failure path leaves users with no working replacement.

Identified by Warden · code-review · WHL-YKX

Comment on lines +371 to +376
return deployCommand
.replace(
originalWranglerDeployCommand,
`${originalWranglerDeployCommand} ${newArgs.join(" ")} `,
)
.trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Deploy arg insertion replaces the first substring match, not the deploy segment

safeInsertArgsToWranglerDeployCommand uses String.replace on the deploy segment text, so an earlier wrangler deploy substring in another command receives the new flags and the real deploy command is left untouched.

Evidence
  • getWranglerDeployCommand() correctly picks the deploy segment after splitShellCommands (e.g. the second part of echo Running wrangler deploy && wrangler deploy).
  • The rewrite applies deployCommand.replace(originalWranglerDeployCommand, ...) which substitutes the first text occurrence of that segment.
  • In scripts where an earlier command contains the same wrangler deploy text, the flags are inserted there and the actual wrangler deploy invocation is unchanged.

Identified by Warden · code-review · EL5-RSX

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — c438f132 Deployed Nov 27, 2026 by vercel[bot]
Preview – sentry-local — c438f132 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