Remove recommend, make suggest informational, add require-dev, fixes #78, fixes #510

main
Jordi Boggiano 12 years ago
parent a46296e938
commit 53191eb0fe

@ -32,8 +32,7 @@ class InstallCommand extends Command
->setDefinition(array( ->setDefinition(array(
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'), 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('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('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages (ignored when installing from an existing lock file).'),
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
The <info>install</info> command reads the composer.json file from the The <info>install</info> command reads the composer.json file from the
@ -57,8 +56,7 @@ EOT
->setDryRun($input->getOption('dry-run')) ->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose')) ->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source')) ->setPreferSource($input->getOption('prefer-source'))
->setInstallRecommends(!$input->getOption('no-install-recommends')) ->setDevMode($input->getOption('dev'))
->setInstallSuggests($input->getOption('install-suggests'))
; ;
return $install->run() ? 0 : 1; return $install->run() ? 0 : 1;

@ -30,8 +30,7 @@ class UpdateCommand extends Command
->setDefinition(array( ->setDefinition(array(
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'), 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('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('dev', null, InputOption::VALUE_NONE, 'Enables installation of dev-require packages.'),
new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages.'),
)) ))
->setHelp(<<<EOT ->setHelp(<<<EOT
The <info>update</info> command reads the composer.json file from the The <info>update</info> command reads the composer.json file from the
@ -55,11 +54,10 @@ EOT
->setDryRun($input->getOption('dry-run')) ->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose')) ->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source')) ->setPreferSource($input->getOption('prefer-source'))
->setInstallRecommends(!$input->getOption('no-install-recommends')) ->setDevMode($input->getOption('dev'))
->setInstallSuggests($input->getOption('install-suggests'))
->setUpdate(true) ->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 $eventDispatcher;
protected $preferSource = false; protected $preferSource = false;
protected $devMode = false;
protected $dryRun = false; protected $dryRun = false;
protected $verbose = false; protected $verbose = false;
protected $installRecommends = true;
protected $installSuggests = false;
protected $update = false; protected $update = false;
/** /**
@ -332,14 +331,6 @@ class Installer
{ {
$links = $this->package->getRequires(); $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; return $links;
} }
@ -379,7 +370,7 @@ class Installer
* @param boolean $dryRun * @param boolean $dryRun
* @return Installer * @return Installer
*/ */
public function setDryRun($dryRun=true) public function setDryRun($dryRun = true)
{ {
$this->dryRun = (boolean) $dryRun; $this->dryRun = (boolean) $dryRun;
@ -387,53 +378,40 @@ class Installer
} }
/** /**
* install recommend packages * prefer source installation
*
* @param boolean $noInstallRecommends
* @return Installer
*/
public function setInstallRecommends($installRecommends=true)
{
$this->installRecommends = (boolean) $installRecommends;
return $this;
}
/**
* also install suggested packages
* *
* @param boolean $installSuggests * @param boolean $preferSource
* @return Installer * @return Installer
*/ */
public function setInstallSuggests($installSuggests=true) public function setPreferSource($preferSource = true)
{ {
$this->installSuggests = (boolean) $installSuggests; $this->preferSource = (boolean) $preferSource;
return $this; return $this;
} }
/** /**
* prefer source installation * update packages
* *
* @param boolean $preferSource * @param boolean $update
* @return Installer * @return Installer
*/ */
public function setPreferSource($preferSource=true) public function setUpdate($update = true)
{ {
$this->preferSource = (boolean) $preferSource; $this->update = (boolean) $update;
return $this; return $this;
} }
/** /**
* update packages * enables dev packages
* *
* @param boolean $update * @param boolean $update
* @return Installer * @return Installer
*/ */
public function setUpdate($update=true) public function setDevMode($devMode = true)
{ {
$this->update = (boolean) $update; $this->devMode = (boolean) $devMode;
return $this; return $this;
} }
@ -444,7 +422,7 @@ class Installer
* @param boolean $verbose * @param boolean $verbose
* @return Installer * @return Installer
*/ */
public function setVerbose($verbose=true) public function setVerbose($verbose = true)
{ {
$this->verbose = (boolean) $verbose; $this->verbose = (boolean) $verbose;

@ -52,7 +52,7 @@ class AliasPackage extends BasePackage
$this->dev = VersionParser::isDev($version); $this->dev = VersionParser::isDev($version);
// replace self.version dependencies // replace self.version dependencies
foreach (array('requires', 'recommends', 'suggests') as $type) { foreach (array('requires', 'devRequires') as $type) {
$links = $aliasOf->{'get'.ucfirst($type)}(); $links = $aliasOf->{'get'.ucfirst($type)}();
foreach ($links as $index => $link) { foreach ($links as $index => $link) {
// link is self.version, but must be replacing also the replaced version // link is self.version, but must be replacing also the replaced version
@ -141,17 +141,9 @@ class AliasPackage extends BasePackage
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getRecommends() public function getDevRequires()
{ {
return $this->recommends; return $this->devRequires;
}
/**
* {@inheritDoc}
*/
public function getSuggests()
{
return $this->suggests;
} }
/** /**
@ -266,6 +258,10 @@ class AliasPackage extends BasePackage
{ {
return $this->aliasOf->getHomepage(); return $this->aliasOf->getHomepage();
} }
public function getSuggests()
{
return $this->aliasOf->getSuggests();
}
public function getAuthors() public function getAuthors()
{ {
return $this->aliasOf->getAuthors(); return $this->aliasOf->getAuthors();

@ -25,12 +25,11 @@ use Composer\Repository\PlatformRepository;
abstract class BasePackage implements PackageInterface abstract class BasePackage implements PackageInterface
{ {
public static $supportedLinkTypes = array( public static $supportedLinkTypes = array(
'require' => 'requires', 'require' => array('description' => 'requires', 'method' => 'requires'),
'conflict' => 'conflicts', 'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'),
'provide' => 'provides', 'provide' => array('description' => 'provides', 'method' => 'provides'),
'replace' => 'replaces', 'replace' => array('description' => 'replaces', 'method' => 'replaces'),
'recommend' => 'recommends', 'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'),
'suggest' => 'suggests',
); );
protected $name; protected $name;

@ -12,6 +12,7 @@
namespace Composer\Package\Dumper; namespace Composer\Package\Dumper;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
/** /**
@ -26,7 +27,6 @@ class ArrayDumper
'binaries' => 'bin', 'binaries' => 'bin',
'scripts', 'scripts',
'type', 'type',
'names',
'extra', 'extra',
'installationSource' => 'installation-source', 'installationSource' => 'installation-source',
'license', 'license',
@ -36,6 +36,7 @@ class ArrayDumper
'keywords', 'keywords',
'autoload', 'autoload',
'repositories', 'repositories',
'includePaths' => 'include-path',
); );
$data = array(); $data = array();
@ -64,14 +65,18 @@ class ArrayDumper
$data['dist']['shasum'] = $package->getDistSha1Checksum(); $data['dist']['shasum'] = $package->getDistSha1Checksum();
} }
foreach (array('require', 'conflict', 'provide', 'replace', 'suggest', 'recommend') as $linkType) { foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
if ($links = $package->{'get'.ucfirst($linkType).'s'}()) { if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
foreach ($links as $link) { 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) { foreach ($keys as $method => $key) {
if (is_numeric($method)) { if (is_numeric($method)) {
$method = $key; $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])) { if (isset($config[$type])) {
$method = 'set'.ucfirst($description); $method = 'set'.ucfirst($opts['method']);
$package->{$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'])) { if (isset($config['autoload'])) {
$package->setAutoload($config['autoload']); $package->setAutoload($config['autoload']);
} }

@ -53,7 +53,7 @@ class MemoryPackage extends BasePackage
protected $conflicts = array(); protected $conflicts = array();
protected $provides = array(); protected $provides = array();
protected $replaces = array(); protected $replaces = array();
protected $recommends = array(); protected $devRequires = array();
protected $suggests = array(); protected $suggests = array();
protected $autoload = array(); protected $autoload = array();
protected $includePaths = array(); protected $includePaths = array();
@ -484,25 +484,25 @@ class MemoryPackage extends BasePackage
/** /**
* Set the recommended packages * 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} * {@inheritDoc}
*/ */
public function getRecommends() public function getDevRequires()
{ {
return $this->recommends; return $this->devRequires;
} }
/** /**
* Set the suggested packages * 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) public function setSuggests(array $suggests)
{ {

@ -220,20 +220,18 @@ interface PackageInterface
function getReplaces(); function getReplaces();
/** /**
* Returns a set of links to packages which are recommended in * Returns a set of links to packages which are required to develop
* combination with this package. These would most likely be installed * this package. These are installed if in dev mode.
* automatically in combination with this package.
* *
* @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 * Returns a set of package names and reasons why they are useful in
* with this package. These can be suggested to the user, but will not be * combination with this package.
* automatically installed with this package.
* *
* @return array An array of package links defining suggested packages * @return array An array of package suggestions with descriptions
*/ */
function getSuggests(); function getSuggests();

Loading…
Cancel
Save