1
0
Fork 0

refactored install command to use new Locker

pull/40/head
everzet 2011-10-01 15:33:43 +03:00
parent cc2f2b79ca
commit 96122aada8
3 changed files with 16 additions and 15 deletions

View File

@ -8,6 +8,7 @@ use Composer\Installer;
use Composer\Downloader; use Composer\Downloader;
use Composer\Repository; use Composer\Repository;
use Composer\Package; use Composer\Package;
use Composer\Json\JsonFile;
use Composer\Console\Application as ComposerApplication; use Composer\Console\Application as ComposerApplication;
// initialize repository manager // initialize repository manager
@ -29,10 +30,14 @@ $im->setInstaller('library', new Installer\LibraryInstaller('vendor', $dm, $rm->
$loader = new Package\Loader\JsonLoader(); $loader = new Package\Loader\JsonLoader();
$package = $loader->load('composer.json'); $package = $loader->load('composer.json');
// init locker
$locker = new Package\Locker(new JsonFile('composer.lock'), $rm);
// initialize composer // initialize composer
$composer = new Composer(); $composer = new Composer();
$composer->setPackage($package); $composer->setPackage($package);
$composer->setPackageLock(new Package\PackageLock('composer.lock')); $composer->setLocker($locker);
$composer->setRepositoryManager($rm); $composer->setRepositoryManager($rm);
$composer->setDownloadManager($dm); $composer->setDownloadManager($dm);
$composer->setInstallationManager($im); $composer->setInstallationManager($im);

View File

@ -47,11 +47,11 @@ EOT
{ {
$composer = $this->getComposer(); $composer = $this->getComposer();
if ($composer->getPackageLock()->isLocked()) { if ($composer->getLocker()->isLocked()) {
$output->writeln('<info>Found lockfile. Reading</info>'); $output->writeln('<info>Found lockfile. Reading</info>');
$installationManager = $composer->getInstallationManager(); $installationManager = $composer->getInstallationManager();
foreach ($composer->getPackageLock()->getLockedPackages() as $package) { foreach ($composer->getLocker()->getLockedPackages() as $package) {
if (!$installationManager->isPackageInstalled($package)) { if (!$installationManager->isPackageInstalled($package)) {
$operation = new Operation\InstallOperation($package, 'lock resolving'); $operation = new Operation\InstallOperation($package, 'lock resolving');
$installationManager->execute($operation); $installationManager->execute($operation);
@ -85,14 +85,10 @@ EOT
$installationManager->execute($operation); $installationManager->execute($operation);
} }
// TODO implement lock $composer->getLocker()->lockPackages($localRepo->getPackages());
if (false) { $output->writeln('> Locked');
$composer->getPackageLock()->lock($localRepo->getPackages());
$output->writeln('> Locked');
}
$localRepo->write(); $localRepo->write();
$output->writeln('> Done'); $output->writeln('> Done');
} }
} }

View File

@ -13,7 +13,7 @@
namespace Composer; namespace Composer;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\PackageLock; use Composer\Package\Locker;
use Composer\Repository\RepositoryManager; use Composer\Repository\RepositoryManager;
use Composer\Installer\InstallationManager; use Composer\Installer\InstallationManager;
use Composer\Downloader\DownloadManager; use Composer\Downloader\DownloadManager;
@ -27,7 +27,7 @@ class Composer
const VERSION = '1.0.0-DEV'; const VERSION = '1.0.0-DEV';
private $package; private $package;
private $lock; private $locker;
private $repositoryManager; private $repositoryManager;
private $downloadManager; private $downloadManager;
@ -43,14 +43,14 @@ class Composer
return $this->package; 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) public function setRepositoryManager(RepositoryManager $manager)