From 96122aada8bdc5f54ad766fbcccaa69f5be15608 Mon Sep 17 00:00:00 2001 From: everzet Date: Sat, 1 Oct 2011 15:33:43 +0300 Subject: [PATCH] refactored install command to use new Locker --- bin/composer | 7 ++++++- src/Composer/Command/InstallCommand.php | 12 ++++-------- src/Composer/Composer.php | 12 ++++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bin/composer b/bin/composer index 623d10b15..a2fba3ad0 100755 --- a/bin/composer +++ b/bin/composer @@ -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); diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 8250ba23f..23dc89780 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -47,11 +47,11 @@ EOT { $composer = $this->getComposer(); - if ($composer->getPackageLock()->isLocked()) { + if ($composer->getLocker()->isLocked()) { $output->writeln('Found lockfile. Reading'); $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'); } } diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 9040043c3..be34af653 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -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)