fxpio / foxy

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

Easy transition from composer-asset-plugin to foxy #8

Closed schmunk42 closed 6 years ago

schmunk42 commented 6 years ago

Could there be a functionality to support cap syntax? Like so...

Maybe even with a mapping for bower-Xyz.js to npm-xyz if needed. (optional)

francoispluchino commented 6 years ago

Extracting the asset dependencies in a package.json file is not complicated in itself. However there are 2 important points that pose a problem:

  1. A conversion of the Composer to NPM versions must be done (therefore a possible risk of bug as for CAP)
  2. Bower is no longer supported, and is not supported in Foxy

For the first problem, we can make a converter, however I do not want to pollute Foxy with this code, so we could have an additional Composer plugin foxy/legacy or foxy/foxy-legacy. This plugin will require Foxy, and will perform the conversion via an event triggered by Foxy.

So to summarize:

  1. Add triggers in Foxy (use the Composer event system)
  2. Create the foxy-legacy plugin to create a package.json file for the NPM dependencies ; throw an exception if Bower packages are found ; and create a converter of range versions in opposition of CAP (Composer to NPM and not NPM to Composer)

PS. This is still not packages.json, but package.json ;-)

francoispluchino commented 6 years ago

I also forgot, that the VCS repositories must be converted in the dependency versions in the package.json file. It's a lot of work for a halftone result (potential bugs and Bower isn't unsupported).

I can already add the triggers in Foxy, which will allow any other plugin to be created, if Foxy does not officially support it.

francoispluchino commented 6 years ago

Foxy events are added by 3f16cd09192a9c455415a6e6b2b2b6e93ea1a27b.

schmunk42 commented 6 years ago

Wow, nice!

This issue can be closed then, please reopen if needed.

francoispluchino commented 6 years ago

Removing NPM dependencies in Composer before the resolution by the Solver SAT may cause problems. I'll look if it's achievable.

francoispluchino commented 6 years ago

It's not possible without a plugin installed in global mode, because the pre-dependencies-solving event is triggered only with the already installed plugins. And even with that, it will be difficult to remove the asset packages. A package mock must be created for each version required during the resolution, and installation operations must be removed after the resolution.