phar-io / composer-distributor

Distribute PHAR files via Composer
Other
12 stars 2 forks source link

Seperate OperationPackage to validate the PackageEvent is for the configured package #21

Closed marcelthole closed 3 years ago

marcelthole commented 3 years ago

Hey,

i tested some with the captainhook/captainhook-phar and noticed a bug with a fresh install with multiple packages.

For example i have the following composer.json and nothing elese.

  "require": {
    "captainhook/captainhook-phar": "5.8.0",
    "aws/aws-sdk-php": "3.175.3"
  }

after a composer install i noticed multiple file downloads with the wrong version.

Every(?) packages will trigger the installOrUpdateFunction Event and try to install captainhook in the version of the other Package.

In this merge request i seperated the Composer V2 and Composer V1 logic into a OperationPackage to use it in the PackageVersion and the ConfiguredMediator. I tried to run the cs-fixer, but the cs-fixer will change a lot. So i skipped the cs-fixer.

For now every configured package has to use the same packageName in the distributor.xml as the composer package name. If the name differs, the hook is not triggerd and no installation would be made.

In my example, with Captainhook a seperate fix is required to change the package name from packageName="captainhook/captainhook" to packageName="captainhook/captainhook-phar" in the distributor.xml