bigbite / build-tools

MIT License
6 stars 1 forks source link

Support list mode within install command #80

Open g-elwell opened 1 year ago

g-elwell commented 1 year ago

The feature

Currently, the install command offered by the build tools will recursively run npm install across all projects.

Similar to the build command, this isn't always preferable. For example you may have installed a plugin that was build using the build tools and is detected as a project, but has built assets already.

This has came up for me on a project that has transitioned into a multisite. Originally the build tools were running within the theme directory, but now that multiple themes might exist, it makes sense to run the build tools from the project root.

This project also contains a few plugins that the build tools sees as projects, so we're using list mode to ensure that only the themes are built. Without list support for the install command, we need to rely on navigating through directories to run npm install, and having each install command listed in the ci config.

Alternative approaches

We can hook into the preinstall npm script to run npm install on our themes, e.g:

"preinstall": "(cd themes/parent-theme && npm i) && (cd themes/child-theme && npm i)",

This works well locally and should run in CI too, but if we support 'all projects' mode during install I think we should support 'list' mode too.

In fact, it probably makes sense that the project discovery logic and checks which are currently running within the build command should be extracted and shared to run across all commands.

ampersarnie commented 1 year ago

@g-elwell Absolutely see the need for this. I'll start planning it in for a release.