- Issue created by @juagarc4
- π¨πSwitzerland juagarc4
juagarc4 β changed the visibility of the branch 3.x to hidden.
- Merge request !7fix: library wrong referenced if installed with composer β (Merged) created by juagarc4
- Status changed to Needs review
9 months ago 6:11pm 15 March 2024 - π©πͺGermany sascha_meissner Planet earth
Hey juagarc4,
thank you so much for reporting and working on this issue!I looked into this and actually it looks like different repository than suggested in the readme of this module.
This module is shipped with a composer.libraries.json which will contain the expected librarye.g.:
```
"kiprotect.klaro": {
"type": "package",
"package": {
"name": "kiprotect/klaro",
"type": "drupal-library",
"version": "0.7.18",
"dist": {
"url": "https://github.com/kiprotect/klaro/archive/v0.7.18.zip",
"type": "zip"
}
}
}
```But it seems that klaro has changed itΒ΄s github structure and also the library name, still the shipped snippet above still is working.
I will checkout how to continue on this, but if changing the library path would be the solution one would also have to think about all existent installations where the library will not be able to be loaded anymore because the path is wrong for them :/ - π¨πSwitzerland juagarc4
Hi sascha_meissner,
Sorry, I didn't see the composer.libraries.json. But this explains now why the library was not downloaded as I installed the module the first time.
I suppose the composer.libraries.json is being merged with composer.json by means of "wikimedia/composer-merge-plugin" but I can't see the corresponding "merge-plugin" configuration in composer.json.
Since the Drupal core itself is not using this approach anymore since version 8.8 and Klaro supports Drupal 9+, does it make sense to continue using it here?
https://www.drupal.org/node/3069730 βI would suggest to add the required library repository and its reference in the composer.json and remove the composer.libraries.json.
Would it be possible?It will work for new installations and for updates. But I'm not sure how the old library can be removed from system. Will it be removed by the update of the new version of the module or would it require a manual action of the user?
- Status changed to Needs work
9 months ago 6:54pm 18 March 2024 - π©πͺGermany sascha_meissner Planet earth
@juagarc4 Thank you for your input and your suggestions, iΒ΄d say it would make perfectly sense to adapt to the latest guide on "managing dependencies for a custom project" i wasnt up to date on this development, we just added the merge-plugin approach for convenience, if i remeber correctly we did so because webform plugin did it like this. And yes this requires to manually include the composer.libraries.json into your root composer.json TBH in our own projects we use a custom scaffold that will only put the two required dist/js and css files into libraries/klaro because we think its not the best practice to have the "whole library" inlcuding example pages and so on publicly within libraries folder when you just need the built files, this probably led to the decision not to force anyone in using a specific way on how to put the files into where they are expected. I will continue on this tomorrow and check with my collegues what they think!
- π¨πSwitzerland juagarc4
Hi sascha_meissner,
Thanks for considering my proposal.
I'm agree with you regarding "not to force anyone in using a specific way on how to put the files into where they are expected".
For this reason you can use only a composer.json with the reference to the repository and then use a section "suggest" to inform the users about the required libraries to be installed. It's a less intrusive way to let them know that it's important and at the same time let them the freedom to install it however they want.I updated the MR with these changes. You can take a look and decide if it is an option for you.
In this way the file composer.libraries.yml is only for BC reasons needed. -
sascha_meissner β
committed 43459bd8 on 3.x
Issue #3428601 add backwards compatibility for old library package-name
-
sascha_meissner β
committed 43459bd8 on 3.x
-
sascha_meissner β
committed 96726bf4 on 3.x
Issue #3428601 update contents of composer.libraries.json
-
sascha_meissner β
committed 96726bf4 on 3.x
- π©πͺGermany sascha_meissner Planet earth
Hey juagarc4,
thanks for your update! i added hook_library_info_alter that grants compatibility for both installations, e.g it will work if installed in libraries/klaro or libraries/klaro-js, also added a watchdog message if none of them are found. + i updated the contents of composer.libraries.json with the new package so there is also backwards compatibility if anyone already included the composer.libraries.json in their root composer.json
i accidently pushed (also your commits) to 3.x of origin, but iΒ΄d say its a happy accident because i wanted to keep your changes anyway ;)
So i want to update the Readme a little bit when there is an opportunity and test a little bit and then it should be part of the next release :-) - π¨πSwitzerland juagarc4
Hi sascha_meissner,
don't worry. it's ok for me. I'm glad to have been helpful :-).
I change then the status to "fixed" if you don't have anything against.
- Status changed to Fixed
9 months ago 6:18pm 20 March 2024 Automatically closed - issue fixed for 2 weeks with no activity.