Skip to content

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

Merged
BYK merged 10 commits intomainfrom
feat/install-prefer-local-bin
Feb 9, 2026
Merged

feat(cli): add setup command for shell integration#213
BYK merged 10 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 - Dynamically 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 --no-modify-path   # Skip PATH modification
sentry cli setup --no-completions   # 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)

Dynamic shell completions

Completion scripts are auto-generated from the Stricli route map — when commands are added or removed, completions update automatically. No manual maintenance needed.

Automatic flag telemetry

A buildCommand wrapper auto-captures flag values as Sentry tags (e.g., flag.verbose, flag.no-modify-path) and positional args as Sentry context. Commands just import buildCommand from lib/command.js instead of @stricli/core.

Kebab-case flag support

Enabled allow-kebab-for-camel in Stricli config so all flags accept both --noModifyPath and --no-modify-path.

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
No flag telemetry Automatic flag/arg capture for all commands
Static completion scripts Dynamic generation from route map

New files

File Purpose
src/lib/shell.ts Shell detection, config file finding, PATH modification
src/lib/completions.ts Dynamic shell completion script generation
src/lib/command.ts buildCommand wrapper with automatic telemetry
src/commands/cli/setup.ts The setup command
test/lib/shell.test.ts 35 tests
test/lib/completions.test.ts 30 tests
test/lib/command.test.ts 8 tests
test/commands/cli/setup.test.ts 11 tests

Removed

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

Fixes #67.

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

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 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 📚

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

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

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-09 11:56 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Codecov Results 📊

✅ Patch coverage is 93.19%. Project has 3923 uncovered lines.
❌ Project coverage is 67.04%. Comparing base (base) to head (head).

Files with missing lines (63)
File Patch % Lines
human.ts 55.31% ⚠️ 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
upgrade.ts 64.54% ⚠️ 128 Missing
help.ts 19.85% ⚠️ 109 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
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
app.ts 76.32% ⚠️ 18 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
upgrade.ts 94.74% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 Missing
setup.ts 96.64% ⚠️ 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    76.46%    67.04%    -9.42%
==========================================
  Files           66        97       +31
  Lines         8758     11904     +3146
  Branches         0         0         —
==========================================
+ Hits          6696      7981     +1285
- Misses        2062      3923     +1861
- 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
Add buildCommand wrapper that automatically captures flag values as
telemetry tags (e.g., flag.verbose, flag.no-modify-path). Commands
just need to import buildCommand from lib/command.js instead of
@stricli/core - no other changes needed.

- Add setFlagContext() helper in telemetry.ts
- Add buildCommand wrapper in new lib/command.ts
- Update all 19 commands to use the wrapper
- Use POSIX-style flags in install script (--no-modify-path, --no-completions)
- Add positional args capture via setArgsContext() as Sentry context
- Improve telemetry tests with spyOn to verify actual Sentry.setTag calls
BYK added 3 commits February 9, 2026 11:11
…ricli route map

Walk the route map with getAllEntries() to discover commands, subcommands,
and aliases automatically. No manual maintenance needed when commands change.

Also fixes missing completions for log/list, auth/token, and shortcut
aliases (issues, orgs, projects, logs).
Enable allow-kebab-for-camel in Stricli scanner config so flags like
--no-modify-path work (fixes install script regression).

Add tests for setup command (11 tests, 96% coverage), command wrapper
integration (5 tests exercising actual Stricli run), shell utilities
(GitHub Actions PATH, unknown shells, write failures).
Add property-based tests using fast-check for shell utilities and
completion generation, including a real bash simulation that sources
the generated completion script and verifies COMPREPLY output.

New test files:
- test/lib/shell.property.test.ts (14 property tests)
- test/lib/completions.property.test.ts (12 tests incl. bash sim)

Trim existing unit tests to remove overlap with property tests,
keeping only I/O and dispatch tests in the original files.
@BYK BYK marked this pull request as ready for review February 9, 2026 12:02
@BYK BYK merged commit 2f189e7 into main Feb 9, 2026
27 checks passed
@BYK BYK deleted the feat/install-prefer-local-bin branch February 9, 2026 12:17
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.

Autocomplete commands

1 participant