Skip to content

refactor(init): split tools and preflight#764

Merged
betegon merged 6 commits intomainfrom
bt/init-tool-preflight-refactor
Apr 16, 2026
Merged

refactor(init): split tools and preflight#764
betegon merged 6 commits intomainfrom
bt/init-tool-preflight-refactor

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 16, 2026

Summary

  • rename init local operations to tools with an explicit file-per-tool registry
  • extract org/project/team/auth resolution into preflight and pass an immutable init context into the runner
  • move init-specific tests to preflight/tool suites and preserve existing project reuse behavior

Testing

  • bun run typecheck
  • bun test test/lib/init/interactive.test.ts test/lib/init/preflight.test.ts test/lib/init/wizard-runner.test.ts test/lib/init/tools/run-commands.test.ts test/lib/init/tools/registry.test.ts test/lib/init/tools/filesystem-tools.test.ts test/lib/init/tools/create-sentry-project.test.ts

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (build) Add musl binaries for Alpine Linux support by BYK in #762
  • (custom-headers) Add SENTRY_CUSTOM_HEADERS for self-hosted proxy auth by BYK in #761
  • (init) Pre-supply existingSentry to eliminate roundtrip by betegon in #755

Bug Fixes 🐛

  • (arg-parsing) Normalize spaces in slugs and trim whitespace in issue IDs (CLI-14M, CLI-16M) by BYK in #757
  • (search) Rewrite OR queries to in-list syntax across all --query commands (CLI-16J) by BYK in #758
  • (upgrade) Retry spawn on EBUSY for Windows Defender file locking (CLI-16E) by BYK in #756

Internal Changes 🔧

  • (init) Split tools and preflight by betegon in #764
  • (time-range) Parse --period at flag level via parsePeriod by BYK in #760
  • Regenerate docs by github-actions[bot] in 34bf056d

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-764/

Built to branch gh-pages at 2026-04-16 19:40 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

Codecov Results 📊

134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1652 uncovered lines.
✅ Project coverage is 95.46%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.45%    95.46%    +0.01%
==========================================
  Files          237       252       +15
  Lines        36049     36426      +377
  Branches         0         0         —
==========================================
+ Hits         34412     34774      +362
- Misses        1637      1652       +15
- Partials         0         0         —

Generated by Codecov Action

Comment thread src/lib/init/tools/glob.ts Outdated
Comment thread src/lib/init/tools/grep.ts Outdated
Comment thread src/lib/init/tools/glob.ts Outdated
Comment thread src/lib/init/preflight.ts
Comment thread src/lib/init/wizard-runner.ts
Comment thread src/lib/init/tools/run-commands.ts Outdated
Comment thread src/lib/init/preflight.ts
Comment thread src/lib/init/tools/create-sentry-project.ts
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

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 and found 1 potential issue.

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 94c214f. Configure here.

Comment thread src/lib/init/preflight.ts
return null;
}

return mergeProjectSelection(seed, resolved);
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.

Redundant API call fetches same project data twice

Low Severity

In the detection flow, tryGetExistingProjectData is called twice for the same org/project. First in resolveDetectedProject (line 190), storing the result in seed.existingProject. Then again in resolveExistingProjectChoice (line 242) via resolveProjectSelection, which ignores the already-fetched data. Each call triggers two HTTP requests (getProject + tryGetPrimaryDsn), so this doubles the API cost of the detection path. The seed.existingProject value could be passed to resolveExistingProjectChoice to skip the redundant fetch.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 94c214f. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

doing it in a follow up

@betegon betegon merged commit 54fad1a into main Apr 16, 2026
26 checks passed
@betegon betegon deleted the bt/init-tool-preflight-refactor branch April 16, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant