vaimo / composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and composer command for testing/troubleshooting patches.
MIT License
290 stars 41 forks source link

Use proper way to retrieve the Composer version #92

Closed Seldaek closed 2 years ago

Seldaek commented 2 years ago

Fixes https://github.com/vaimo/composer-patches/issues/81

peterjaap commented 2 years ago

@zamoroka while you're merging, can you do this one as well? :)

zamoroka commented 2 years ago

Hi @Seldaek , @peterjaap The \Composer\Composer::getVersion() was introduced in composer 1.8.5 which means that we need to drop support of all previous releases

peterjaap commented 2 years ago

Since 1.8.5 was released in april 2019 and Composer 1 is on it's way out, I'd be perfectly fine with that.

zamoroka commented 2 years ago

@Seldaek could you please add the min composer version in composer.json?

        "composer-plugin-api": "^1.8.5 || ^2.0",
Seldaek commented 2 years ago

There is no way to do this unfortunately as the plugin-api is stuck at 1.1.0 on Composer 1.

Either we require composer-runtime-api: ^1 || ^2 which will force Composer 1.10.6+ or 2.0+, or we leave it as is and probably it'll be fine.

From my stats I see 1-2% of installs coming from Composer versions older than 1.8.5 so I think it's fairly irrelevant, those are unlikely to be updating packages anyway..

zamoroka commented 2 years ago

@Seldaek I think adding

  "composer/composer": ">=1.8.5"

to the "require" section could do the trick

Seldaek commented 2 years ago

Nope this is a bad idea as it'd add composer in the vendor dir, and not actually fix anything. Your options are what I said above, or if you want to absolutely support everything add a method_exists call before using getVersion?

zamoroka commented 2 years ago

ok, let then go with composer-runtime-api: ^1 || ^2 option. Thanks for your comments

Seldaek commented 2 years ago

Yeah I think this makes the most sense, anyone stuck on an old composer will then remain on the previous version of the plugin, no big deal.

Seldaek commented 2 years ago

OK good to go then I think.