Skip to content

Commit ac6b75d

Browse files
feat(cli): use positionals and existing CLI flags in sentry wizard
`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>
1 parent 39e20d5 commit ac6b75d

15 files changed

Lines changed: 592 additions & 539 deletions

File tree

‎apps/cli-docs/src/fragments/commands/wizard.md‎

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,49 @@
44

55
`sentry wizard` sets up the Sentry SDK in the project in the current
66
directory. It asks a few questions, installs the SDK for your framework,
7-
writes its configuration, and sets up source map or debug file uploads.
8-
Pass `-i` with an integration, such as `nextjs`, to skip the integration
9-
picker.
7+
writes its configuration, and sets up source map or debug file uploads. It
8+
takes an optional `<org>/<project>` first, then an optional integration:
9+
10+
- Pass an integration, such as `nextjs`, to skip the integration picker.
11+
- Pass `<org>/<project>` first to skip the org and project pickers, or
12+
`<org>/` to pick only the project. Without it, the wizard asks; it doesn't
13+
detect a project from your files.
14+
- An integration id is never read as a project or org, and a single bare
15+
word is always read as an integration. Write a project or org with a `/`:
16+
`my-org/my-project`, `my-org/`, or `/my-project`. For a project spelled
17+
like an integration, write `my-org/nextjs`.
18+
- `-f`/`--force` changes a project with uncommitted changes without asking,
19+
and installs the SDK even when the package manager's checks fail.
1020

1121
It logs in with your `sentry auth login` account, or starts a login when you
12-
have none, and lets you pick or create the Sentry project to send data to.
13-
Pass `--org` and `--project` to skip those questions.
22+
have none, on the Sentry instance the rest of the CLI uses: `SENTRY_URL`, or
23+
the stored login's. To use a self-hosted instance, log in to it first with
24+
`sentry auth login --url`.
25+
26+
Set `SENTRY_SPOTLIGHT=1` to set up Spotlight for local development instead,
27+
with no Sentry account or login. Telemetry follows the CLI's settings
28+
(`SENTRY_CLI_NO_TELEMETRY`, `DO_NOT_TRACK`, `sentry cli defaults`), and the
29+
global `--verbose` flag shows the wizard's debug output.
1430

1531
`sentry wizard` changes your project's files. To have a coding agent set up
1632
Sentry instead, run `sentry init`, which prints the agent's setup guide and
1733
changes nothing.
1834

1935
## Coming from `@sentry/wizard`
2036

21-
`sentry wizard` takes the same integrations and flags as
22-
`npx @sentry/wizard`, so `npx @sentry/wizard -i nextjs` and
23-
`sentry wizard -i nextjs` do the same thing. These were removed:
24-
25-
- The sign-up flags `--signup`, `--promo-code` and `--coming-from`. Passing one
26-
fails with an explanation. Sign up at https://sentry.io/signup/ (and apply a
27-
promo code there), then run the wizard.
28-
- The Cordova and Electron wizards. Follow their setup guides in the Sentry
29-
docs instead.
37+
`sentry wizard` takes the same integration ids as `npx @sentry/wizard -i`,
38+
but not its flags or `SENTRY_WIZARD_*` environment variables:
39+
40+
| `@sentry/wizard` | `sentry wizard` |
41+
| -------------------------------------- | ------------------------------------------------ |
42+
| `-i nextjs` | `nextjs` |
43+
| `--org my-org --project my-project` | `my-org/my-project`, before the integration |
44+
| `--url`, `-u`, `--saas` | `sentry auth login --url`, or `SENTRY_URL` |
45+
| `--spotlight` | `SENTRY_SPOTLIGHT=1` |
46+
| `--force-install`, `--ignore-git-changes` | `-f`/`--force` |
47+
| `--disable-telemetry` | `SENTRY_CLI_NO_TELEMETRY=1` or `DO_NOT_TRACK=1` |
48+
| `--debug` | `--verbose` or `--log-level debug` |
49+
| `--signup`, `--promo-code`, `--coming-from` | Sign up at https://sentry.io/signup/ first |
50+
51+
The Cordova and Electron wizards were retired. Follow their setup guides in
52+
the Sentry docs instead.

‎packages/cli/plugins/sentry-cli/skills/sentry-cli/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ Print instructions for a coding agent to set up Sentry
818818

819819
Set up the Sentry SDK in your project interactively
820820

821-
- `sentry wizard` — Set up the Sentry SDK in your project interactively
821+
- `sentry wizard [<org>/<project>] [<integration>]` — Set up the Sentry SDK in your project interactively
822822

823823
→ Full flags and examples: `references/wizard.md`
824824

‎packages/cli/plugins/sentry-cli/skills/sentry-cli/references/wizard.md‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ requires:
1111

1212
Set up the Sentry SDK in your project interactively
1313

14-
### `sentry wizard`
14+
### `sentry wizard [<org>/<project>] [<integration>]`
1515

1616
Set up the Sentry SDK in your project interactively
1717

18+
**Arguments:**
19+
20+
| Argument | Description |
21+
|----------|-------------|
22+
| `[<org>/<project>] [<integration>]` | &lt;org&gt;/&lt;project&gt; to set up (skips the project picker), then the integration (skips the integration picker) |
23+
1824
**Flags:**
19-
- `-i, --integration <value> - Integration to set up (skips the picker)`
20-
- `-u, --url <value> - URL of your self-hosted Sentry instance`
21-
- `--org <value> - Slug of the Sentry organization to use`
22-
- `--project <value> - Slug of the Sentry project to use`
23-
- `--saas - Use Sentry SaaS (sentry.io) without asking`
24-
- `--spotlight - Set up Spotlight for local development, without a Sentry account`
25-
- `--force-install - Install the SDK even when the package manager's checks fail`
26-
- `--ignore-git-changes - Don't ask before changing a project with uncommitted changes`
27-
- `--disable-telemetry - Don't send telemetry about this run to Sentry`
28-
- `--debug - Print the wizard's debug output`
25+
- `-f, --force - Change a project with uncommitted changes without asking, and install the SDK even when the package manager's checks fail`
2926

3027
**Examples:**
3128

3229
```bash
33-
# Pick an integration and set it up
30+
# Pick an integration and a project, then set it up
3431
sentry wizard
3532

36-
# Set up Next.js for a known org and project on sentry.io
37-
sentry wizard -i nextjs --saas --org my-org --project my-project
33+
# Set up Next.js, picking the project
34+
sentry wizard nextjs
35+
36+
# Set up Next.js for a known org and project
37+
sentry wizard my-org/my-project nextjs
3838

3939
# Set up Next.js for Spotlight, without a Sentry account
40-
sentry wizard -i nextjs --spotlight
40+
SENTRY_SPOTLIGHT=1 sentry wizard nextjs
4141
```
4242

4343
All commands also support `--json`, `--fields`, `--help`, `--log-level`, and `--verbose` flags.

‎packages/cli/script/check-env-coverage.ts‎

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
* test-only hooks, and vars inherited from the SDK are listed (with a reason) in
1616
* INTERNAL_ENV_VARS so their exclusion is explicit and reviewable.
1717
*
18+
* It also fails when any file under src/ names a prefix in
19+
* RETIRED_ENV_PREFIXES, such as the `SENTRY_WIZARD_*` vars of `@sentry/wizard`.
20+
*
1821
* Usage:
1922
* pnpm ts script/check-env-coverage.ts
2023
*
2124
* Exit codes:
2225
* 0 - Every user-facing env var read by the CLI or an installer is documented
2326
* or explicitly internal
24-
* 1 - Coverage gap, redundant allowlist entry, or stale allowlist entry
27+
* 1 - Coverage gap, redundant allowlist entry, stale allowlist entry, or a
28+
* retired env var prefix (RETIRED_ENV_PREFIXES) under src/
2529
*/
2630

2731
import { readFile } from "node:fs/promises";
@@ -51,10 +55,6 @@ const INTERNAL_ENV_VARS = new Map<string, string>([
5155
"SENTRY_ENVIRONMENT",
5256
"bash-hook traceback template only; inherited SDK convention",
5357
],
54-
[
55-
"SENTRY_SPOTLIGHT",
56-
"set by `local run` for the child app; the CLI only names it in Worker setup hints",
57-
],
5858
[
5959
"SENTRY_TRACES_SAMPLE_RATE",
6060
"inherited from the SDK when spawning subprocesses, not a CLI config knob",
@@ -79,6 +79,17 @@ const INTERNAL_ENV_VARS = new Map<string, string>([
7979
["SENTRY_RN_SOURCEMAP_REPORT", "internal react-native wrapper plumbing"],
8080
]);
8181

82+
/**
83+
* Env var prefixes the CLI dropped on purpose. No file under src/ may name
84+
* one, read or not, so none comes back as a hidden alias. Each has a reason.
85+
*/
86+
const RETIRED_ENV_PREFIXES = new Map<string, string>([
87+
[
88+
"SENTRY_WIZARD_",
89+
"`sentry wizard` takes `<org>/<project>` and the integration as positionals, and reads only the CLI's own env vars (SENTRY_URL, SENTRY_SPOTLIGHT, SENTRY_LOG_LEVEL)",
90+
],
91+
]);
92+
8293
const registryNames = new Set(ENV_VAR_REGISTRY.map((entry) => entry.name));
8394

8495
/**
@@ -230,6 +241,22 @@ for (const name of INTERNAL_ENV_VARS.keys()) {
230241
}
231242
}
232243

244+
// Every file type under src/, generated files included, not just the env
245+
// reads above: a retired name in a string or a comment fails too.
246+
for (const file of await glob("src/**/*")) {
247+
const content = await readFile(file, "utf-8");
248+
for (const [prefix, reason] of RETIRED_ENV_PREFIXES) {
249+
const index = content.indexOf(prefix);
250+
if (index !== -1) {
251+
const line = content.slice(0, index).split("\n").length;
252+
errors.push(
253+
`Retired env var prefix: ${prefix} (at ${file}:${line})\n` +
254+
` Remove it: ${reason}.`,
255+
);
256+
}
257+
}
258+
}
259+
233260
if (errors.length > 0) {
234261
logger.error(
235262
[

0 commit comments

Comments
 (0)