Skip to content

feat(discover): rewrite bunx prisma → rtk prisma#2005

Open
YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:feat/bunx-prisma-rewrite
Open

feat(discover): rewrite bunx prisma → rtk prisma#2005
YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:feat/bunx-prisma-rewrite

Conversation

@YOMXXX
Copy link
Copy Markdown
Contributor

@YOMXXX YOMXXX commented May 21, 2026

Summary

Bun is the primary JS runtime on a growing share of Prisma projects. `bunx prisma ` is semantically equivalent to `npx prisma ` — same CLI, same output format, same subcommands — but the hook didn't recognise it, so the reporter's 45 monthly `bunx prisma` invocations (#1401) were flowing through the Bash hook completely unfiltered.

Fix

One `RtkRule` change in `src/discover/rules.rs`:

```diff

  • pattern: r"^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx)\s+)?prisma",
  • pattern: r"^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx|bunx)\s+)?prisma",
    rtk_cmd: "rtk prisma",
    rewrite_prefixes: &[
  •    "bunx prisma",
       "npm exec prisma",
       …
    
    ],
    ```

No new output-filtering logic — the entire Bun-Prisma stack goes through the same `src/cmds/js/prisma_cmd.rs` handler as npx/pnpm/npm; only the rewrite recognition was missing.

Behaviour

Input After
`bunx prisma migrate dev` `rtk prisma migrate dev`
`bunx prisma migrate dev --name add_col` `rtk prisma migrate dev --name add_col`
`bunx prisma migrate deploy` `rtk prisma migrate deploy`
`bunx prisma migrate status` `rtk prisma migrate status`
`bunx prisma generate` `rtk prisma generate`
`bunx prisma db seed` `rtk prisma db seed`
`bunx prisma studio` `rtk prisma studio`

`npx prisma` / `pnpm prisma` / `pnpm dlx prisma` continue to work exactly as before — same rule, just one more alternation branch.

Scope notes

  • This PR is intentionally narrow: it only adds `bunx` to the existing Prisma rule. Other `bun` runner forms (`bun x`, `bun run`, bare `bun prisma`) are not covered here; if usage data shows they matter we can extend the alternation in a follow-up.
  • Other RTK-handled binaries that ship as `bunx ` (vitest, playwright, tsc, prettier, biome, jest, eslint…) are out of scope. The reporter only flagged Prisma — happy to do a sweep in a separate PR if maintainers want broad bun adoption.

Test plan

  • `test_classify_prisma` and `test_rewrite_prisma` extended with `bunx prisma` (locks the invariant fence per runner).
  • New `test_rewrite_bunx_prisma_subcommands` covers the six subcommand shapes the reporter named.
  • `cargo fmt --all` clean.
  • `cargo clippy --all-targets` zero warnings.
  • `cargo test --bin rtk -- --test-threads=8` → 1910 passed.

Fixes #1401

Bun is now the primary JS runtime on a growing share of Prisma projects.
`bunx prisma <sub>` is semantically equivalent to `npx prisma <sub>` —
same CLI, same output format, same subcommands — but the hook didn't
recognise it, so 45+ monthly invocations per reporter were flowing
through the Bash hook completely unfiltered.

Add `bunx` to the existing Prisma `RtkRule`:

- Regex pattern: insert `|bunx` into the runner alternation so
  `bunx prisma …` classifies as `Supported(rtk prisma)`.
- `rewrite_prefixes`: add `"bunx prisma"` so the rewrite path produces
  `rtk prisma …` and main.rs's filter dispatch picks up the existing
  `src/cmds/js/prisma_cmd.rs` handler unchanged.

No new output-filtering logic is needed — the entire Bun-Prisma stack
goes through the same code path as npx/pnpm/npm; only the rewrite
recognition was missing.

Tests:
- Extend `test_classify_prisma` and `test_rewrite_prisma` with
  `bunx prisma` so the same per-runner invariant fence guards bun.
- Add `test_rewrite_bunx_prisma_subcommands` covering the six surface
  shapes the reporter calls out (`migrate dev`, `migrate dev --name …`,
  `migrate deploy`, `migrate status`, `generate`, `db seed`, `studio`).
  Pins the regex against a future tweak that silently drops one shape.

cargo fmt / clippy --all-targets / test --bin rtk: 1910 passed,
0 warnings.

Fixes rtk-ai#1401
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: rewrite bunx prisma → rtk prisma (bun runner for Prisma CLI)

1 participant