From 051c2d825a38bfe3b5ea8d10393a992f250cb903 Mon Sep 17 00:00:00 2001 From: Jesus Manuel Olivas Date: Sat, 28 Oct 2017 12:22:00 -0700 Subject: [PATCH] [debug:libraries] Show libraries when debugging extensions. (#3537) --- src/Command/Debug/LibrariesCommand.php | 48 ++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/Command/Debug/LibrariesCommand.php b/src/Command/Debug/LibrariesCommand.php index afd5b58a2..8d580787d 100644 --- a/src/Command/Debug/LibrariesCommand.php +++ b/src/Command/Debug/LibrariesCommand.php @@ -81,22 +81,58 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $group = $input->getArgument('group'); + $extension = $input->getArgument('group'); - if (!$group) { + if (!$extension) { $groups = $this->getAllLibraries(); + $tableRow = []; + $tableHeader = [ - $this->trans('commands.debug.libraries.messages.name'), + $this->trans('commands.debug.libraries.messages.extension'), + $this->trans('commands.debug.libraries.messages.library'), ]; - $io->table($tableHeader, $groups, 'compact'); + foreach ($groups as $extension) { + $library = $this->libraryDiscovery + ->getLibrariesByExtension($extension); + + if (!$library) { + continue; + } + + if ($libraryKeys = array_keys($library)) { + $libraryKeys = array_map( + function ($value) use ($extension) { + return $extension . '/' . $value; + }, + $libraryKeys + ); + + $tableRow[] = [ + $extension, + $libraryKeys = implode("\n", $libraryKeys) . "\n" + ]; + } + } + + $io->table($tableHeader, $tableRow, 'default'); } else { + $libraryName = null; + if ($library = explode('/', $extension)) { + $extension = $library[0]; + $libraryName = $library[1]; + } + $librariesData = $this->libraryDiscovery - ->getLibrariesByExtension($group); + ->getLibrariesByExtension($extension); foreach ($librariesData as $key => $libraries) { - $io->comment($key); + if ($libraryName && $libraryName != $key) { + continue; + } + + $io->writeln(''.$extension.'/'.$key.''); $io->writeln(Yaml::encode($libraries)); } }