refactored install command to use new Locker
parent
cc2f2b79ca
commit
96122aada8
|
@ -8,6 +8,7 @@ use Composer\Installer;
|
|||
use Composer\Downloader;
|
||||
use Composer\Repository;
|
||||
use Composer\Package;
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Console\Application as ComposerApplication;
|
||||
|
||||
// initialize repository manager
|
||||
|
@ -29,10 +30,14 @@ $im->setInstaller('library', new Installer\LibraryInstaller('vendor', $dm, $rm->
|
|||
$loader = new Package\Loader\JsonLoader();
|
||||
$package = $loader->load('composer.json');
|
||||
|
||||
|
||||
// init locker
|
||||
$locker = new Package\Locker(new JsonFile('composer.lock'), $rm);
|
||||
|
||||
// initialize composer
|
||||
$composer = new Composer();
|
||||
$composer->setPackage($package);
|
||||
$composer->setPackageLock(new Package\PackageLock('composer.lock'));
|
||||
$composer->setLocker($locker);
|
||||
$composer->setRepositoryManager($rm);
|
||||
$composer->setDownloadManager($dm);
|
||||
$composer->setInstallationManager($im);
|
||||
|
|
|
@ -47,11 +47,11 @@ EOT
|
|||
{
|
||||
$composer = $this->getComposer();
|
||||
|
||||
if ($composer->getPackageLock()->isLocked()) {
|
||||
if ($composer->getLocker()->isLocked()) {
|
||||
$output->writeln('<info>Found lockfile. Reading</info>');
|
||||
|
||||
$installationManager = $composer->getInstallationManager();
|
||||
foreach ($composer->getPackageLock()->getLockedPackages() as $package) {
|
||||
foreach ($composer->getLocker()->getLockedPackages() as $package) {
|
||||
if (!$installationManager->isPackageInstalled($package)) {
|
||||
$operation = new Operation\InstallOperation($package, 'lock resolving');
|
||||
$installationManager->execute($operation);
|
||||
|
@ -85,14 +85,10 @@ EOT
|
|||
$installationManager->execute($operation);
|
||||
}
|
||||
|
||||
// TODO implement lock
|
||||
if (false) {
|
||||
$composer->getPackageLock()->lock($localRepo->getPackages());
|
||||
$output->writeln('> Locked');
|
||||
}
|
||||
$composer->getLocker()->lockPackages($localRepo->getPackages());
|
||||
$output->writeln('> Locked');
|
||||
|
||||
$localRepo->write();
|
||||
|
||||
$output->writeln('> Done');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace Composer;
|
||||
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\PackageLock;
|
||||
use Composer\Package\Locker;
|
||||
use Composer\Repository\RepositoryManager;
|
||||
use Composer\Installer\InstallationManager;
|
||||
use Composer\Downloader\DownloadManager;
|
||||
|
@ -27,7 +27,7 @@ class Composer
|
|||
const VERSION = '1.0.0-DEV';
|
||||
|
||||
private $package;
|
||||
private $lock;
|
||||
private $locker;
|
||||
|
||||
private $repositoryManager;
|
||||
private $downloadManager;
|
||||
|
@ -43,14 +43,14 @@ class Composer
|
|||
return $this->package;
|
||||
}
|
||||
|
||||
public function setPackageLock($lock)
|
||||
public function setLocker(Locker $locker)
|
||||
{
|
||||
$this->lock = $lock;
|
||||
$this->locker = $locker;
|
||||
}
|
||||
|
||||
public function getPackageLock()
|
||||
public function getLocker()
|
||||
{
|
||||
return $this->lock;
|
||||
return $this->locker;
|
||||
}
|
||||
|
||||
public function setRepositoryManager(RepositoryManager $manager)
|
||||
|
|
Loading…
Reference in New Issue