feat(cli): add bun and bunx command support#2186
Open
danielctc wants to merge 1 commit into
Open
Conversation
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.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
rtk bunandrtk bunxsupport, mirroring the existingnpm/npx/pnpmhandlers.Closes #832. Also addresses #1316, #599, #1735, #1305, #930, #1802, #197.
Why
bunis one of the most common unhandled commands surfaced byrtk discover— on a bun-first projectbun runalone shows ~350 invocations/month — yetnpm,npxandpnpmare all routed. This closes the gap for the Bun ecosystem.How
src/discover/rules.rs) —bun (run|x|test)→rtk bun,bunx …→rtk bunx, bothPackageManager/ 70% like the npm/npx rules.src/cmds/js/bun_cmd.rs) — strips bun'sbun run v…/bun test v…banner and the$ <cmd>echo line (bun's equivalent of npm's> pkg@verboilerplate); collapses blank lines; returnsokwhen nothing remains. Auto-discovered viaautomod.src/main.rs) —Bun/Bunxclap subcommands.Bunxintelligently routestsc/eslint/prisma/next/prettier/playwrightinto the existing specialised filters exactly asNpxdoes; everything else falls through the bunx filter.src/core/tracking.rs) —bun/bunxcategorised underjssortk gainattributes their savings.Design notes
bun buildandbun installare deliberately NOT rewritten —bun buildis bun's bundler andbun installis the installer; neither is a script run, and filtering their output would be surprising. Thebun (run|x|test)pattern scopes the rewrite to script execution only. Tests assert this.runinjection (unlike npm). Because the rewrite only routesbun run|x|test, the bun subcommand is already present in the args — and injectingrunwould wrongly turnbun buildinto a script run.bunxdispatch layer (mirroringnpx) rather than by expanding the per-tool rewrite regexes, to keep the diff focused. Extending those patterns sortk rewrite "bunx tsc"resolves directly tortk tsccan follow if preferred.Tests
8 new tests, all passing:
test_rewrite_bun/test_rewrite_bunx— rewrite mapping, plus negative assertions thatbun build/bun installare left untouched.test_filter_bun_output/test_filter_bun_test_banner/test_filter_bun_output_empty— filter behaviour.cargo fmt --checkandcargo clippyclean.Note: 3 pre-existing
curl_cmdtest failures on the base branch ("bytes total"assertions) are unrelated to this change —curl_cmd.rsis untouched here.