refactored install command to use new Locker
parent
cc2f2b79ca
commit
96122aada8
|
@ -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);
|
||||||
|
|
|
@ -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) {
|
|
||||||
$composer->getPackageLock()->lock($localRepo->getPackages());
|
|
||||||
$output->writeln('> Locked');
|
$output->writeln('> Locked');
|
||||||
}
|
|
||||||
|
|
||||||
$localRepo->write();
|
$localRepo->write();
|
||||||
|
|
||||||
$output->writeln('> Done');
|
$output->writeln('> Done');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue