Add output for metapackage installs/updates/.. fixes #7586
parent
dec2b5cd50
commit
98a15bc93c
|
@ -215,8 +215,8 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
public function update(PackageInterface $initial, PackageInterface $target, $path)
|
public function update(PackageInterface $initial, PackageInterface $target, $path)
|
||||||
{
|
{
|
||||||
$name = $target->getName();
|
$name = $target->getName();
|
||||||
$from = $initial->getPrettyVersion();
|
$from = $initial->getFullPrettyVersion();
|
||||||
$to = $target->getPrettyVersion();
|
$to = $target->getFullPrettyVersion();
|
||||||
|
|
||||||
$actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Updating' : 'Downgrading';
|
$actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Updating' : 'Downgrading';
|
||||||
$this->io->writeError(" - " . $actionName . " <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>): ", false);
|
$this->io->writeError(" - " . $actionName . " <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>): ", false);
|
||||||
|
|
|
@ -546,7 +546,7 @@ class Factory
|
||||||
$im->addInstaller(new Installer\LibraryInstaller($io, $composer, null));
|
$im->addInstaller(new Installer\LibraryInstaller($io, $composer, null));
|
||||||
$im->addInstaller(new Installer\PearInstaller($io, $composer, 'pear-library'));
|
$im->addInstaller(new Installer\PearInstaller($io, $composer, 'pear-library'));
|
||||||
$im->addInstaller(new Installer\PluginInstaller($io, $composer));
|
$im->addInstaller(new Installer\PluginInstaller($io, $composer));
|
||||||
$im->addInstaller(new Installer\MetapackageInstaller());
|
$im->addInstaller(new Installer\MetapackageInstaller($io));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace Composer\Installer;
|
||||||
|
|
||||||
use Composer\Repository\InstalledRepositoryInterface;
|
use Composer\Repository\InstalledRepositoryInterface;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
|
use Composer\Package\Version\VersionParser;
|
||||||
|
use Composer\IO\IOInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metapackage installation manager.
|
* Metapackage installation manager.
|
||||||
|
@ -22,6 +24,13 @@ use Composer\Package\PackageInterface;
|
||||||
*/
|
*/
|
||||||
class MetapackageInstaller implements InstallerInterface
|
class MetapackageInstaller implements InstallerInterface
|
||||||
{
|
{
|
||||||
|
private $io;
|
||||||
|
|
||||||
|
public function __construct(IOInterface $io)
|
||||||
|
{
|
||||||
|
$this->io = $io;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +52,8 @@ class MetapackageInstaller implements InstallerInterface
|
||||||
*/
|
*/
|
||||||
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||||
{
|
{
|
||||||
|
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
|
||||||
|
|
||||||
$repo->addPackage(clone $package);
|
$repo->addPackage(clone $package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +66,12 @@ class MetapackageInstaller implements InstallerInterface
|
||||||
throw new \InvalidArgumentException('Package is not installed: '.$initial);
|
throw new \InvalidArgumentException('Package is not installed: '.$initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$name = $target->getName();
|
||||||
|
$from = $initial->getFullPrettyVersion();
|
||||||
|
$to = $target->getFullPrettyVersion();
|
||||||
|
$actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Updating' : 'Downgrading';
|
||||||
|
$this->io->writeError(" - " . $actionName . " <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
|
||||||
|
|
||||||
$repo->removePackage($initial);
|
$repo->removePackage($initial);
|
||||||
$repo->addPackage(clone $target);
|
$repo->addPackage(clone $target);
|
||||||
}
|
}
|
||||||
|
@ -68,6 +85,8 @@ class MetapackageInstaller implements InstallerInterface
|
||||||
throw new \InvalidArgumentException('Package is not installed: '.$package);
|
throw new \InvalidArgumentException('Package is not installed: '.$package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
|
||||||
|
|
||||||
$repo->removePackage($package);
|
$repo->removePackage($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ class FileDownloaderTest extends TestCase
|
||||||
{
|
{
|
||||||
$oldPackage = $this->getMock('Composer\Package\PackageInterface');
|
$oldPackage = $this->getMock('Composer\Package\PackageInterface');
|
||||||
$oldPackage->expects($this->once())
|
$oldPackage->expects($this->once())
|
||||||
->method('getPrettyVersion')
|
->method('getFullPrettyVersion')
|
||||||
->will($this->returnValue('1.2.0'));
|
->will($this->returnValue('1.2.0'));
|
||||||
$oldPackage->expects($this->once())
|
$oldPackage->expects($this->once())
|
||||||
->method('getVersion')
|
->method('getVersion')
|
||||||
|
@ -218,7 +218,7 @@ class FileDownloaderTest extends TestCase
|
||||||
|
|
||||||
$newPackage = $this->getMock('Composer\Package\PackageInterface');
|
$newPackage = $this->getMock('Composer\Package\PackageInterface');
|
||||||
$newPackage->expects($this->once())
|
$newPackage->expects($this->once())
|
||||||
->method('getPrettyVersion')
|
->method('getFullPrettyVersion')
|
||||||
->will($this->returnValue('1.0.0'));
|
->will($this->returnValue('1.0.0'));
|
||||||
$newPackage->expects($this->once())
|
$newPackage->expects($this->once())
|
||||||
->method('getVersion')
|
->method('getVersion')
|
||||||
|
|
|
@ -27,7 +27,7 @@ class MetapackageInstallerTest extends TestCase
|
||||||
|
|
||||||
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
||||||
|
|
||||||
$this->installer = new MetapackageInstaller();
|
$this->installer = new MetapackageInstaller($this->io);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInstall()
|
public function testInstall()
|
||||||
|
@ -45,7 +45,13 @@ class MetapackageInstallerTest extends TestCase
|
||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
{
|
{
|
||||||
$initial = $this->createPackageMock();
|
$initial = $this->createPackageMock();
|
||||||
|
$initial->expects($this->once())
|
||||||
|
->method('getVersion')
|
||||||
|
->will($this->returnValue('1.0.0'));
|
||||||
$target = $this->createPackageMock();
|
$target = $this->createPackageMock();
|
||||||
|
$target->expects($this->once())
|
||||||
|
->method('getVersion')
|
||||||
|
->will($this->returnValue('1.0.1'));
|
||||||
|
|
||||||
$this->repository
|
$this->repository
|
||||||
->expects($this->exactly(2))
|
->expects($this->exactly(2))
|
||||||
|
|
Loading…
Reference in New Issue