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