Reuse normal installer logic for locked installs
parent
96122aada8
commit
cc769af923
|
@ -16,6 +16,7 @@ use Composer\DependencyResolver;
|
|||
use Composer\DependencyResolver\Pool;
|
||||
use Composer\DependencyResolver\Request;
|
||||
use Composer\DependencyResolver\Operation;
|
||||
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
@ -47,20 +48,6 @@ EOT
|
|||
{
|
||||
$composer = $this->getComposer();
|
||||
|
||||
if ($composer->getLocker()->isLocked()) {
|
||||
$output->writeln('<info>Found lockfile. Reading</info>');
|
||||
|
||||
$installationManager = $composer->getInstallationManager();
|
||||
foreach ($composer->getLocker()->getLockedPackages() as $package) {
|
||||
if (!$installationManager->isPackageInstalled($package)) {
|
||||
$operation = new Operation\InstallOperation($package, 'lock resolving');
|
||||
$installationManager->execute($operation);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// creating repository pool
|
||||
$pool = new Pool;
|
||||
$pool->addRepository($composer->getRepositoryManager()->getLocalRepository());
|
||||
|
@ -70,9 +57,18 @@ EOT
|
|||
|
||||
// creating requirements request
|
||||
$request = new Request($pool);
|
||||
if ($composer->getLocker()->isLocked()) {
|
||||
$output->writeln('> Found lockfile. Reading.');
|
||||
|
||||
foreach ($composer->getLocker()->getLockedPackages() as $package) {
|
||||
$constraint = new VersionConstraint('=', $package->getVersion());
|
||||
$request->install($package->getName(), $constraint);
|
||||
}
|
||||
} else {
|
||||
foreach ($composer->getPackage()->getRequires() as $link) {
|
||||
$request->install($link->getTarget(), $link->getConstraint());
|
||||
}
|
||||
}
|
||||
|
||||
// prepare solver
|
||||
$installationManager = $composer->getInstallationManager();
|
||||
|
@ -85,8 +81,10 @@ EOT
|
|||
$installationManager->execute($operation);
|
||||
}
|
||||
|
||||
if (!$composer->getLocker()->isLocked()) {
|
||||
$composer->getLocker()->lockPackages($localRepo->getPackages());
|
||||
$output->writeln('> Locked');
|
||||
}
|
||||
|
||||
$localRepo->write();
|
||||
$output->writeln('> Done');
|
||||
|
|
Loading…
Reference in New Issue