Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Improve flow:package:list command #3363

Open
wants to merge 4 commits into
base: 8.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 11 additions & 32 deletions Neos.Flow/Classes/Command/PackageCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,46 +103,25 @@ 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();
$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'];
/** @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) {
$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');
}

/**
Expand Down
Loading