Problem/Motivation
When using a tool like bower or composer to download the slick library for automated deployments, the library will not be installed into the slick folder as is required by the module. It will be installed into slick-carousel instead.
While it is possible to rewrite this folder after download, this is cumbersome and error prone. It should be possible to use the default download folder for the slick library.
Proposed resolution
The easiest solution would be to just change the folder in the modules libraries.yml to slick-carousel, but that would break existing installations. A solution for installations that use the libraries module would be to check for both folders in hook_library_info_alter().
Comment | File | Size | Author |
---|---|---|---|
#14 | 2855190-13.patch | 863 bytes | maosmurf |
#5 | 2855190-5.patch | 1.07 KB | daniel.bosen |
#2 | 2855190-1.patch | 1.06 KB | daniel.bosen |
Comments
Comment #2
daniel.bosenComment #3
gausarts CreditAttribution: gausarts commentedThank you for the solution.
This had been discussed here: #2792129: bower support
Just a tiny nitpick.
Weight is specified to allow inserting extension between main library and initialization script. Useful if you want to act on slick events which are normally required before Slick is initialized.
We need to bring back weight here.
I need to read more about the better way to handle this other than
hook_library_later()
, but I am putting below for discussion.I am still thinking if we can change the "slick-carousel" into "slick" inside the module's composer.json using the following instruction which requires
composer/installers
:https://getcomposer.org/doc/faqs/how-do-i-install-a-package-to-a-custom-...
As you know, the
{$name}
part is a reference to "slick-carousel" which is globally applied to any package.I haven't tested this, there may be things I am not aware of here, but for just in case you already did:
Does composer allow to hard-code
{$name}
to just "slick", and automatically update the folder name?Aside from that, we already had a good lesson from colorbox here: #2814045: composer.json issue in latest dev and 1.2.0
Thoughts?
Comment #4
daniel.bosenAh, missed the weight earlier, will provide a new patch for this. Adding installer-path to your modules composer.json will not work, since this information is not propagated to the root composer file of the projects using the slick module. So everybody would have to add an appropriate line to its composer.json. This is not very desirable.
But in theory it would be possible for people using drupal project to add somthing like this to their composer.json. But it is a bit more complicated, you need to add the asset-packegist repository, require composer/installers and you schould propably require oomphinc/composer-installers-extender also.
With this prerequisites you can add "web/libraries/slick": ["bower-asset/slick-carousel"] to your installer-paths.
Comment #5
daniel.bosenComment #6
gausarts CreditAttribution: gausarts commentedThank you for valuable info.
I forgot to mention, my question was also based on deprecated CM command. When I run
composer drupal-update
, it merged each module'scomposer.json
intomerge-plugin
of the rootcomposer.json
automatically, trimmed down for sanity:Unfortunately CM was deprecated last January.
This made me think a possibility, but didn't actually investigate further as I need to update Slick
composer.json
at d.o to actually test downloading Slick library in the first place.Based on your info, I am happy to abandon hope for this for now ;)
Please allow some delay to commit this. Thanks again.
Comment #7
daniel.bosenHallo gausarts,
any news on this? Would be super helpful for beeing able to install the module with composer only.
Best regards,
Daniel
Comment #9
gausarts CreditAttribution: gausarts commentedSorry for delay. And thanks for the sweet solution ;)
Comment #10
daniel.bosenNice, thank you! Now how about a new release tag?
Comment #11
gausarts CreditAttribution: gausarts commentedI was planning to release a new tag after my wife's birthday 29/3. I will see if I can do a few clicks sooner ;)
Comment #12
Majdi CreditAttribution: Majdi commented@daniel.bosen I try what you describe in comment #4, But its not working, I think that because composer/installers not required by slick-carousel, so its always downloaded in vendor path
Comment #13
maosmurf CreditAttribution: maosmurf commentedWhile the installation works nicely now, Drupal's status page still complains about missing SlickJS library.
> The Slick library should be installed at /libraries/slick/slick/slick.min.js, or any path supported by libraries.module if installed.
This is due to the fact, that while the actual lookup has a fallback to
libraries_get_path('slick-carousel')
, the functionslick_requirements
is still relying solely onlibraries_get_path('slick')
.?>
This patch applies the previously by @daniel.bosen provided fallback (in
slick_library_info_alter
) tofunction slick_requirements
as well.Comment #14
maosmurf CreditAttribution: maosmurf commentedComment #15
maosmurf CreditAttribution: maosmurf commentedComment #16
gausarts CreditAttribution: gausarts commented@maosmurf, thank you.
This part was fixed. Let's focus here for the side or extra issues:
#2907371: Composer / bower integration? Configurable paths?
Comment #17
ñull CreditAttribution: ñull as a volunteer and commentedSince this is still not fixed in the release, I based my solution on #2855190-4: Using bower or composer to download the slick library is cumbersome. but it turns out a bit more complex than described there. You need:
In your composer.json you need to add inside the extra section:
After that preparation you can:
composer require npm-asset/slick-carousel
... which will then get nicely installed in web/libraries/slick in stead of web/libraries/slick-carousel . I did not try but with bower it should work as well.
Comment #18
candelas CreditAttribution: candelas commented@gausarts is patch in #13 needed? Thanks :)
Comment #19
Marc Angles CreditAttribution: Marc Angles commentedAs far as I can tell this module does not install cleanly on D8.
Why is this issue closed ?
Running composer require drupal/slick does not download the library. And installing the library is still cumbersome...
Comment #20
SerShevchykAdd to key "repositories" in your composer.json :
and then to key "require" add :
After this run "composer install" and then you can find new folder with slick code in your libraries folder. It's not a fix for the bug, but can help you quickly get slick library
Comment #21
gausarts CreditAttribution: gausarts commentedPlease read #3, #6, #21.
Basically consider this:
Hope that clarifies your concern why this was closed ;)
Comment #22
jcmartinezUsing @Shefarik solution #20 I got this message from composer:
To make it work, I had to tweak a bit. I have it working with:
and in the require section, I had to add:
Comment #23
PhilYA little amend to post #22: this is it but don't forget to run
composer update --lock
right after manually editing the composer.json file (this is a general rule not related to Slick).Comment #24
plato1123 CreditAttribution: plato1123 commented#22 worked great for me, nice time saver!
Comment #25
markie CreditAttribution: markie at Kanopi Studios commented#22 works for me. Thanks for the lead.
Comment #26
DamienMcKennaFYI if you have asset-packagist.org added to the composer.json file you can do it even more simply. To set this up, add these pieces to the composer.json file:
Then just do this:
$ composer require bower-asset/slick-carousel
That works for any NPM package, just prefix the npm package name with "bower-asset/".
BTW the version of the Slick library currently available is 1.8.1, not 1.9.0, you can confirm this by downloading https://github.com/kenwheeler/slick/archive/master.zip and looking at the package.json file.
Comment #27
splash112 CreditAttribution: splash112 commented#26 is dependant on composer-installers-extender
Install with:
composer require oomphinc/composer-installers-extender