getkirby / composer-installer

Kirby's custom Composer installer
https://getkirby.com
MIT License
5 stars 1 forks source link

Feature Request: New Composer Type `kirby-custom` #2

Closed HYR closed 2 years ago

HYR commented 3 years ago

Feature Request

Add a new composer package type of kirby-custom to allow devs to create plugins that install to custom locations. Combine type: kirby-custom with some other property like like custom-type... for example: custom-type: theme or custom-type: cron and then allow the site's composer.json file to define where they get installed. That way the plugin developer for the custom type doesn't get full control over where it installs which could become a security risk.

Use Case

My current use case is theme development in plugins.

Currently all plugins get installed in /site/plugins. I'd like to create my theme plugins and install them to a custom location like /site/themes to prevent them from being auto loaded. Then load a chosen via a config option at after all other plugins have loaded.

/site/blueprints
/site/config
/site/plugins
/site/themes  # Custom Location

This could be useful to Kirby Devs for other purposes as well.

@lukasbestle If you need more context see our direct message on Discord. Thanks!

lukasbestle commented 3 years ago

@HYR Have you found the time so far to check my suggestion from our discussion on Discord in March?

I'm posting it here again for reference in case other users have the same issue:

I've thought about it again and come to the conclusion that it would probably be better in the long run to use the native Composer installer for this use-case of custom install directories: https://github.com/composer/installers#custom-install-paths

It should do exactly what you need without adding complexity to Kirby's installer and also without duplicating the feature. After all, the use-case of "completely custom Composer install paths" is not specific to Kirby.

At the moment you might run into weird issues with Kirby sites once you use the composer/installers package. Once any plugin requires that package, it might clash with our installer for other plugins that use getkirby/composer-installer. The workaround to fix all the weird issues is to manually delete the vendor folder inside all plugins in site/plugins. I've just created a PR to fix this in composer/installers, but it will only be merged with composer/installers v2.0 (no idea when that is going to happen): https://github.com/composer/installers/pull/485

In the meantime, you could already try composer/installers for your use-case to check if it does what you need at all. If not, please get back to me and we'll discuss the options. 🙂

HYR commented 3 years ago

Hey @lukasbestle,

No, I'm sorry, I haven't yet. I'll try to get to it this coming week and report back to you. Thanks!

lukasbestle commented 2 years ago

In the meantime, composer/installers v2 has been released, so the issue I described above is no longer relevant. Completely custom install paths can be achieved with https://github.com/composer/installers#custom-install-paths now.