Skip to content

Conversation

hussainweb
Copy link
Contributor

The composer.json in the project allows placing components marked as drupal-library in the
correct directory, but most libraries are not available to composer by default. We should
add documentation on how to add a repository with an example to help get users started.

The composer.json in the project allows placing components marked as drupal-library in the
correct directory, but most libraries are not available to composer by default. We should
add documentation on how to add a repository with an example to help get users started.
@webflo
Copy link
Member

webflo commented Nov 5, 2016

I think inline package definitions are not a best practice. We should at least mention the limitations. See the blue box on https://getcomposer.org/doc/05-repositories.md#package-2

@hussainweb
Copy link
Contributor Author

It's a fair point. Even though there are limitations, it is still essential in many cases. You may use bower or npm for your theme but that approach doesn't really work well here where this needs to be present site-wide in libraries directory. I have added the warning with a link back to getcomposer.org.

@weitzman
Copy link
Contributor

weitzman commented Jan 6, 2017

I ma finding more and more js libraries available via Composer. Maybe we should mention those as well (use installer-paths to place them in web/libraries)

@kasperg
Copy link
Member

kasperg commented Jan 8, 2017

Another options is Asset Packagist which makes Bower and NPM available through Composer.

I like the idea there are currently some caveats regarding placement that I am not too keen on - hiqdev/asset-packagist#20. Perhaps they can be addressed.

@joelpittet
Copy link
Contributor

Trying to figure out how to deal with deleting test folders that come with packages https://www.drupal.org/node/1189632
Indicated on this project:
https://www.drupal.org/project/dropzonejs

@webflo
Copy link
Member

webflo commented Mar 30, 2017

@joelpittet You could try to creata a subclass \Drupal\Core\Composer\Composer and override \Drupal\Core\Composer\Composer::$packageToCleanup. Add add the subclass to your composer.json as additional script.

@joelpittet
Copy link
Contributor

joelpittet commented Mar 30, 2017

Toying with who will get the responsibility, possibly npm/yarn, but maybe composer, thanks for the suggestion @webflo

@rodrigoaguilera
Copy link
Contributor

rodrigoaguilera commented Apr 25, 2017

I found a way that can make the installation of external libraries from npmjs.org or bower into the folder /web/libraries/ easier

Recently this composer repo was created
https://asset-packagist.org/
but there still the problem that this libraries do not set a "type" for "composer/installers" to use so is difficult to set a path like /web/libraries/$name

There is this plugin that add a default type to all packages
https://github.com/oomphinc/composer-installers-extender

So we modify this project to add the assets repo, the plugin and write something like the following in the composer.json

"installer-types": ["library"],
"installer-paths": {
  "web/libraries/{$name}": [
    "type:drupal-library",
    "vendor:npm-asset",
    "vendor:bower-asset"	
  ],
}

So we can do things like
composer require "npm-asset/jquery.easing":"~1.0"

and it will place the library into /web/libraries/jquery.easing

There is another explanation here
https://asset-packagist.org/site/about

No need to duplicate js libraries in packagist for a drupal "version".
In projects with a lot of external libraries the repositories section can get quite messy and https://github.com/fxpio/composer-asset-plugin is slow and complicated.
Also overcomes the limitations referenced in this PR about changing the library version.

Is it interesting to add this to the drupal composer project?

@rodrigoaguilera
Copy link
Contributor

I submitted a PR with the idea from last comment
#286

I think it will make this one obsolete.

@AlexSkrypnyk
Copy link
Collaborator

This pull request/issue has been inactive for over a year and is being closed due to inactivity. If the issue still persists or the contribution is still relevant, please feel free to reopen it or create a new one.

Thank you for your understanding and your contributions to the project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants