microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.81k stars 592 forks source link

[rush] Feature request: rush run command #3214

Open jonasb opened 2 years ago

jonasb commented 2 years ago

Summary

When writing command line tools, I find it quite easy to forget build the project before running when making incremental changes.

What I would appreciate is a new Rush command (e.g. rush run), which would build before running the provided command.

Details

Example of how it could work:

My compiled tool is/will be at lib/mytool.js. I run rush run node lib/mytool.js (or use a shebang in lib/mytool.js to avoid node).

Rush checks if any project needs to be built (using same logic as rush build --to . to avoid building unrelated projects). I'd prefer if this check was silent, or maybe a small terminal "spinner".

If any projects need to be built, they are built (maybe with more compact logs?).

The command provided to rush run is executed, node lib/mytool.js in this example.

Alternatively, this could be a "silent" flag to "rush build" to avoid some of the logs (especially when no build is performed), but rush build --silent -t . && node lib/mytool.js is quite a mouthful for such a common (for me) use case.

Previously I was using ts-node which ensured that I always ran the latest version of the code the project, but 1) I prefer to compile my code with heft and 2) it has no knowledge of related project in the monorepo that needs to be rebuilt. I guess a heft run could be an option, but it would also not be aware of related projects. Heft already has heft start which is similar, but I don't want to restart my command line tool on code changes.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version?
rushVersion from rush.json?
useWorkspaces from rush.json?
Operating system?
Would you consider contributing a PR?
Node.js version (node -v)?
iclanton commented 2 years ago

We could perhaps add another script alongside common/scripts/install-run.js and common/scripts/install-run-rush.js that installs dependencies, builds, and runs a script. Would you be interested in putting this together?