forked from acquia/blt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildCommand.php
132 lines (116 loc) · 3.35 KB
/
BuildCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
namespace Acquia\Blt\Robo\Commands\Setup;
use Acquia\Blt\Robo\BltTasks;
use Robo\Contract\VerbosityThresholdInterface;
use Symfony\Component\Finder\Finder;
/**
* Defines commands in the "setup:build" namespace.
*/
class BuildCommand extends BltTasks {
/**
* Install dependencies, builds docroot, installs Drupal.
*
* @command setup
*
* @aliases setup:all
*/
public function setup() {
$this->say("Setting up local environment for site '{$this->getConfigValue('site')}'...");
$status_code = $this->invokeCommands([
'setup:build',
'setup:hash-salt',
'internal:drupal:install',
'install-alias',
]);
return $status_code;
}
/**
* Installs Drupal and sets correct file/directory permissions.
*
* @command setup:drupal:install
*
* @interactGenerateSettingsFiles
*
* @validateMySqlAvailable
* @validateDocrootIsPresent
*
* @todo Add a @validateSettingsFilesArePresent
*/
public function drupalInstall() {
$status_code = $this->invokeCommands([
'drupal:install',
]);
if ($status_code) {
return $status_code;
}
$this->setSitePermissions();
return $status_code;
}
/**
* Set correct permissions for files and folders in docroot/sites/*.
*/
protected function setSitePermissions() {
$taskFilesystemStack = $this->taskFilesystemStack();
$multisite_dir = $this->getConfigValue('docroot') . '/sites/' . $this->getConfigValue('site');
$finder = new Finder();
$dirs = $finder
->in($multisite_dir)
->directories()
->depth('< 1')
->exclude('files');
foreach ($dirs->getIterator() as $dir) {
$taskFilesystemStack->chmod($dir->getRealPath(), 0755);
}
$files = $finder
->in($multisite_dir)
->files()
->depth('< 1')
->exclude('files');
foreach ($files->getIterator() as $dir) {
$taskFilesystemStack->chmod($dir->getRealPath(), 0644);
}
$taskFilesystemStack->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE);
$result = $taskFilesystemStack->run();
return $result;
}
/**
* Generates all required files for a full build.
*
* @command setup:build
*/
public function build() {
$status_code = $this->invokeCommands([
'setup:behat',
// setup:composer:install must run prior to setup:settings to ensure that
// scaffold files are present.
'setup:composer:install',
'setup:git-hooks',
'setup:settings',
// 'frontend'.
]);
if ($status_code) {
return $status_code;
}
if ($this->getConfig()->has('simplesamlphp') && $this->getConfigValue('simplesamlphp')) {
$result = $this->taskExec($this->getConfigValue('composer.bin') . "/blt simplesamlphp:build:config")
->detectInteractive()
->dir($this->getConfigValue('repo.root'))
->run();
}
$result = $this->invokeHook("post-setup-build");
return $result;
}
/**
* Installs Composer dependencies.
*
* @command setup:composer:install
*/
public function composerInstall() {
$result = $this->taskExec("export COMPOSER_EXIT_ON_PATCH_FAILURE=1; composer install --ansi --no-interaction")
->dir($this->getConfigValue('repo.root'))
->detectInteractive()
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
->run();
return $result;
}
}