This is a set of tools for developing Drupal contrib modules and themes in the context of a project.
This is a Composer command which switches a Drupal module from being installed normally to using a git clone that is symlinked into the project.
This allows testing and developing a contrib module in the context of a project.
For example, suppose your Widgets.Com website is using the drupal_cats module, but you have found a bug in it. You can make changes to the drupal_cats module files, but they are not under version control, so you cannot make a MR on drupal.org from them. You could copy them to a separate git clone of drupal_cats, but that quickly becomes tedious with multiple files. Furthermore, your project's installed copy of drupal_cats is at a fixed release (hopefully!), and the code you want to fix may have changed in the latest HEAD.
The Switch to clone command makes this all simple to do:
composer drupal-contrib:switch-clone drupal_cats
. This does the
following:
When your fix is ready, remove the 'drupal_cats' path repository from your
composer.json, and do composer update drupal/drupal_cats
to switch your
project back to using the distribution version of the drupal/drupal_cats
package.
If you need to perform any Composer operations in the meantime, you may need to temporarily switch the git repository to the main development branch or the release tag where it was checked out to begin with, in order to satisfy Composer's package version requirements.
This is a Composer command which switches a Drupal module from being installed as a symlink to a git clone, to be being installed normally from a package release.
Use this command to reverse the effect of the composer drupal-contrib:switch-clone
command, and restore your project's usage of the
module to normal operation.
composer drupal-contrib:switch-package drupal_cats
. This does the
following:
The git repository for the module is not changed or deleted. You can change back
to using this with the drupal-contrib:switch-clone
command.
This is a Composer command which applies your work in a module's git clone to the project as a patch.
Use this when you have finished work on a bug or a feature in a contrib module, and want to apply this fix to your project's codebase. The diff from a drupal.org merge request is not always suitable in this scenario, as the merge request will be on the development branch of the module, and the diff for this might not apply to the version that your project it using. Instead, this command takes a diff from the feature branch to the release that your project has installed.
This requires the project to have the cweagans/composer-patches
package
installed.
composer drupal-contrib:apply-patch-from-branch drupal_cats
. This does
the following:
You should also contribute your fix back to drupal.org as a merge request!
Install with Composer:
composer require joachim-n/drupal-project-contrib-development