In order to provide better separation and management of custom dependencies and patches, we've introduced two new files:
custom-dependencies/composer.json
: For managing custom dependenciescustom-dependecies/patches.custom.json
: For managing Drupal patches
These changes allow for better organization and separation of concerns within the project. By isolating custom dependencies and patches in separate files, it reduces the likelihood of merge conflicts when updating the upstream and provides a clearer structure for managing project-specific dependencies and patches. By following the guidelines introduced below, you'll ensure a consistent and organized approach to managing your custom dependencies and patches within your project.
- Locate the
custom-dependencies/composer.json
file in the project. - Remove all custom dependencies out of the root
composer.json
file, and move them intocustom-dependencies/composer.json
. - Add, update, or remove custom dependencies from the "require" section of the
custom-dependencies/composer.json
file as needed.
- Locate the
custom-dependencies/patches.custom.json
file in the project. - Remove all custom patches out of the root
composer.json
file, and move them intocustom-dependencies/patches.custom.json
. - Add, update, or remove patches in the
custom-dependencies/patches.custom.json
file as needed.
Example of what the patches.custom.json file contents would look like with a single patch:
{
"drupal/image_widget_crop": {
"#2865396: Provide option to apply default crop if user doesn't select any": "https://www.drupal.org/files/issues/2022-06-23/2865396-67.patch"
}
}
To manage your custom dependencies and patches moving forward, follow these steps:
- Make changes to the
custom-dependencies/composer.json
file as needed. - Run
composer update
to apply the changes to your project.
- Make changes to the
custom-dependencies/patches.custom.json
file as needed. - Run
composer update
to apply the patches to your project.
In order to simplify the process of adding custom dependencies and to maintain the separation between the upstream and custom dependencies, we've introduced a new Composer command called custom-require
. This command adds the specified package to the custom-dependencies/composer.json
file and updates the dependencies in the custom-dependencies
directory.
The custom-require
command ensures that users can easily add custom dependencies without directly modifying the root composer.json
file. It reduces the chances of merge conflicts and provides a seamless experience for managing custom dependencies.
To add a new dependency, run the following commands from the project root:
composer custom-require <package>
composer update
Similar to the custom-require
command to add dependencies, we have also added a custom-remove
command to remove those dependencies.
To remove a dependency from your custom-dependencies/composer.json
file, run the following commands from the project root:
composer custom-remove <package>
composer update
The standard composer require
and composer remove
commands will still work, however we HIGHLY recommend that you try not to use them. In a future update, we may need to edit the root composer.json
file, which puts you in danger of a nasty merge conflict.