fxpio / foxy

A fast, reliable, and secure NPM/Yarn/pnpm bridge for Composer
https://foxypkg.com
MIT License
173 stars 21 forks source link

Support Composer 2 #33

Closed samdark closed 4 years ago

samdark commented 4 years ago

composer-plugin-api for upcoming Composer 2 (can be installed with composer self-update --snapshot) has version 2.0.0.

The foxy/foxy package requires composer-plugin-api version 1.0.0 thus can't be used with Composer 2.

francoispluchino commented 4 years ago

I have not yet had the opportunity to look in more detail the version 2.0 of Composer. Is it just a matter of version constraint? Or, are there more problematic changes for this plugin?

cebe commented 4 years ago

The interface has changed, see https://github.com/composer/composer/blob/master/UPGRADE-2.0.md#upgrades-guides-for-composer-1x-to-20

samdark commented 4 years ago

Looks like the following would work:

  1. Change constraint in composer.json. "composer-plugin-api": "^1.0|^2.0",
  2. In the Foxy class add two dummy methods:

    public function deactivate(Composer $composer, IOInterface $io): void
    {
        // do nothing
    }
    
    public function uninstall(Composer $composer, IOInterface $io): void
    {
      // do nothing
    }
  3. You may do cleanup in deactivate and uninstall but it doesn't seem to be necessary for the plugin to just work as before.
  4. There could be extras...
francoispluchino commented 4 years ago

@samdark Thank you! I will try to find some time this weekend to test the compatibility with Composer v2.

francoispluchino commented 4 years ago

Compatibility added by b7473e7cc79080b6369e2e5c161a43f814088f82.

samdark commented 4 years ago

Interesting. Composer 2 fails to install it:

Loading composer repositories with package information
Updating dependencies
Lock file operations: 47 installs, 0 updates, 0 removals
   ...
  - Locking foxy/foxy (dev-master 7efd3d1)
   ...
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 47 installs, 0 updates, 0 removals
  - Installing foxy/foxy (dev-master 7efd3d1): Extracting archive
Plugin initialization failed (Invalid version string "d173af2d7ac1408655df2cf6670ea0262e06d137"), uninstalling plugin
  - Removing foxy/foxy (dev-master 7efd3d1)
    Install of foxy/foxy failed
samdark commented 4 years ago

You can try with https://github.com/yiisoft/yii-bootstrap4

francoispluchino commented 4 years ago

Sure enough, I also get this error now.

francoispluchino commented 4 years ago

My test was with the master branch and not with a compiled version of Composer. This comes from checking the version of Composer which is a SHA1 and not @package_version@ for the snapshots.

I add this case right away.

francoispluchino commented 4 years ago

Compatibility with Composer snapshots added by 201420a5aac203de7e7e87e620fe5e046cca78c8.

samdark commented 4 years ago

Works now. Thank you!