feat(tools): add Rush monorepo support#176
Conversation
Add Rush monorepo detection and route pnpm agent to use when running inside a Rush workspace. Rush provides as a CLI-compatible wrapper around pnpm, so only the executable name needs to change — no argument construction logic is affected. - Add to BaseOptions - Add with isRushMonorepo() and findRushRoot() - Pre-check for rush.json in getPackageManager() before package-manager-detector - Resolve pnpm executable dynamically in pnpm agent based on options.rush Closes antfu#139
|
Would you like to contribute to package-manager-detector first to make this more generic? Thanks |
Sure! I'll contribute to package-manager-detector first to add Rush support there. One question before I start: currently detect() returns the package manager name as a string. For Rush, we need to signal both "this is pnpm" and "use rush-pnpm as the executable". Would you prefer: A separate export like getAgent() that returns both the package manager and the resolved executable name? |
|
Maybe we could have |
Hi @antfu, I've opened a PR on package-manager-detector as you suggested: antfu-collective/package-manager-detector#75 Added Once it's released, I'll update the node-modules-inspector PR to consume the new version. Let me know if anything needs to be adjusted. |
Description
Closes #139
Add support for Rush monorepos by detecting
rush.jsonand usingrush-pnpmas the executable in the pnpm agent.How it works
Rush provides
rush-pnpm— a transparent wrapper around the user'spnpmbinary that configures it to work within the Rush monorepo.Since
rush-pnpmaccepts the same CLI arguments aspnpm, we onlyneed to swap the executable.
Detection strategy:
package-manager-detector, check forrush.jsonby traversing up fromcwd.options.rush = trueand return'pnpm'as the agent.options.rushand usesrush-pnpminstead ofpnpm.Changes
types/base.ts— Add optionalrush?: booleantoBaseOptionsutils/rush.ts— New module:isRushMonorepo()andfindRushRoot()agent-entry/detect.ts— Pre-check for Rush beforepackage-manager-detectoragents/pnpm/list.ts— Resolve executable dynamically viaresolveExecutable()Notes
rush-pnpmis CLI-compatible withpnpm, sopnpm ls,pnpm root, etc.work identically. No argument construction logic changes.
getCatalogs()returns{}automatically for Rush projects since theydon't have
pnpm-workspace.yaml.Validations