Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core: getData] Added new parameters, Improve custom chain for gitbook update #341

Merged
merged 20 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1096794
[chain] Avoid overwrite chain command options with global/default opt…
enzolutions May 25, 2017
b0f939c
Revert "[chain] Avoid overwrite chain command options with global/def…
enzolutions May 25, 2017
7eed558
[chain] Avoid overwrite chain command options with global/default opt…
enzolutions May 25, 2017
87cb227
Merge remote-tracking branch 'upstream/master'
enzolutions Jun 9, 2017
2655713
Remove YAML command in behalf of new separate repository https://gith…
enzolutions Jun 9, 2017
8d9dc91
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 3, 2017
0f82011
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 10, 2017
ccf5fc0
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 12, 2017
7aaa09e
Fix language separator hyphen instead of underscore
enzolutions Jul 12, 2017
0835cf1
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 13, 2017
bdc4c8e
Added constant DRUPAL_CONSOLE_LIBRARY to be used in library translations
enzolutions Jul 13, 2017
8986349
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 13, 2017
7cbfa49
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 14, 2017
8e16c27
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 14, 2017
9dd109f
Merge remote-tracking branch 'upstream/master'
enzolutions Jul 17, 2017
7e7a8c5
Expose drush command to all users
enzolutions Jul 24, 2017
4449dbf
Register drush command as a regular command
enzolutions Jul 26, 2017
c19b02f
Merge remote-tracking branch 'upstream/master'
enzolutions Oct 4, 2017
a52116a
Merge remote-tracking branch 'upstream/master'
enzolutions Apr 13, 2018
4cfb9e2
Update logic to return commands and namespaces base on parameters to …
enzolutions Apr 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dist/chain/update-gitbook.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -16,17 +16,21 @@ 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 }}'
{% endfor %}
- command: settings:set
arguments:
name: language
value: en
value: en
19 changes: 18 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ private function registerExtendCommands()
->loadExtendConfiguration();
}

public function getData()
public function getData($filterNamespaces = null, $excludeNamespaces = [], $excludeChainCommands = false)
{
$singleCommands = [
'about',
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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) {
Expand Down