pull/2175/head
parent
d1a1758b84
commit
21299e0bc4
|
@ -15,7 +15,9 @@ namespace Composer;
|
||||||
use Composer\Autoload\AutoloadGenerator;
|
use Composer\Autoload\AutoloadGenerator;
|
||||||
use Composer\DependencyResolver\DefaultPolicy;
|
use Composer\DependencyResolver\DefaultPolicy;
|
||||||
use Composer\DependencyResolver\Operation\UpdateOperation;
|
use Composer\DependencyResolver\Operation\UpdateOperation;
|
||||||
|
use Composer\DependencyResolver\Operation\InstallOperation;
|
||||||
use Composer\DependencyResolver\Operation\UninstallOperation;
|
use Composer\DependencyResolver\Operation\UninstallOperation;
|
||||||
|
use Composer\DependencyResolver\Operation\OperationInterface;
|
||||||
use Composer\DependencyResolver\Pool;
|
use Composer\DependencyResolver\Pool;
|
||||||
use Composer\DependencyResolver\Request;
|
use Composer\DependencyResolver\Request;
|
||||||
use Composer\DependencyResolver\Rule;
|
use Composer\DependencyResolver\Rule;
|
||||||
|
@ -459,7 +461,7 @@ class Installer
|
||||||
$this->io->write('Nothing to install or update');
|
$this->io->write('Nothing to install or update');
|
||||||
}
|
}
|
||||||
|
|
||||||
$operations = $this->moveComposerInstallerToFrontIfNeeded($operations);
|
$operations = $this->moveCustomInstallersToFront($operations);
|
||||||
|
|
||||||
foreach ($operations as $operation) {
|
foreach ($operations as $operation) {
|
||||||
// collect suggestions
|
// collect suggestions
|
||||||
|
@ -538,35 +540,37 @@ class Installer
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workaround: if your packages depend on composer/installers, we must be sure
|
* Workaround: if your packages depend on custom installers, we must be sure
|
||||||
* that composer/installers is installed / updated at FIRST; else it would lead
|
* that those are installed / updated first; else it would lead to packages
|
||||||
* to packages being installed multiple times in different folders, when running
|
* being installed multiple times in different folders, when running Composer
|
||||||
* composer twice.
|
* twice.
|
||||||
*
|
|
||||||
* While this does not fix the root-causes of https://github.com/composer/composer/issues/1147,
|
|
||||||
* it at least fixes the symptoms and makes usage of composer possible (again)
|
|
||||||
* in such scenarios.
|
|
||||||
*
|
*
|
||||||
* @param array<DependencyResolver\Operation\OperationInterface> $operations
|
* While this does not fix the root-causes of https://github.com/composer/composer/issues/1147,
|
||||||
* @return array<DependencyResolver\Operation\OperationInterface> the modified
|
* it at least fixes the symptoms and makes usage of composer possible (again)
|
||||||
|
* in such scenarios.
|
||||||
|
*
|
||||||
|
* @param OperationInterface[] $operations
|
||||||
|
* @return OperationInterface[] reordered operation list
|
||||||
*/
|
*/
|
||||||
private function moveComposerInstallerToFrontIfNeeded($operations)
|
private function moveCustomInstallersToFront(array $operations)
|
||||||
{
|
{
|
||||||
$operationForComposerInstallers = NULL;
|
$installerOps = array();
|
||||||
$operations = array_filter($operations, function($operation) use (&$operationForComposerInstallers) {
|
foreach ($operations as $idx => $op) {
|
||||||
if ( ($operation instanceof DependencyResolver\Operation\InstallOperation && $operation->getPackage()->getName() === 'composer/installers')
|
if ($op instanceof InstallOperation) {
|
||||||
|| ($operation instanceof DependencyResolver\Operation\UpdateOperation && $operation->getInitialPackage()->getName() === 'composer/installers')
|
$package = $op->getPackage();
|
||||||
) {
|
} else if ($op instanceof UpdateOperation) {
|
||||||
$operationForComposerInstallers = $operation;
|
$package = $op->getTargetPackage();
|
||||||
return FALSE;
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
if ($package->getRequires() === array() && $package->getType() === 'composer-installer') {
|
||||||
});
|
$installerOps[] = $op;
|
||||||
if ($operationForComposerInstallers !== NULL) {
|
unset($operations[$idx]);
|
||||||
array_unshift($operations, $operationForComposerInstallers);
|
}
|
||||||
}
|
}
|
||||||
return $operations;
|
|
||||||
|
return array_merge($installerOps, $operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createPool()
|
private function createPool()
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
--TEST--
|
||||||
|
Composer installers are installed first if they have no requirements
|
||||||
|
--COMPOSER--
|
||||||
|
{
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"package": [
|
||||||
|
{ "name": "pkg", "version": "1.0.0" },
|
||||||
|
{ "name": "pkg2", "version": "1.0.0" },
|
||||||
|
{ "name": "inst", "version": "1.0.0", "type": "composer-installer" },
|
||||||
|
{ "name": "inst2", "version": "1.0.0", "type": "composer-installer", "require": { "pkg2": "*" } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"pkg": "1.0.0",
|
||||||
|
"inst": "1.0.0",
|
||||||
|
"inst2": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--RUN--
|
||||||
|
install
|
||||||
|
--EXPECT--
|
||||||
|
Installing inst (1.0.0)
|
||||||
|
Installing pkg (1.0.0)
|
||||||
|
Installing pkg2 (1.0.0)
|
||||||
|
Installing inst2 (1.0.0)
|
Loading…
Reference in New Issue