Skip to content

Commit

Permalink
Release
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma committed Jun 24, 2024
1 parent cbb5eac commit 0ce0a95
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

# [2.4.1] = 24 June 2024
### Fixed
- Added JSON format to module list output

# [2.4.0] = 21 June 2024
### Added
- New CLI `yireo_extensionchecker:list:modules` (module name, enabled/disabled, composer version)
Expand Down
30 changes: 25 additions & 5 deletions Console/Command/ListModulesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface as Input;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface as Output;
use Yireo\ExtensionChecker\Composer\ComposerFileFactory;
use Yireo\ExtensionChecker\Composer\ComposerProvider;
Expand Down Expand Up @@ -41,6 +42,7 @@ protected function configure()
{
$this->setName('yireo_extensionchecker:list:modules');
$this->setDescription('List all Magento modules');
$this->addOption('format', null, InputOption::VALUE_OPTIONAL, 'Format (json, default)');
}

/**
Expand All @@ -51,6 +53,14 @@ protected function configure()
*/
protected function execute(Input $input, Output $output): int
{
$moduleRows = $this->getModuleRows();
$format = $input->getOption('format');

if ($format === 'json') {
$output->writeln(json_encode($moduleRows));
return Command::SUCCESS;
}

$table = new Table($output);
$table->setHeaders([
'Module',
Expand All @@ -59,25 +69,35 @@ protected function execute(Input $input, Output $output): int
'Composer Version'
]);

foreach ($moduleRows as $moduleRow) {
$table->addRow($moduleRow);
}

$table->render();

return Command::SUCCESS;
}

private function getModuleRows(): array
{
$componentPaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE);
$moduleNames = array_keys($componentPaths);
$moduleRows = [];

foreach ($moduleNames as $moduleName) {
$moduleInfo = $this->moduleList->getOne($moduleName);
$status = $moduleInfo ? 'enabled' : 'disabled';
$setupVersion = isset($moduleInfo['setup_version']) ? $moduleInfo['setup_version'] : '-';

$table->addRow([
$moduleRows[] = [
$moduleName,
$status,
$setupVersion,
$this->getComposerVersion($moduleName)
]);
];
}

$table->render();

return Command::SUCCESS;
return $moduleRows;
}

private function getComposerVersion(string $moduleName): string
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "yireo/magento2-extensionchecker",
"license": "OSL-3.0",
"type": "magento2-module",
"version": "2.4.0",
"version": "2.4.1",
"homepage": "https://github.com/yireo/Yireo_ExtensionChecker",
"description": "Scan the code of a Magento module",
"keywords": [
Expand Down

0 comments on commit 0ce0a95

Please sign in to comment.