webimpress / composer-extra-dependency

Composer plugin to require extra dependencies
BSD 2-Clause "Simplified" License
11 stars 2 forks source link

Added functionality to choose one dependency from the list #8

Open michalbundyra opened 6 years ago

michalbundyra commented 6 years ago

New feature. Now we can define list of dependencies and give user a choice which one should be installed. In case your library is compatible with many libraries, and you want force user to choose one of them and give them a list of supported libraries to choose. Configuration for this new feature is the following (extra section in composer.json):

    "extra": {
        "dependency-or": {
            "Question": [
                "package/to-choose",
                "package/or-this",
                ...
            ]
        }
    }

And user on composer update will be prompted with "Question" and list of packages:

Question
  [0] package/to-choose
  [1] package/or-this
  Make your selection: ...

User will be prompted only when none of these packages are not installed. If there is at least one package installed or defined in root composer user will be not prompted.

/cc @basz @weierophinney

michalbundyra commented 6 years ago

@basz the plugin before also looks for installed dependencies, not only these defined in root composer. If installed package has been found it was just added into root composer.

Change in this PR provide functionality to choose between packages to install (and as you know - I'm going to use it in http-middleware-compatibility to allow choose between http-middleware and http-server-middleware).