From e93efb21f062884f50f35acc6f4366f62a91dbf1 Mon Sep 17 00:00:00 2001 From: enzo - Eduardo Garcia Date: Sat, 21 Apr 2018 07:21:09 +1000 Subject: [PATCH] [core: getData] Added new parameters, Improve custom chain for gitbook update (#341) --- dist/chain/update-gitbook.yml | 10 +++++++--- src/Application.php | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/dist/chain/update-gitbook.yml b/dist/chain/update-gitbook.yml index 9cdd4c2..c42185e 100644 --- a/dist/chain/update-gitbook.yml +++ b/dist/chain/update-gitbook.yml @@ -1,5 +1,5 @@ # How to use -# update:gitbook --directory="/path/to/drupal-project/" +# update:gitbook --directory="/path/to/drupal-console/gitbook-repository/" command: name: update:gitbook description: 'Update gitbook' @@ -16,12 +16,16 @@ commands: - node - views - features -{% set languages = ['en', 'es', 'hi', 'hu', 'pt_br', 'ro', 'vn', 'zh_hans'] %} + - command: 'develop:translation:sync' +{% set languages = ['en', 'ca', 'es', 'hi', 'hu', 'ja', 'mr', 'pt-br', 'ro', 'ru', 'vn' , 'zh-hans'] %} {% for language in languages %} - command: settings:set arguments: name: language value: {{ language }} + - command: exec + arguments: + bin: 'rm -Rf {{ directory }}/{{ language }}/commands' - command: develop:doc:gitbook options: path: '{{ directory }}/{{ language }}' @@ -29,4 +33,4 @@ commands: - command: settings:set arguments: name: language - value: en + value: en \ No newline at end of file diff --git a/src/Application.php b/src/Application.php index 9ee2003..ae5166e 100644 --- a/src/Application.php +++ b/src/Application.php @@ -664,7 +664,7 @@ private function registerExtendCommands() ->loadExtendConfiguration(); } - public function getData() + public function getData($filterNamespaces = null, $excludeNamespaces = [], $excludeChainCommands = false) { $singleCommands = [ 'about', @@ -693,9 +693,16 @@ public function getData() return (strpos($item, ':')<=0); } ); + sort($namespaces); array_unshift($namespaces, 'misc'); + // Exclude specific namespaces + $namespaces = array_diff($namespaces, $excludeNamespaces); + + // filter namespaces if available + if($filterNamespaces) $namespaces = array_intersect($namespaces, $filterNamespaces); + foreach ($namespaces as $namespace) { $commands = $this->all($namespace); usort( @@ -705,6 +712,11 @@ public function getData() ); foreach ($commands as $command) { + // Exclude command if is a chain command and was requested to exclude chain commands + if($excludeChainCommands && $command instanceof ChainCustomCommand) { + continue; + } + if (method_exists($command, 'getModule')) { if ($command->getModule() == 'Console') { $data['commands'][$namespace][] = $this->commandData( @@ -719,6 +731,11 @@ public function getData() } } + // Remove namepsaces without commands + $namespaces = array_filter($namespaces, function($namespace) use( $data) { + return count($data['commands'][$namespace]) > 0; + }); + $input = $this->getDefinition(); $options = []; foreach ($input->getOptions() as $option) {