Composer preserve paths
, (*1)
Composer plugin for preserving paths while installing, updating or uninstalling packages., (*2)
This way you can:, (*3)
- provide custom files or directories that will not be overwritten on
composer install
or composer update
- place packages within the directory of another package (using a composer installer like
composer/installers or
davidbarratt/custom-installer)
This plugin was originally developed by Johannes Haseitl. I updated it to allow wildcard pattern matching when defining preserved paths, which is necessary if you have many sites installed with same Drupal installation (i.e., you have many directories like example.com, example.net, example.org, etc under folder sites/ of your Drupal installation)., (*4)
Installation
Simply install the plugin with composer: composer require deminy/composer-preserve-paths
, (*5)
Configuration
For configuring the paths you need to set preserve-paths
within the extra
of your root composer.json
., (*6)
{
"extra": {
"preserve-paths": [
"htdocs/sites/all/modules/contrib",
"htdocs/sites/all/themes/contrib",
"htdocs/sites/all/libraries",
"htdocs/sites/all/drush",
"htdocs/sites/*.com",
"htdocs/sites/*.net",
"htdocs/sites/*.org"
]
}
}
Example
An example composer.json using davidbarratt/custom-installer:, (*7)
{
"repositories": [
{
"type": "composer",
"url": "https://packagist.drupal-composer.org/"
}
],
"require": {
"davidbarratt/custom-installer": "dev-master",
"deminy/composer-preserve-paths": "dev-master",
"drupal/views": "7.*",
"drupal/drupal": "7.*"
},
"config": {
"vendor-dir": "vendor"
},
"extra": {
"custom-installer": {
"drupal-module": "htdocs/sites/all/modules/contrib/{$name}/",
"drupal-theme": "htdocs/sites/all/themes/contrib/{$name}/",
"drupal-library": "htdocs/sites/all/libraries/{$name}/",
"drupal-drush": "htdocs/sites/all/drush/{$name}/",
"drupal-profile": "htdocs/profiles/{$name}/",
"drupal-core": "htdocs/"
},
"preserve-paths": [
"htdocs/sites/all/modules/contrib",
"htdocs/sites/all/themes/contrib",
"htdocs/sites/all/libraries",
"htdocs/sites/all/drush",
"htdocs/sites/*.com",
"htdocs/sites/*.net",
"htdocs/sites/*.org"
]
}
}