A CLI to to help simplify and streamline development across multiple Bedrock configurations. Easily start and stop configurations, manage composer repositories and view local changes faster using separate main and local composer.json files, and perform other repetitive dev tasks, all with a few simple commands.
🚧 This project is not accepting external contributions (for now) as it is still under active development. Please hold off on submitting pull requests - I will update this message when I'm ready for community input. Thank you for your interest!
- Features
- Requirements
- Installation
- Project Configuration
- Usage
- Available Commands
- Troubleshooting
- Contributing
- License
- Manage your repositories, both local and remote, using separate
composer.jsonandcomposer.local.jsonfiles - Add local plugin and theme repositories to your
composer.local.jsonfile to preview local changes faster and boost development workflows - Check that the local plugin and theme paths were set correctly in your
.envfile - Use a
.brutilsrcfile to track the activecomposer.jsonfile in each config to easily know which changes you're viewing locally, as well as the configuration name and default vendor name for in-house themes and plugins (optional) - Automate other common Docker + Composer workflows like starting, stopping and rebuilding containers, or updating Composer dependencies
jq(this is necessary to modify the composer.local.json when adding local repositories)- Install: use the
brutils initto configure your project to usebrutils. This copies theDockerfile.composerfile to your configuration, which is then used in thedocker-compose.override.ymlfile as seen in Project Configuration below.
- Install: use the
- The name of the configuration should have
bedrockin thedocker-compose.ymlfile for certain commands (eg.start,stop) to work as expected. You can override the container names to each service to thedocker-compose.override.ymlfile usingcontainer_name, if necessary, eg.
# docker-compose.override.yml
php
container_name: my-site-bedrock-php
# ...- Clone this repository to your preferred directory
- Ensure that
brutilshas the correct permissions to be executable:
chmod +x brutils- Set up a symlink to add it to the location of your other CLIs, eg.
ln -s /path/to/brutils /usr/local/bin/brutilsNOTE: If you're already using a CLI named brutils, you can symlink it under another name (eg. br-utils) to avoid conflicts. In case this command doesn't work due to permissions, you can use sudo ln -s instead.
4. Please see Project Configuration to configure each Bedrock configuration to work seamlessly with this tool.
-
Run
brutils initto begin the project configuration. It will prompt you for the configuration name or use the default one shown, and you can set an optional vendor name if working with in-house plugins or themes locally. These are all stored in a.brutilsrcconfiguration file saved in each project root. This command also adds the following files:.env.local: A copy of your.envfile with two additional variables,PLUGINS_PATHandTHEMES_PATH. If this file already exists, it will just add these variables to it. These variables let you take advantage of symlinking and improved development workflow for your plugins and themes. If for some reason these aren't set, you can use the commandbrutils add-pathsto add the variables to the.envfile. After that, you need add the local paths where your plugins and themes are stored respectively.Dockerfile.composer: A modified composer build addingjqto the service.docker-compose.override.yml: An overriding config that merges with thedocker-compose.ymlfile when thedocker composecommand is used. If this file already exists, it won't create a new one, but you will have to add the additional config lines manually. You can reference thetemplates/docker-compose.override.ymlfile to complete the configuration correctly.
-
The
.brutilsrcfile also tracks the current composer file (composer.jsonorcomposer.local.json). This allows you to switch safely between configs in multiple terminals or windows. -
After you run
brutils init, you then need to update your.gitignoreso it doesn't track the following files:
# Docker
# ...
docker-compose.override.yml
Dockerfile.composer
# Composer
# ...
composer.local.*
# Bedrock Utility CLI Variables
.brutilsrcbrutils <command> [options]Most of the commands will only work in a Bedrock configuration from the project root folder.
start: Stop all other running Bedrock configs and start the current onestop: Stop the current Bedrock configrebuild [--full]: Rebuild the current Bedrock config viadocker compose. The optional--fullflag removes all containers and volumes and rebuilds from scratch.cleanup: Remove orphaned Composer containersinstall-local: Runcomposer installoncomposer.local.json. Adds acomposer.local.jsonif not already createduse-local|update-local: Switch tocomposer.local.jsonand update depsadd-local-repo <plugin|theme> <repo-name> [<vendor>]: Adds local theme or plugin repository tocomposer.local.jsonupdate|update-main|use-main <vendor/package>: Switches tocomposer.json. Updates all dependencies if no argument is supplied, or a single dependency if the correct format is supplied.add-paths: AddPLUGINS_PATHandTHEMES_PATHvariables to.env.localcheck-paths: Verify plugin/theme paths are set in.env.localand point to your local pathswhich: Verify whichcomposer.jsonfile is being usedhelp|-h|--help: Show help menu-v|--version: Display plugin version
- PLUGINS_PATH and THEMES_PATH variables not set?
Make sure you have the
.env.localfile with the paths correctly set, and if you already had adocker-compose.override.ymlfile, that it mounts the volumes toPLUGINS_PATHandTHEMES_PATHfornginx,phpandcomposerrespectively. You can reference thetemplates/docker-compose.override.ymlfile to set them properly. - COMPOSER env variable not set?
Make sure
.brutilsrcexists and has the correct value (eg.COMPOSER=composer.local.json) - Local repository not found?
Double-check your plugin/ theme name and path.
brutilsassumes local repos are in the path/opt/plugins/name-of-pluginor/opt/themes/name-of-theme.
This CLI is currently under active development and currently not ready to accept external contributions just yet. Please feel free to explore or use the code, but hold off on submitting issues or pull requests at this time. Thanks for understanding!