mbtproject / mbt

The most flexible build tool for monorepo
https://github.com/mbtproject
Apache License 2.0
219 stars 35 forks source link

Add "default command" behavior #112

Open sergey-ostapenko opened 6 years ago

sergey-ostapenko commented 6 years ago

It will be great to add default command handler into mbt configs, with possibility to determine name of command invoked:

name: UniversalCommandModule
commands:
  default:
    cmd: sh
    args: 
      - "$MBT_REPO_PATH/scripts/$MBT_COMMAND_NAME.sh"

Acting like that you will be able to add commands without changes in config files. You just need to add new script to the correct location, and that's it. Even if your projects are not unified, you still can use default command to handle missing commands in your way.

buddhike commented 6 years ago

Thanks @sergey-ostapenko

Whilst I was working on the first implementation of run-in command, I thought about making it more general purpose like this:

mbt run-in branch ./custom.sh arg1 arg2 arg3
mbt run-in commit <sha> npm run blah
...

That way, you could run any executable without needing to change the spec files. This would be very convenient to the user. However, you loose the visibility in the version control system. I wonder if this proposal would fall into the same category.

What do you think?

sergey-ostapenko commented 6 years ago

@buddyspike Yes, I think it will work great when you have set of very very similar projects. The only difference here - you cannot alter command behavior for special cases. Let's consider the following workflow:

1) You running the command mbt run-in branch --command test 2) If such command is defined, the step will be executed according to the configuration. 3) If command is not defined and there is default command handler - it will be used. 4) If no command and no default handler - command will be reported as skipped for the module.

Also it is not true that we will lose possibility to track changes in source control: script files along with build configurations will be more than enough to track the history.