Skip to content

fix: expand npm rewrite rule to route install, ci, test, and other subcommands - #1204

Open
MehmetGoekce wants to merge 1 commit into
rtk-ai:developfrom
MehmetGoekce:fix/npm-rewrite-subcommands
Open

MehmetGoekce wants to merge 1 commit into
rtk-ai:developfrom
MehmetGoekce:fix/npm-rewrite-subcommands

Conversation

@MehmetGoekce

Copy link
Copy Markdown

Summary

Fixes #1148

  • The npm rule in rules.rs only matched run|exec, so npm install, npm ci, npm test etc. bypassed RTK entirely
  • The filter in npm_cmd.rs already handles all subcommands — this fix routes them there
  • Adds: install, i, ci, uninstall, remove, update, list, ls, outdated, audit, test, t, start
  • Matches pnpm parity (which already routes list|ls|outdated|install)

Intentionally NOT included

  • whoami, ping, version, prefix, root, bin — one-line output, no meaningful savings
  • login, logout, adduser, init, create — interactive commands
  • help — should never be filtered

Test plan

  • 5 new unit tests in registry.rs (install, install+package, ci, test, run regression)
  • Full test suite: 1355 passed, 0 failed
  • Manual smoke test: rtk rewrite "npm install" → rtk npm install (exit 0)
  • Regression: rtk rewrite "npm run build" still works
  • Negative: rtk rewrite "npm whoami" → exit 1 (correctly unmatched)

@CLAassistant

CLAassistant commented Apr 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hey! Thanks for the fix.

We've moved to a develop branch as the default target for PRs — master is now reserved for releases. Could you retarget this PR to develop?

You can do it via the PR UI (Edit → change base branch) or with:

gh pr edit --base develop

See CONTRIBUTING.md for the workflow.

@MehmetGoekce
MehmetGoekce force-pushed the fix/npm-rewrite-subcommands branch from 712d3e0 to b4119a1 Compare April 13, 2026 11:54
@MehmetGoekce
MehmetGoekce changed the base branch from master to develop April 13, 2026 11:54
@MehmetGoekce

Copy link
Copy Markdown
Author

Thanks for the heads-up! Retargeted to develop and rebased onto the latest upstream/develop so the diff only contains the fix. Happy to address any review feedback.

@MehmetGoekce
MehmetGoekce force-pushed the fix/npm-rewrite-subcommands branch from b4119a1 to cd902f6 Compare April 15, 2026 07:59
@MehmetGoekce

Copy link
Copy Markdown
Author

Rebased onto upstream/develop to resolve the conflict with bab3a53 (feat(discover): handle more npm/npx/pnpm/pnpx patterns).

The npm rule now merges both pattern sets and preserves the fix for #1148:

^npm\s+(audit|ci|exec|i|install|list|ls|outdated|remove|run|run-script|rum|start|t|test|uninstall|update|urn|x)(\s|$)

Two notes on the resolution:

  • Alternatives were consolidated and alphabetized.
  • The trailing \s+ was changed to (\s|$) so standalone subcommands like npm ci, npm install, npm test still match (they have no trailing whitespace when invoked bare).

All 1454 tests pass locally, including the 5 new ones for #1148. Diff against develop is down to 2 files (rules.rs + registry.rs).

@MehmetGoekce
MehmetGoekce force-pushed the fix/npm-rewrite-subcommands branch from cd902f6 to e0c0666 Compare April 26, 2026 07:59
@MehmetGoekce

Copy link
Copy Markdown
Author

Rebased onto current upstream/develop (78 commits since the last rebase).

Two upstream commits touched the same area:

  • 5e84e94 — fix(npm): regex match end line independently picked up the \s+ → (\s|$) boundary fix, but only for the run/exec aliases. The actual subcommands from bug: npm rule in rewrite registry misses install — filter already exists in npm_cmd.rs #1148 (install, ci, test, audit, etc.) are still missing from the pattern, so the issue remains open without this PR.
  • 7e3690a — added test_rewrite_npm_bare_subcommand and test_rewrite_npm_with_args covering the aliases. Both upstream tests are preserved on top of the five subcommand tests this PR introduces.

Final diff is unchanged in shape: 2 files (rules.rs + registry.rs), +41/-1. Local cargo test reports 1687 passed, 6 ignored. cargo fmt --check clean.

@MehmetGoekce

Copy link
Copy Markdown
Author

Friendly ping 🙂 — this PR picked up a fresh conflict in registry.rs after ~283 commits landed on develop. I've prepared the rebase locally and it's clean: conflict resolved additively (upstream's Gradle tests + my npm-coverage tests both kept), adapted to the new 3-arg rewrite_command signature, cargo fmt --check clean, 2077 passed / 0 failed. Final diff is unchanged in shape — 2 files (rules.rs + registry.rs), +43/-1. #1148 is still open and no competing PR has merged.

Before I force-push: is this in the review queue for an upcoming version branch? Happy to keep it current — I'd just like to avoid another stale-rebase cycle before it can be looked at.

@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 7, 2026
@MehmetGoekce
MehmetGoekce force-pushed the fix/npm-rewrite-subcommands branch from e0c0666 to 3ba887a Compare September 12, 2026 18:47
…bcommands

The npm rule only matched `run|exec`, so `npm install`, `npm ci`,
`npm test` etc. bypassed RTK entirely. The filter in npm_cmd.rs
already handles all subcommands — this fix routes them there.

Adds: install, i, ci, uninstall, remove, update, list, ls, outdated,
audit, test, t, start — matching pnpm parity and NPM_SUBCOMMANDS.

Fixes rtk-ai#1148
@MehmetGoekce
MehmetGoekce force-pushed the fix/npm-rewrite-subcommands branch from 3ba887a to c8fd21c Compare September 13, 2026 07:32
@MehmetGoekce

Copy link
Copy Markdown
Author

Still relevant — rebased onto current `develop` (868 commits since the last update) and pushed a fresh, conflict-free diff. Tests: 3542 passed / 0 failed / 8 ignored, `cargo fmt --check` clean. Diff shape unchanged: 2 files (`rules.rs` + `registry.rs`), +43/-1.

Note on the linked issue: #1148 was closed as a duplicate of #3671, which describes the same gap (bare `npm install`/`ci`/`test`/`audit` still fall through to the narrow `exec|run|run-script|rum|urn|x` pattern on current `develop`) — this PR still fixes 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.

bug: npm rule in rewrite registry misses install — filter already exists in npm_cmd.rs

3 participants