public function execute() { foreach ($this->repository->getUnusedPhars() as $unusedPhar) { $this->repository->removePhar($unusedPhar); $this->output->writeInfo(sprintf('Phar %s %s has been deleted.', $unusedPhar->getName(), $unusedPhar->getVersion()->getVersionString())); } }
public function execute() { $destination = $this->config->getWorkingDirectory() . '/' . $this->config->getPharName(); $phar = $this->repository->getByUsage($destination); $this->output->writeInfo(sprintf('Removing Phar %s %s', $phar->getName(), $phar->getVersion()->getVersionString())); $this->repository->removeUsage($phar, $destination); unlink($destination); if (!$this->repository->hasUsages($phar)) { $this->output->writeInfo(sprintf('Phar %s %s has no more known usages. You can run \'phive purge\' to remove unused Phars.', $phar->getName(), $phar->getVersion()->getVersionString())); } }
public function testInstallByUrlGetsPharFromRepositoryAndInvokesInstaller() { $url = new Url('https://example.com/foo-1.20.1.phar'); $file = new File(new Filename('foo.phar'), 'bar'); $requestedPhar = RequestedPhar::fromUrl($url); $phar = new Phar('foo', new Version('1.20.1'), $file); $this->repository->hasPhar('foo', new Version('1.20.1'))->shouldBeCalled()->willReturn(true); $this->repository->getPhar('foo', new Version('1.20.1'))->shouldBeCalled()->willReturn($phar); $this->repository->addUsage($phar, '/tmp/foo')->shouldBeCalled(); $this->installer->install($file, '/tmp/foo', true)->shouldBeCalled(); $this->getPharService()->install($requestedPhar, '/tmp', true); }