fxpio / composer-asset-plugin

NPM/Bower Dependency Manager for Composer
MIT License
893 stars 156 forks source link

Bower not picking up versioned dependency #312

Open MrPetovan opened 6 years ago

MrPetovan commented 6 years ago

Related to #311

Since https://github.com/friendica/friendica already has the npm-asset/jquery:^1.11.4 dependency and we are using the same asset directory for both repositories, I tried importing bower-asset/jquery-2.x to satisfy a new Bower dependency.

However, Bower went on and still installed bower-asset/jquery:^3.3 which overwrote /vendor/asset-folder/jquery.

How can I direct bower to use the versioned dependency for subsequent imports?

It could look something like:

{
    "config": {
        "fxp-asset": {
            "satisfies": {
                "bower-asset/jquery-2.x": "bower-asset/jquery"
            }
        }
    }
}
francoispluchino commented 6 years ago

This is not possible because it's the Solver SAT of the Composer that is responsible to resolve the dependencies, and that the bower-asset/ and npm-asset/ are 2 different vendors.

MrPetovan commented 6 years ago

I believe this is a different question, here the vendors are the same for both sides of the satisfy config clause.

francoispluchino commented 6 years ago

Did you try the resolution section?

MrPetovan commented 6 years ago

I saw it but I don't think it is relevant to my problem.

Expanded explanation:

francoispluchino commented 6 years ago

Ok, I understand better now. I think this may be possible to turn each dependency into another dependency with a map for the conversion. But this map will only be available for the Composer root package.

MrPetovan commented 6 years ago

But this map will only be available for the Composer root package.

What does this mean? Let's take an example:

composer.json:

{
    "require": {
        "fxp/composer-asset-plugin": "~1.3",
        "npm-asset/jquery": "^1",
        "bower-asset/jquery-2.x": "^2",
        "bower-asset/example": "*",
    },
    "config": {
        "fxp-asset": {
            "installer-paths": {
                "npm-asset-library": "vendor/asset",
                "bower-asset-library": "vendor/asset"
            },
            "satisfies": {
                "bower-asset/jquery-2.x": "bower-asset/jquery"
            }
        }
    },
}
francoispluchino commented 6 years ago

Because the config section is only available for the Composer root package. The config section of Composer package is doesn't used if the package is installed in the dependencies. So, you cannot define the map in the library, for this map to be used in the project (root package).

MrPetovan commented 6 years ago

So, would I be able to require bower-asset/example without importing bower-asset/jquery in the above example?

francoispluchino commented 6 years ago

Yes, of course.

MrPetovan commented 6 years ago

Ok, I was just making sure. Thank you so much for the answers!