Problem/Motivation
When we using composer manager to manage Drupal module packages with composer we does not add explicitly the dependencies of modules into composer.json of application but we should have all packages required by modules on install it.
To assume composer with Dropzonejs we just need to add an composer.json.
Actually we have the following message when we try to user vcs repositories via github too :
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of git@github.com:drupal-media/dropzonejs.git, could not load a package from it.
Proposed resolution
Add correct composer.json on module basis.
Comment | File | Size | Author |
---|---|---|---|
#4 | interdiff-4.txt | 746 bytes | woprrr |
#4 | add_composer_json_to-2853274-4.patch | 1.38 KB | woprrr |
#2 | add_composer_json_to-2853274-2.patch | 1.1 KB | woprrr |
Capture d’écran 2017-02-16 à 15.26.38.png | 214.81 KB | woprrr |
Comments
Comment #2
woprrr CreditAttribution: woprrr at NeoLynk commentedComment #3
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedGreat. There was also a pull request on github. Maybe we can use something from there.
chrfritsch is a maintainer too now, John has not been very active, so I think it's best to put chrfritsch here.
Comment #4
woprrr CreditAttribution: woprrr at NeoLynk commentedHere the fix ;), I don't seen the Github PR it's important for contributor to backport her PR into D.O to prevent these problems but it's not easy... I voluntary immoted the libraries require {} because that can introduces few problems with "custom" composer architectures. The require project are not drupal-library it's impossible to place it onto libraries without explicit extra {installer-path:}, that's the responsabilities to manager to add this, BUT we add suggest package to inform composer users to our requirement that reduce hightly the potential miss-configuration etc... In addition we can user libraries API to download/user sources that it's better to take this responsabilites to maintainer of applications.
I've think another wording for suggest like :
Comment #6
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedCommitted, thanks.
Comment #7
zet CreditAttribution: zet commentedFrom https://getcomposer.org/doc/04-schema.md#suggest :
so the respond.js should not be a suggestion, because it does not "enhance or work well" with this module.
DropzoneJS library is a actually a requirement for this module to function, and this have nothing to do with the fact that installer-path for libraries should need to be setup after from a project root composer.json
A Drupal 8 site should be easily installed and extended with the "composer create-project ..." command and "composer require ...", without the need to go and manually download required libraries. That's the main purpose of composer, if not we could just stick to drush dl.
So when you install the Drupal 8 project with composer and want to add this module,
"composer require drupal/dropzonejs " and "composer update" should be all.
Comment #8
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedI agree and share the same frustration with you, it should be easy.
But in this case we are not dealing with a php lib that lives on packegist, it's a js library that lives on a separate repository. And drush dl didn't support pulling this kind of dependencies either.
There are third party libraries that one can include in the composer file, that then download js dependencies, but I don't think I saw much Drupal projects using them. I would be happy to hear more about that though.
Comment #9
woprrr CreditAttribution: woprrr at NeoLynk commentedYes, I agree too :( I've opted for the better degraded solution with suggest to insitate manager to dl that but that is an requirement... We have same problem in ImageWidgetCrop module and we have avoid that by not add any mention and use by default External CDNJS and if user want purpose a fallback with Libraries module usage. I suposse is that the "Drupal" right way but not verry good for Composer manager :/ We have possibility to "fork" that libraries and add correct type: drupal-library to permit using that ... I didn't see other better solutions :(
Comment #10
zet CreditAttribution: zet commentedSince in this specific case dropzonejs is an integration module for the dropzone.js library, clearly listed as a requirement and linked from the module page to the library/project github page, what I don't understand is why the composer.json file included with the drupal module dropzonejs does not contain something like this:
web/libraries/{$name} is the path that drupal8 project is using.
Then if any distribution wants to include the module in the distribution, the distribution global composer.json should override the module defined "installer-paths" to something like docroot/libraries/{$name} or sites/default/files/libraries/{name} or whatever they desire
Actually the code above is an example from what I included in the Thunder ( https://www.drupal.org/project/thunder ) distribution's main composer.json managing to download the required libraries without nodejs, npm and bower. I guess the distribution is using nodejs, npm and bower to download them ( correct me if I'm wrong)