diff --git a/src/Blocks/AbstractBlocksCli.php b/src/Blocks/AbstractBlocksCli.php index a1c901d45..98bf18099 100644 --- a/src/Blocks/AbstractBlocksCli.php +++ b/src/Blocks/AbstractBlocksCli.php @@ -232,17 +232,34 @@ private function outputDependencyItems(string $source, string $type): void if ($dependencies) { $componentsCommandName = UseComponentCli::COMMAND_NAME; - $allDependencies = \array_map(static fn ($item) => Components::camelToKebabCase($item), $dependencies); - $allDependencies = \implode(', ', \array_unique(\array_values($allDependencies))); + $blocksCommandName = UseBlockCli::COMMAND_NAME; - $this->cliLogAlert(\implode("\n", [ - "This {$type} may need some dependencies to work correctly.", - '', - 'To add them to your project, run:', - "%Uwp boilerplate {$this->getCommandParentName()} {$componentsCommandName} --name='{$allDependencies}'%n", - '', - 'If a dependency already exists in your project, you can skip it.', - ]), 'info', 'Dependencies found'); + $outputComand = []; + + if ($componentsDependencies) { + $componentsDependenciesAll = \array_map(static fn ($item) => Components::camelToKebabCase($item), $componentsDependencies); + $componentsDependenciesAll = \implode(', ', \array_unique(\array_values($componentsDependenciesAll))); + + $outputComand[] = "%Uwp boilerplate {$this->getCommandParentName()} {$componentsCommandName} --name='{$componentsDependenciesAll}'%n"; + } + + if ($innerBlocksDependency) { + $innerBlocksDependencyAll = \array_map(static fn ($item) => Components::camelToKebabCase($item), $innerBlocksDependency); + $innerBlocksDependencyAll = \implode(', ', \array_unique(\array_values($innerBlocksDependencyAll))); + + $outputComand[] = "%Uwp boilerplate {$this->getCommandParentName()} {$blocksCommandName} --name='{$innerBlocksDependencyAll}'%n"; + } + + if ($outputComand) { + $this->cliLogAlert(\implode("\n", [ + "This {$type} may need some dependencies to work correctly.", + '', + 'To add them to your project, run:', + ...$outputComand, + '', + 'If a dependency already exists in your project, you can skip it.', + ]), 'info', 'Dependencies found'); + } } } diff --git a/src/Blocks/UseBlockCli.php b/src/Blocks/UseBlockCli.php index 17556032d..bea3ebef3 100644 --- a/src/Blocks/UseBlockCli.php +++ b/src/Blocks/UseBlockCli.php @@ -18,6 +18,13 @@ */ class UseBlockCli extends AbstractBlocksCli { + /** + * Command name. + * + * @var string + */ + public const COMMAND_NAME = 'use-block'; + /** * Get WPCLI command parent name * @@ -35,7 +42,7 @@ public function getCommandParentName(): string */ public function getCommandName(): string { - return 'use-block'; + return self::COMMAND_NAME; } /**