@@ -20,13 +20,13 @@ |
||
20 | 20 | */ |
21 | 21 | namespace Deployer; |
22 | 22 | |
23 | -set('bin/yarn', function () { |
|
23 | +set('bin/yarn', function() { |
|
24 | 24 | return run('which yarn'); |
25 | 25 | }); |
26 | 26 | |
27 | 27 | // In there is a {{previous_release}}, node_modules will be copied from it before installing deps with yarn. |
28 | 28 | desc('Install Yarn packages'); |
29 | -task('yarn:install', function () { |
|
29 | +task('yarn:install', function() { |
|
30 | 30 | if (has('previous_release')) { |
31 | 31 | if (test('[ -d {{previous_release}}/node_modules ]')) { |
32 | 32 | run('cp -R {{previous_release}}/node_modules {{release_path}}'); |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | */ |
27 | 27 | namespace Deployer; |
28 | 28 | |
29 | -set('bin/npm', function () { |
|
29 | +set('bin/npm', function() { |
|
30 | 30 | return run('which npm'); |
31 | 31 | }); |
32 | 32 | |
33 | 33 | // In there is a {{previous_release}}, node_modules will be copied from it before installing deps. |
34 | 34 | desc('Install npm packages'); |
35 | -task('npm:install', function () { |
|
35 | +task('npm:install', function() { |
|
36 | 36 | if (has('previous_release')) { |
37 | 37 | if (test('[ -d {{previous_release}}/node_modules ]')) { |
38 | 38 | run('cp -R {{previous_release}}/node_modules {{release_path}}'); |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | |
49 | 49 | |
50 | 50 | desc('Install npm packages with a clean slate'); |
51 | -task('npm:ci', function () { |
|
51 | +task('npm:ci', function() { |
|
52 | 52 | run("cd {{release_path}} && {{bin/npm}} ci"); |
53 | 53 | }); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ]); |
29 | 29 | |
30 | 30 | desc('Ensure what provision run as root'); |
31 | -task('provision:switch-user', function () { |
|
31 | +task('provision:switch-user', function() { |
|
32 | 32 | run('whoami'); |
33 | 33 | if (get('remote_user') !== 'root') { |
34 | 34 | set('remote_user', 'root'); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | //Deployer::get()->preTask->add('provision:*', 'provision:switch-user'); |
39 | 39 | |
40 | 40 | desc('Check pre-required state'); |
41 | -task('provision:check', function () { |
|
41 | +task('provision:check', function() { |
|
42 | 42 | $ok = true; |
43 | 43 | if (get('php_version') !== '7.4') { |
44 | 44 | $ok = false; |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | }); |
60 | 60 | |
61 | 61 | desc('Upgrade all packages'); |
62 | -task('provision:upgrade', function () { |
|
62 | +task('provision:upgrade', function() { |
|
63 | 63 | run('apt-get update', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive']]); |
64 | 64 | run('apt-get upgrade -y', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive']]); |
65 | 65 | }); |
66 | 66 | |
67 | 67 | desc('Install base packages'); |
68 | -task('provision:install', function () { |
|
68 | +task('provision:install', function() { |
|
69 | 69 | $packages = [ |
70 | 70 | 'build-essential', |
71 | 71 | 'curl', |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | }); |
89 | 89 | |
90 | 90 | desc('Configure SSH'); |
91 | -task('provision:ssh', function () { |
|
91 | +task('provision:ssh', function() { |
|
92 | 92 | run('sed -i "/PasswordAuthentication yes/d" /etc/ssh/sshd_config'); |
93 | 93 | run('echo "" | sudo tee -a /etc/ssh/sshd_config'); |
94 | 94 | run('echo "" | sudo tee -a /etc/ssh/sshd_config'); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | }); |
103 | 103 | |
104 | 104 | desc('Setup deployer user'); |
105 | -task('provision:user:deployer', function () { |
|
105 | +task('provision:user:deployer', function() { |
|
106 | 106 | if (test('id deployer >/dev/null 2>&1')) { |
107 | 107 | info('deployer user already exist'); |
108 | 108 | } else { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | }); |
138 | 138 | |
139 | 139 | desc('Setup firewall'); |
140 | -task('provision:firewall', function () { |
|
140 | +task('provision:firewall', function() { |
|
141 | 141 | run('ufw allow 22'); |
142 | 142 | run('ufw allow 80'); |
143 | 143 | run('ufw allow 443'); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | }); |
146 | 146 | |
147 | 147 | desc('Install PHP packages'); |
148 | -task('provision:install:php', function () { |
|
148 | +task('provision:install:php', function() { |
|
149 | 149 | $packages = [ |
150 | 150 | "php-bcmath", |
151 | 151 | "php-cli", |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | |
171 | 171 | |
172 | 172 | desc('Install Composer'); |
173 | -task('provision:install:composer', function () { |
|
173 | +task('provision:install:composer', function() { |
|
174 | 174 | run('curl -sS https://getcomposer.org/installer | php'); |
175 | 175 | run('mv composer.phar /usr/local/bin/composer'); |
176 | 176 | }); |
177 | 177 | |
178 | 178 | desc('Configure PHP-CLI'); |
179 | -task('provision:config:php-cli', function () { |
|
179 | +task('provision:config:php-cli', function() { |
|
180 | 180 | run('sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/{{php_version}}/cli/php.ini'); |
181 | 181 | run('sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php/{{php_version}}/cli/php.ini'); |
182 | 182 | run('sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/{{php_version}}/cli/php.ini'); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | }); |
185 | 185 | |
186 | 186 | desc('Configure PHP-FPM'); |
187 | -task('provision:config:php-fpm', function () { |
|
187 | +task('provision:config:php-fpm', function() { |
|
188 | 188 | run('sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/{{php_version}}/fpm/php.ini'); |
189 | 189 | run('sed -i "s/display_errors = .*/display_errors = On/" /etc/php/{{php_version}}/fpm/php.ini'); |
190 | 190 | run('sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/{{php_version}}/fpm/php.ini'); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | }); |
194 | 194 | |
195 | 195 | desc('Configure FPM Pool'); |
196 | -task('provision:config:php-fpm:pool', function () { |
|
196 | +task('provision:config:php-fpm:pool', function() { |
|
197 | 197 | run('sed -i "s/^user = www-data/user = deployer/" /etc/php/{{php_version}}/fpm/pool.d/www.conf'); |
198 | 198 | run('sed -i "s/^group = www-data/group = deployer/" /etc/php/{{php_version}}/fpm/pool.d/www.conf'); |
199 | 199 | run('sed -i "s/;listen\.owner.*/listen.owner = deployer/" /etc/php/{{php_version}}/fpm/pool.d/www.conf'); |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | }); |
204 | 204 | |
205 | 205 | desc('Configure php sessions directory'); |
206 | -task('provision:config:php:sessions', function () { |
|
206 | +task('provision:config:php:sessions', function() { |
|
207 | 207 | run('chmod 733 /var/lib/php/sessions'); |
208 | 208 | run('chmod +t /var/lib/php/sessions'); |
209 | 209 | }); |
210 | 210 | |
211 | 211 | desc('Generating DH (Diffie Hellman) key'); |
212 | -task('provision:nginx:dhparam', function () { |
|
212 | +task('provision:nginx:dhparam', function() { |
|
213 | 213 | if (test('[ -f /etc/nginx/dhparams.pem ]')) { |
214 | 214 | info('/etc/nginx/dhparams.pem already exist'); |
215 | 215 | } else { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | }); |
221 | 221 | |
222 | 222 | desc('Install nginx & php-fpm'); |
223 | -task('provision:nginx', function () { |
|
223 | +task('provision:nginx', function() { |
|
224 | 224 | run('systemctl enable nginx.service'); |
225 | 225 | |
226 | 226 | run('sed -i "s/user www-data;/user deployer;/" /etc/nginx/nginx.conf'); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | 'storage/logs', |
18 | 18 | ]); |
19 | 19 | set('log_files', 'storage/logs/*.log'); |
20 | -set('laravel_version', function () { |
|
20 | +set('laravel_version', function() { |
|
21 | 21 | $result = run('{{bin/php}} {{release_path}}/artisan --version'); |
22 | 22 | preg_match_all('/(\d+\.?)+/', $result, $matches); |
23 | 23 | return $matches[0][0] ?? 5.5; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function artisan($command, $options = []) |
42 | 42 | { |
43 | - return function () use ($command, $options) { |
|
43 | + return function() use ($command, $options) { |
|
44 | 44 | $versionTooEarly = array_key_exists('min', $options) |
45 | 45 | && laravel_version_compare($options['min'], '<'); |
46 | 46 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * [Laravel filesystem configuration](https://laravel.com/docs/5.2/filesystem#configuration) |
163 | 163 | */ |
164 | 164 | desc('Make symlink for public disk'); |
165 | -task('deploy:public_disk', function () { |
|
165 | +task('deploy:public_disk', function() { |
|
166 | 166 | // Remove from source. |
167 | 167 | run('if [ -d $(echo {{release_path}}/public/storage) ]; then rm -rf {{release_path}}/public/storage; fi'); |
168 | 168 |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Deployer; |
3 | 3 | |
4 | -task('deploy:info', function () { |
|
4 | +task('deploy:info', function() { |
|
5 | 5 | $what = ''; |
6 | 6 | $branch = get('branch'); |
7 | 7 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * Determines which branch to deploy. Can be overridden with cli option `--branch`. |
8 | 8 | * If not specified, will get current git HEAD branch as default branch to deploy. |
9 | 9 | */ |
10 | -set('branch', function () { |
|
10 | +set('branch', function() { |
|
11 | 11 | try { |
12 | 12 | $branch = runLocally('git rev-parse --abbrev-ref HEAD'); |
13 | 13 | } catch (\Throwable $exception) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * Faster cloning by borrowing objects from existing clones. |
35 | 35 | */ |
36 | -set('git_cache', function () { |
|
36 | +set('git_cache', function() { |
|
37 | 37 | $gitVersion = run('{{bin/git}} version'); |
38 | 38 | $regs = []; |
39 | 39 | if (preg_match('/((\d+\.?)+)/', $gitVersion, $regs)) { |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * Update code at {{release_path}} on host. |
49 | 49 | */ |
50 | 50 | desc('Update code'); |
51 | -task('deploy:update_code', function () { |
|
51 | +task('deploy:update_code', function() { |
|
52 | 52 | $repository = get('repository'); |
53 | 53 | $branch = get('branch'); |
54 | 54 | $git = get('bin/git'); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * Facts |
27 | 27 | */ |
28 | 28 | |
29 | -set('user', function () { |
|
29 | +set('user', function() { |
|
30 | 30 | if (getenv('CI') !== false) { |
31 | 31 | return 'ci'; |
32 | 32 | } |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | set('http_user', false); |
66 | 66 | set('http_group', false); |
67 | 67 | |
68 | -set('clear_paths', []); // Relative path from release_path |
|
69 | -set('clear_use_sudo', false); // Using sudo in clean commands? |
|
68 | +set('clear_paths', []); // Relative path from release_path |
|
69 | +set('clear_use_sudo', false); // Using sudo in clean commands? |
|
70 | 70 | |
71 | 71 | set('cleanup_use_sudo', false); // Using sudo in cleanup commands? |
72 | 72 | |
73 | -set('use_relative_symlink', function () { |
|
73 | +set('use_relative_symlink', function() { |
|
74 | 74 | return commandSupportsOption('ln', '--relative'); |
75 | 75 | }); |
76 | -set('use_atomic_symlink', function () { |
|
76 | +set('use_atomic_symlink', function() { |
|
77 | 77 | return commandSupportsOption('mv', '--no-target-directory'); |
78 | 78 | }); |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Return current release path. |
87 | 87 | */ |
88 | -set('current_path', function () { |
|
88 | +set('current_path', function() { |
|
89 | 89 | $link = run("readlink {{deploy_path}}/current"); |
90 | 90 | return substr($link, 0, 1) === '/' ? $link : get('deploy_path') . '/' . $link; |
91 | 91 | }); |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Custom bins |
96 | 96 | */ |
97 | -set('bin/php', function () { |
|
97 | +set('bin/php', function() { |
|
98 | 98 | return locateBinaryPath('php'); |
99 | 99 | }); |
100 | 100 | |
101 | -set('bin/git', function () { |
|
101 | +set('bin/git', function() { |
|
102 | 102 | return locateBinaryPath('git'); |
103 | 103 | }); |
104 | 104 | |
105 | -set('bin/composer', function () { |
|
105 | +set('bin/composer', function() { |
|
106 | 106 | if (commandExist('composer')) { |
107 | 107 | $composer = '{{bin/php}} ' . locateBinaryPath('composer'); |
108 | 108 | } |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | return $composer; |
116 | 116 | }); |
117 | 117 | |
118 | -set('bin/symlink', function () { |
|
118 | +set('bin/symlink', function() { |
|
119 | 119 | return get('use_relative_symlink') ? 'ln -nfs --relative' : 'ln -nfs'; |
120 | 120 | }); |
121 | 121 | |
122 | 122 | // Path to a file which will store temp script with sudo password. |
123 | 123 | // Defaults to `.dep/sudo_pass`. This script is only temporary and will be deleted after |
124 | 124 | // sudo command executed. |
125 | -set('sudo_askpass', function () { |
|
125 | +set('sudo_askpass', function() { |
|
126 | 126 | if (test('[ -d {{deploy_path}}/.dep ]')) { |
127 | 127 | return '{{deploy_path}}/.dep/sudo_pass'; |
128 | 128 | } else { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * Success message |
160 | 160 | */ |
161 | -task('deploy:success', function () { |
|
161 | +task('deploy:success', function() { |
|
162 | 162 | info('successfully deployed!'); |
163 | 163 | }) |
164 | 164 | ->shallow() |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * Deploy failure |
170 | 170 | */ |
171 | -task('deploy:failed', function () { |
|
171 | +task('deploy:failed', function() { |
|
172 | 172 | })->hidden(); |
173 | 173 | |
174 | 174 | fail('deploy', 'deploy:failed'); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * Follow latest application logs. |
178 | 178 | */ |
179 | 179 | desc('Follow latest application logs.'); |
180 | -task('logs', function () { |
|
180 | +task('logs', function() { |
|
181 | 181 | if (!has('log_files')) { |
182 | 182 | warning("Please, specify \"log_files\" option."); |
183 | 183 | return; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $state = 'root'; |
44 | 44 | foreach (explode("\n", $content) as $i => $line) { |
45 | 45 | $m = []; |
46 | - $match = function ($regexp) use ($line, &$m) { |
|
46 | + $match = function($regexp) use ($line, &$m) { |
|
47 | 47 | return preg_match("#$regexp#", $line, $m); |
48 | 48 | }; |
49 | 49 | switch ($state) { |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | $desc = ''; |
108 | - if($first && $comment !== '') { |
|
108 | + if ($first && $comment !== '') { |
|
109 | 109 | $this->comment = $comment; |
110 | 110 | } |
111 | 111 | $first = false; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | { |
44 | 44 | foreach ($this->recipes as $recipe) { |
45 | 45 | // $find will try to return DocConfig for a given config $name. |
46 | - $findConfig = function (string $name) use ($recipe): ?DocConfig { |
|
46 | + $findConfig = function(string $name) use ($recipe): ?DocConfig { |
|
47 | 47 | if (array_key_exists($name, $recipe->config)) { |
48 | 48 | return $recipe->config[$name]; |
49 | 49 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | return null; |
63 | 63 | }; |
64 | - $findConfigOverride = function (DocRecipe $recipe, string $name) use (&$findConfigOverride): ?DocConfig { |
|
64 | + $findConfigOverride = function(DocRecipe $recipe, string $name) use (&$findConfigOverride): ?DocConfig { |
|
65 | 65 | foreach ($recipe->require as $r) { |
66 | 66 | if (array_key_exists($r, $this->recipes)) { |
67 | 67 | if (array_key_exists($name, $this->recipes[$r]->config)) { |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | return null; |
78 | 78 | }; |
79 | 79 | // Replace all {{name}} with link to correct config declaration. |
80 | - $replaceLinks = function (string $comment) use ($findConfig): string { |
|
81 | - return preg_replace_callback('#(\{\{(?<name>[\w_:]+)\}\})#', function ($m) use ($findConfig) { |
|
80 | + $replaceLinks = function(string $comment) use ($findConfig): string { |
|
81 | + return preg_replace_callback('#(\{\{(?<name>[\w_:]+)\}\})#', function($m) use ($findConfig) { |
|
82 | 82 | $name = $m['name']; |
83 | 83 | $config = $findConfig($name); |
84 | 84 | if ($config !== null) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | return "{{" . $name . "}}"; |
90 | 90 | }, $comment); |
91 | 91 | }; |
92 | - $findTask = function (string $name) use ($recipe): ?DocTask { |
|
92 | + $findTask = function(string $name) use ($recipe): ?DocTask { |
|
93 | 93 | if (array_key_exists($name, $recipe->tasks)) { |
94 | 94 | return $recipe->tasks[$name]; |
95 | 95 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | function indent($text) |
203 | 203 | { |
204 | - return implode("\n", array_map(function ($line) { |
|
204 | + return implode("\n", array_map(function($line) { |
|
205 | 205 | return " " . $line; |
206 | 206 | }, explode("\n", $text))); |
207 | 207 | } |