contao / manager-bundle

[READ-ONLY] Contao Manager Bundle
GNU Lesser General Public License v3.0
17 stars 10 forks source link

Run composer scripts #82

Closed patrickjDE closed 6 years ago

patrickjDE commented 6 years ago

Not sure if this belongs here or into contao/manager-plugin, but I'd love to see a possibility to run composer post-install/update scripts in the managed edition, without the user having to manually add them to the project's composer.json.

aschempp commented 6 years ago

What script exactly do you want to execute?

patrickjDE commented 6 years ago

Any custom composer script provided by the installed/updated bundle.

I'm aware that they can be manually added to the composer.json in the managed edition too, but it's easy to miss for bundle users, especially when installing bundles via the manager.

aschempp commented 6 years ago

I'm not exactly sure what you mean. There is only one post-install/update script in the managed edition, and that is defined in the root composer.json of the managed edition (see https://github.com/contao/managed-edition/blob/master/composer.json#L32).

A bundle cannot register a post-install/update script, that is not possible in composer nor in Contao. The only thing that exists are runonce.php files, but these are only for Contao 3 modules (which still run in Contao 4) and are executed by the install tool.

aschempp commented 6 years ago

Now that I read your intro again, I think my assumption was wrong. You don't want to run scripts in your app, but you (as a developer) want to register a migration script to be run? That is currently not easy, but has already been discussed.

Closed in favor or https://github.com/contao/installation-bundle/issues/96 and https://github.com/contao/installation-bundle/issues/50

patrickjDE commented 6 years ago

That's actually not quite what I mean. I'll elaborate a bit further.

A bundle cannot register a post-install/update script, that is not possible in composer nor in Contao.

I know. But still there exist bundles that actually need to run their own post-install scripts and they usually overcome this limitation by requiring the application developer/bundle user to add the scripts manually to the application's composer.json. Which works well and is perfectly fine for classic Symfony apps where bundles are added by developers that read installation instructions ;)

Now imagine a Contao module which is available as a bundle and needs to run its own post-install script. Adding a module is quick and easy, the manager makes it almost as painless as back in Contao 3. As such, modules are quite often even added by non-developers. But having to add a script manuallly complicates things:

Or else stuff will break, probably resulting in quite a few "this module doesn't work" reactions. Thus, it would be great if the bundle developer could automate this process, just like the managed edition already automates registering the bundle.

Technically the basic idea is simple - the managed edition's setup process is already run by a post-install script, so it should be hardly more than a pass-through of the composer event object to the bundle's script(s). There just needs to be a way to communicate which scripts should be run, e.g. via the bundle's manager plugin class, extra parameters in the bundle's composer.json, or the like.

Symfony Flex does something similar with the recipe stuff, but I haven't had the time yet to take a closer look at how it's accomplished there.

aschempp commented 6 years ago

that is fairly similar to exactly what the other two issues are talking about 😉