Skip to content

refactor(setup): unify binary placement via setup --install#217

Merged
BYK merged 10 commits intomainfrom
byk/setup-install-unify
Feb 9, 2026
Merged

refactor(setup): unify binary placement via setup --install#217
BYK merged 10 commits intomainfrom
byk/setup-install-unify

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 9, 2026

Summary

  • Move binary placement and directory selection from the bash install script into sentry cli setup --install, creating a single TypeScript code path shared by fresh installs and upgrades
  • Extract shared binary management helpers into src/lib/binary.ts (install dir resolution, download URLs, locking, atomic replacement)
  • Simplify install script to download-to-temp + delegate to setup --install
  • Change upgrade command to spawn the NEW binary with setup --install (curl) or setup (package managers) after downloading
  • Make setup the single owner of setInstallInfo, removing it from upgrade

Changes

File What
src/lib/binary.ts New — shared binary management (dir selection, locking, replacement)
src/commands/cli/setup.ts --install flag, handleInstall(), welcome message
src/commands/cli/upgrade.ts Spawns setup on new binary, resolveTargetVersion extraction
src/lib/upgrade.ts Imports from binary.ts, executeUpgrade returns temp path
install Downloads to temp, delegates everything to setup --install
src/bin.ts cleanupOldBinary()startCleanupOldBinary() rename
test/lib/binary.test.ts New — 17 tests for binary helpers
test/lib/upgrade.test.ts Updated imports and expectations

Test plan

  • bun run lint — clean
  • bun run typecheck — clean
  • 87 tests across binary.test.ts, upgrade.test.ts, setup.test.ts pass
  • SKILL.md regenerated

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 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 ✨

Cli

  • Add setup command for shell integration by BYK in #213
  • Add plural command aliases for list commands by betegon in #209

Other

  • (formatters) Display span duration in span tree by betegon in #219
  • (log) Add view command to display log entry details by betegon in #212
  • (setup) Auto-install Claude Code agent skill during setup by BYK in #216

Bug Fixes 🐛

Upgrade

  • Handle EPERM in isProcessRunning for cross-user locks by BYK in #211
  • Replace curl pipe with direct binary download by BYK in #208

Documentation 📚

  • (log) Add documentation for sentry log view command by betegon in #214
  • Add documentation for log command by betegon in #210

Internal Changes 🔧

  • (ci) Remove merge-artifacts job with Craft 2.21.1 by BYK in #215
  • (setup) Unify binary placement via setup --install by BYK in #217

🤖 This preview updates automatically when you update the PR.

…ment

Move binary placement, directory selection, and post-install steps from
the bash install script into the TypeScript setup command via --install.
This creates a single code path shared by fresh installs and upgrades:

- Extract binary management helpers into src/lib/binary.ts (directory
  selection, download URLs, locking, replacement, cleanup)
- Add --install flag to setup command that handles binary placement from
  a temp download location, then continues with PATH/completions/skills
- Simplify install script to just download to temp + delegate to setup
- Change upgrade to spawn the NEW binary with setup --install (curl) or
  setup (package managers) after downloading
- Remove setInstallInfo from upgrade.ts (setup now owns this)
- Fix cognitive complexity lint error in upgrade.ts by extracting
  resolveTargetVersion helper
@BYK BYK force-pushed the byk/setup-install-unify branch from 9714494 to 4531bac Compare February 9, 2026 15:25
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

Codecov Results 📊

✅ Patch coverage is 80.94%. Project has 3947 uncovered lines.
✅ Project coverage is 67.47%. Comparing base (base) to head (head).

Files with missing lines (64)
File Patch % Lines
human.ts 56.12% ⚠️ 391 Missing
resolve-target.ts 15.28% ⚠️ 366 Missing
list.ts 14.39% ⚠️ 345 Missing
list.ts 23.47% ⚠️ 212 Missing
api-client.ts 69.27% ⚠️ 197 Missing
oauth.ts 25.10% ⚠️ 194 Missing
list.ts 21.96% ⚠️ 167 Missing
view.ts 22.07% ⚠️ 166 Missing
plan.ts 19.37% ⚠️ 154 Missing
help.ts 19.85% ⚠️ 109 Missing
upgrade.ts 57.71% ⚠️ 107 Missing
interactive-login.ts 9.17% ⚠️ 99 Missing
view.ts 25.81% ⚠️ 92 Missing
view.ts 47.70% ⚠️ 91 Missing
clipboard.ts 4.49% ⚠️ 85 Missing
status.ts 24.07% ⚠️ 82 Missing
view.ts 49.07% ⚠️ 82 Missing
migration.ts 47.44% ⚠️ 82 Missing
list.ts 27.18% ⚠️ 75 Missing
browser.ts 4.11% ⚠️ 70 Missing
login.ts 33.33% ⚠️ 64 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
explain.ts 33.33% ⚠️ 56 Missing
telemetry.ts 79.86% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
upgrade.ts 66.91% ⚠️ 46 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
refresh.ts 40.63% ⚠️ 38 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
utils.ts 88.94% ⚠️ 25 Missing
view.ts 61.54% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
binary.ts 88.67% ⚠️ 17 Missing
output.ts 15.00% ⚠️ 17 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
help.ts 57.14% ⚠️ 15 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
logout.ts 56.00% ⚠️ 11 Missing
token.ts 52.17% ⚠️ 11 Missing
fix.ts 83.61% ⚠️ 10 Missing
qrcode.ts 33.33% ⚠️ 10 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.76% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
shell.ts 96.23% ⚠️ 6 Missing
app.ts 92.86% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 Missing
setup.ts 97.84% ⚠️ 4 Missing
index.ts 95.96% ⚠️ 4 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
json.ts 33.33% ⚠️ 2 Missing
alias.ts 99.42% ⚠️ 1 Missing
completions.ts 99.37% ⚠️ 1 Missing
env-file.ts 99.19% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 97.96% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    67.31%    67.47%    +0.16%
==========================================
  Files           98        99        +1
  Lines        12002     12133      +131
  Branches         0         0         —
==========================================
+ Hits          8079      8186      +107
- Misses        3923      3947       +24
- Partials         0         0         —

Generated by Codecov Action

BYK added 3 commits February 9, 2026 16:33
Add tests for:
- setup --install flag: binary placement, welcome message, quiet mode
- upgrade command: --check mode branches, already-up-to-date, version
  validation, v-prefix stripping
- binary.ts: fetchWithUpgradeError (AbortError, network errors,
  non-Error throws), replaceBinary (Unix atomic rename)
@BYK BYK marked this pull request as ready for review February 9, 2026 18:34
CodeQL flagged urlStr.includes('registry.npmjs.org') as an
incomplete URL substring sanitization (high severity). Use
URL parsing to check hostname exactly instead.
…de check

- Fix lock self-deadlock: acquireLock now recognizes process.ppid so the
  child (setup --install) can take over the parent's (upgrade) lock instead
  of erroring with 'Another upgrade is already in progress'
- Fix tempPath collision: installBinary skips unlink+copy when sourcePath
  already IS the .download file (upgrade spawn case)
- Fix PATH separator: use path.delimiter instead of hardcoded ':' in both
  binary.ts and shell.ts for Windows compatibility
- Fix silent failure: runSetupOnNewBinary now checks exit code and throws
  UpgradeError on non-zero exit
- Update stale comment in downloadBinaryToTemp explaining the ppid handoff
- Add tests for ppid lock takeover, tempPath collision, and lock lifecycle
@BYK BYK force-pushed the byk/setup-install-unify branch from 62386d7 to 9e5d954 Compare February 9, 2026 20:08
- upgrade: always use execPath instead of storedInfo?.path which could
  reference a stale binary from a different installation method
- binary: use static mkdirSync import instead of redundant dynamic import
…cation

During curl upgrades, the child setup process re-evaluates
determineInstallDir() which could resolve to a different directory
(e.g. ~/.local/bin appeared since the original install). This left
a stale binary at the original location that could shadow the new one.

Fix: pass SENTRY_INSTALL_DIR in the child's environment, set to the
current binary's install directory, so determineInstallDir() stays
pinned to the same location.
- upgrade: forward setup child's stdout/stderr to terminal so users
  see progress (Binary, PATH, Completions, Agent skills)
- binary: rename replaceBinary → replaceBinarySync with JSDoc explaining
  why synchronous is intentional (uninterruptible rename sequence)
- binary: convert installBinary's mkdir, unlink, chmod to async variants
  (function is already async; sync was unnecessary for these ops)
- test: update imports for replaceBinarySync rename
Copy link

@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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

startsWith(dir) without a trailing separator could false-positive
on directories sharing a prefix (e.g. ~/.local/binaries matching
~/.local/bin). Append path.sep to KNOWN_CURL_PATHS so the check
requires a proper directory boundary.
@BYK BYK merged commit 35aff8f into main Feb 9, 2026
23 checks passed
@BYK BYK deleted the byk/setup-install-unify branch February 9, 2026 22:30
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