Skip to content

Commit e93efb2

Browse files
authored
[core: getData] Added new parameters, Improve custom chain for gitbook update (#341)
1 parent bf1fb4a commit e93efb2

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

dist/chain/update-gitbook.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# How to use
2-
# update:gitbook --directory="/path/to/drupal-project/"
2+
# update:gitbook --directory="/path/to/drupal-console/gitbook-repository/"
33
command:
44
name: update:gitbook
55
description: 'Update gitbook'
@@ -16,17 +16,21 @@ commands:
1616
- node
1717
- views
1818
- features
19-
{% set languages = ['en', 'es', 'hi', 'hu', 'pt_br', 'ro', 'vn', 'zh_hans'] %}
19+
- command: 'develop:translation:sync'
20+
{% set languages = ['en', 'ca', 'es', 'hi', 'hu', 'ja', 'mr', 'pt-br', 'ro', 'ru', 'vn' , 'zh-hans'] %}
2021
{% for language in languages %}
2122
- command: settings:set
2223
arguments:
2324
name: language
2425
value: {{ language }}
26+
- command: exec
27+
arguments:
28+
bin: 'rm -Rf {{ directory }}/{{ language }}/commands'
2529
- command: develop:doc:gitbook
2630
options:
2731
path: '{{ directory }}/{{ language }}'
2832
{% endfor %}
2933
- command: settings:set
3034
arguments:
3135
name: language
32-
value: en
36+
value: en

src/Application.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ private function registerExtendCommands()
664664
->loadExtendConfiguration();
665665
}
666666

667-
public function getData()
667+
public function getData($filterNamespaces = null, $excludeNamespaces = [], $excludeChainCommands = false)
668668
{
669669
$singleCommands = [
670670
'about',
@@ -693,9 +693,16 @@ public function getData()
693693
return (strpos($item, ':')<=0);
694694
}
695695
);
696+
696697
sort($namespaces);
697698
array_unshift($namespaces, 'misc');
698699

700+
// Exclude specific namespaces
701+
$namespaces = array_diff($namespaces, $excludeNamespaces);
702+
703+
// filter namespaces if available
704+
if($filterNamespaces) $namespaces = array_intersect($namespaces, $filterNamespaces);
705+
699706
foreach ($namespaces as $namespace) {
700707
$commands = $this->all($namespace);
701708
usort(
@@ -705,6 +712,11 @@ public function getData()
705712
);
706713

707714
foreach ($commands as $command) {
715+
// Exclude command if is a chain command and was requested to exclude chain commands
716+
if($excludeChainCommands && $command instanceof ChainCustomCommand) {
717+
continue;
718+
}
719+
708720
if (method_exists($command, 'getModule')) {
709721
if ($command->getModule() == 'Console') {
710722
$data['commands'][$namespace][] = $this->commandData(
@@ -719,6 +731,11 @@ public function getData()
719731
}
720732
}
721733

734+
// Remove namepsaces without commands
735+
$namespaces = array_filter($namespaces, function($namespace) use( $data) {
736+
return count($data['commands'][$namespace]) > 0;
737+
});
738+
722739
$input = $this->getDefinition();
723740
$options = [];
724741
foreach ($input->getOptions() as $option) {

0 commit comments

Comments
 (0)