Commit 6f46e16
refactor(init): reuse resolveOrCreateTeam for wizard team resolution (#679)
## Summary
The init wizard had ~55 lines of inline team resolution that duplicated
`resolveOrCreateTeam` from `resolve-team.ts`. Both implementations did
the same thing: list teams → 0 teams (auto-create) → 1 team
(auto-select) → N teams (filter by membership → pick).
Adds an `onAmbiguous` callback to `ResolveTeamOptions` so the wizard can
present a clack `select()` prompt when multiple teams match, instead of
the shared function throwing `ContextError`.
Also fixes a silent error-swallowing catch (`captureException` +
continue) that let team resolution failures pass through unnoticed — the
wizard would continue without a team and fail later when project
creation needed one.
## Changes
- `resolve-team.ts`: Added optional `onAmbiguous` callback to
`ResolveTeamOptions`. When provided, it's called with the candidate
teams instead of throwing `ContextError`. Non-breaking — existing
callers are unaffected.
- `wizard-runner.ts`: Replaced inline team resolution with a call to
`resolveOrCreateTeam`. Errors now surface properly instead of being
silently swallowed. Removed unused imports (`createTeam`, `listTeams`,
`getSentryBaseUrl`).
## Test plan
- [ ] `npx tsc --noEmit` passes
- [ ] `npx biome check` passes on changed files
- [ ] Run `sentry init` against an org with 0, 1, and multiple teams
- [ ] Run `sentry init --yes` against an org with multiple teams (should
auto-pick first)
- [ ] Cancel team selection mid-prompt — should exit cleanly with code 0
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 2009674 commit 6f46e16
2 files changed
+41
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | | - | |
| 28 | + | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
506 | 505 | | |
507 | 506 | | |
508 | 507 | | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
560 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
561 | 538 | | |
562 | 539 | | |
563 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
| |||
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
145 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
146 | 156 | | |
147 | 157 | | |
148 | 158 | | |
| |||
0 commit comments