Manage modules and themes with composer in addons/.#2412
Manage modules and themes with composer in addons/.#2412Daniel-KM wants to merge 26 commits intoomeka:developfrom
Conversation
|
So the idea here is that this allows you to have some modules or themes in the container but also mount a volume and easily have others. Am I understanding that right? I would imagine this will require some work in the AssetUrl helper at least, which makes assumptions about what paths to files inside plugin modules/themes look like. AssetUrl already looks up the actual module and theme objects to get versions so getting their real base path shouldn't be a big deal. I'm not 100% convinced/certain of the actual path though... I feel like keeping the actual modules and themes folders so all their contents are expected to be modules and themes might be best. I could see maybe custom/themes and custom/modules maybe? The connection with composer, I imagine you're thinking to have composer install the modules/themes included in the composer.json into either the "custom" or "regular" path. Which are you thinking? Maybe informs what a good name would be. |
|
In most of my project, i always include major modules (value suggest, custom vocab, easy admin, etc.) and i have one or two custom modules (even if i try now to include all new features in existing modules), and a custom theme, lightly or from scratch. So, yes, the aim is to include common modules inside the container (so upgrade as a whole) and a volume for specific modules and the same for themes. It's important for themes, because users want generally to modify it (even if css editor helps). For the structure, the choice of drupal is three modules/ modules/custom/ modules/contrib/ + hierarchical for sites. For wordpress there are no custom dir. For jommla, there are components, modules and plugins. Symfony and laravel enforce composer, included custom packages. So i proposed to have main modules in /modules/ (the ones that are used anywhere) and the other ones in /modules/custom/, but indeed, it may be /modules_custom/ or custom/modules/ as you say, simpler because all custom are in a specific dir, so one volume to manage. In fact, maybe this pr is too early, and it may be simpler to use composer for all modules (vendor/xxx/yyy/ (mixed)), or vendor/xxx/yyy and vendor/modules/xxx/yyy), so in that cases modules/ will be custom or old modules, but it may hard to override a vendor module. And it may be the same for themes, that are often customized. Inheritance of themes may be useful, but slower. So something to think about. So the aim is to think about that before pr in https://github.com/composer/installers, where you can find a lot of other types and directories for many apps. |
|
Not planning to work on this right away but in the way of notes: I'm not at all set in stone on this but to my current thinking this kind of parallel folder setup could make sense, but I think my preference on loading/names would go something like, the existing modules and themes folders stay for the current method of loading and installation, and have it be Composer-installed ones that use a new path... That feels like it's more likely to offer a smooth upgrade path. Of course, there's more to work out. A separate folder isn't required for composer to work, but might be desirable on its own, particularly for the container-related reasons mentioned in previous comments. There'll also be more process/convention-type stuff to think of: there are options for doing things like merging multiple Composer files, which might be desirable to keep a particular install's list of required addons separate from the core's own requirements; will modules continue to support both installation styles or require installation through Composer, things like that. I'll note here also that we do have a Composer plugin that ships with Omeka S for installing addons: right now it installs to the "normal" folders as that's all there is. Changing where that existing plugin puts things is a good first step for those trying things out in this area. |
3b8aee8 to
299b008
Compare
|
I fully implemented automatic install with composer in the directories addons/modules/ and addons/themes/ and manual install (via unzip or git) in modules/ and themes/, that takes priority when there is duplicate. So now easy to use modules/ and themes/ as volume for a container. And a lot easier to manage Omeka. And side benefits: performance is better during init, since data about modules are stored by composer one time, so no need to load all composer.json and all module.ini and to analyse them all for each request. Only the first commits were needed for the feature, but in practice, there was issues with the overriding mechanism, the module Common, the asset dependencies, and the possibility to continue to manage modules and themes without composer, so there are a lot of commits next to implement/fix these points. There are a lot of tests too (built automatically by my ide), because it is an important core feature. Note: this pull request is fully compatible with current omeka behavior (it was a hard point), so it can be included in 4.2.1, without waiting for 4.3. So the upgrade is very smooth. Another important feature that can be included in 4.2.1 without any impact is the one about roles in config and the one about full jsonSerializing() of representations (only rare modules should be fixed and i can push a pr for them), but it is another subject. I already published the module Common on packagist (https://packagist.org/packages/daniel-km/omeka-s-module-common), because it was a module that caused issues, that are fixed now. Future versions of modules won't have to "require" it, only "use" it, as any module. So module can have dependency: for example, once updated, the module Urify will install the module Value Suggest automatically. Note that on packagist, omeka/omeka-s is already published, but it was declared with type "project" (in composer.json). So it explains the need to use "omeka/omeka-s-core" in modules. I added a readme in addons/readme.md. Last point: i prepared the commit for composer-installers, that has no very original code and that retakes the same code than the internal composer install plugin. So i wait for your confirmation or your comments to publish new modules and composer installer. There are Test Override and Test Override theme too, but only to test the current feature. Note: This feature was funded for the digital library Manioc (back end is omeka s, front end is drupal) of the Université des Antilles (subvention Agence bibliographique de l’enseignement supérieur Abes) and they ask me to indicate it. |
|
It'll be a little bit before I can fully review this. A couple immediate pieces of feedback from my quick look:
Maybe it's clear already, but I'm going to be pretty picky on this one since the dependency stuff generally and the addons are such a key component. More as a side note: we have control now of our "omeka" namespace in Packagist (which for boring reasons we didn't before) so it's more feasible to extract things like the installer composer plugin we have now into an actual separate package. |
|
Thanks for the response. So some quick remarks too:
The feature is done in a way that it does not change anything for current installations and modules for smooth evolution. |
|
|
I removed most of the code (extra keys, common, composer plugins, etc) you what don't want. So remaining in the pr :
The reflexions that remain:
|
|
And for inflexion : in fact, the main name in composer.json can be anything , with any vendor and project name, even if they don't exist and it is not related to the repository, but it is simpler to use the same anywhere and for search on packagist (it lists all omeka-s-module-xxx together). So the choice is between automatic inflexion or manual installer-name. |
When using docker containers, the question to store the modules and the themes in a volume or inside the container is always complex, some projects prefer one way and some other the other way. So the possibility to use a specific directory /modules/custom/ and /themes/custom/ is a good solution to many uses cases. Some other applications choose /modules-custom/ and /themes-custom/ or some other alternatives, but the first seems simpler to understand. This is the solution used by drupal.
Furthermore, this is the first pr to finalize using one single composer for all omeka (composer used to manage modules and themes natively), while keeping old modules compatible.