Fix lowercase behavior
parent
a8f4c2d7c5
commit
07e181c6eb
|
@ -10,6 +10,8 @@ use Composer\Downloader\ZipDownloader;
|
|||
use Composer\Command\InstallCommand;
|
||||
use Composer\Installer\LibraryInstaller;
|
||||
|
||||
setlocale(LC_ALL, 'C');
|
||||
|
||||
$composer = new Composer();
|
||||
$composer->addDownloader('git', new GitDownloader);
|
||||
$composer->addDownloader('pear', new PearDownloader);
|
||||
|
|
|
@ -65,7 +65,7 @@ class InstallCommand
|
|||
// TODO there should be an update flag or dedicated update command
|
||||
// TODO check lock file to remove packages that disappeared from the requirements
|
||||
foreach ($config['require'] as $name => $version) {
|
||||
$name = $this->lowercase($name);
|
||||
$name = strtolower($name);
|
||||
if ('latest' === $version) {
|
||||
$request->install($name);
|
||||
} else {
|
||||
|
@ -90,7 +90,7 @@ class InstallCommand
|
|||
switch ($task['job']) {
|
||||
case 'install':
|
||||
$package = $task['package'];
|
||||
echo '> Installing '.$package->getName().PHP_EOL;
|
||||
echo '> Installing '.$package->getPrettyName().PHP_EOL;
|
||||
if ($sourceInstall) {
|
||||
// TODO
|
||||
} else {
|
||||
|
@ -98,16 +98,16 @@ class InstallCommand
|
|||
$downloaderType = $package->getDistType();
|
||||
$type = 'dist';
|
||||
} elseif ($package->getSourceType()) {
|
||||
echo 'Package '.$package->getName().' has no dist url, installing from source instead.';
|
||||
echo 'Package '.$package->getPrettyName().' has no dist url, installing from source instead.';
|
||||
$downloaderType = $package->getSourceType();
|
||||
$type = 'source';
|
||||
} else {
|
||||
throw new \UnexpectedValueException('Package '.$package->getName().' has no source or dist URL.');
|
||||
throw new \UnexpectedValueException('Package '.$package->getPrettyName().' has no source or dist URL.');
|
||||
}
|
||||
$downloader = $composer->getDownloader($downloaderType);
|
||||
$installer = $composer->getInstaller($package->getType());
|
||||
if (!$installer->install($package, $downloader, $type)) {
|
||||
throw new \LogicException($package->getName().' could not be installed.');
|
||||
throw new \LogicException($package->getPrettyName().' could not be installed.');
|
||||
}
|
||||
}
|
||||
$lock[$package->getName()] = array('version' => $package->getVersion());
|
||||
|
@ -158,12 +158,4 @@ class InstallCommand
|
|||
file_put_contents('composer.lock', json_encode($content, JSON_FORCE_OBJECT)."\n");
|
||||
echo '> composer.lock dumped'.PHP_EOL;
|
||||
}
|
||||
|
||||
protected function lowercase($str)
|
||||
{
|
||||
if (function_exists('mb_strtolower')) {
|
||||
return mb_strtolower($str, 'UTF-8');
|
||||
}
|
||||
return strtolower($str, 'UTF-8');
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ use Composer\Repository\RepositoryInterface;
|
|||
abstract class BasePackage implements PackageInterface
|
||||
{
|
||||
protected $name;
|
||||
protected $prettyName;
|
||||
protected $repository;
|
||||
protected $id;
|
||||
|
||||
|
@ -34,14 +35,13 @@ abstract class BasePackage implements PackageInterface
|
|||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->prettyName = $name;
|
||||
$this->name = strtolower($name);
|
||||
$this->id = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the package's name without version info, thus not a unique identifier
|
||||
*
|
||||
* @return string package name
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
|
@ -49,12 +49,15 @@ abstract class BasePackage implements PackageInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a set of names that could refer to this package
|
||||
*
|
||||
* No version or release type information should be included in any of the
|
||||
* names. Provided or replaced package names need to be returned as well.
|
||||
*
|
||||
* @return array An array of strings referring to this package
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPrettyName()
|
||||
{
|
||||
return $this->prettyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getNames()
|
||||
{
|
||||
|
@ -74,16 +77,16 @@ abstract class BasePackage implements PackageInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -157,7 +160,7 @@ abstract class BasePackage implements PackageInterface
|
|||
'version' => $matches[1]
|
||||
.(!empty($matches[2]) ? $matches[2] : '.0')
|
||||
.(!empty($matches[3]) ? $matches[3] : '.0'),
|
||||
'type' => strtolower(!empty($matches[4]) ? $matches[4] : 'stable'),
|
||||
'type' => !empty($matches[4]) ? strtolower($matches[4]) : 'stable',
|
||||
'dev' => !empty($matches[5]),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,13 @@ interface PackageInterface
|
|||
*/
|
||||
function getName();
|
||||
|
||||
/**
|
||||
* Returns the package's pretty (i.e. with proper case) name
|
||||
*
|
||||
* @return string package name
|
||||
*/
|
||||
function getPrettyName();
|
||||
|
||||
/**
|
||||
* Returns a set of names that could refer to this package
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue