Thinkmill / manypkg

☔️ An umbrella for your monorepo
MIT License
884 stars 48 forks source link

Feat: add prompt command/option to select a command to run within a package #93

Open emmenko opened 3 years ago

emmenko commented 3 years ago

Hi 👋

Background

In our team we use and rely a lot on the @manypkg/cli for both our open source and private projects.

In one of our private monorepos, there are multiple application packages and we have a custom script that we run from the workspace root to prompt the developer to choose which application to start.

It's pretty simple. In fact we use @manypkg/get-packages to get the list of application names/dirs to be prompted.

Proposal

I think it might make sense to have this option built into the @manypkg/cli, so that other people can also benefit from that.

Essentially the end result would be the same as manypkg run pkg-a start, except that the pkg-a is selected from the prompt options.

Whether it would be a separate command (e.g. prompt) or a flag of the run command, that's up to discussion.

For example:

# Usage: manypkg prompt --match <glob> <script>

manypkg prompt --match @my-scope/* start

? Select the package to run the command "start" from › - Use arrow-keys. Return to submit.
❯   @my-scope/a
    @my-scope/b
    @my-scope/c
    @my-scope/d

or

# Usage: manypkg run <glob> <script> --prompt

manypkg run @my-scope/* start --prompt

? Select the package to run the command "start" from › - Use arrow-keys. Return to submit.
❯   @my-scope/a
    @my-scope/b
    @my-scope/c
    @my-scope/d

If you like the idea and are willing to accept this, I'm happy to contribute with the implementation.

Looking forward to your feedback.