Commit 7bb8ccf
refactor(init): reuse resolveOrg for offline-first org detection (#666)
## Summary
The init wizard's `resolveOrgSlug()` was reimplementing org detection
that `resolveOrg()` in `resolve-target.ts` already handles. The shared
resolver covers CLI flags, env vars (`SENTRY_ORG`), config defaults, and
DSN auto-detection with numeric ID normalization — the init version only
did DSN scanning and missed env vars and config defaults entirely.
Now `resolveOrgSlug()` calls `resolveOrg({ cwd })` first, and only falls
through to `listOrganizations()` + interactive select when nothing is
detected offline.
## Test Plan
- [x] `bun test test/lib/init/` — 165 tests passing
- [ ] `sentry init` with `SENTRY_ORG=<slug>` set — should pick it up
without prompting
- [ ] `sentry init` without env vars — should still show org picker as
before
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 04a1efd commit 7bb8ccf
File tree
2 files changed
+29
-43
lines changed- src/lib/init
- test/lib/init
2 files changed
+29
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
| |||
709 | 706 | | |
710 | 707 | | |
711 | 708 | | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
712 | 712 | | |
713 | | - | |
714 | | - | |
| 713 | + | |
| 714 | + | |
715 | 715 | | |
716 | | - | |
| 716 | + | |
717 | 717 | | |
718 | 718 | | |
719 | 719 | | |
720 | | - | |
721 | | - | |
722 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
723 | 728 | | |
724 | 729 | | |
725 | 730 | | |
726 | 731 | | |
727 | 732 | | |
728 | 733 | | |
729 | 734 | | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
730 | 738 | | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
| 739 | + | |
| 740 | + | |
745 | 741 | | |
746 | 742 | | |
747 | 743 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
305 | 301 | | |
306 | 302 | | |
307 | 303 | | |
308 | 304 | | |
309 | | - | |
| 305 | + | |
310 | 306 | | |
311 | 307 | | |
312 | | - | |
313 | | - | |
314 | | - | |
| 308 | + | |
| 309 | + | |
315 | 310 | | |
316 | 311 | | |
317 | 312 | | |
| |||
321 | 316 | | |
322 | 317 | | |
323 | 318 | | |
324 | | - | |
| 319 | + | |
325 | 320 | | |
326 | | - | |
327 | 321 | | |
328 | | - | |
329 | | - | |
| 322 | + | |
330 | 323 | | |
331 | 324 | | |
332 | | - | |
| 325 | + | |
333 | 326 | | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 327 | + | |
338 | 328 | | |
339 | 329 | | |
340 | 330 | | |
| |||
0 commit comments