1
0
Fork 0

Add output for metapackage installs/updates/.. fixes #7586

pull/7932/head
Jordi Boggiano 2019-01-29 11:14:22 +01:00
parent dec2b5cd50
commit 98a15bc93c
5 changed files with 31 additions and 6 deletions

View File

@ -215,8 +215,8 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
public function update(PackageInterface $initial, PackageInterface $target, $path)
{
$name = $target->getName();
$from = $initial->getPrettyVersion();
$to = $target->getPrettyVersion();
$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>): ", false);

View File

@ -546,7 +546,7 @@ class Factory
$im->addInstaller(new Installer\LibraryInstaller($io, $composer, null));
$im->addInstaller(new Installer\PearInstaller($io, $composer, 'pear-library'));
$im->addInstaller(new Installer\PluginInstaller($io, $composer));
$im->addInstaller(new Installer\MetapackageInstaller());
$im->addInstaller(new Installer\MetapackageInstaller($io));
}
/**

View File

@ -14,6 +14,8 @@ namespace Composer\Installer;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;
use Composer\IO\IOInterface;
/**
* Metapackage installation manager.
@ -22,6 +24,13 @@ use Composer\Package\PackageInterface;
*/
class MetapackageInstaller implements InstallerInterface
{
private $io;
public function __construct(IOInterface $io)
{
$this->io = $io;
}
/**
* {@inheritDoc}
*/
@ -43,6 +52,8 @@ class MetapackageInstaller implements InstallerInterface
*/
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
$repo->addPackage(clone $package);
}
@ -55,6 +66,12 @@ class MetapackageInstaller implements InstallerInterface
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->addPackage(clone $target);
}
@ -68,6 +85,8 @@ class MetapackageInstaller implements InstallerInterface
throw new \InvalidArgumentException('Package is not installed: '.$package);
}
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
$repo->removePackage($package);
}

View File

@ -210,7 +210,7 @@ class FileDownloaderTest extends TestCase
{
$oldPackage = $this->getMock('Composer\Package\PackageInterface');
$oldPackage->expects($this->once())
->method('getPrettyVersion')
->method('getFullPrettyVersion')
->will($this->returnValue('1.2.0'));
$oldPackage->expects($this->once())
->method('getVersion')
@ -218,7 +218,7 @@ class FileDownloaderTest extends TestCase
$newPackage = $this->getMock('Composer\Package\PackageInterface');
$newPackage->expects($this->once())
->method('getPrettyVersion')
->method('getFullPrettyVersion')
->will($this->returnValue('1.0.0'));
$newPackage->expects($this->once())
->method('getVersion')

View File

@ -27,7 +27,7 @@ class MetapackageInstallerTest extends TestCase
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->installer = new MetapackageInstaller();
$this->installer = new MetapackageInstaller($this->io);
}
public function testInstall()
@ -45,7 +45,13 @@ class MetapackageInstallerTest extends TestCase
public function testUpdate()
{
$initial = $this->createPackageMock();
$initial->expects($this->once())
->method('getVersion')
->will($this->returnValue('1.0.0'));
$target = $this->createPackageMock();
$target->expects($this->once())
->method('getVersion')
->will($this->returnValue('1.0.1'));
$this->repository
->expects($this->exactly(2))