Repository navigation
refactor(cli): make the install scripts readable top to bottom - #2404
Conversation
Restructure both installers around a short happy path: bash main() and PowerShell Invoke-Install now read as the list of install steps, and each step is a small named helper with a comment saying what it does and why. Nested branches become guard clauses, repeated failure handling becomes one helper, and the bash script runs main on its last line so a truncated download executes nothing. Behavior, messages, telemetry steps, and setup arguments are unchanged. The only test change follows from the trap now naming main() as the function. Co-Authored-By: Evan Purkhiser <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The bash installer now downloads into the directory `sentry cli setup` installs into, as setup's own temp file (sentry.download), instead of $TMPDIR with a fallback to that directory when the temp directory is full. Setup renames the download into place, a small or full /tmp no longer matters, and write_staged and the fallback paths go away. Co-Authored-By: Evan Purkhiser <[email protected]>
When Sentry's release registry is down, an unpinned install now fails with "Failed to fetch latest stable version... install a specific version" instead of paging through GitHub releases for the newest stable cli@ tag. A pinned version still downloads from its GitHub release. This removes the GitHub API client, its rate-limit and token handling, and the release-page parsing from install, and Find-LatestToolkitVersion from install.ps1. Co-Authored-By: BYK <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9b6cc85. Configure here.
MathurAditya724
left a comment
There was a problem hiding this comment.
Reviewed the implementation, neighboring patterns, regression coverage, and review threads on this exact head. Local validation: 38 local Bash installer tests passed, including mocked downloads/checksums, fallback paths, and PTY handoffs. The 17 PowerShell cases were skipped locally because pwsh is unavailable; hosted CI is green. No actionable findings remain; hosted checks are green.

Summary
Restructures
packages/cli/installandpackages/cli/install.ps1so that someone reading the installer before they pipe it to a shell can follow it. Today that means reading 700 lines of top-level code. Two behavior changes are listed below. Otherwise requests, messages, telemetrysteptags, setup arguments, and exit codes stay the same.Key Changes
main()and PowerShellInvoke-Installcome right after the header and list the install steps in order: parse args, detect the platform, resolve the release, download and verify, runsentry cli setup, then runsentry initif asked.require_downloadandrequire_good_checksum, and the duplicated JSONawkone-liners move intojson_field.main "$@"on its last line, so acurl | bashdownload that gets cut off runs nothing.Repair-DownloadandAssert-Sha256merge intoConfirm-Download. Gzip expansion moves intoExpand-Gzip. Download, setup, and init each get their own function.Behavior change: no GitHub fallback for
latest(both installers)When Sentry's release registry is down, an unpinned install now stops with "Failed to fetch latest stable version from Sentry's release registry. Retry or install a specific version". It no longer pages through GitHub releases to find the newest stable
cli@tag. A pinned version (--version/SENTRY_VERSION) still downloads from its GitHub release. This removes the GitHub API client, its token and rate-limit handling, and the release-page parsing from bash, plusFind-LatestToolkitVersionfrom PowerShell.Behavior change: bash downloads straight into the install directory
The bash installer used to download to
$TMPDIRand fall back to the install directory when the temp directory was full. Now it always downloads into the directorysentry cli setupinstalls into, as setup's own temp file (sentry.download). Setup renames it into place instead of copying it, and a small or full/tmpno longer matters. This removeswrite_stagedand the fallback paths.Side effects:
sentry.downloadcan be left behind. Normal exits and Ctrl-C clean it up.SENTRY_INSTALL_DIRinstead ofTMPDIR.Porting to POSIX
shis out of scope. The script depends on the bash ERR trap and$BASH_COMMANDreporting, arrays,nocasematch, andprintf -v.via @evanpurkhiser, @BYK.
--
View Session [Sentry]