blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

[Feature] Allow to run additional commands in the recipe installer #392

Closed noxify closed 2 years ago

noxify commented 2 years ago

What do you want and why?

This feature request is based on comments in blitz-js/blitz#2905

@beerose explained it very good in the PR:

While runBlitzCommand is a nice improvement, I think runCommand can be useful so that recipes creators have full flexibility. E.g. let's say we have a new recipe adding some library, and as one of the setup steps, users need to run init or something similar. Having runCommand and running init inside of the recipe could be nice.

Possible implementation(s)

I had in mind to implement only something like runBlitzCommand ( Example: builder.runBlitzCommand('prisma migrate') ).

But with the comment from @beerose, I think it's better to implement it more generic via runCommand ( Example: builder.runCommand('blitz prisma migrate') ).

This allows us to run whatever we want - We could also run something like builder.runCommand('rm -rf /') but @beerose commented already to this:

As for the rm -rf — someone should spot it in the review, and this code should never be merged.

Additional context

I'm not sure if there are other ways to run a command from a script as with: https://nodejs.org/api/child_process.html

beerose commented 2 years ago

Thanks for creating this issue! We use cross-spawn package in other places, so that's something we can use here as well.

Would you like to work on that?

noxify commented 2 years ago

If it's not urgent, I can give it a try after my vacation ( 2 weeks ).

beerose commented 2 years ago

Awesome!

noxify commented 2 years ago

Reminder for myself:

Docs to update: