parent
a46296e938
commit
53191eb0fe
|
@ -32,8 +32,7 @@ class InstallCommand extends Command
|
|||
->setDefinition(array(
|
||||
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
||||
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
|
||||
new InputOption('no-install-recommends', null, InputOption::VALUE_NONE, 'Do not install recommended packages (ignored when installing from an existing lock file).'),
|
||||
new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages (ignored when installing from an existing lock file).'),
|
||||
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
The <info>install</info> command reads the composer.json file from the
|
||||
|
@ -57,8 +56,7 @@ EOT
|
|||
->setDryRun($input->getOption('dry-run'))
|
||||
->setVerbose($input->getOption('verbose'))
|
||||
->setPreferSource($input->getOption('prefer-source'))
|
||||
->setInstallRecommends(!$input->getOption('no-install-recommends'))
|
||||
->setInstallSuggests($input->getOption('install-suggests'))
|
||||
->setDevMode($input->getOption('dev'))
|
||||
;
|
||||
|
||||
return $install->run() ? 0 : 1;
|
||||
|
|
|
@ -30,8 +30,7 @@ class UpdateCommand extends Command
|
|||
->setDefinition(array(
|
||||
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
||||
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
|
||||
new InputOption('no-install-recommends', null, InputOption::VALUE_NONE, 'Do not install recommended packages.'),
|
||||
new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages.'),
|
||||
new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
The <info>update</info> command reads the composer.json file from the
|
||||
|
@ -55,11 +54,10 @@ EOT
|
|||
->setDryRun($input->getOption('dry-run'))
|
||||
->setVerbose($input->getOption('verbose'))
|
||||
->setPreferSource($input->getOption('prefer-source'))
|
||||
->setInstallRecommends(!$input->getOption('no-install-recommends'))
|
||||
->setInstallSuggests($input->getOption('install-suggests'))
|
||||
->setDevMode($input->getOption('dev'))
|
||||
->setUpdate(true)
|
||||
;
|
||||
|
||||
return $install->run();
|
||||
return $install->run() ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,18 +283,6 @@ class Solver
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package->getRecommends() as $link) {
|
||||
foreach ($this->pool->whatProvides($link->getTarget(), $link->getConstraint()) as $recommend) {
|
||||
$workQueue->enqueue($recommend);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($package->getSuggests() as $link) {
|
||||
foreach ($this->pool->whatProvides($link->getTarget(), $link->getConstraint()) as $suggest) {
|
||||
$workQueue->enqueue($suggest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,10 +77,9 @@ class Installer
|
|||
protected $eventDispatcher;
|
||||
|
||||
protected $preferSource = false;
|
||||
protected $devMode = false;
|
||||
protected $dryRun = false;
|
||||
protected $verbose = false;
|
||||
protected $installRecommends = true;
|
||||
protected $installSuggests = false;
|
||||
protected $update = false;
|
||||
|
||||
/**
|
||||
|
@ -332,14 +331,6 @@ class Installer
|
|||
{
|
||||
$links = $this->package->getRequires();
|
||||
|
||||
if ($this->installRecommends) {
|
||||
$links = array_merge($links, $this->package->getRecommends());
|
||||
}
|
||||
|
||||
if ($this->installSuggests) {
|
||||
$links = array_merge($links, $this->package->getSuggests());
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
|
@ -379,46 +370,20 @@ class Installer
|
|||
* @param boolean $dryRun
|
||||
* @return Installer
|
||||
*/
|
||||
public function setDryRun($dryRun=true)
|
||||
public function setDryRun($dryRun = true)
|
||||
{
|
||||
$this->dryRun = (boolean) $dryRun;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* install recommend packages
|
||||
*
|
||||
* @param boolean $noInstallRecommends
|
||||
* @return Installer
|
||||
*/
|
||||
public function setInstallRecommends($installRecommends=true)
|
||||
{
|
||||
$this->installRecommends = (boolean) $installRecommends;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* also install suggested packages
|
||||
*
|
||||
* @param boolean $installSuggests
|
||||
* @return Installer
|
||||
*/
|
||||
public function setInstallSuggests($installSuggests=true)
|
||||
{
|
||||
$this->installSuggests = (boolean) $installSuggests;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* prefer source installation
|
||||
*
|
||||
* @param boolean $preferSource
|
||||
* @return Installer
|
||||
*/
|
||||
public function setPreferSource($preferSource=true)
|
||||
public function setPreferSource($preferSource = true)
|
||||
{
|
||||
$this->preferSource = (boolean) $preferSource;
|
||||
|
||||
|
@ -431,20 +396,33 @@ class Installer
|
|||
* @param boolean $update
|
||||
* @return Installer
|
||||
*/
|
||||
public function setUpdate($update=true)
|
||||
public function setUpdate($update = true)
|
||||
{
|
||||
$this->update = (boolean) $update;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* enables dev packages
|
||||
*
|
||||
* @param boolean $update
|
||||
* @return Installer
|
||||
*/
|
||||
public function setDevMode($devMode = true)
|
||||
{
|
||||
$this->devMode = (boolean) $devMode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* run in verbose mode
|
||||
*
|
||||
* @param boolean $verbose
|
||||
* @return Installer
|
||||
*/
|
||||
public function setVerbose($verbose=true)
|
||||
public function setVerbose($verbose = true)
|
||||
{
|
||||
$this->verbose = (boolean) $verbose;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class AliasPackage extends BasePackage
|
|||
$this->dev = VersionParser::isDev($version);
|
||||
|
||||
// replace self.version dependencies
|
||||
foreach (array('requires', 'recommends', 'suggests') as $type) {
|
||||
foreach (array('requires', 'devRequires') as $type) {
|
||||
$links = $aliasOf->{'get'.ucfirst($type)}();
|
||||
foreach ($links as $index => $link) {
|
||||
// link is self.version, but must be replacing also the replaced version
|
||||
|
@ -141,17 +141,9 @@ class AliasPackage extends BasePackage
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRecommends()
|
||||
public function getDevRequires()
|
||||
{
|
||||
return $this->recommends;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getSuggests()
|
||||
{
|
||||
return $this->suggests;
|
||||
return $this->devRequires;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,6 +258,10 @@ class AliasPackage extends BasePackage
|
|||
{
|
||||
return $this->aliasOf->getHomepage();
|
||||
}
|
||||
public function getSuggests()
|
||||
{
|
||||
return $this->aliasOf->getSuggests();
|
||||
}
|
||||
public function getAuthors()
|
||||
{
|
||||
return $this->aliasOf->getAuthors();
|
||||
|
|
|
@ -25,12 +25,11 @@ use Composer\Repository\PlatformRepository;
|
|||
abstract class BasePackage implements PackageInterface
|
||||
{
|
||||
public static $supportedLinkTypes = array(
|
||||
'require' => 'requires',
|
||||
'conflict' => 'conflicts',
|
||||
'provide' => 'provides',
|
||||
'replace' => 'replaces',
|
||||
'recommend' => 'recommends',
|
||||
'suggest' => 'suggests',
|
||||
'require' => array('description' => 'requires', 'method' => 'requires'),
|
||||
'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'),
|
||||
'provide' => array('description' => 'provides', 'method' => 'provides'),
|
||||
'replace' => array('description' => 'replaces', 'method' => 'replaces'),
|
||||
'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'),
|
||||
);
|
||||
|
||||
protected $name;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
namespace Composer\Package\Dumper;
|
||||
|
||||
use Composer\Package\BasePackage;
|
||||
use Composer\Package\PackageInterface;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +27,6 @@ class ArrayDumper
|
|||
'binaries' => 'bin',
|
||||
'scripts',
|
||||
'type',
|
||||
'names',
|
||||
'extra',
|
||||
'installationSource' => 'installation-source',
|
||||
'license',
|
||||
|
@ -36,6 +36,7 @@ class ArrayDumper
|
|||
'keywords',
|
||||
'autoload',
|
||||
'repositories',
|
||||
'includePaths' => 'include-path',
|
||||
);
|
||||
|
||||
$data = array();
|
||||
|
@ -64,14 +65,18 @@ class ArrayDumper
|
|||
$data['dist']['shasum'] = $package->getDistSha1Checksum();
|
||||
}
|
||||
|
||||
foreach (array('require', 'conflict', 'provide', 'replace', 'suggest', 'recommend') as $linkType) {
|
||||
if ($links = $package->{'get'.ucfirst($linkType).'s'}()) {
|
||||
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
|
||||
if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
|
||||
foreach ($links as $link) {
|
||||
$data[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
|
||||
$data[$type][$link->getTarget()] = $link->getPrettyConstraint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($packages = $package->getSuggests()) {
|
||||
$data['suggest'] = $packages;
|
||||
}
|
||||
|
||||
foreach ($keys as $method => $key) {
|
||||
if (is_numeric($method)) {
|
||||
$method = $key;
|
||||
|
|
|
@ -156,15 +156,19 @@ class ArrayLoader
|
|||
}
|
||||
}
|
||||
|
||||
foreach (Package\BasePackage::$supportedLinkTypes as $type => $description) {
|
||||
foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
|
||||
if (isset($config[$type])) {
|
||||
$method = 'set'.ucfirst($description);
|
||||
$method = 'set'.ucfirst($opts['method']);
|
||||
$package->{$method}(
|
||||
$this->loadLinksFromConfig($package, $description, $config[$type])
|
||||
$this->loadLinksFromConfig($package, $opts['description'], $config[$type])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['suggest']) && is_array($config['suggest'])) {
|
||||
$package->setSuggests($config['suggest']);
|
||||
}
|
||||
|
||||
if (isset($config['autoload'])) {
|
||||
$package->setAutoload($config['autoload']);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class MemoryPackage extends BasePackage
|
|||
protected $conflicts = array();
|
||||
protected $provides = array();
|
||||
protected $replaces = array();
|
||||
protected $recommends = array();
|
||||
protected $devRequires = array();
|
||||
protected $suggests = array();
|
||||
protected $autoload = array();
|
||||
protected $includePaths = array();
|
||||
|
@ -484,25 +484,25 @@ class MemoryPackage extends BasePackage
|
|||
/**
|
||||
* Set the recommended packages
|
||||
*
|
||||
* @param array $recommends A set of package links
|
||||
* @param array $devRequires A set of package links
|
||||
*/
|
||||
public function setRecommends(array $recommends)
|
||||
public function setDevRequires(array $devRequires)
|
||||
{
|
||||
$this->recommends = $recommends;
|
||||
$this->devRequires = $devRequires;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getRecommends()
|
||||
public function getDevRequires()
|
||||
{
|
||||
return $this->recommends;
|
||||
return $this->devRequires;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the suggested packages
|
||||
*
|
||||
* @param array $suggests A set of package links
|
||||
* @param array $suggests A set of package names/comments
|
||||
*/
|
||||
public function setSuggests(array $suggests)
|
||||
{
|
||||
|
|
|
@ -220,20 +220,18 @@ interface PackageInterface
|
|||
function getReplaces();
|
||||
|
||||
/**
|
||||
* Returns a set of links to packages which are recommended in
|
||||
* combination with this package. These would most likely be installed
|
||||
* automatically in combination with this package.
|
||||
* Returns a set of links to packages which are required to develop
|
||||
* this package. These are installed if in dev mode.
|
||||
*
|
||||
* @return array An array of package links defining recommended packages
|
||||
* @return array An array of package links defining packages required for development
|
||||
*/
|
||||
function getRecommends();
|
||||
function getDevRequires();
|
||||
|
||||
/**
|
||||
* Returns a set of links to packages which are suggested in combination
|
||||
* with this package. These can be suggested to the user, but will not be
|
||||
* automatically installed with this package.
|
||||
* Returns a set of package names and reasons why they are useful in
|
||||
* combination with this package.
|
||||
*
|
||||
* @return array An array of package links defining suggested packages
|
||||
* @return array An array of package suggestions with descriptions
|
||||
*/
|
||||
function getSuggests();
|
||||
|
||||
|
|
Loading…
Reference in New Issue