Add minimum-stability flag on root package to filter packages by stability
parent
b0134b56c5
commit
66068fedcb
|
@ -143,6 +143,10 @@
|
||||||
"description": "A set of additional repositories where packages can be found.",
|
"description": "A set of additional repositories where packages can be found.",
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
},
|
},
|
||||||
|
"minimum-stability": {
|
||||||
|
"type": ["string"],
|
||||||
|
"description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable."
|
||||||
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"type": ["array"],
|
"type": ["array"],
|
||||||
"description": "A set of files that should be treated as binaries and symlinked into bin-dir (from config).",
|
"description": "A set of files that should be treated as binaries and symlinked into bin-dir (from config).",
|
||||||
|
|
|
@ -14,17 +14,35 @@ namespace Composer\DependencyResolver;
|
||||||
|
|
||||||
use Composer\Package\LinkConstraint\LinkConstraintInterface;
|
use Composer\Package\LinkConstraint\LinkConstraintInterface;
|
||||||
use Composer\Repository\RepositoryInterface;
|
use Composer\Repository\RepositoryInterface;
|
||||||
|
use Composer\Repository\CompositeRepository;
|
||||||
|
use Composer\Repository\InstalledRepositoryInterface;
|
||||||
|
use Composer\Repository\PlatformRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A package pool contains repositories that provide packages.
|
* A package pool contains repositories that provide packages.
|
||||||
*
|
*
|
||||||
* @author Nils Adermann <naderman@naderman.de>
|
* @author Nils Adermann <naderman@naderman.de>
|
||||||
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
class Pool
|
class Pool
|
||||||
{
|
{
|
||||||
protected $repositories = array();
|
protected $repositories = array();
|
||||||
protected $packages = array();
|
protected $packages = array();
|
||||||
protected $packageByName = array();
|
protected $packageByName = array();
|
||||||
|
protected $acceptableStabilities;
|
||||||
|
|
||||||
|
public function __construct($minimumStability = 'dev')
|
||||||
|
{
|
||||||
|
$stabilities = array(
|
||||||
|
'stable',
|
||||||
|
'RC',
|
||||||
|
'beta',
|
||||||
|
'alpha',
|
||||||
|
'dev',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->acceptableStabilities = array_flip(array_splice($stabilities, 0, array_search($minimumStability, $stabilities) + 1));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a repository and its packages to this package pool
|
* Adds a repository and its packages to this package pool
|
||||||
|
@ -33,14 +51,27 @@ class Pool
|
||||||
*/
|
*/
|
||||||
public function addRepository(RepositoryInterface $repo)
|
public function addRepository(RepositoryInterface $repo)
|
||||||
{
|
{
|
||||||
$this->repositories[] = $repo;
|
if ($repo instanceof CompositeRepository) {
|
||||||
|
$repos = $repo->getRepositories();
|
||||||
|
} else {
|
||||||
|
$repos = array($repo);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($repo->getPackages() as $package) {
|
foreach ($repos as $repo) {
|
||||||
$package->setId(count($this->packages) + 1);
|
$this->repositories[] = $repo;
|
||||||
$this->packages[] = $package;
|
|
||||||
|
|
||||||
foreach ($package->getNames() as $name) {
|
$exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
|
||||||
$this->packageByName[$name][] = $package;
|
foreach ($repo->getPackages() as $package) {
|
||||||
|
if (!$exempt && !isset($this->acceptableStabilities[$package->getStability()])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$package->setId(count($this->packages) + 1);
|
||||||
|
$this->packages[] = $package;
|
||||||
|
|
||||||
|
foreach ($package->getNames() as $name) {
|
||||||
|
$this->packageByName[$name][] = $package;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ class Installer
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating repository pool
|
// creating repository pool
|
||||||
$pool = new Pool;
|
$pool = new Pool($this->package->getMinimumStability());
|
||||||
$pool->addRepository($installedRepo);
|
$pool->addRepository($installedRepo);
|
||||||
foreach ($this->repositoryManager->getRepositories() as $repository) {
|
foreach ($this->repositoryManager->getRepositories() as $repository) {
|
||||||
$pool->addRepository($repository);
|
$pool->addRepository($repository);
|
||||||
|
|
|
@ -76,6 +76,10 @@ class RootPackageLoader extends ArrayLoader
|
||||||
$package->setAliases($aliases);
|
$package->setAliases($aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($config['minimum-stability'])) {
|
||||||
|
$package->setMinimumStability($config['minimum-stability']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($config['repositories'])) {
|
if (isset($config['repositories'])) {
|
||||||
foreach ($config['repositories'] as $index => $repo) {
|
foreach ($config['repositories'] as $index => $repo) {
|
||||||
if (isset($repo['packagist']) && $repo['packagist'] === false) {
|
if (isset($repo['packagist']) && $repo['packagist'] === false) {
|
||||||
|
|
|
@ -48,6 +48,8 @@ class MemoryPackage extends BasePackage
|
||||||
protected $prettyAlias;
|
protected $prettyAlias;
|
||||||
protected $dev;
|
protected $dev;
|
||||||
|
|
||||||
|
protected $minimumStability = 'dev';
|
||||||
|
|
||||||
protected $requires = array();
|
protected $requires = array();
|
||||||
protected $conflicts = array();
|
protected $conflicts = array();
|
||||||
protected $provides = array();
|
protected $provides = array();
|
||||||
|
@ -597,6 +599,24 @@ class MemoryPackage extends BasePackage
|
||||||
return $this->homepage;
|
return $this->homepage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the minimumStability
|
||||||
|
*
|
||||||
|
* @param string $minimumStability
|
||||||
|
*/
|
||||||
|
public function setMinimumStability($minimumStability)
|
||||||
|
{
|
||||||
|
$this->minimumStability = $minimumStability;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getMinimumStability()
|
||||||
|
{
|
||||||
|
return $this->minimumStability;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the autoload mapping
|
* Set the autoload mapping
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue