koala-framework / composer-extra-assets

Composer Plugin for installing Assets using native npm/bower
BSD 2-Clause "Simplified" License
42 stars 11 forks source link

Integrate bower-installer #15

Closed claudio-silva closed 8 years ago

claudio-silva commented 9 years ago

This is a suggestion. To really make this plugin the killer solution for managing bower dependencies on PHP projects, what's missing is an integration with bower-installer. This would allow the automatic copy of selected files from the bower-installed repositories into the application's public assets directory.

What would have to be added to this plugin:

  1. (optional) install bower-installer, if not yet installed.
  2. support an install section on the packages' composer.json extra section.
  3. merge those sections into the bower.json's install section.
  4. run bower-installer whenever composer-extra-assets runs bower. This feature could be optional and enabled by a configuration setting for those people that need it.

Would you consider implementing this feature or, at least, accepting a pull request implementing it?

claudio-silva commented 9 years ago

I've been thinking about this, and I guess my proposed solution might not be the best way to handle this, because even if bower-installer copied files to a destination folder, one might still need to process those files afterwards (ex. minification, concatenation). So, striving for a more generic solution, the list above might be simplified and reduced to:

  1. Merge keys from a new extra.bower-extra section on packages' composer.json into bower.json. These keys may be called install (for use by bower-installer) or anyhting else (for use by other plugins).
  2. Implement a hook to launch an external process/script whenever composer-extra-assets runs bower. This will allow the lauch of a build tool to process the assets installed by bower.

And that's it. Point 2 is neccessary because:

So, this solution would allow bower-installer or any other build tool to run synchronized with composer-extra-assets. What do you think?

claudio-silva commented 8 years ago

I can see you are very busy and this project seems to be somewhat stale. I had to create my own alternative to fit our needs. So, there's no need to keep this issue open. Regards

nsams commented 8 years ago

Sorry, I was on vacation when you created this issue and totally forgot about it :/

I think that could be implemented as composer plugin:

we can't just use one of composer's event scripts (like post-update-cmd) because we can't be sure composer-extra-assets has changed anything.

No real problem if it is done on every update/install - only a performance issue that can be solved by caching or remembering a state somewhere.

we can't just use another composer plugin because we can't be sure composer-extra-assets has already run before that plugin.

events have a priority, making sure the plugin gets called after composer-extra-assets can be done by using the right priority.

claudio-silva commented 8 years ago

Ok, no problem. Thanks for your feedback. As I said, we had to develop our own solution because we were in a hurry.

We are also toying with a new possibility that Bower currently provides, which is the feature of requiring local folder as Bower packages. This way, there is no need for us to merge required frontend packages from multiple Composer packages, we can just add those Composer packages directly as Bower dependencies and Bower reads each Bower.json and joins all the requirements, solving version conflicts and prompting the user to help, if required. I didn't know it could do that, as there is no mention of it on the documentation. If you also don't know about it, we can read this thread. Perhaps it may be of use to you too.

nsams commented 8 years ago

Wow, interesting! Thank you for that information...