From 927aeaa7057694a6573547c2b6701e56aac60635 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 24 Jun 2024 21:27:17 +0200 Subject: [PATCH] Remove `storyblok:components:overview` in favor of `storyblok:debug` --- CHANGELOG.md | 1 + UPGRADE.md | 7 +- src/Command/ComponentsOverviewCommand.php | 126 ---------------------- src/Command/DebugCommand.php | 19 +++- 4 files changed, 25 insertions(+), 128 deletions(-) delete mode 100644 src/Command/ComponentsOverviewCommand.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1673166..99bf645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * (improvement) Detect space id / content token mismatch and automatically abort all further requests. * (feature) Add `storyblok:debug` command. +* (deprecation) Deprecate `storyblok:components:overview` command, use `storyblok:debug` instead. 3.12.1 diff --git a/UPGRADE.md b/UPGRADE.md index 9f8bcd0..fa4fa9c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,6 +1,11 @@ -2.x to 4.0 +3.x to 4.0 ========== +* Removed `storyblok:components:overview` command, use `storyblok:debug` instead. + + +2.x to 4.0 +========== * `AbstractField::enablePreview()` is removed, use `AbstractField::useAsAdminDisplayName()` instead. diff --git a/src/Command/ComponentsOverviewCommand.php b/src/Command/ComponentsOverviewCommand.php deleted file mode 100644 index b98a1a6..0000000 --- a/src/Command/ComponentsOverviewCommand.php +++ /dev/null @@ -1,126 +0,0 @@ -title("Storyblok: Components Overview"); - - [$registered, $unregistered] = $this->fetchOverview($output->isVerbose()); - - if (!empty($registered)) - { - $io->section("Registered Components"); - $io->table( - [ - "Key", - "Name", - "Component", - "Story", - ], - $registered, - ); - } - - if (!empty($unregistered)) - { - $io->section("Unknown Components"); - $io->listing($unregistered); - } - - return 0; - } - - /** - * - */ - private function fetchOverview (bool $verbose) : array - { - $registered = []; - $unregistered = []; - - foreach ($this->managementApi->fetchAllRegisteredComponents() as $componentKey) - { - $details = $this->getComponentDetails($componentKey, $verbose); - - if (null === $details) - { - $unregistered[] = sprintf("%s", $componentKey); - continue; - } - - $registered[] = [ - sprintf("%s", $componentKey), - ...$details, - ]; - } - - return [$registered, $unregistered]; - } - - /** - * - */ - private function getComponentDetails (string $componentKey, bool $verbose) : ?array - { - $renderClass = static function (?string $className) use ($verbose) - { - if (null === $className) - { - return "—"; - } - - if (!$verbose) - { - $className = u($className)->afterLast("\\")->toString(); - } - - return sprintf("%s", $className); - }; - - try - { - $component = $this->componentManager->getComponent($componentKey); - - return [ - $component->getDisplayName(), - $renderClass(get_debug_type($component)), - $renderClass($component->getStoryClass()), - ]; - } - catch (UnknownComponentKeyException) - { - return null; - } - } -} diff --git a/src/Command/DebugCommand.php b/src/Command/DebugCommand.php index c92a21a..1d5bde8 100644 --- a/src/Command/DebugCommand.php +++ b/src/Command/DebugCommand.php @@ -15,7 +15,12 @@ use function Symfony\Component\String\u; -#[AsCommand("storyblok:debug")] +#[AsCommand( + "storyblok:debug", + description: "Displays debug info for the current Storyblok connection and config.", + // TODO v4: remove alias + aliases: ["storyblok:components:overview"], +)] final class DebugCommand extends Command { /** @@ -39,6 +44,18 @@ protected function execute (InputInterface $input, OutputInterface $output) : in $io = new TorrStyle($input, $output); $io->title("Storyblok: Debug"); + // TODO v4: remove check + if ("storyblok:debug" !== $input->getFirstArgument()) + { + $message = sprintf( + "The command `%s` is deprecated. Use `%s` instead.", + $input->getFirstArgument(), + "storyblok:debug", + ); + trigger_deprecation("21torr/storyblok", "3.13.0", $message); + $io->caution($message); + } + try { $this->showInfo($io);