elgentos / magento2-composer-quality-patches
Converts Magento's Quality Patches to a JSON format to be used with vaimo/composer-patches
Installs: 14 431
Dependents: 0
Suggesters: 0
Security: 0
Stars: 21
Watchers: 3
Forks: 2
Open Issues: 1
Type:magento2-module
Requires
- magento/magento-composer-installer: *
- magento/quality-patches: ^1.1.14
- vaimo/composer-patches: *
This package is auto-updated.
Last update: 2022-12-01 00:16:17 UTC
README
This extension adds one command: bin/magento elgentos:quality-patches:convert
It generates a composer.quality-patches.json
file to use with the vaimo/composer-patches
package. It will also add that file to composer.json
when it hasn't been set yet, and add a post-update-cmd hook to automatically update the patches file.
This depends on magento/quality-patches
and vaimo/composer-patches
.
Some patches will give a "Hmm... Ignoring the trailing garbage." warnings, causing the patch to fail. There are two ways to handle this;
- Add this to your
composer.json
to let patches fail without stopping the patching:
{ "extra": { "patcher": { "graceful": true } } }
- Add this to your post-install-cmd to fix the double new lines and run the patcher again:
{ "scripts": { "post-install-cmd": [ "# Remove double new lines from patches to make vaimo/composer-patches process them correctly", "find vendor/magento/quality-patches -type f -name '*.patch' -exec sed --in-place -e :a -e '/^\\n*$/{$d;N;};/\\n$/ba' {} \\;", "# Now run patch:apply again to apply the patches and use --no-scripts to avoid an infinite loop", "composer2 patch:apply --no-scripts" ] } }
We prefer option 2 because when using option 1, other patches that fail for other reasons will not stop our deployment.
Install & Usage
composer require elgentos/magento2-composer-quality-patches bin/magento s:up bin/magento elgentos:quality-patches:convert composer patch:apply
Alternative method of automatically applying patches
composer require magento/quality-patches
- Add this to your
composer.json
;
{ "scripts": { "post-install-cmd": [ "./vendor/bin/magento-patches status | grep 'Not applied' | cut -d ' ' -f2 | xargs --no-run-if-empty ./vendor/bin/magento-patches apply" ] } }