Skip to content

feat(cli): add setup command for shell integration#213

Draft
BYK wants to merge 5 commits intomainfrom
feat/install-prefer-local-bin
Draft

feat(cli): add setup command for shell integration#213
BYK wants to merge 5 commits intomainfrom
feat/install-prefer-local-bin

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 6, 2026

Summary

Adds a new sentry cli setup command that configures shell integration, replacing the bash-based PATH modification logic with a proper TypeScript implementation.

New sentry cli setup command

  • PATH modification - Detects shell type, finds config file, adds PATH export
  • Shell completions - Generates and installs completions for bash, zsh, and fish
  • Install metadata - Records method/path/version for future upgrades
sentry cli setup                    # Auto-detect and configure
sentry cli setup --method curl      # Record install method
sentry cli setup --noModifyPath     # Skip PATH modification
sentry cli setup --noCompletions    # Skip shell completions

Simplified install script

The curl install script is now much simpler - it just downloads the binary and calls sentry cli setup:

Install priority order:

  1. $SENTRY_INSTALL_DIR (if set)
  2. ~/.local/bin (if exists AND in $PATH)
  3. ~/bin (if exists AND in $PATH)
  4. ~/.sentry/bin (fallback)

Benefits

Before After
PATH modification in bash (~100 lines) PATH modification in TypeScript (testable)
No shell completions Tab completion for bash/zsh/fish
record-install + bash logic Single setup command handles everything
Manual download users get no help Can run sentry cli setup to configure

New files

File Purpose
src/lib/shell.ts Shell detection, config file finding, PATH modification
src/lib/completions.ts Shell completion script generation
src/commands/cli/setup.ts The setup command
test/lib/shell.test.ts 25 tests
test/lib/completions.test.ts 18 tests

Removed

  • src/commands/cli/record-install.ts - functionality merged into setup --method

@BYK BYK requested a review from betegon February 6, 2026 16:11
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 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

  • (log) Add view command to display log entry details by betegon in #212

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 📚

  • Add documentation for log command by betegon in #210

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

PR Preview Action v1.8.1

QR code for preview link

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

Built to branch gh-pages at 2026-02-06 17:06 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Codecov Results 📊

✅ Patch coverage is 81.13%. Project has 2023 uncovered lines.
✅ Project coverage is 76.96%. Comparing base (base) to head (head).

Files with missing lines (42)
File Patch % Lines
human.ts 55.31% ⚠️ 391 Missing
resolve-target.ts 15.28% ⚠️ 366 Missing
oauth.ts 25.10% ⚠️ 194 Missing
api-client.ts 70.62% ⚠️ 176 Missing
upgrade.ts 64.54% ⚠️ 128 Missing
view.ts 47.70% ⚠️ 91 Missing
migration.ts 47.44% ⚠️ 82 Missing
browser.ts 4.11% ⚠️ 70 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
telemetry.ts 77.51% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
shell.ts 76.88% ⚠️ 37 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
utils.ts 88.94% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
output.ts 15.00% ⚠️ 17 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 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
upgrade.ts 94.74% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 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 98.91% ⚠️ 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    76.73%    76.96%    +0.23%
==========================================
  Files           65        68        +3
  Lines         8419      8780      +361
  Branches         0         0         —
==========================================
+ Hits          6460      6757      +297
- Misses        1959      2023       +64
- Partials         0         0         —

Generated by Codecov Action

Install script changes:
- Prefer ~/.local/bin or ~/bin when available and in $PATH
- Fall back to ~/.sentry/bin only when needed (adds to PATH)
- Support SENTRY_INSTALL_DIR env var for custom locations
- Call 'sentry cli record-install' after installation

New 'sentry cli record-install' command:
- Records method, path, version in SQLite metadata table
- Called automatically by install script
- Enables future upgrades to use correct method/path

Detection improvements:
- Check stored install info first (fast path)
- Legacy detection for existing installs (auto-saves for future)
- Expanded known curl paths: ~/.local/bin, ~/bin, ~/.sentry/bin

Upgrade command:
- Persists --method flag for future upgrades
- Uses stored path for curl upgrades instead of hardcoded path
@BYK BYK force-pushed the feat/install-prefer-local-bin branch from 716990a to 3e73719 Compare February 6, 2026 16:15
BYK added 4 commits February 6, 2026 16:24
New 'sentry cli setup' command that:
- Configures PATH by modifying shell config files
- Installs shell completions (bash, zsh, fish)
- Records installation metadata for upgrades

This moves PATH modification logic from bash to TypeScript for:
- Better error handling and testability
- Reusability for users who download binary manually
- Shell completion installation in the same step

Install script now simply calls 'sentry cli setup --method curl'
after downloading the binary.

New files:
- src/lib/shell.ts - Shell detection and PATH utilities
- src/lib/completions.ts - Shell completion generation
- src/commands/cli/setup.ts - The setup command
The setup command now handles recording install info via --method flag,
making record-install redundant. Removed to simplify the codebase.
The executeUpgrade and cleanupOldBinary tests were failing in CI because
paths were computed once at module load time, potentially capturing stale
database state from previous test runs.
@BYK BYK force-pushed the feat/install-prefer-local-bin branch from 9de75a0 to faedb9e Compare February 6, 2026 17:05
@BYK BYK changed the title feat(install): prefer ~/.local/bin and record installation method feat(cli): add setup command for shell integration Feb 6, 2026
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