Skip to content

install: collapse dependent bool groups into enums on CommandLineArguments - #36764

Merged
Jarred-Sumner merged 1 commit into
mainfrom
claude/farm/590a68bc/install-options-enums
Aug 2, 2026
Merged

Jarred-Sumner merged 1 commit into
mainfrom
claude/farm/590a68bc/install-options-enums

Conversation

@robobun

@robobun robobun commented Aug 2, 2026 •

Copy link
Copy Markdown
Collaborator

What

Two groups of mutually-exclusive bools on the install CLI types become the enums they already fold into:

Update{development,optional,peer} → DependencyGroup

struct Update on Options was three bools, at most one ever set (via an if/else if cascade), consumed by an identical cascade in updatePackageJSONAndInstall to pick one of dependencies / devDependencies / optionalDependencies / peerDependencies. bun_install_types::DependencyGroup already exists with exactly these four constants and a .prop field carrying the package.json key. The struct is removed, the field becomes DependencyGroup, and the consumer cascade becomes a single .prop read.

silent / quiet / verbose → LogLevel

CommandLineArguments carried three separate bools that Options::load folded into LogLevel via a four-branch cascade. The CLI now stores log_level: LogLevel directly; Options::load just folds in the no-progress bit via the new LogLevel::without_progress().

--silent is checked first in the precedence, so LogLevel::is_silent() is true exactly when --silent was passed. The four callers that previously read cli.silent to suppress summaries/errors (Options::load, bun outdated, bun publish, bun update -i) are routed through is_silent() and behave identically.

Why

Making illegal states unrepresentable: Update{development:true, peer:true} was constructible but meaningless, and there were two parallel encodings of the same four-way choice (Update vs DependencyGroup). Net -16 lines with the cascades gone.

The LogLevel change has one observable effect: previously Output::is_verbose() (set by RUNNER_DEBUG=1 in GitHub Actions) would win over an explicit --silent for the log level, so RUNNER_DEBUG=1 bun install --silent leaked verbose lockfile diagnostics to stderr:

Clean lockfile: 1 packages - 1 packages in 11.8us
No packages! Deleted empty lockfile

while still suppressing the summary. With --silent checked first it is now fully silent, which is what --silent promises.

Verification

  • New test: RUNNER_DEBUG=1 bun install --silent produces no output (fails on main, passes here).
  • bun-add.test.ts (54 tests, covers --dev/--optional/--peer) and bun-pack.test.ts (76 tests, covers --silent) pass unchanged.

no test proof · iteration 0 · Platform-specific test(s) that do not run on this machine. Deferring to CI, which covers all platforms: test/cli/install/bun-install.test.ts

…ments

Replace two groups of mutually-exclusive bools with the enums they
already fold into:

- Update{development,optional,peer} on Options and the matching
  development/optional/peer bools on CommandLineArguments become the
  existing bun_install_types::DependencyGroup. The if/else-if cascades
  that picked exactly one of devDependencies/optionalDependencies/
  peerDependencies/dependencies collapse to a single field read.

- silent/quiet/verbose on CommandLineArguments become LogLevel directly
  (the type Options.log_level already carries). Options::load then just
  folds in the no-progress bit via LogLevel::without_progress() instead
  of a four-branch cascade.

Checking --silent first means LogLevel::is_silent() matches the --silent
flag exactly, so the four callers that previously read cli.silent to
suppress output behave the same. The one observable change is that
--silent now wins over an env-derived verbose (RUNNER_DEBUG=1), so
'bun install --silent' is actually silent there instead of leaking
verbose lockfile diagnostics.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 seconds

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ddfb675e-7046-4e0c-b66f-c109cdb7a641

📥 Commits

Reviewing files that changed from the base of the PR and between 2569ae3 and dcdb1a0.

📒 Files selected for processing (8)
  • src/install/PackageManager/CommandLineArguments.rs
  • src/install/PackageManager/PackageManagerOptions.rs
  • src/install/PackageManager/updatePackageJSONAndInstall.rs
  • src/install_types/resolver_hooks.rs
  • src/runtime/cli/outdated_command.rs
  • src/runtime/cli/publish_command.rs
  • src/runtime/cli/update_interactive_command.rs
  • test/cli/install/bun-install.test.ts

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the claude label Aug 2, 2026

@claude claude Bot left a comment

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.

LGTM — clean refactor collapsing mutually-exclusive bool groups into their existing enums.

What was reviewed:

  • DependencyGroup precedence (dev > optional > peer > dependencies) and .prop values match the removed cascades exactly.
  • LogLevel precedence flip (--silent now beats --verbose/RUNNER_DEBUG) is intentional, documented, and covered by the new test; is_silent() semantics preserved for the four cli.silent callers.
  • Grepped for remaining readers of the removed fields (cli.{silent,quiet,verbose,development,optional,peer}, update.{development,optional,peer}) — none. pack_command reads options.log_level (unaffected).
  • without_progress() + set_verbose_install(is_verbose()) reproduce the old Options::load cascade for all flag combinations except the documented precedence change.
Extended reasoning...

Overview

This PR collapses two groups of mutually-exclusive bools on install CLI types into the enums they already fold into:

  1. CommandLineArguments::{development,optional,peer} and Options::Update{development,optional,peer} → DependencyGroup (an existing type in bun_install_types with .prop carrying the package.json key). The if/else-if cascade in updatePackageJSONAndInstall becomes a single .prop read.
  2. CommandLineArguments::{silent,quiet,verbose} → LogLevel (already the type on Options). Adds LogLevel::is_silent() and ::without_progress(). Options::load now copies cli.log_level and folds in the no-progress bit instead of re-deriving from three bools.

Touches 7 source files (CLI arg parsing, options load, one consumer, three command entry points, and a Default impl on DependencyGroup) plus one new test.

Security risks

None. This is internal representation of CLI flags for bun install and related subcommands. No auth, crypto, network, or untrusted-input parsing paths are affected.

Level of scrutiny

Moderate — mechanical refactor with one intentional user-facing precedence change. I traced both refactors end-to-end:

  • DependencyGroup: The old parse set three independent bools; the old load picked with precedence dev > optional > peer; the old consumer mapped to the same four package.json keys DependencyGroup::{DEV,OPTIONAL,PEER,DEPENDENCIES}.prop carries. The new parse encodes the same precedence directly. Behavior-identical.
  • LogLevel: The precedence changed from verbose > silent > quiet (in Options::load) to silent > verbose > quiet (in parse). This means RUNNER_DEBUG=1 bun install --silent (and explicit --silent --verbose) now yields Silent instead of Verbose. The PR documents this as a fix (silent should mean silent), and adds a test. The four sites that previously read cli.silent directly (Options::load summary gate, outdated, publish, update -i) now call is_silent(); because --silent is checked first, is_silent() is true exactly when --silent was passed — matching the old cli.silent bool. set_verbose_install and without_progress() reproduce the rest of the old cascade.

I grepped src/ for any remaining readers of the removed fields — none. pack_command.rs reads manager.options.log_level == LogLevel::Quiet, which is still populated correctly.

Other factors

  • No CODEOWNERS on these paths.
  • Existing test coverage: PR description reports bun-add.test.ts (--dev/--optional/--peer) and bun-pack.test.ts (--silent/--quiet) pass unchanged.
  • New test asserts the RUNNER_DEBUG + --silent case produces empty stdout/stderr.
  • Net -16 lines, deletes the Update struct entirely (dead after this change).
  • The bug hunter found no issues.

@robobun

robobun commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Self-review probed 30 angles and found no surviving concerns. The existing --dev/--optional/--peer coverage in bun-add.test.ts and the --silent/--quiet coverage in bun-pack.test.ts pass unchanged; the new test is the only one that distinguishes before/after. Waiting on CI.

@Jarred-Sumner
Jarred-Sumner merged commit 7354c5e into main Aug 2, 2026
54 of 55 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the claude/farm/590a68bc/install-options-enums branch August 2, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants