Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 2021c3c

Browse files
authored
Adding more verbosity control variables. (#530)
* Adding more verbosity control variables. * Documenting vars.
1 parent 822b39d commit 2021c3c

14 files changed

+157
-59
lines changed

phing/build.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<taskdef name="randomstring" classname="phingcludes.RandomStringTask" />
88
<taskdef name="disabletargets" classname="phingcludes.DisableTargetsTask" />
99
<taskdef name="filterFileListByFileSet" classname="phingcludes.FilterFileListByFileSetTask"/>
10+
<taskdef name="verbosityTask" classname="phingcludes.VerbosityTask"/>
1011
<taskdef name="phpVariable" classname="phingcludes.PhpVariableTask"/>
1112

1213
<if>
@@ -89,7 +90,7 @@
8990
<available file="${target-hooks.${hook-name}.dir}" type="dir" property="dirExists" />
9091
<then>
9192
<echo>Executing command in ${target-hooks.${hook-name}.dir}:</echo>
92-
<exec dir="${target-hooks.${hook-name}.dir}" command="${target-hooks.${hook-name}.command}" logoutput="true" checkreturn="true" level="info" passthru="true" />
93+
<exec dir="${target-hooks.${hook-name}.dir}" command="${target-hooks.${hook-name}.command}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true" />
9394
</then>
9495
<else>
9596
<fail>The directory ${target-hooks.${hook-name}.dir} does not exist. Will not run command for ${hook-name}.</fail>

phing/build.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@ behat:
1313
# - ${docroot}/profiles
1414
- ${repo.root}/tests/behat
1515
tags: '~ajax'
16+
verbose: ${blt.verbose}
1617

1718
blt:
1819
update:
1920
ignore-existing-file: ${blt.root}/scripts/blt/ignore-existing.txt
21+
# Default verbosity level for <exec> tasks.
22+
exec_level: verbose
23+
# If blt.level >= info, this will be changed to true. Affects verbosity of tasks like Drush, Behat.
24+
verbose: false
25+
# From most to least verbose: debug, verbose, info, warn, error.
26+
# Equivalent of using Phing arguments -debug, -verbose, [none], -quiet, -silent
27+
# Note that this does not affect passthru output.
28+
level: info
2029

2130
composer:
2231
bin: ${repo.root}/vendor/bin
2332

2433
deploy:
34+
# If true, dependencies will be built during deploy. If false, you should commit dependencies directly.
2535
build-dependencies: true
2636
dir: ${repo.root}/deploy
2737
exclude_file: ${blt.root}/phing/files/deploy-exclude.txt
@@ -44,7 +54,7 @@ drush:
4454
uri: ${multisite.name}
4555
assume: yes
4656
passthru: yes
47-
verbose: yes
57+
verbose: ${blt.verbose}
4858

4959
multisite:
5060
# The docroot/sites/default directory is used by default.

phing/phingcludes/BehatTask.php

+18-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public function setStrict($strict)
289289
*/
290290
public function setVerbose($verbose)
291291
{
292-
$this->verbose = StringHelper::booleanValue($verbose);
292+
$this->verbose = StringHelper::booleanValue($verbose) || StringHelper::booleanValue((bool) $verbose);
293293
}
294294

295295
/**
@@ -385,6 +385,13 @@ protected function behatExists($executable)
385385
return (empty($return) ? false : true);
386386
}
387387

388+
/**
389+
* Initialize the task.
390+
*/
391+
public function init() {
392+
$this->setVerbose($this->getProject()->getProperty('behat.verbose'));
393+
}
394+
388395
/**
389396
* The main entry point method.
390397
*
@@ -471,6 +478,10 @@ public function main()
471478
$this->options[] = 'verbose';
472479
}
473480

481+
if (Phing::getMsgOutputLevel() >= Project::MSG_VERBOSE) {
482+
$this->options[] = 'verbose';
483+
}
484+
474485
if ($this->colors) {
475486
$this->options[] = 'colors';
476487
}
@@ -488,7 +499,12 @@ public function main()
488499
$command[] = $this->createOption($name, $value);
489500
}
490501
$command = implode(' ', $command);
491-
$this->log("Running '$command'");
502+
if ($this->verbose) {
503+
$this->log("Running '$command'", Project::MSG_INFO);
504+
}
505+
else {
506+
$this->log("Running '$command'", Project::MSG_VERBOSE);
507+
}
492508

493509
// Run Behat.
494510
$last_line = system($command, $return);

phing/phingcludes/VerbosityTask.php

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/**
4+
* A phing task to loop through properties.
5+
*/
6+
require_once 'phing/Task.php';
7+
use Symfony\Component\Yaml\Yaml;
8+
9+
class VerbosityTask extends Task {
10+
11+
/**
12+
* Path the Drush executable.
13+
*/
14+
public function setLevel($str) {
15+
$this->level = $str;
16+
}
17+
18+
19+
/**
20+
* The main entry point method.
21+
*
22+
* @return bool
23+
* @throws BuildException
24+
*/
25+
public function main() {
26+
27+
$map = [
28+
'debug' => Project::MSG_DEBUG,
29+
'verbose' => Project::MSG_VERBOSE,
30+
'info' => Project::MSG_INFO,
31+
'warn' => Project::MSG_WARN,
32+
'error' => Project::MSG_ERR,
33+
];
34+
35+
if (is_numeric($this->level)) {
36+
$this->setLoggerLevel($this->level);
37+
}
38+
elseif (array_key_exists($this->level, $map)) {
39+
$this->setLoggerLevel($map[$this->level]);
40+
}
41+
else {
42+
$this->log("blt.level '{$this->level}' is invalid. Acceptable values are " . implode(', ', array_keys($map)), Project::MSG_ERR);
43+
}
44+
}
45+
public function setLoggerLevel($level) {
46+
$listeners = $this->getProject()->getBuildListeners();
47+
foreach ($listeners as $listener) {
48+
$listener->setMessageOutputLevel($level);
49+
}
50+
}
51+
52+
}

phing/tasks/acsf.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<target name="acsf:init" description="Initializes ACSF support for project.">
44
<echo>Adding acsf module as a dependency.</echo>
5-
<exec dir="${repo.root}" command="composer require drupal/acsf:^8" logoutput="true" checkreturn="true" passthru="true" level="info"/>
5+
<exec dir="${repo.root}" command="composer require drupal/acsf:^8" logoutput="true" checkreturn="true" passthru="true" level="${blt.exec_level}"/>
66
<echo>Executing initialization command for acsf module.</echo>
77
<drush command="acsf-init">
88
<option name="include">"${docroot}/modules/contrib/acsf/acsf_init"</option>

phing/tasks/blt.xml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<project name="blt" default="update">
22
<target name="create-project" hidden="true">
3-
<exec dir="${repo.root}" command="git init" logoutput="true" checkreturn="true" level="info" passthru="true"/>
3+
<exec dir="${repo.root}" command="git init" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
44
<echo>Updating composer dependencies, this make take a while...</echo>
5-
<exec dir="${repo.root}" command="export COMPOSER_PROCESS_TIMEOUT=600; composer update --no-interaction" logoutput="true" checkreturn="true" level="info" passthru="true"/>
6-
<exec dir="${repo.root}" command="git add -A" logoutput="true" checkreturn="true" level="info" passthru="true"/>
7-
<exec dir="${repo.root}" command="git commit -m 'Initial commit.'" logoutput="true" checkreturn="true" level="info" passthru="true"/>
5+
<exec dir="${repo.root}" command="export COMPOSER_PROCESS_TIMEOUT=600; composer update --no-interaction" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
6+
<exec dir="${repo.root}" command="git add -A" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
7+
<exec dir="${repo.root}" command="git commit -m 'Initial commit.'" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
88
<exec dir="${repo.root}" command="cat ${blt.root}/scripts/blt/ascii-art.txt" logoutput="true" passthru="true" checkreturn="false"/>
99
</target>
1010

@@ -17,10 +17,10 @@
1717
<target name="blt:rsync-template" hidden="true">
1818
<echo>Copying files from BLT's template into your project.</echo>
1919
<!-- @todo Do not overwrite structured or executable files. Instead, update them intelligently settings.php, drush.wrapper etc. -->
20-
<exec dir="${repo.root}" command="rsync -a --no-g ${blt.root}/template/ ${repo.root}/ --exclude-from=${blt.update.ignore-existing-file}" logoutput="true" checkreturn="true" level="info" passthru="true"/>
20+
<exec dir="${repo.root}" command="rsync -a --no-g ${blt.root}/template/ ${repo.root}/ --exclude-from=${blt.update.ignore-existing-file}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
2121

2222
<!--Rsync files without overwriting existing-->
23-
<exec dir="${repo.root}" command="rsync -a --no-g ${blt.root}/template/ ${repo.root}/ --include-from=${blt.update.ignore-existing-file} --ignore-existing" logoutput="true" checkreturn="true" level="info" passthru="true"/>
23+
<exec dir="${repo.root}" command="rsync -a --no-g ${blt.root}/template/ ${repo.root}/ --include-from=${blt.update.ignore-existing-file} --ignore-existing" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
2424
</target>
2525

2626
<target name="update" depends="blt:rsync-template, blt:update-composer, blt:update-yml, setup:drupal:settings" hidden="true">
@@ -41,9 +41,9 @@
4141
<echo>Merging BLT's composer.json template with your project's composer.json.</echo>
4242
<echo>This MAY overwrite some existing values.</echo>
4343
<!--Values in the project's existing composer.json file will be overwritten.-->
44-
<exec dir="${repo.root}" command="${repo.root}/vendor/bin/blt-console composer:munge ${repo.root}/composer.json ${blt.root}/template/composer.json > ${repo.root}/composer.json.tmp" logoutput="true" checkreturn="true" level="info"/>
44+
<exec dir="${repo.root}" command="${repo.root}/vendor/bin/blt-console composer:munge ${repo.root}/composer.json ${blt.root}/template/composer.json > ${repo.root}/composer.json.tmp" logoutput="true" checkreturn="true" level="${blt.exec_level}"/>
4545
<!--@todo Find out why can't we just redirect output directly back to composer.json. -->
46-
<exec dir="${repo.root}" command="mv ${repo.root}/composer.json.tmp ${repo.root}/composer.json" logoutput="true" checkreturn="true" level="info" passthru="true"/>
46+
<exec dir="${repo.root}" command="mv ${repo.root}/composer.json.tmp ${repo.root}/composer.json" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
4747
<echo>If your composer.json was modified, you need to run "composer update".</echo>
4848
</target>
4949

@@ -52,14 +52,14 @@
5252
<echo>Merging BLT's project.yml template with your project's project.yml.</echo>
5353
<echo>This WILL NOT overwrite existing values.</echo>
5454
<!--Values in the project's existing project.yml file will be preserved and not overridden.-->
55-
<exec dir="${repo.root}" command="${repo.root}/vendor/bin/blt-console yaml:munge ${blt.root}/template/project.yml ${repo.root}/project.yml > ${repo.root}/project.yml.tmp" logoutput="true" checkreturn="true" level="info"/>
55+
<exec dir="${repo.root}" command="${repo.root}/vendor/bin/blt-console yaml:munge ${blt.root}/template/project.yml ${repo.root}/project.yml > ${repo.root}/project.yml.tmp" logoutput="true" checkreturn="true" level="${blt.exec_level}"/>
5656
<!--@todo Find out why can't we just redirect output directly back to project.yml. -->
57-
<exec dir="${repo.root}" command="mv ${repo.root}/project.yml.tmp ${repo.root}/project.yml" logoutput="true" checkreturn="true" level="info" passthru="true"/>
57+
<exec dir="${repo.root}" command="mv ${repo.root}/project.yml.tmp ${repo.root}/project.yml" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
5858
<echo>project.yml has been modified.</echo>
5959
</target>
6060

6161
<target name="cleanup" description="Removes deprecated BLT files and directories.">
62-
<exec dir="${repo.root}" command="${blt.root}/scripts/blt/remove-deprecated.sh" logoutput="true" checkreturn="true" level="info" passthru="true" />
62+
<exec dir="${repo.root}" command="${blt.root}/scripts/blt/remove-deprecated.sh" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true" />
6363
</target>
6464

6565
<target name="install-alias" description="Installs the BLT alias for command line usage." hidden="true">
@@ -69,10 +69,10 @@
6969
<if>
7070
<equals arg1="${create_alias}" arg2="true"/>
7171
<then>
72-
<exec dir="${blt.root}/scripts/blt" command="./install-alias.sh -y" logoutput="true" level="info" passthru="true"/>
72+
<exec dir="${blt.root}/scripts/blt" command="./install-alias.sh -y" logoutput="true" level="${blt.exec_level}" passthru="true"/>
7373
</then>
7474
<else>
75-
<exec dir="${blt.root}/scripts/blt" command="./install-alias.sh" logoutput="true" level="info" passthru="true"/>
75+
<exec dir="${blt.root}/scripts/blt" command="./install-alias.sh" logoutput="true" level="${blt.exec_level}" passthru="true"/>
7676
</else>
7777
</if>
7878
</then>

phing/tasks/deploy.xml

+14-14
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@
4949
<echo message="Fetching from git remote ${deploy.remote}"/>
5050

5151
<!-- Generate an md5 sum of the remote URL to use as remote name. -->
52-
<exec command="echo ${deploy.remote} | openssl md5 | cut -d' ' -f 2" outputProperty="remoteName" checkreturn="true" level="info"/>
53-
<exec command="git remote add ${remoteName} ${deploy.remote}" dir="${deploy.dir}" logoutput="true" checkreturn="true" level="info" passthru="true"/>
52+
<exec command="echo ${deploy.remote} | openssl md5 | cut -d' ' -f 2" outputProperty="remoteName" checkreturn="true" level="${blt.exec_level}"/>
53+
<exec command="git remote add ${remoteName} ${deploy.remote}" dir="${deploy.dir}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
5454

5555
<!-- @todo Only call this for the first remote. -->
5656
<phingcall target="deploy:remote:pull" />
5757
</target>
5858

5959
<target name="deploy:remote:pull" description="Checks out deploy branch from upstream remote." hidden="true">
60-
<exec command="git fetch ${remoteName} ${deploy.branch}" dir="${deploy.dir}" logoutput="true" level="info" passthru="true"/>
60+
<exec command="git fetch ${remoteName} ${deploy.branch}" dir="${deploy.dir}" logoutput="true" level="${blt.exec_level}" passthru="true"/>
6161

6262
<!-- Create the new branch, "[source-branch-name]-build". -->
6363
<!-- We intentionally use checkreturn="false" in case the branch already exists. `git checkout -B` does not seem to work as advertised -->
64-
<exec command="git checkout -b ${deploy.branch}" dir="${deploy.dir}" logoutput="true" checkreturn="false" level="info" passthru="true"/>
64+
<exec command="git checkout -b ${deploy.branch}" dir="${deploy.dir}" logoutput="true" checkreturn="false" level="${blt.exec_level}" passthru="true"/>
6565

6666
<!-- Pull the latest updates (if available). -->
6767
<exec command="git merge ${remoteName}/${deploy.branch}" dir="${deploy.dir}" logoutput="true" passthru="true"/>
@@ -88,8 +88,8 @@
8888

8989
<target name="deploy:commit" hidden="true">
9090
<!-- We make these commands quiet because they can cause the output to be so long that Travis CI stops logging. -->
91-
<exec command="git add -A" dir="${deploy.dir}" logoutput="true" checkreturn="true" level="info" passthru="true"/>
92-
<exec command="git commit -m '${deploy.commitMsg}' --quiet" dir="${deploy.dir}" logoutput="true" checkreturn="true" level="info" passthru="true"/>
91+
<exec command="git add -A" dir="${deploy.dir}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
92+
<exec command="git commit -m '${deploy.commitMsg}' --quiet" dir="${deploy.dir}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
9393
</target>
9494

9595
<target name="deploy:composer:install" description="Downloads core and contrib to deploy folder." hidden="true">
@@ -104,7 +104,7 @@
104104
<include name="composer.lock"/>
105105
</fileset>
106106
</copy>
107-
<exec dir="${deploy.dir}" command="export COMPOSER_EXIT_ON_PATCH_FAILURE=1; composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader" logoutput="true" checkreturn="true" level="info" passthru="true"/>
107+
<exec dir="${deploy.dir}" command="export COMPOSER_EXIT_ON_PATCH_FAILURE=1; composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
108108
</then>
109109
<else>
110110
<echo>Dependencies will not be built because deploy.build-dependencies is not enabled.</echo>
@@ -119,7 +119,7 @@
119119
<!-- @todo Support multisite. -->
120120
<chmod file="${docroot}/sites/default" mode="0777" />
121121

122-
<exec dir="${repo.root}" command="rsync -a --no-g --delete --delete-excluded --exclude-from=${deploy.exclude_file} ${repo.root}/ ${deploy.dir}/ --filter 'protect /.git/'" logoutput="true" checkreturn="true" level="info" passthru="true"/>
122+
<exec dir="${repo.root}" command="rsync -a --no-g --delete --delete-excluded --exclude-from=${deploy.exclude_file} ${repo.root}/ ${deploy.dir}/ --filter 'protect /.git/'" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
123123

124124
<!-- Use our own .gitignore -->
125125
<copy file="${deploy.gitignore_file}" tofile="${deploy.dir}/.gitignore" overwrite="true"/>
@@ -131,8 +131,8 @@
131131

132132
<target name="deploy:prepare-dir" description="Delete the existing deploy directory and re-initialize as an empty git repository." hidden="true">
133133
<delete dir="${deploy.dir}" failonerror="false" quiet="true" />
134-
<exec command="git init ${deploy.dir}" logoutput="true" checkreturn="true" level="info" passthru="true"/>
135-
<exec dir="${deploy.dir}" command="git config --local core.excludesfile false" logoutput="true" checkreturn="true" level="info" passthru="true"/>
134+
<exec command="git init ${deploy.dir}" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
135+
<exec dir="${deploy.dir}" command="git config --local core.excludesfile false" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
136136
<echo>Global .gitignore file is being disabled for this repository to prevent unexpected behavior.</echo>
137137
</target>
138138

@@ -142,13 +142,13 @@
142142

143143
<target name="deploy:push-remote" description="Pushes to a git remote." hidden="true">
144144
<exec command="echo ${deploy.remote} | openssl md5 | cut -d' ' -f 2" outputProperty="remoteName"/>
145-
<exec command="git push ${remoteName} ${deploy.branch}" dir="${deploy.dir}" outputProperty="deploy.push.output" logoutput="true" checkreturn="true" level="info"/>
146-
<exec command="export DEPLOY_UPTODATE=$(echo '${deploy.push.output}' | grep --quiet 'Everything up-to-date')" logoutput="true" checkreturn="true" level="info" passthru="true"/>
145+
<exec command="git push ${remoteName} ${deploy.branch}" dir="${deploy.dir}" outputProperty="deploy.push.output" logoutput="true" checkreturn="true" level="${blt.exec_level}"/>
146+
<exec command="export DEPLOY_UPTODATE=$(echo '${deploy.push.output}' | grep --quiet 'Everything up-to-date')" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
147147
</target>
148148

149149
<target name="deploy:sanitize" description="Removes sensitive files from the deploy docroot." hidden="true">
150-
<exec command="find . -type d | grep '\.git' | xargs rm -rf" dir="${deploy.dir}/docroot" logoutput="true" checkreturn="true" level="info" passthru="true"/>
151-
<exec command="find . -type d | grep '\.git' | xargs rm -rf" dir="${deploy.dir}/vendor" logoutput="true" checkreturn="true" level="info" passthru="true"/>
150+
<exec command="find . -type d | grep '\.git' | xargs rm -rf" dir="${deploy.dir}/docroot" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
151+
<exec command="find . -type d | grep '\.git' | xargs rm -rf" dir="${deploy.dir}/vendor" logoutput="true" checkreturn="true" level="${blt.exec_level}" passthru="true"/>
152152
<delete>
153153
<fileset dir="${deploy.dir}/docroot">
154154
<include name="core/*.txt"/>

phing/tasks/properties.xml

+14
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@
2323
</then>
2424
</if>
2525

26+
<verbosityTask level="${blt.level}"/>
27+
<!-- When blt verbosity level is above "warn", then increase verbosity of exec_level and various other tasks using blt.verbose property (Behat, Drush). -->
28+
<if>
29+
<or>
30+
<equals arg1="${blt.level}" arg2="debug"/>
31+
<equals arg1="${blt.level}" arg2="verbose"/>
32+
<equals arg1="${blt.level}" arg2="info"/>
33+
</or>
34+
<then>
35+
<property name="blt.exec_level" value="info"/>
36+
<property name="blt.verbose" value="true"/>
37+
</then>
38+
</if>
39+
2640
<echo level="verbose">Executing commands against multisite "${multisite.name}"</echo>
2741

2842
<!-- Default drush alias. -->

0 commit comments

Comments
 (0)