Skip to content

feat(cli): add bun and bunx command support#2186

Open
danielctc wants to merge 1 commit into
rtk-ai:developfrom
danielctc:feat/bun-bunx-support
Open

feat(cli): add bun and bunx command support#2186
danielctc wants to merge 1 commit into
rtk-ai:developfrom
danielctc:feat/bun-bunx-support

Conversation

@danielctc
Copy link
Copy Markdown

What

Adds rtk bun and rtk bunx support, mirroring the existing npm/npx/pnpm handlers.

Closes #832. Also addresses #1316, #599, #1735, #1305, #930, #1802, #197.

Why

bun is one of the most common unhandled commands surfaced by rtk discover — on a bun-first project bun run alone shows ~350 invocations/month — yet npm, npx and pnpm are all routed. This closes the gap for the Bun ecosystem.

How

  • Rewrite rules (src/discover/rules.rs) — bun (run|x|test)rtk bun, bunx …rtk bunx, both PackageManager / 70% like the npm/npx rules.
  • Filter (src/cmds/js/bun_cmd.rs) — strips bun's bun run v… / bun test v… banner and the $ <cmd> echo line (bun's equivalent of npm's > pkg@ver boilerplate); collapses blank lines; returns ok when nothing remains. Auto-discovered via automod.
  • Dispatch (src/main.rs) — Bun/Bunx clap subcommands. Bunx intelligently routes tsc/eslint/prisma/next/prettier/playwright into the existing specialised filters exactly as Npx does; everything else falls through the bunx filter.
  • Telemetry (src/core/tracking.rs) — bun/bunx categorised under js so rtk gain attributes their savings.
  • Docs — README Package Managers section.

Design notes

  • bun build and bun install are deliberately NOT rewrittenbun build is bun's bundler and bun install is the installer; neither is a script run, and filtering their output would be surprising. The bun (run|x|test) pattern scopes the rewrite to script execution only. Tests assert this.
  • No run injection (unlike npm). Because the rewrite only routes bun run|x|test, the bun subcommand is already present in the args — and injecting run would wrongly turn bun build into a script run.
  • Smart-routing is done at the bunx dispatch layer (mirroring npx) rather than by expanding the per-tool rewrite regexes, to keep the diff focused. Extending those patterns so rtk rewrite "bunx tsc" resolves directly to rtk tsc can follow if preferred.

Tests

8 new tests, all passing:

  • test_rewrite_bun / test_rewrite_bunx — rewrite mapping, plus negative assertions that bun build / bun install are left untouched.
  • test_filter_bun_output / test_filter_bun_test_banner / test_filter_bun_output_empty — filter behaviour.

cargo fmt --check and cargo clippy clean.

Note: 3 pre-existing curl_cmd test failures on the base branch ("bytes total" assertions) are unrelated to this change — curl_cmd.rs is untouched here.

bun is among the most common unhandled commands in `rtk discover`
(bun run alone shows ~350 invocations/month on bun-first projects),
yet npm, npx and pnpm are all routed. Add bun/bunx rewrite rules, a
bun output filter that strips the `bun run v…` banner and the
`$ <cmd>` echo line, and bunx intelligent routing into the existing
tsc/eslint/prisma/next/prettier/playwright filters, mirroring the npx
handler.

bun build and bun install are deliberately left unrouted so bundler
and installer output is never altered.
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

feat: add Bun runtime support (bun test, bun run, bunx)

2 participants