Cleanups of IOInterface
parent
edf948454b
commit
434c9ecdeb
|
@ -77,7 +77,7 @@ class Application extends BaseApplication
|
|||
try {
|
||||
$this->composer = Factory::create($this->io);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->io->writeln($e->getMessage());
|
||||
$this->io->write($e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
|
||||
$fileName = rtrim($path.'/'.md5(time().rand()).'.'.pathinfo($url, PATHINFO_EXTENSION), '.');
|
||||
|
||||
$this->io->writeln(" - Package <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
|
||||
$this->io->write(" - Package <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
|
||||
|
||||
if (!extension_loaded('openssl') && (0 === strpos($url, 'https:') || 0 === strpos($url, 'http://github.com'))) {
|
||||
// bypass https for github if openssl is disabled
|
||||
|
@ -105,7 +105,7 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
|
||||
$this->io->overwrite(" Downloading: <comment>connection...</comment>", 80);
|
||||
copy($url, $fileName, $ctx);
|
||||
$this->io->overwriteln(" Downloading", 80);
|
||||
$this->io->overwrite(" Downloading", 80);
|
||||
|
||||
if (!file_exists($fileName)) {
|
||||
throw new \UnexpectedValueException($url.' could not be saved to '.$fileName.', make sure the'
|
||||
|
@ -116,11 +116,11 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
throw new \UnexpectedValueException('The checksum verification of the archive failed (downloaded from '.$url.')');
|
||||
}
|
||||
|
||||
$this->io->writeln(' Unpacking archive');
|
||||
$this->io->write(' Unpacking archive');
|
||||
$this->extract($fileName, $path);
|
||||
|
||||
|
||||
$this->io->writeln(' Cleaning up');
|
||||
$this->io->write(' Cleaning up');
|
||||
unlink($fileName);
|
||||
|
||||
// If we have only a one dir inside it suppose to be a package itself
|
||||
|
@ -135,7 +135,7 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
rmdir($contentDir);
|
||||
}
|
||||
|
||||
$this->io->writeln('');
|
||||
$this->io->write('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,17 +57,9 @@ class ConsoleIO implements IOInterface
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function write($messages, $newline = false, $type = 0)
|
||||
public function write($messages, $newline = true)
|
||||
{
|
||||
$this->output->write($messages, $newline, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function writeln($messages, $type = 0)
|
||||
{
|
||||
$this->output->writeln($messages, $type);
|
||||
$this->output->write($messages, $newline);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,62 +87,6 @@ class ConsoleIO implements IOInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function overwriteln($messages, $size = 80, $type = 0)
|
||||
{
|
||||
$this->overwrite($messages, $size, true, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setVerbosity($level)
|
||||
{
|
||||
$this->output->setVerbosity($level);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getVerbosity()
|
||||
{
|
||||
return $this->output->getVerbosity();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setDecorated($decorated)
|
||||
{
|
||||
$this->output->setDecorated($decorated);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isDecorated()
|
||||
{
|
||||
return $this->output->isDecorated();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setFormatter(OutputFormatterInterface $formatter)
|
||||
{
|
||||
$this->output->setFormatter($formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getFormatter()
|
||||
{
|
||||
return $this->output->getFormatter();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -167,6 +103,9 @@ class ConsoleIO implements IOInterface
|
|||
return $this->helperSet->get('dialog')->askConfirmation($this->output, $question, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function askAndValidate($question, $validator, $attempts = false, $default = null)
|
||||
{
|
||||
return $this->helperSet->get('dialog')->askAndValidate($this->output, $question, $validator, $attempts, $default);
|
||||
|
|
|
@ -30,23 +30,21 @@ interface IOInterface extends OutputInterface
|
|||
function isInteractive();
|
||||
|
||||
/**
|
||||
* Overwrites a previous message to the output.
|
||||
* Writes a message to the output.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines of a single string
|
||||
* @param integer $size The size of line
|
||||
* @param string|array $messages The message as an array of lines or a single string
|
||||
* @param Boolean $newline Whether to add a newline or not
|
||||
* @param integer $type The type of output
|
||||
*/
|
||||
function overwrite($messages, $size = 80, $newline = false, $type = 0);
|
||||
function write($messages, $newline = true);
|
||||
|
||||
/**
|
||||
* Overwrites a previous message to the output and adds a newline at the end.
|
||||
* Overwrites a previous message to the output.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines of a single string
|
||||
* @param string|array $messages The message as an array of lines or a single string
|
||||
* @param integer $size The size of line
|
||||
* @param integer $type The type of output
|
||||
* @param Boolean $newline Whether to add a newline or not
|
||||
*/
|
||||
function overwriteln($messages, $size = 80, $type = 0);
|
||||
function overwrite($messages, $size = 80, $newline = true);
|
||||
|
||||
/**
|
||||
* Asks a question to the user.
|
||||
|
|
|
@ -140,7 +140,7 @@ class LibraryInstaller implements InstallerInterface
|
|||
foreach ($package->getBinaries() as $bin) {
|
||||
$link = $this->binDir.'/'.basename($bin);
|
||||
if (file_exists($link)) {
|
||||
$this->io->writeln('Skipped installation of '.$bin.' for package '.$package->getName().', name conflicts with an existing file');
|
||||
$this->io->write('Skipped installation of '.$bin.' for package '.$package->getName().', name conflicts with an existing file');
|
||||
continue;
|
||||
}
|
||||
$bin = $this->getInstallPath($package).'/'.$bin;
|
||||
|
|
|
@ -41,7 +41,9 @@ abstract class VcsDriver
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the https or http protocol.
|
||||
* Get the https or http protocol depending on SSL support.
|
||||
*
|
||||
* Call this only if you know that the server supports both.
|
||||
*
|
||||
* @return string The correct type of protocol
|
||||
*/
|
||||
|
@ -70,7 +72,6 @@ abstract class VcsDriver
|
|||
if ($this->io->hasAuthorization($this->url)) {
|
||||
$authStr = base64_encode($auth['username'] . ':' . $auth['password']);
|
||||
$params['http'] = array('header' => "Authorization: Basic $authStr\r\n");
|
||||
|
||||
} else if (null !== $this->io->getLastUsername()) {
|
||||
$authStr = base64_encode($this->io->getLastUsername() . ':' . $this->io->getLastPassword());
|
||||
$params['http'] = array('header' => "Authorization: Basic $authStr\r\n");
|
||||
|
@ -116,9 +117,7 @@ abstract class VcsDriver
|
|||
throw new \RuntimeException("The '" . $this->contentUrl . "' URL not found");
|
||||
}
|
||||
|
||||
if ($this->firstCall) {
|
||||
$this->firstCall = false;
|
||||
}
|
||||
|
||||
// get authorization informations
|
||||
if (401 === $messageCode || $ps) {
|
||||
|
@ -132,7 +131,7 @@ abstract class VcsDriver
|
|||
throw new \RuntimeException($mess);
|
||||
}
|
||||
|
||||
$this->io->writeln("Authorization for <info>" . $this->contentUrl . "</info>:");
|
||||
$this->io->write("Authorization for <info>" . $this->contentUrl . "</info>:");
|
||||
$username = $this->io->ask(' Username: ');
|
||||
$password = $this->io->askAndHideAnswer(' Password: ');
|
||||
$this->io->setAuthorization($this->url, $username, $password);
|
||||
|
|
|
@ -88,7 +88,7 @@ class VcsRepository extends ArrayRepository
|
|||
} catch (\Exception $e) {
|
||||
if (strpos($e->getMessage(), 'JSON Parse Error') !== false) {
|
||||
if ($debug) {
|
||||
$this->io->writeln('Skipped tag '.$tag.', '.$e->getMessage());
|
||||
$this->io->write('Skipped tag '.$tag.', '.$e->getMessage());
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
|
@ -112,18 +112,18 @@ class VcsRepository extends ArrayRepository
|
|||
// broken package, version doesn't match tag
|
||||
if ($data['version_normalized'] !== $parsedTag) {
|
||||
if ($debug) {
|
||||
$this->io->writeln('Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json');
|
||||
$this->io->write('Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
$this->io->writeln('Importing tag '.$tag.' ('.$data['version_normalized'].')');
|
||||
$this->io->write('Importing tag '.$tag.' ('.$data['version_normalized'].')');
|
||||
}
|
||||
|
||||
$this->addPackage($loader->load($this->preProcess($driver, $data, $identifier)));
|
||||
} elseif ($debug) {
|
||||
$this->io->writeln('Skipped tag '.$tag.', '.($parsedTag ? 'no composer file was found' : 'invalid name'));
|
||||
$this->io->write('Skipped tag '.$tag.', '.($parsedTag ? 'no composer file was found' : 'invalid name'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ class VcsRepository extends ArrayRepository
|
|||
$data['version_normalized'] = $parsedBranch;
|
||||
} else {
|
||||
if ($debug) {
|
||||
$this->io->writeln('Skipped branch '.$branch.', invalid name and no composer file was found');
|
||||
$this->io->write('Skipped branch '.$branch.', invalid name and no composer file was found');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ class VcsRepository extends ArrayRepository
|
|||
foreach ($this->getPackages() as $package) {
|
||||
if ($normalizedStableVersion === $package->getVersion()) {
|
||||
if ($debug) {
|
||||
$this->io->writeln('Skipped branch '.$branch.', already tagged');
|
||||
$this->io->write('Skipped branch '.$branch.', already tagged');
|
||||
}
|
||||
|
||||
continue 2;
|
||||
|
@ -166,12 +166,12 @@ class VcsRepository extends ArrayRepository
|
|||
}
|
||||
|
||||
if ($debug) {
|
||||
$this->io->writeln('Importing branch '.$branch.' ('.$data['version_normalized'].')');
|
||||
$this->io->write('Importing branch '.$branch.' ('.$data['version_normalized'].')');
|
||||
}
|
||||
|
||||
$this->addPackage($loader->load($this->preProcess($driver, $data, $identifier)));
|
||||
} elseif ($debug) {
|
||||
$this->io->writeln('Skipped branch '.$branch.', no composer file was found');
|
||||
$this->io->write('Skipped branch '.$branch.', no composer file was found');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue