Closed soullivaneuh closed 7 years ago
What is the expected use-case for this feature?
@bd808 I'll give you my concrete case.
I'm merging the Prestashop composer.json file, which provide a bunch of Prestashop modules: https://github.com/PrestaShop/PrestaShop/blob/b4955c65420e65f5dfa6a0a90e8bc27b74f431c8/composer.json#L42-L94
Modules are optional, and there is some I don't need at all.
The goal is to remove them from the merge.
I already made a custom working script for my project:
use Composer\Package\Link;
use Composer\Script\Event;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\VersionParser;
final class ComposerScripts
{
const PACKAGES_TO_REMOVE = [
'prestashop/blockreassurance',
'prestashop/ps_banner',
'prestashop/ps_customtext',
'prestashop/ps_imageslider',
];
/**
* @param Event $event
*/
public static function preUpdate(Event $event)
{
$versionParser = new VersionParser();
$lastStableConstraint = $versionParser->parseConstraints('<9999999-dev');
$composer = $event->getComposer();
$root = $composer->getPackage();
/** @var Link[] $requires */
$requires = $root->getRequires();
foreach ($requires as $r => $require) {
// Manage only Prestashop required packages.
if ('prestashop/prestashop' !== $require->getSource()) {
continue;
}
if (in_array($require->getTarget(), static::PACKAGES_TO_REMOVE, true)) {
unset($requires[$r]);
continue;
}
}
$root->setRequires(array_values($requires));
}
}
But having options like described would be better.
I'm struggling to see how this is generally applicable functionality. I see how it helps your particular project, but broadly I don't think that using composer-merge-plugin to modify the dependencies declared by project type Composer packages is likely to be a common use-case.
I understand. I have to do this waiting some improvement from PrestaShop composer management.
As you wish for this issue.
Declined
It would be great to add a
ignore-packages
option in order to ignore some package from the merge.Example:
What do you think? I could work on a PR for this.