From 0ce0a95bd2c68377b68bbd2c661823670d9b9ac4 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Mon, 24 Jun 2024 15:06:42 +0200 Subject: [PATCH] Release --- CHANGELOG.md | 4 ++++ Console/Command/ListModulesCommand.php | 30 +++++++++++++++++++++----- composer.json | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fecab7..4fe4af1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Console/Command/ListModulesCommand.php b/Console/Command/ListModulesCommand.php index 30f5e41..5d99b86 100644 --- a/Console/Command/ListModulesCommand.php +++ b/Console/Command/ListModulesCommand.php @@ -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; @@ -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)'); } /** @@ -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', @@ -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 diff --git a/composer.json b/composer.json index 72e4fa2..e306812 100644 --- a/composer.json +++ b/composer.json @@ -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": [