Add --dry-run option and list all operations on --verbose
parent
d020f2701d
commit
f2662b193d
|
@ -37,6 +37,7 @@ class InstallCommand extends Command
|
||||||
->setDescription('Parses the composer.json file and downloads the needed dependencies.')
|
->setDescription('Parses the composer.json file and downloads the needed dependencies.')
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('dev', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
new InputOption('dev', 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).'),
|
||||||
))
|
))
|
||||||
->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
|
||||||
|
@ -52,11 +53,14 @@ EOT
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
return $this->install($output, $input->getOption('dev'));
|
return $this->install($input, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function install(OutputInterface $output, $preferSource, $update = false)
|
public function install(InputInterface $input, OutputInterface $output, $update = false)
|
||||||
{
|
{
|
||||||
|
$preferSource = (Boolean) $input->getOption('dev');
|
||||||
|
$dryRun = (Boolean) $input->getOption('dry-run');
|
||||||
|
$verbose = $dryRun || $input->getOption('verbose');
|
||||||
$composer = $this->getComposer();
|
$composer = $this->getComposer();
|
||||||
|
|
||||||
if ($preferSource) {
|
if ($preferSource) {
|
||||||
|
@ -142,20 +146,27 @@ EOT
|
||||||
|
|
||||||
// execute operations
|
// execute operations
|
||||||
foreach ($operations as $operation) {
|
foreach ($operations as $operation) {
|
||||||
$installationManager->execute($operation);
|
if ($verbose) {
|
||||||
|
$output->writeln((string) $operation);
|
||||||
|
}
|
||||||
|
if (!$dryRun) {
|
||||||
|
$installationManager->execute($operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($update || !$composer->getLocker()->isLocked()) {
|
if (!$dryRun) {
|
||||||
$composer->getLocker()->lockPackages($localRepo->getPackages());
|
if ($update || !$composer->getLocker()->isLocked()) {
|
||||||
$output->writeln('> Locked');
|
$composer->getLocker()->lockPackages($localRepo->getPackages());
|
||||||
|
$output->writeln('> Locked');
|
||||||
|
}
|
||||||
|
|
||||||
|
$localRepo->write();
|
||||||
|
|
||||||
|
$output->writeln('> Generating autoload files');
|
||||||
|
$generator = new AutoloadGenerator;
|
||||||
|
$generator->dump($localRepo, $composer->getPackage(), $installationManager, $installationManager->getVendorPath().'/.composer');
|
||||||
}
|
}
|
||||||
|
|
||||||
$localRepo->write();
|
|
||||||
|
|
||||||
$output->writeln('> Generating autoload files');
|
|
||||||
$generator = new AutoloadGenerator;
|
|
||||||
$generator->dump($localRepo, $composer->getPackage(), $installationManager, $installationManager->getVendorPath().'/.composer');
|
|
||||||
|
|
||||||
$output->writeln('> Done');
|
$output->writeln('> Done');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ class UpdateCommand extends Command
|
||||||
->setDescription('Updates your dependencies to the latest version, and updates the composer.lock file.')
|
->setDescription('Updates your dependencies to the latest version, and updates the composer.lock file.')
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputOption('dev', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
|
new InputOption('dev', 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).'),
|
||||||
))
|
))
|
||||||
->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
|
||||||
|
@ -53,6 +54,6 @@ EOT
|
||||||
$composer = $this->getComposer();
|
$composer = $this->getComposer();
|
||||||
|
|
||||||
$installCommand = $this->getApplication()->find('install');
|
$installCommand = $this->getApplication()->find('install');
|
||||||
return $installCommand->install($output, $input->getOption('dev'), true);
|
return $installCommand->install($input, $output, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,4 +55,12 @@ class InstallOperation extends SolverOperation
|
||||||
{
|
{
|
||||||
return 'install';
|
return 'install';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return 'Installing '.$this->package;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,4 +34,11 @@ interface OperationInterface
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getReason();
|
function getReason();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializes the operation in a human readable format
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function __toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,4 +55,12 @@ class UninstallOperation extends SolverOperation
|
||||||
{
|
{
|
||||||
return 'uninstall';
|
return 'uninstall';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return 'Uninstalling '.$this->package;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,4 +68,12 @@ class UpdateOperation extends SolverOperation
|
||||||
{
|
{
|
||||||
return 'update';
|
return 'update';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return 'Updating '.$this->initialPackage.' to '.$this->targetPackage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue