From 59d6a948398f9b5d09623dac1841738c0b78b50f Mon Sep 17 00:00:00 2001 From: Simon Krull Date: Sat, 8 Jun 2024 08:44:00 +0200 Subject: [PATCH 1/4] FEATURE: Improve package:list command --- .../Command/PackageCommandController.php | 42 +++++-------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/Neos.Flow/Classes/Command/PackageCommandController.php b/Neos.Flow/Classes/Command/PackageCommandController.php index 25e6616f5a..53544e4739 100644 --- a/Neos.Flow/Classes/Command/PackageCommandController.php +++ b/Neos.Flow/Classes/Command/PackageCommandController.php @@ -103,46 +103,24 @@ public function createCommand(string $packageKey, string $packageType = PackageI /** * List available packages * - * Lists all locally available packages. Displays the package key, version and - * package title. + * Lists all locally available packages. Displays the package key, installed version and package title. * - * @param boolean $loadingOrder The returned packages are ordered by their loading order. * @return void The list of packages */ - public function listCommand(bool $loadingOrder = false) + public function listCommand(): void { - $availablePackages = []; - $frozenPackages = []; - $longestPackageKey = 0; + $availablePackages = $this->packageManager->getAvailablePackages(); + ksort($availablePackages); $freezeSupported = $this->bootstrap->getContext()->isDevelopment(); - foreach ($this->packageManager->getAvailablePackages() as $packageKey => $package) { - if (strlen($packageKey) > $longestPackageKey) { - $longestPackageKey = strlen($packageKey); - } - - $availablePackages[$packageKey] = $package; - - if ($this->packageManager->isPackageFrozen($packageKey)) { - $frozenPackages[$packageKey] = $package; - } - } - - if ($loadingOrder === false) { - ksort($availablePackages); - } - - $this->outputLine('PACKAGES:'); + $tableRows = []; + $tableHeaderRows = ['Package Key', 'Installed Version', 'Frozen State']; /** @var PackageInterface|PackageKeyAwareInterface $package */ - foreach ($availablePackages as $package) { - $frozenState = ($freezeSupported && isset($frozenPackages[$package->getPackageKey()]) ? '* ' : ' '); - $this->outputLine(' ' . str_pad($package->getPackageKey(), $longestPackageKey + 3) . $frozenState . str_pad($package->getInstalledVersion(), 15)); - } - - if (count($frozenPackages) > 0 && $freezeSupported) { - $this->outputLine(); - $this->outputLine(' * frozen package'); + foreach ($availablePackages as $packageKey => $package) { + $frozenState = ($freezeSupported && $this->packageManager->isPackageFrozen($packageKey) ? 'Frozen' : 'Not Frozen'); + $tableRows[] = [$package->getPackageKey(), $package->getInstalledVersion(), $frozenState]; } + $this->output->outputTable($tableRows, $tableHeaderRows); } /** From 6b9d33ee6ffafce439c5ef66e6627e9a798bae8b Mon Sep 17 00:00:00 2001 From: Simon Krull Date: Sat, 8 Jun 2024 15:41:50 +0200 Subject: [PATCH 2/4] TASK: use symbols instead of word to identify Frozen State --- Neos.Flow/Classes/Command/PackageCommandController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Neos.Flow/Classes/Command/PackageCommandController.php b/Neos.Flow/Classes/Command/PackageCommandController.php index 53544e4739..1ee8eb711b 100644 --- a/Neos.Flow/Classes/Command/PackageCommandController.php +++ b/Neos.Flow/Classes/Command/PackageCommandController.php @@ -117,7 +117,7 @@ public function listCommand(): void $tableHeaderRows = ['Package Key', 'Installed Version', 'Frozen State']; /** @var PackageInterface|PackageKeyAwareInterface $package */ foreach ($availablePackages as $packageKey => $package) { - $frozenState = ($freezeSupported && $this->packageManager->isPackageFrozen($packageKey) ? 'Frozen' : 'Not Frozen'); + $frozenState = ($freezeSupported && $this->packageManager->isPackageFrozen($packageKey) ? '✓' : '✗'); $tableRows[] = [$package->getPackageKey(), $package->getInstalledVersion(), $frozenState]; } $this->output->outputTable($tableRows, $tableHeaderRows); From 0facaaffbe4a09a0ec463d57006b614983ee8fea Mon Sep 17 00:00:00 2001 From: Simon Krull Date: Thu, 13 Jun 2024 14:55:08 +0200 Subject: [PATCH 3/4] TASK: remove Freeze State column and use * for package state besides packageKey --- Neos.Flow/Classes/Command/PackageCommandController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Neos.Flow/Classes/Command/PackageCommandController.php b/Neos.Flow/Classes/Command/PackageCommandController.php index 1ee8eb711b..90dadd2491 100644 --- a/Neos.Flow/Classes/Command/PackageCommandController.php +++ b/Neos.Flow/Classes/Command/PackageCommandController.php @@ -114,13 +114,15 @@ public function listCommand(): void $freezeSupported = $this->bootstrap->getContext()->isDevelopment(); $tableRows = []; - $tableHeaderRows = ['Package Key', 'Installed Version', 'Frozen State']; + $tableHeaderRows = ['Package Key', 'Installed Version']; /** @var PackageInterface|PackageKeyAwareInterface $package */ foreach ($availablePackages as $packageKey => $package) { - $frozenState = ($freezeSupported && $this->packageManager->isPackageFrozen($packageKey) ? '✓' : '✗'); - $tableRows[] = [$package->getPackageKey(), $package->getInstalledVersion(), $frozenState]; + $packageKeyWithFrozenState = ($freezeSupported && $this->packageManager->isPackageFrozen($packageKey)) ? $package->getPackageKey() . '*' : $package->getPackageKey(); + $tableRows[] = [$packageKeyWithFrozenState, $package->getInstalledVersion()]; } $this->output->outputTable($tableRows, $tableHeaderRows); + $this->outputLine(); + $this->outputLine('* = Frozen package'); } /** From 2d0f9fe7fce284d9692a00d4101ce08066252de1 Mon Sep 17 00:00:00 2001 From: Simon Krull Date: Fri, 14 Jun 2024 16:00:53 +0200 Subject: [PATCH 4/4] TASK: sort availablePackages by loading order --- Neos.Flow/Classes/Command/PackageCommandController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Neos.Flow/Classes/Command/PackageCommandController.php b/Neos.Flow/Classes/Command/PackageCommandController.php index 90dadd2491..5df8e06758 100644 --- a/Neos.Flow/Classes/Command/PackageCommandController.php +++ b/Neos.Flow/Classes/Command/PackageCommandController.php @@ -110,7 +110,6 @@ public function createCommand(string $packageKey, string $packageType = PackageI public function listCommand(): void { $availablePackages = $this->packageManager->getAvailablePackages(); - ksort($availablePackages); $freezeSupported = $this->bootstrap->getContext()->isDevelopment(); $tableRows = [];