@@ -59,7 +59,7 @@ |
||
59 | 59 | $this->loop, |
60 | 60 | new React\Http\Middleware\StreamingRequestMiddleware(), |
61 | 61 | new React\Http\Middleware\RequestBodyBufferMiddleware(16 * 1024 * 1024), // 16 MiB |
62 | - function (ServerRequestInterface $request) { |
|
62 | + function(ServerRequestInterface $request) { |
|
63 | 63 | try { |
64 | 64 | return $this->router($request); |
65 | 65 | } catch (Throwable $exception) { |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | return 0; |
183 | 183 | } |
184 | 184 | |
185 | - $callback = function (string $output) { |
|
185 | + $callback = function(string $output) { |
|
186 | 186 | $output = preg_replace('/\n$/', '', $output); |
187 | 187 | if (strlen($output) !== 0) { |
188 | 188 | $this->output->writeln($output); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /** @var Process[] $processes */ |
193 | 193 | $processes = []; |
194 | 194 | |
195 | - $this->server->loop->futureTick(function () use (&$processes, $hosts, $task) { |
|
195 | + $this->server->loop->futureTick(function() use (&$processes, $hosts, $task) { |
|
196 | 196 | foreach ($hosts as $host) { |
197 | 197 | $processes[] = $this->createProcess($host, $task); |
198 | 198 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | }); |
204 | 204 | |
205 | - $this->server->loop->addPeriodicTimer(0.03, function ($timer) use (&$processes, $callback) { |
|
205 | + $this->server->loop->addPeriodicTimer(0.03, function($timer) use (&$processes, $callback) { |
|
206 | 206 | $this->gatherOutput($processes, $callback); |
207 | 207 | if ($this->output->isDecorated() && !getenv('CI')) { |
208 | 208 | $this->output->write(spinner()); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | foreach ($this->recipes as $recipe) { |
53 | 53 | // $find will try to return DocConfig for a given config $name. |
54 | - $findConfig = function (string $name) use ($recipe): ?DocConfig { |
|
54 | + $findConfig = function(string $name) use ($recipe): ?DocConfig { |
|
55 | 55 | if (array_key_exists($name, $recipe->config)) { |
56 | 56 | return $recipe->config[$name]; |
57 | 57 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | return null; |
71 | 71 | }; |
72 | - $findConfigOverride = function (DocRecipe $recipe, string $name) use (&$findConfigOverride): ?DocConfig { |
|
72 | + $findConfigOverride = function(DocRecipe $recipe, string $name) use (&$findConfigOverride): ?DocConfig { |
|
73 | 73 | foreach ($recipe->require as $r) { |
74 | 74 | if (array_key_exists($r, $this->recipes)) { |
75 | 75 | if (array_key_exists($name, $this->recipes[$r]->config)) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return null; |
86 | 86 | }; |
87 | 87 | // Replace all {{name}} with link to correct config declaration. |
88 | - $replaceLinks = function (string $comment) use ($findConfig): string { |
|
88 | + $replaceLinks = function(string $comment) use ($findConfig): string { |
|
89 | 89 | $output = ''; |
90 | 90 | $code = false; |
91 | 91 | foreach (explode("\n", $comment) as $i => $line) { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $output .= "\n"; |
98 | 98 | continue; |
99 | 99 | } |
100 | - $output .= preg_replace_callback('#(\{\{(?<name>[\w_:\-/]+)\}\})#', function ($m) use ($findConfig) { |
|
100 | + $output .= preg_replace_callback('#(\{\{(?<name>[\w_:\-/]+)\}\})#', function($m) use ($findConfig) { |
|
101 | 101 | $name = $m['name']; |
102 | 102 | $config = $findConfig($name); |
103 | 103 | if ($config !== null) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | return $output; |
113 | 113 | }; |
114 | - $findTask = function (string $name, bool $searchOtherRecipes = true) use ($recipe): ?DocTask { |
|
114 | + $findTask = function(string $name, bool $searchOtherRecipes = true) use ($recipe): ?DocTask { |
|
115 | 115 | if (array_key_exists($name, $recipe->tasks)) { |
116 | 116 | return $recipe->tasks[$name]; |
117 | 117 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | MARKDOWN; |
172 | 172 | |
173 | - $map = function (DocTask $task, $ident = '') use (&$map, $findTask, &$intro): void { |
|
173 | + $map = function(DocTask $task, $ident = '') use (&$map, $findTask, &$intro): void { |
|
174 | 174 | foreach ($task->group as $taskName) { |
175 | 175 | $t = $findTask($taskName); |
176 | 176 | if ($t !== null) { |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | function indent(string $text): string |
358 | 358 | { |
359 | - return implode("\n", array_map(function ($line) { |
|
359 | + return implode("\n", array_map(function($line) { |
|
360 | 360 | return " " . $line; |
361 | 361 | }, explode("\n", $text))); |
362 | 362 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $deployer->hosts->set($aliases[0], $host); |
74 | 74 | return $host; |
75 | 75 | } else { |
76 | - $hosts = array_map(function ($hostname) use ($deployer): Host { |
|
76 | + $hosts = array_map(function($hostname) use ($deployer): Host { |
|
77 | 77 | $host = new Host($hostname); |
78 | 78 | $deployer->hosts->set($hostname, $host); |
79 | 79 | return $host; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $deployer->hosts->set($host->getAlias(), $host); |
96 | 96 | return $host; |
97 | 97 | } else { |
98 | - $hosts = array_map(function ($hostname) use ($deployer): Localhost { |
|
98 | + $hosts = array_map(function($hostname) use ($deployer): Localhost { |
|
99 | 99 | $host = new Localhost($hostname); |
100 | 100 | $deployer->hosts->set($host->getAlias(), $host); |
101 | 101 | return $host; |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | } |
368 | 368 | } |
369 | 369 | $options = array_merge($namedArguments, $options); |
370 | - $run = function ($command, $options = []): string { |
|
370 | + $run = function($command, $options = []): string { |
|
371 | 371 | $host = currentHost(); |
372 | 372 | |
373 | 373 | $command = parse($command); |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'Recipe file path'), |
96 | 96 | ); |
97 | 97 | |
98 | - $this['console'] = function () use ($console) { |
|
98 | + $this['console'] = function() use ($console) { |
|
99 | 99 | return $console; |
100 | 100 | }; |
101 | - $this['input'] = function () { |
|
101 | + $this['input'] = function() { |
|
102 | 102 | throw new \RuntimeException('Uninitialized "input" in Deployer container.'); |
103 | 103 | }; |
104 | - $this['output'] = function () { |
|
104 | + $this['output'] = function() { |
|
105 | 105 | throw new \RuntimeException('Uninitialized "output" in Deployer container.'); |
106 | 106 | }; |
107 | - $this['inputDefinition'] = function () { |
|
107 | + $this['inputDefinition'] = function() { |
|
108 | 108 | return new InputDefinition(); |
109 | 109 | }; |
110 | - $this['questionHelper'] = function () { |
|
110 | + $this['questionHelper'] = function() { |
|
111 | 111 | return $this->getHelper('question'); |
112 | 112 | }; |
113 | 113 | |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | * Config * |
116 | 116 | ******************************/ |
117 | 117 | |
118 | - $this['config'] = function () { |
|
118 | + $this['config'] = function() { |
|
119 | 119 | return new Configuration(); |
120 | 120 | }; |
121 | 121 | // -l act as if it had been invoked as a login shell (i.e. source ~/.profile file) |
122 | 122 | // -s commands are read from the standard input (no arguments should remain after this option) |
123 | - $this->config['shell'] = function () { |
|
123 | + $this->config['shell'] = function() { |
|
124 | 124 | if (currentHost() instanceof Localhost) { |
125 | 125 | return 'bash -s'; // Non-login shell for localhost. |
126 | 126 | } |
@@ -133,43 +133,43 @@ discard block |
||
133 | 133 | * Core * |
134 | 134 | ******************************/ |
135 | 135 | |
136 | - $this['pop'] = function ($c) { |
|
136 | + $this['pop'] = function($c) { |
|
137 | 137 | return new Printer($c['output']); |
138 | 138 | }; |
139 | - $this['sshClient'] = function ($c) { |
|
139 | + $this['sshClient'] = function($c) { |
|
140 | 140 | return new Client($c['output'], $c['pop'], $c['logger']); |
141 | 141 | }; |
142 | - $this['rsync'] = function ($c) { |
|
142 | + $this['rsync'] = function($c) { |
|
143 | 143 | return new Rsync($c['pop'], $c['output']); |
144 | 144 | }; |
145 | - $this['processRunner'] = function ($c) { |
|
145 | + $this['processRunner'] = function($c) { |
|
146 | 146 | return new ProcessRunner($c['pop'], $c['logger']); |
147 | 147 | }; |
148 | - $this['tasks'] = function () { |
|
148 | + $this['tasks'] = function() { |
|
149 | 149 | return new TaskCollection(); |
150 | 150 | }; |
151 | - $this['hosts'] = function () { |
|
151 | + $this['hosts'] = function() { |
|
152 | 152 | return new HostCollection(); |
153 | 153 | }; |
154 | - $this['scriptManager'] = function ($c) { |
|
154 | + $this['scriptManager'] = function($c) { |
|
155 | 155 | return new ScriptManager($c['tasks']); |
156 | 156 | }; |
157 | - $this['selector'] = function ($c) { |
|
157 | + $this['selector'] = function($c) { |
|
158 | 158 | return new Selector($c['hosts']); |
159 | 159 | }; |
160 | - $this['fail'] = function () { |
|
160 | + $this['fail'] = function() { |
|
161 | 161 | return new Collection(); |
162 | 162 | }; |
163 | - $this['messenger'] = function ($c) { |
|
163 | + $this['messenger'] = function($c) { |
|
164 | 164 | return new Messenger($c['input'], $c['output'], $c['logger']); |
165 | 165 | }; |
166 | - $this['server'] = function ($c) { |
|
166 | + $this['server'] = function($c) { |
|
167 | 167 | return new Server( |
168 | 168 | $c['output'], |
169 | 169 | $this, |
170 | 170 | ); |
171 | 171 | }; |
172 | - $this['master'] = function ($c) { |
|
172 | + $this['master'] = function($c) { |
|
173 | 173 | return new Master( |
174 | 174 | $c['input'], |
175 | 175 | $c['output'], |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $c['messenger'], |
178 | 178 | ); |
179 | 179 | }; |
180 | - $this['importer'] = function () { |
|
180 | + $this['importer'] = function() { |
|
181 | 181 | return new Importer(); |
182 | 182 | }; |
183 | 183 | |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | * Logger * |
186 | 186 | ******************************/ |
187 | 187 | |
188 | - $this['log_handler'] = function () { |
|
188 | + $this['log_handler'] = function() { |
|
189 | 189 | return !empty($this['log']) |
190 | 190 | ? new FileHandler($this['log']) |
191 | 191 | : new NullHandler(); |
192 | 192 | }; |
193 | - $this['logger'] = function () { |
|
193 | + $this['logger'] = function() { |
|
194 | 194 | return new Logger($this['log_handler']); |
195 | 195 | }; |
196 | 196 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $output->writeln([ |
336 | 336 | "<fg=white;bg=red> {$class} </> <comment>in {$file} on line {$exception->getLine()}:</>", |
337 | 337 | "", |
338 | - implode("\n", array_map(function ($line) { |
|
338 | + implode("\n", array_map(function($line) { |
|
339 | 339 | return " " . $line; |
340 | 340 | }, explode("\n", $exception->getMessage()))), |
341 | 341 | "", |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * Silverstripe configuration |
11 | 11 | */ |
12 | 12 | |
13 | -set('shared_assets', function () { |
|
13 | +set('shared_assets', function() { |
|
14 | 14 | if (test('[ -d {{release_or_current_path}}/public ]') || test('[ -d {{deploy_path}}/shared/public ]')) { |
15 | 15 | return 'public/assets'; |
16 | 16 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | ]); |
30 | 30 | |
31 | 31 | // Silverstripe cli script |
32 | -set('silverstripe_cli_script', function () { |
|
32 | +set('silverstripe_cli_script', function() { |
|
33 | 33 | $paths = [ |
34 | 34 | 'framework/cli-script.php', |
35 | 35 | 'vendor/silverstripe/framework/cli-script.php', |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * Helper tasks |
46 | 46 | */ |
47 | 47 | desc('Runs /dev/build'); |
48 | -task('silverstripe:build', function () { |
|
48 | +task('silverstripe:build', function() { |
|
49 | 49 | run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build'); |
50 | 50 | }); |
51 | 51 | |
52 | 52 | desc('Runs /dev/build?flush=all'); |
53 | -task('silverstripe:buildflush', function () { |
|
53 | +task('silverstripe:buildflush', function() { |
|
54 | 54 | run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build flush=all'); |
55 | 55 | }); |
56 | 56 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // Name of lsb_release like: focal, bionic, etc. |
15 | 15 | // As only Ubuntu 20.04 LTS is supported for provision should be the `focal`. |
16 | -set('lsb_release', function () { |
|
16 | +set('lsb_release', function() { |
|
17 | 17 | return run("lsb_release -s -c"); |
18 | 18 | }); |
19 | 19 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ]); |
38 | 38 | |
39 | 39 | desc('Checks pre-required state'); |
40 | -task('provision:check', function () { |
|
40 | +task('provision:check', function() { |
|
41 | 41 | if (get('remote_user') !== 'root' && get('become') !== 'root') { |
42 | 42 | warning(''); |
43 | 43 | warning('Run provision as root: -o remote_user=root'); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | })->oncePerNode(); |
61 | 61 | |
62 | 62 | desc('Collects required params'); |
63 | -task('provision:configure', function () { |
|
63 | +task('provision:configure', function() { |
|
64 | 64 | $params = [ |
65 | 65 | 'sudo_password', |
66 | 66 | 'domain', |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | |
98 | 98 | desc('Adds repositories and update'); |
99 | -task('provision:update', function () { |
|
99 | +task('provision:update', function() { |
|
100 | 100 | // PHP |
101 | 101 | run('apt-add-repository ppa:ondrej/php -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive']]); |
102 | 102 | |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | ->verbose(); |
119 | 119 | |
120 | 120 | desc('Upgrades all packages'); |
121 | -task('provision:upgrade', function () { |
|
121 | +task('provision:upgrade', function() { |
|
122 | 122 | run('apt-get upgrade -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
123 | 123 | }) |
124 | 124 | ->oncePerNode() |
125 | 125 | ->verbose(); |
126 | 126 | |
127 | 127 | desc('Installs packages'); |
128 | -task('provision:install', function () { |
|
128 | +task('provision:install', function() { |
|
129 | 129 | $packages = [ |
130 | 130 | 'acl', |
131 | 131 | 'apt-transport-https', |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ->oncePerNode(); |
160 | 160 | |
161 | 161 | desc('Configures a server'); |
162 | -task('provision:server', function () { |
|
162 | +task('provision:server', function() { |
|
163 | 163 | run('usermod -a -G www-data caddy'); |
164 | 164 | $html = <<<'HTML' |
165 | 165 | <!DOCTYPE html> |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | })->oncePerNode(); |
221 | 221 | |
222 | 222 | desc('Configures the ssh'); |
223 | -task('provision:ssh', function () { |
|
223 | +task('provision:ssh', function() { |
|
224 | 224 | run("sed -i 's/PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config"); |
225 | 225 | run('ssh-keygen -A'); |
226 | 226 | run('service ssh restart'); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | } |
231 | 231 | })->oncePerNode(); |
232 | 232 | |
233 | -set('sudo_password', function () { |
|
233 | +set('sudo_password', function() { |
|
234 | 234 | return askHiddenResponse(' Password for sudo: '); |
235 | 235 | }); |
236 | 236 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | set('ssh_copy_id', '~/.ssh/id_rsa.pub'); |
240 | 240 | |
241 | 241 | desc('Setups a deployer user'); |
242 | -task('provision:deployer', function () { |
|
242 | +task('provision:deployer', function() { |
|
243 | 243 | if (test('id deployer >/dev/null 2>&1')) { |
244 | 244 | // TODO: Check what created deployer user configured correctly. |
245 | 245 | // TODO: Update sudo_password of deployer user. |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | })->oncePerNode(); |
287 | 287 | |
288 | 288 | desc('Setups a firewall'); |
289 | -task('provision:firewall', function () { |
|
289 | +task('provision:firewall', function() { |
|
290 | 290 | run('ufw allow 22'); |
291 | 291 | run('ufw allow 80'); |
292 | 292 | run('ufw allow 443'); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | })->oncePerNode(); |
295 | 295 | |
296 | 296 | desc('Verifies what provision was successful'); |
297 | -task('provision:verify', function () { |
|
297 | +task('provision:verify', function() { |
|
298 | 298 | fetch('{{domain}}', 'get', [], null, $info, true); |
299 | 299 | if ($info['http_code'] === 404) { |
300 | 300 | info("provisioned successfully!"); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | // Used in `chown` and `acl` modes of {{writable_mode}}. |
7 | 7 | // Attempts automatically to detect http user in process list. |
8 | 8 | |
9 | -set('http_user', function () { |
|
9 | +set('http_user', function() { |
|
10 | 10 | $candidates = explode("\n", run("ps axo comm,user | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | sort | awk '{print \$NF}' | uniq")); |
11 | 11 | $httpUser = array_shift($candidates); |
12 | 12 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | // Used to make a writable directory by a server. |
24 | 24 | // Used in `chgrp` mode of {{writable_mode}} only. |
25 | 25 | // Attempts automatically to detect http user in process list. |
26 | -set('http_group', function () { |
|
26 | +set('http_group', function() { |
|
27 | 27 | $candidates = explode("\n", run("ps axo comm,group | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | sort | awk '{print \$NF}' | uniq")); |
28 | 28 | $httpGroup = array_shift($candidates); |
29 | 29 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | set('writable_chmod_mode', '0755'); |
60 | 60 | |
61 | 61 | desc('Makes writable dirs'); |
62 | -task('deploy:writable', function () { |
|
62 | +task('deploy:writable', function() { |
|
63 | 63 | $dirs = join(' ', get('writable_dirs')); |
64 | 64 | $mode = get('writable_mode'); |
65 | 65 | $recursive = get('writable_recursive') ? '-R' : ''; |
@@ -3,7 +3,7 @@ |
||
3 | 3 | namespace Deployer; |
4 | 4 | |
5 | 5 | desc('Prepares host for deploy'); |
6 | -task('deploy:setup', function () { |
|
6 | +task('deploy:setup', function() { |
|
7 | 7 | run( |
8 | 8 | <<<EOF |
9 | 9 | [ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}; |