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.",
|
||||
"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": {
|
||||
"type": ["array"],
|
||||
"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\Repository\RepositoryInterface;
|
||||
use Composer\Repository\CompositeRepository;
|
||||
use Composer\Repository\InstalledRepositoryInterface;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
|
||||
/**
|
||||
* A package pool contains repositories that provide packages.
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class Pool
|
||||
{
|
||||
protected $repositories = array();
|
||||
protected $packages = 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
|
||||
|
@ -33,9 +51,21 @@ class Pool
|
|||
*/
|
||||
public function addRepository(RepositoryInterface $repo)
|
||||
{
|
||||
if ($repo instanceof CompositeRepository) {
|
||||
$repos = $repo->getRepositories();
|
||||
} else {
|
||||
$repos = array($repo);
|
||||
}
|
||||
|
||||
foreach ($repos as $repo) {
|
||||
$this->repositories[] = $repo;
|
||||
|
||||
$exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
|
||||
foreach ($repo->getPackages() as $package) {
|
||||
if (!$exempt && !isset($this->acceptableStabilities[$package->getStability()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$package->setId(count($this->packages) + 1);
|
||||
$this->packages[] = $package;
|
||||
|
||||
|
@ -44,6 +74,7 @@ class Pool
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getPriority(RepositoryInterface $repo)
|
||||
{
|
||||
|
|
|
@ -207,7 +207,7 @@ class Installer
|
|||
}
|
||||
|
||||
// creating repository pool
|
||||
$pool = new Pool;
|
||||
$pool = new Pool($this->package->getMinimumStability());
|
||||
$pool->addRepository($installedRepo);
|
||||
foreach ($this->repositoryManager->getRepositories() as $repository) {
|
||||
$pool->addRepository($repository);
|
||||
|
|
|
@ -76,6 +76,10 @@ class RootPackageLoader extends ArrayLoader
|
|||
$package->setAliases($aliases);
|
||||
}
|
||||
|
||||
if (isset($config['minimum-stability'])) {
|
||||
$package->setMinimumStability($config['minimum-stability']);
|
||||
}
|
||||
|
||||
if (isset($config['repositories'])) {
|
||||
foreach ($config['repositories'] as $index => $repo) {
|
||||
if (isset($repo['packagist']) && $repo['packagist'] === false) {
|
||||
|
|
|
@ -48,6 +48,8 @@ class MemoryPackage extends BasePackage
|
|||
protected $prettyAlias;
|
||||
protected $dev;
|
||||
|
||||
protected $minimumStability = 'dev';
|
||||
|
||||
protected $requires = array();
|
||||
protected $conflicts = array();
|
||||
protected $provides = array();
|
||||
|
@ -597,6 +599,24 @@ class MemoryPackage extends BasePackage
|
|||
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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue