Add Helper Wrapper
parent
cad1497b95
commit
9af46ad800
|
@ -12,13 +12,16 @@
|
|||
|
||||
namespace Composer\Console;
|
||||
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
use Symfony\Component\Console\Application as BaseApplication;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Composer\Console\Output\ConsoleOutput;
|
||||
use Composer\Console\Helper\Wrapper;
|
||||
use Composer\Command;
|
||||
use Composer\Composer;
|
||||
use Composer\Installer;
|
||||
|
@ -37,8 +40,7 @@ use Composer\Json\JsonFile;
|
|||
class Application extends BaseApplication
|
||||
{
|
||||
protected $composer;
|
||||
protected $input;
|
||||
protected $output;
|
||||
protected $wrapper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -67,8 +69,7 @@ class Application extends BaseApplication
|
|||
{
|
||||
$this->registerCommands();
|
||||
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
$this->wrapper = new Wrapper($input, $output);
|
||||
|
||||
return parent::doRun($input, $output);
|
||||
}
|
||||
|
@ -79,7 +80,7 @@ class Application extends BaseApplication
|
|||
public function getComposer()
|
||||
{
|
||||
if (null === $this->composer) {
|
||||
$this->composer = self::bootstrapComposer(null, $this->input, $this->output);
|
||||
$this->composer = self::bootstrapComposer(null, $this->wrapper);
|
||||
}
|
||||
|
||||
return $this->composer;
|
||||
|
@ -90,7 +91,7 @@ class Application extends BaseApplication
|
|||
*
|
||||
* @return Composer
|
||||
*/
|
||||
public static function bootstrapComposer($composerFile = null, InputInterface $input = null, OutputInterface $output = null)
|
||||
public static function bootstrapComposer($composerFile = null, WrapperInterface $wrapper)
|
||||
{
|
||||
// load Composer configuration
|
||||
if (null === $composerFile) {
|
||||
|
@ -128,7 +129,7 @@ class Application extends BaseApplication
|
|||
$binDir = getenv('COMPOSER_BIN_DIR') ?: $packageConfig['config']['bin-dir'];
|
||||
|
||||
// initialize repository manager
|
||||
$rm = new Repository\RepositoryManager($input, $output);
|
||||
$rm = new Repository\RepositoryManager($wrapper);
|
||||
$rm->setLocalRepository(new Repository\FilesystemRepository(new JsonFile($vendorDir.'/.composer/installed.json')));
|
||||
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
|
||||
$rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
|
||||
|
@ -140,8 +141,8 @@ class Application extends BaseApplication
|
|||
$dm->setDownloader('git', new Downloader\GitDownloader());
|
||||
$dm->setDownloader('svn', new Downloader\SvnDownloader());
|
||||
$dm->setDownloader('hg', new Downloader\HgDownloader());
|
||||
$dm->setDownloader('pear', new Downloader\PearDownloader($input, $output));
|
||||
$dm->setDownloader('zip', new Downloader\ZipDownloader($input, $output));
|
||||
$dm->setDownloader('pear', new Downloader\PearDownloader($wrapper));
|
||||
$dm->setDownloader('zip', new Downloader\ZipDownloader($wrapper));
|
||||
|
||||
// initialize installation manager
|
||||
$im = new Installer\InstallationManager($vendorDir);
|
||||
|
@ -154,7 +155,7 @@ class Application extends BaseApplication
|
|||
|
||||
// load default repository unless it's explicitly disabled
|
||||
if (!isset($packageConfig['repositories']['packagist']) || $packageConfig['repositories']['packagist'] !== false) {
|
||||
$rm->addRepository(new Repository\ComposerRepository($input, $output, array('url' => 'http://packagist.org')));
|
||||
$rm->addRepository(new Repository\ComposerRepository(array('url' => 'http://packagist.org')));
|
||||
}
|
||||
|
||||
// init locker
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Console\Helper;
|
||||
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Helper\HelperInterface;
|
||||
|
||||
/**
|
||||
* Helper wrapper.
|
||||
*
|
||||
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
||||
*/
|
||||
class Wrapper implements WrapperInterface
|
||||
{
|
||||
protected $input;
|
||||
protected $output;
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param InputInterface $input The input instance
|
||||
* @param ConsoleOutputInterface $output The output instance
|
||||
* @param HelperInterface $helper The helper instance
|
||||
*/
|
||||
public function __construct(InputInterface $input, ConsoleOutputInterface $output, HelperInterface $helper = null)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setInput(InputInterface $input)
|
||||
{
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setOutput(ConsoleOutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getHelper()
|
||||
{
|
||||
return $this->helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setHelper(HelperInterface $helper)
|
||||
{
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function overwrite($messages, $size = 80, $newline = false, $type = 0)
|
||||
{
|
||||
for ($place = $size; $place > 0; $place--) {
|
||||
$this->getOutput()->write("\x08");
|
||||
}
|
||||
|
||||
$this->getOutput()->write($messages, false, $type);
|
||||
|
||||
for ($place = ($size - strlen($messages)); $place > 0; $place--) {
|
||||
$this->getOutput()->write(' ');
|
||||
}
|
||||
|
||||
// clean up the end line
|
||||
for ($place = ($size - strlen($messages)); $place > 0; $place--) {
|
||||
$this->getOutput()->write("\x08");
|
||||
}
|
||||
|
||||
if ($newline) {
|
||||
$this->getOutput()->writeln('');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function overwriteln($messages, $size = 80, $type = 0)
|
||||
{
|
||||
$this->overwrite($messages, $size, true, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function promptSilent($title = '')
|
||||
{
|
||||
// for windows OS
|
||||
if (preg_match('/^win/i', PHP_OS)) {
|
||||
$vbscript = sys_get_temp_dir() . '/prompt_password.vbs';
|
||||
file_put_contents($vbscript,
|
||||
'wscript.echo(Inputbox("' . addslashes($title) . '","'
|
||||
. addslashes($title) . '", ""))');
|
||||
$command = "cscript //nologo " . escapeshellarg($vbscript);
|
||||
$value = rtrim(shell_exec($command));
|
||||
unlink($vbscript);
|
||||
$this->getOutput()->writeln('');
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// for other OS
|
||||
else {
|
||||
$command = "/usr/bin/env bash -c 'echo OK'";
|
||||
|
||||
if (rtrim(shell_exec($command)) !== 'OK') {
|
||||
throw new \RuntimeException("Can't invoke bash for silent prompt");
|
||||
}
|
||||
|
||||
$command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'";
|
||||
$value = rtrim(shell_exec($command));
|
||||
$this->getOutput()->writeln('');
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Helper\HelperInterface;
|
||||
|
||||
/**
|
||||
* Helper wrapper interface.
|
||||
*
|
||||
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
||||
*/
|
||||
interface WrapperInterface
|
||||
{
|
||||
/**
|
||||
* Returns an InputInterface instance.
|
||||
*
|
||||
* @return InputInterface "InputArgument", "InputOption", "InputDefinition"
|
||||
*/
|
||||
function getInput();
|
||||
|
||||
/**
|
||||
* Set an InputInterface instance.
|
||||
*
|
||||
* @param InputInterface $input The input
|
||||
*/
|
||||
function setInput(InputInterface $input);
|
||||
|
||||
/**
|
||||
* Returns an ConsoleOutput instance.
|
||||
*
|
||||
* @return ConsoleOutputInterface
|
||||
*/
|
||||
function getOutput();
|
||||
|
||||
/**
|
||||
* Set an ConsoleOutput instance.
|
||||
*
|
||||
* @param ConsoleOutputInterface $output The output
|
||||
*/
|
||||
function setOutput(ConsoleOutputInterface $output);
|
||||
|
||||
/**
|
||||
* Returns an HelperInterface instance.
|
||||
*
|
||||
* @return HelperInterface
|
||||
*/
|
||||
function getHelper();
|
||||
|
||||
/**
|
||||
* Set an HelperInterface instance.
|
||||
*
|
||||
* @param HelperInterface $helper The helper
|
||||
*/
|
||||
function setHelper(HelperInterface $helper);
|
||||
|
||||
/**
|
||||
* Overwrites a previous 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 Boolean $newline Whether to add a newline or not
|
||||
* @param integer $type The type of output
|
||||
*/
|
||||
public function overwrite($messages, $size = 80, $newline = false, $type = 0);
|
||||
|
||||
/**
|
||||
* Overwrites a previous message to the output and adds a newline at the end.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines of a single string
|
||||
* @param integer $size The size of line
|
||||
* @param integer $type The type of output
|
||||
*/
|
||||
public function overwriteln($messages, $size = 80, $type = 0);
|
||||
|
||||
/**
|
||||
* Interactively prompts for input without echoing to the terminal.
|
||||
*
|
||||
* @param string $title The title of prompt (used only for windows)
|
||||
*
|
||||
* @return string The value
|
||||
*/
|
||||
public function promptSilent($title = '');
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Console\Output;
|
||||
|
||||
use Symfony\Component\Console\Output\ConsoleOutput as BaseConsoleOutput;
|
||||
|
||||
/**
|
||||
* ConsoleOutput is the default class for all CLI output.
|
||||
*
|
||||
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
||||
*/
|
||||
class ConsoleOutput extends BaseConsoleOutput
|
||||
{
|
||||
/**
|
||||
* Overwrites a previous 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 Boolean $newline Whether to add a newline or not
|
||||
* @param integer $type The type of output
|
||||
*/
|
||||
public function overwrite($messages, $size = 80, $newline = false, $type = 0)
|
||||
{
|
||||
for ($place = $size; $place > 0; $place--) {
|
||||
$this->write("\x08");
|
||||
}
|
||||
|
||||
$this->write($messages, false, $type);
|
||||
|
||||
for ($place = ($size - strlen($messages)); $place > 0; $place--) {
|
||||
$this->write(' ');
|
||||
}
|
||||
|
||||
// clean up the end line
|
||||
for ($place = ($size - strlen($messages)); $place > 0; $place--) {
|
||||
$this->write("\x08");
|
||||
}
|
||||
|
||||
if ($newline) {
|
||||
$this->writeln('');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrites a previous message to the output and adds a newline at the end.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines of a single string
|
||||
* @param integer $size The size of line
|
||||
* @param integer $type The type of output
|
||||
*/
|
||||
public function overwriteln($messages, $size = 80, $type = 0)
|
||||
{
|
||||
$this->write($messages, $size, true, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interactively prompts for input without echoing to the terminal.
|
||||
* Requires a bash shell or Windows and won't work with safe_mode
|
||||
* settings (Uses `shell_exec`).
|
||||
*
|
||||
* @param string $title The title of prompt (only for windows)
|
||||
*
|
||||
* @return string The value
|
||||
*/
|
||||
public function promptSilent($title = '')
|
||||
{
|
||||
if (preg_match('/^win/i', PHP_OS)) {
|
||||
$vbscript = sys_get_temp_dir() . '/prompt_password.vbs';
|
||||
file_put_contents($vbscript,
|
||||
'wscript.echo(Inputbox("' . addslashes($title) . '","'
|
||||
. addslashes($title) . '", ""))');
|
||||
$command = "cscript //nologo " . escapeshellarg($vbscript);
|
||||
$value = rtrim(shell_exec($command));
|
||||
unlink($vbscript);
|
||||
$this->writeln('');
|
||||
|
||||
return $value;
|
||||
|
||||
} else {
|
||||
$command = "/usr/bin/env bash -c 'echo OK'";
|
||||
|
||||
if (rtrim(shell_exec($command)) !== 'OK') {
|
||||
trigger_error("Can't invoke bash");
|
||||
return;
|
||||
}
|
||||
|
||||
$command = "/usr/bin/env bash -c 'read -s mypassword && echo \$mypassword'";
|
||||
$value = rtrim(shell_exec($command));
|
||||
$this->writeln('');
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,9 +11,8 @@
|
|||
|
||||
namespace Composer\Downloader;
|
||||
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
/**
|
||||
* Base downloader for file packages
|
||||
|
@ -24,20 +23,17 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
*/
|
||||
abstract class FileDownloader implements DownloaderInterface
|
||||
{
|
||||
protected $intput;
|
||||
protected $output;
|
||||
protected $wrapper;
|
||||
protected $bytesMax;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param InputInterface $input The Input instance
|
||||
* @param OutputInterface $output The Output instance
|
||||
* @param WrapperInterface $wrapper The Wrapper instance
|
||||
*/
|
||||
public function __construct(InputInterface $input, OutputInterface $output)
|
||||
public function __construct(WrapperInterface $wrapper)
|
||||
{
|
||||
$this->intput = $input;
|
||||
$this->output = $output;
|
||||
$this->wrapper = $wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +66,7 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
|
||||
$fileName = rtrim($path.'/'.md5(time().rand()).'.'.pathinfo($url, PATHINFO_EXTENSION), '.');
|
||||
|
||||
$this->output->writeln(" - Package <comment>" . $package->getName() . "</comment> (<info>" . $package->getPrettyVersion() . "</info>)");
|
||||
$this->wrapper->getOutput()->writeln(" - Package <comment>" . $package->getName() . "</comment> (<info>" . $package->getPrettyVersion() . "</info>)");
|
||||
|
||||
if (!extension_loaded('openssl') && (0 === strpos($url, 'https:') || 0 === strpos($url, 'http://github.com'))) {
|
||||
// bypass https for github if openssl is disabled
|
||||
|
@ -104,8 +100,7 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
|
||||
copy($url, $fileName, $ctx);
|
||||
|
||||
$this->output->overwrite(" Downloading: <comment>OK</comment>", 80);
|
||||
$this->writeln('');
|
||||
$this->wrapper->overwriteln(" Downloading: <comment>OK</comment>", 80);
|
||||
|
||||
if (!file_exists($fileName)) {
|
||||
throw new \UnexpectedValueException($url.' could not be saved to '.$fileName.', make sure the'
|
||||
|
@ -116,11 +111,11 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
throw new \UnexpectedValueException('The checksum verification of the archive failed (downloaded from '.$url.')');
|
||||
}
|
||||
|
||||
$this->output->writeln(' Unpacking archive');
|
||||
$this->wrapper->getOutput()->writeln(' Unpacking archive');
|
||||
$this->extract($fileName, $path);
|
||||
|
||||
|
||||
$this->output->writeln(' Cleaning up');
|
||||
$this->wrapper->getOutput()->writeln(' Cleaning up');
|
||||
unlink($fileName);
|
||||
|
||||
// If we have only a one dir inside it suppose to be a package itself
|
||||
|
@ -135,8 +130,8 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
rmdir($contentDir);
|
||||
}
|
||||
|
||||
$this->output->overwrite('');
|
||||
$this->output->writeln('');
|
||||
$this->wrapper->overwrite('');
|
||||
$this->wrapper->getOutput()->writeln('');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,7 +190,7 @@ abstract class FileDownloader implements DownloaderInterface
|
|||
$progression = round($progression, 0);
|
||||
|
||||
if (in_array($progression, $levels)) {
|
||||
$this->output->overwrite(" Downloading: <comment>$progression%</comment>", 80);
|
||||
$this->wrapper->overwrite(" Downloading: <comment>$progression%</comment>", 80);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,25 +15,17 @@ namespace Composer\Repository;
|
|||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||
use Composer\Json\JsonFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
||||
*/
|
||||
class ComposerRepository extends ArrayRepository
|
||||
{
|
||||
protected $url;
|
||||
protected $packages;
|
||||
protected $input;
|
||||
protected $output;
|
||||
|
||||
public function __construct(InputInterface $input, OutputInterface $output, array $config)
|
||||
public function __construct(array $config)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
|
||||
if (!preg_match('{^\w+://}', $config['url'])) {
|
||||
// assume http as the default protocol
|
||||
$config['url'] = 'http://'.$config['url'];
|
||||
|
|
|
@ -16,33 +16,24 @@ use Composer\Json\JsonFile;
|
|||
use Composer\Package\PackageInterface;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\Dumper\ArrayDumper;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
/**
|
||||
* Package repository.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
||||
*/
|
||||
class PackageRepository extends ArrayRepository
|
||||
{
|
||||
private $config;
|
||||
private $input;
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* Initializes filesystem repository.
|
||||
*
|
||||
* @param InputInterface $input The Input instance
|
||||
* @param OutputInterface $output The Output instance
|
||||
* @param array $config package definition
|
||||
* @param array $config package definition
|
||||
*/
|
||||
public function __construct(InputInterface $input, OutputInterface $output, array $config)
|
||||
public function __construct(array $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,21 +13,16 @@
|
|||
namespace Composer\Repository;
|
||||
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
/**
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
||||
*/
|
||||
class PearRepository extends ArrayRepository
|
||||
{
|
||||
protected $url;
|
||||
private $input;
|
||||
private $output;
|
||||
|
||||
public function __construct(InputInterface $input, OutputInterface $output, array $config)
|
||||
public function __construct(array $config)
|
||||
{
|
||||
if (!preg_match('{^https?://}', $config['url'])) {
|
||||
$config['url'] = 'http://'.$config['url'];
|
||||
|
@ -37,8 +32,6 @@ class PearRepository extends ArrayRepository
|
|||
}
|
||||
|
||||
$this->url = $config['url'];
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
protected function initialize()
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
|
||||
namespace Composer\Repository;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* Repositories manager.
|
||||
|
@ -27,13 +26,11 @@ class RepositoryManager
|
|||
private $localRepository;
|
||||
private $repositories = array();
|
||||
private $repositoryClasses = array();
|
||||
private $input;
|
||||
private $output;
|
||||
private $wrapper;
|
||||
|
||||
public function __construct(InputInterface $input, OutputInterface $output)
|
||||
public function __construct(WrapperInterface $wrapper)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
$this->wrapper = $wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +75,7 @@ class RepositoryManager
|
|||
}
|
||||
|
||||
$class = $this->repositoryClasses[$type];
|
||||
return new $class($this->input, $this->output, $config);
|
||||
return new $class($config, $this->wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
namespace Composer\Repository\Vcs;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* @author Per Bernhardt <plb@webfactory.de>
|
||||
|
@ -29,13 +28,13 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, InputInterface $input, OutputInterface $output)
|
||||
public function __construct($url, WrapperInterface $wrapper)
|
||||
{
|
||||
preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)\.git$#', $url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
|
||||
parent::__construct($url, $input, $output);
|
||||
parent::__construct($url, $wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
namespace Composer\Repository\Vcs;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
@ -17,11 +16,11 @@ class GitDriver extends VcsDriver implements VcsDriverInterface
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, InputInterface $input, OutputInterface $output)
|
||||
public function __construct($url, WrapperInterface $wrapper)
|
||||
{
|
||||
$this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/';
|
||||
|
||||
parent::__construct($url, $input, $output);
|
||||
parent::__construct($url, $wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
namespace Composer\Repository\Vcs;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
@ -19,13 +18,13 @@ class GitHubDriver extends VcsDriver implements VcsDriverInterface
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, InputInterface $input, OutputInterface $output)
|
||||
public function __construct($url, WrapperInterface $wrapper)
|
||||
{
|
||||
preg_match('#^(?:https?|git)://github\.com/([^/]+)/(.+?)(?:\.git)?$#', $url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
|
||||
parent::__construct($url, $input, $output);
|
||||
parent::__construct($url, $wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
namespace Composer\Repository\Vcs;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* @author Per Bernhardt <plb@webfactory.de>
|
||||
|
@ -29,13 +28,13 @@ class HgBitbucketDriver extends VcsDriver implements VcsDriverInterface
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, InputInterface $input, OutputInterface $output)
|
||||
public function __construct($url, WrapperInterface $wrapper)
|
||||
{
|
||||
preg_match('#^https://bitbucket\.org/([^/]+)/([^/]+)/?$#', $url, $match);
|
||||
$this->owner = $match[1];
|
||||
$this->repository = $match[2];
|
||||
|
||||
parent::__construct($url, $input, $output);
|
||||
parent::__construct($url, $wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
namespace Composer\Repository\Vcs;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* @author Per Bernhardt <plb@webfactory.de>
|
||||
|
@ -27,11 +26,11 @@ class HgDriver extends VcsDriver implements VcsDriverInterface
|
|||
protected $rootIdentifier;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, InputInterface $input, OutputInterface $output)
|
||||
public function __construct($url, WrapperInterface $wrapper)
|
||||
{
|
||||
$this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/';
|
||||
|
||||
parent::__construct($url, $input, $output);
|
||||
parent::__construct($url, $wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
namespace Composer\Repository\Vcs;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
@ -17,9 +16,9 @@ class SvnDriver extends VcsDriver implements VcsDriverInterface
|
|||
protected $branches;
|
||||
protected $infoCache = array();
|
||||
|
||||
public function __construct($url, InputInterface $input, OutputInterface $output)
|
||||
public function __construct($url, WrapperInterface $wrapper)
|
||||
{
|
||||
parent::__construct($this->baseUrl = rtrim($url, '/'), $input, $output);
|
||||
parent::__construct($this->baseUrl = rtrim($url, '/'), $wrapper);
|
||||
|
||||
if (false !== ($pos = strrpos($url, '/trunk'))) {
|
||||
$this->baseUrl = substr($url, 0, $pos);
|
||||
|
|
|
@ -13,32 +13,28 @@
|
|||
namespace Composer\Repository\Vcs;
|
||||
|
||||
/**
|
||||
* A driver implementation
|
||||
* A driver implementation for driver with authentification interaction.
|
||||
*
|
||||
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
||||
*/
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
abstract class VcsDriver
|
||||
{
|
||||
protected $url;
|
||||
protected $input;
|
||||
protected $output;
|
||||
protected $wrapper;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $url The URL
|
||||
* @param InputInterface $input The Input instance
|
||||
* @param OutputInterface $output The output instance
|
||||
* @param string $url The URL
|
||||
* @param WrapperInterface $wrapper The Wrapper instance
|
||||
*/
|
||||
public function __construct($url, InputInterface $input, OutputInterface $output)
|
||||
public function __construct($url, WrapperInterface $wrapper)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
$this->wrapper = $wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,8 +5,7 @@ namespace Composer\Repository;
|
|||
use Composer\Repository\Vcs\VcsDriverInterface;
|
||||
use Composer\Package\Version\VersionParser;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Composer\Console\Helper\WrapperInterface;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
|
@ -17,10 +16,9 @@ class VcsRepository extends ArrayRepository
|
|||
protected $url;
|
||||
protected $packageName;
|
||||
protected $debug;
|
||||
protected $input;
|
||||
protected $output;
|
||||
protected $wrapper;
|
||||
|
||||
public function __construct(InputInterface $input, OutputInterface $output, array $config, array $drivers = null)
|
||||
public function __construct(WrapperInterface $wrapper, array $config, array $drivers = null)
|
||||
{
|
||||
if (!filter_var($config['url'], FILTER_VALIDATE_URL)) {
|
||||
throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$config['url']);
|
||||
|
@ -36,8 +34,7 @@ class VcsRepository extends ArrayRepository
|
|||
);
|
||||
|
||||
$this->url = $config['url'];
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
$this->wrapper = $wrapper;
|
||||
}
|
||||
|
||||
public function setDebug($debug)
|
||||
|
@ -49,7 +46,7 @@ class VcsRepository extends ArrayRepository
|
|||
{
|
||||
foreach ($this->drivers as $driver) {
|
||||
if ($driver::supports($this->url)) {
|
||||
$driver = new $driver($this->url, $this->input, $this->output);
|
||||
$driver = new $driver($this->url, $this->wrapper);
|
||||
$driver->initialize();
|
||||
return $driver;
|
||||
}
|
||||
|
@ -57,7 +54,7 @@ class VcsRepository extends ArrayRepository
|
|||
|
||||
foreach ($this->drivers as $driver) {
|
||||
if ($driver::supports($this->url, true)) {
|
||||
$driver = new $driver($this->url);
|
||||
$driver = new $driver($this->url, $this->wrapper);
|
||||
$driver->initialize();
|
||||
return $driver;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue