-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[debug:update:composer] Add new command (#4105)
- Loading branch information
1 parent
05d4f8f
commit 79c425e
Showing
3 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\Console\Command\Debug\UpdateComposerCommand. | ||
*/ | ||
|
||
namespace Drupal\Console\Command\Debug; | ||
|
||
use Drupal\Console\Command\Shared\UpdateTrait; | ||
use Drupal\Console\Core\Utils\DrupalFinder; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Drupal\Console\Core\Command\Command; | ||
use Symfony\Component\Process\Process; | ||
|
||
class UpdateComposerCommand extends Command | ||
{ | ||
use UpdateTrait; | ||
|
||
/** | ||
* @var DrupalFinder | ||
*/ | ||
protected $drupalFinder; | ||
|
||
/** | ||
* DebugComposerCommand constructor. | ||
* | ||
* @param DrupalFinder $drupalFinder | ||
*/ | ||
public function __construct(DrupalFinder $drupalFinder) { | ||
$this->drupalFinder = $drupalFinder; | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('debug:update:composer') | ||
->setDescription($this->trans('commands.debug.update.composer.description')) | ||
->addOption( | ||
'only-drupal', | ||
null, | ||
InputOption::VALUE_NONE, | ||
$this->trans('commands.debug.update.composer.options.only-drupal') | ||
) | ||
->setAliases(['duc']); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$onlyDrupal = $input->getOption('only-drupal'); | ||
|
||
$process = new Process("composer show --outdated --format=json"); | ||
$process->setTimeout(null); | ||
$process->setWorkingDirectory($this->drupalFinder->getComposerRoot()); | ||
$process->run(); | ||
|
||
if($process->isSuccessful()){ | ||
$jsonData = json_decode($process->getOutput()); | ||
$this->showComposerUpdateTable($jsonData->installed, $onlyDrupal, $this->trans('commands.debug.update.composer.messages.composer-list')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters