composer-patches icon indicating copy to clipboard operation
composer-patches copied to clipboard

Feature: Add command to generate patches

Open andyexeter opened this issue 2 years ago • 2 comments

It'd be great if there was a way to create patches within this plugin.

There's an NPM package called patch-package which does this in the NPM/Node ecosystem. The way it works is you make changes to the file(s) in the node_modules directory then run a command like:

npx patch-package package-name

The package then performs the following steps:

  1. Downloads the package-name package at the same version in the project's lock file to a temporary directory
  2. Diffs the "clean" package against the version in node_modules and creates a patch file in a patches directory in the project root
  3. Deletes the temporary directory

I was wondering whether there's any scope for doing that within this project? I'd be happy to give it a go and submit a PR but would like some feedback before starting :)

I see it working pretty similarly to the above method, with the addition of adding an entry to the extra.patches object in composer.json

andyexeter avatar Feb 25 '22 12:02 andyexeter

@andyexeter Hi! I've had the exam same feeling as you, and found this package that does exactly like the patch-package: https://github.com/symplify/vendor-patches, it actually uses underneath this package, so all is great! 🥳

Liinkiing avatar Apr 16 '22 03:04 Liinkiing

@Liinkiing Thanks! That package looks awesome. I will keep this issue open for the time being, to see if the maintainer of this package would like this sort of functionality natively.

andyexeter avatar Apr 18 '22 09:04 andyexeter

I'd rather keep this plugin focused on applying patches, rather than generating them.

cweagans avatar Feb 07 '23 22:02 cweagans