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

Commit e60061e

Browse files
committed
Drupal 8.4 compatibility improvements.
1 parent cfe62bd commit e60061e

File tree

17 files changed

+129
-22
lines changed

17 files changed

+129
-22
lines changed

config/build.yml

-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ setup:
131131
strategy: install
132132
# If setup.strategy is import, this file will be imported.
133133
dump-file: null
134-
drupal:
135-
install:
136-
import-config: true
137134

138135
sync:
139136
# By default, files are not synced during sync:refresh.

scripts/blt/ci/internal/run_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ yaml-cli update:value blt/project.yml modules.ci.enable.0 views_ui
88
# Build codebase, validate, install Drupal, run basic tests.
99
yaml-cli update:value blt/project.yml cm.strategy none
1010
blt validate:all
11-
blt setup --define environment=ci --yes -vvv
11+
${BLT_DIR}/scripts/travis/tick-tock.sh blt setup --define environment=ci --yes -vvv
1212
blt tests:all --define tests.run-server=true --yes -vvv
1313
blt tests:behat:definitions
1414
cd docroot

scripts/blt/ignore-existing.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ blt/project.yml
99
blt/src/Filesets
1010
composer.json
1111
composer.lock
12-
README.md
1312
drush/site-aliases/aliases.drushrc.php
1413
drush/drushrc.php
1514
docroot/sites/default/services.yml
1615
docroot/sites/default/settings/trusted_host.settings.php
1716
factory-hooks/pre-settings-php/includes.php
17+
phpcs.xml.dist
18+
README.md
1819
tests/behat/behat.yml
1920
tests/behat/example.local.yml
2021
tests/behat/features/bootstrap/Drupal/FeatureContext.php

scripts/drupal-vm/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ drupal_install_site: false
6464
configure_drush_aliases: false
6565

6666
# This is required for front-end building tools.
67-
nodejs_version: "4.x"
67+
nodejs_version: "6.x"
6868
nodejs_npm_global_packages:
6969
- name: bower
7070
- name: gulp-cli
71+
- name: yarn
7172
nodejs_install_npm_user: "{{ drupalvm_user }}"
7273
npm_config_prefix: "/home/{{ drupalvm_user }}/.npm-global"
7374
installed_extras: ${installed_extras}

scripts/travis/run_tests

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -ev
66
yaml-cli update:value blt/project.yml project.local.hostname '127.0.0.1:8888'
77

88
blt validate:all
9-
blt setup --define drush.alias='${drush.aliases.ci}' --define environment=ci --no-interaction --yes -v
9+
${BLT_DIR}/scripts/travis/tick-tock.sh blt setup --define drush.alias='${drush.aliases.ci}' --define environment=ci --no-interaction --yes -v
1010
blt tests:all --define drush.alias='${drush.aliases.ci}' --define tests.run-server=true --yes -v
1111

1212
set +v

scripts/travis/tick-tock.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -u
4+
5+
command=$@
6+
7+
# launch command in the background
8+
${command} &
9+
10+
# ping every second
11+
seconds=0
12+
limit=40*60
13+
while kill -0 $! >/dev/null 2>&1;
14+
do
15+
echo -n -e " \b" # never leave evidence
16+
17+
if [ $seconds == $limit ]; then
18+
break;
19+
fi
20+
21+
seconds=$((seconds + 1))
22+
23+
sleep 1
24+
done

src/Robo/Blt.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Blt implements ContainerAwareInterface, LoggerAwareInterface {
3737
/**
3838
* The BLT version.
3939
*/
40-
const VERSION = '8.9.5';
40+
const VERSION = '9.0.0';
4141

4242
/**
4343
* The Robo task runner.

src/Robo/Commands/Setup/DrupalCommand.php

-7
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ function ($string) {
4949
->assume(TRUE)
5050
->printOutput(TRUE);
5151

52-
$config_strategy = $this->getConfigValue('cm.strategy');
53-
54-
if (!$config_strategy != 'none' && $this->getConfigValue('setup.drupal.install.import-config')) {
55-
$cm_core_key = $this->getConfigValue('cm.core.key');
56-
$task->option('config-dir', $this->getConfigValue("cm.core.dirs.$cm_core_key.path"));
57-
}
58-
5952
$result = $task->detectInteractive()->run();
6053
if ($result->wasSuccessful()) {
6154
$this->getConfig()->set('state.drupal.installed', TRUE);

src/Robo/Commands/Sync/DbCommand.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class DbCommand extends BltTasks {
1414
* Iteratively copies remote db to local db for each multisite.
1515
*
1616
* @command sync:db:all
17+
*
18+
* @executeInDrupalVm
1719
*/
1820
public function syncDbAll() {
1921
$exit_code = 0;
@@ -52,6 +54,7 @@ protected function syncDbMultisite($multisite_name) {
5254
* @command sync:db
5355
*
5456
* @validateDrushConfig
57+
* @executeInDrupalVm
5558
*/
5659
public function syncDbDefault() {
5760

@@ -70,7 +73,7 @@ public function syncDbDefault() {
7073
->assume(TRUE);
7174

7275
if ($this->getConfigValue('drush.sanitize')) {
73-
$task->option('sanitize');
76+
$task->drush('sql-sanitize');
7477
}
7578

7679
$task->drush('cache-clear drush');

src/Robo/Commands/Tests/BehatCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function initialize() {
9292
* @validateMySqlAvailable
9393
* @validateDrupalIsInstalled
9494
* @validateBehatIsConfigured
95-
* @validateInsideVm
95+
* @validateVmConfig
9696
* @launchWebServer
9797
* @executeInDrupalVm
9898
*/

src/Robo/Hooks/DrushHook.php

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Acquia\Blt\Robo\BltTasks;
66
use Acquia\Blt\Robo\Exceptions\BltException;
77
use Consolidation\AnnotatedCommand\CommandData;
8+
use Symfony\Component\Console\Event\ConsoleCommandEvent;
89

910
/**
1011
* Validate Drush configuration for failed commands.
@@ -28,4 +29,18 @@ public function validateDrushConfig(CommandData $commandData) {
2829
}
2930
}
3031

32+
/**
33+
* Corrects drush aliases when inside of the VM.
34+
*
35+
* The VM alias is not available inside the VM.
36+
*
37+
* @hook command-event *
38+
*/
39+
public function drushVmAlias(ConsoleCommandEvent $commandData) {
40+
if ($this->getInspector()->isVmCli()) {
41+
$this->getConfig()->set('drush.alias', '');
42+
$this->getConfig()->set('drush.aliases.local', 'self');
43+
}
44+
}
45+
3146
}

src/Robo/Hooks/ValidateHook.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ public function validateSettingsFilesPresent() {
124124
/**
125125
* Validates that current PHP process is being executed inside of the VM.
126126
*
127-
* @hook validate validateInsideVm
127+
* @hook validate validateVmConfig
128128
*/
129129
public function validateInsideVm() {
130-
if ($this->getInspector()->isDrupalVmLocallyInitialized() && !$this->getInspector()->isVmCli()) {
131-
throw new BltException("You must run this command inside Drupal VM, or else do not use Drupal VM at all. Execute `vagrant ssh` and then execute the command, or else change drush.aliases.local in blt/project.local.yml.");
130+
if ($this->getInspector()->isDrupalVmLocallyInitialized() && $this->getInspector()->isDrupalVmBooted() && !$this->getInspector()->isDrupalVmConfigValid()) {
131+
throw new BltException("Drupal VM configuration is invalid.");
132132
}
133133
}
134134

src/Robo/Inspector/Inspector.php

+21
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Robo\Common\BuilderAwareTrait;
1717
use Robo\Contract\BuilderAwareInterface;
1818
use Robo\Contract\ConfigAwareInterface;
19+
use function substr;
1920
use Symfony\Component\Filesystem\Filesystem;
2021
use Robo\Contract\VerbosityThresholdInterface;
2122
use Tivie\OS\Detector;
@@ -258,6 +259,26 @@ public function isDrushAliasValid($alias) {
258259
return $this->executor->drush("site-alias $alias --format=json")->run()->wasSuccessful();
259260
}
260261

262+
/**
263+
* Gets the major version of drush.
264+
*
265+
* @return int
266+
* The major version of drush.
267+
*/
268+
public function getDrushMajorVersion() {
269+
$version_info = json_decode($this->executor->drush('version --format=json')->run()->getMessage(), TRUE);
270+
if (!empty($version_info['drush-version'])) {
271+
$version = $version_info['drush-version'];
272+
}
273+
else {
274+
$version = $version_info['drush-version'];
275+
}
276+
277+
$major_version = substr($version, 0, 1);
278+
279+
return (int) $major_version;
280+
}
281+
261282
/**
262283
* Determines if MySQL is available, caches result.
263284
*

src/Robo/Tasks/DrushTask.php

+2
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ protected function setGlobalOptions() {
285285
if ($this->include) {
286286
$this->option('include', $this->include);
287287
}
288+
289+
$this->option('config', $this->getConfig()->get('repo.root') . '/drush/drushrc.php');
288290
}
289291

290292
/**

src/Robo/Wizards/TestsWizard.php

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

33
namespace Acquia\Blt\Robo\Wizards;
44

5+
use function file_exists;
56
use Robo\Contract\VerbosityThresholdInterface;
67

78
/**
@@ -32,7 +33,8 @@ public function wizardInstallPhantomJsBinary() {
3233
* Prompts user to generate valid Behat configuration file.
3334
*/
3435
public function wizardConfigureBehat() {
35-
if (!$this->getInspector()->isBehatConfigured()) {
36+
$behat_local_config_file = $this->getConfigValue('repo.root') . '/tests/behat/local.yml';
37+
if (!file_exists($behat_local_config_file) || !$this->getInspector()->isBehatConfigured()) {
3638
$this->logger->warning('Behat is not configured properly.');
3739
$this->say("BLT can (re)generate tests/behat/local.yml using tests/behat/example.local.yml.");
3840
$confirm = $this->confirm("Do you want (re)generate local Behat config in <comment>tests/behat/local.yml</comment>?", TRUE);

src/Update/Updates.php

+40
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,23 @@ public function update_8009003() {
367367
$composer_json['extra']['installer-paths']['docroot/libraries/{$name}'][] = 'type:bower-asset';
368368
$composer_json['extra']['installer-paths']['docroot/libraries/{$name}'][] = 'type:npm-asset';
369369

370+
// Add the Asset Packagist repository if it does not already exist.
371+
if (isset($composer_json['repositories'])) {
372+
$repository_key = NULL;
373+
foreach ($composer_json['repositories'] as $key => $repository) {
374+
if ($repository['type'] == 'composer' && strpos($repository['url'], 'https://asset-packagist.org') === 0) {
375+
$repository_key = $key;
376+
break;
377+
}
378+
}
379+
if (is_null($repository_key)) {
380+
$composer_json['repositories']['asset-packagist'] = [
381+
'type' => 'composer',
382+
'url' => 'https://asset-packagist.org',
383+
];
384+
}
385+
}
386+
370387
$projectAcsfHooks = $this->updater->getRepoRoot() . '/factory-hooks';
371388
$acsf_inited = file_exists($projectAcsfHooks);
372389
if ($acsf_inited) {
@@ -384,4 +401,27 @@ public function update_8009003() {
384401
$this->updater->getOutput()->writeln($formattedBlock);
385402
$this->updater->getOutput()->writeln("");
386403
}
404+
405+
/**
406+
* 8.9.7.
407+
*
408+
* @Update(
409+
* version = "8009007",
410+
* description = "Removing drush files."
411+
* )
412+
*/
413+
public function update_8009007() {
414+
$this->updater->deleteFile('drush.wrapper');
415+
$this->updater->deleteFile('.drush-use');
416+
417+
// Recommend drush upgrade.
418+
$messages = [
419+
"You should replace your local global installation of drush with drush launcher:",
420+
"https://github.com/drush-ops/drush-launcher",
421+
];
422+
$formattedBlock = $this->updater->getFormatter()->formatBlock($messages, 'ice');
423+
$this->updater->getOutput()->writeln("");
424+
$this->updater->getOutput()->writeln($formattedBlock);
425+
$this->updater->getOutput()->writeln("");
426+
}
387427
}

template/phpcs.xml.dist

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<?xml version="1.0"?>
22
<!--
33
To override this file, copy it to phpcs.xml and then modify.
4+
@see https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml#the-annotated-sample-file
45
-->
56
<ruleset name="blt">
67
<description>BLT PHP_CodeSniffer standards overrides.</description>
78

9+
<!-- By default, warnings and errors cause an exception. -->
10+
<config name="ignore_warnings_on_exit" value="0" />
11+
<config name="ignore_errors_on_exit" value="0" />
12+
813
<!-- Set ignore extensions. -->
914
<!-- @see https://www.drupal.org/node/2867601#comment-12075633 -->
1015
<arg name="ignore" value="*.css,*.md,*.txt"/>
@@ -16,7 +21,10 @@
1621

1722
<!-- Include existing standards. -->
1823
<rule ref="Drupal"/>
19-
<rule ref="DrupalPractice"/>
24+
<rule ref="DrupalPractice">
25+
<!-- Ignore specific sniffs. -->
26+
<!-- <exclude name="DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable"/> -->
27+
</rule>
2028

2129
<file>blt</file>
2230
<file>docroot/modules/custom</file>

0 commit comments

Comments
 (0)