@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | add('recipes', ['symfony']); |
8 | 8 | |
9 | -set('symfony_version', function () { |
|
9 | +set('symfony_version', function() { |
|
10 | 10 | $result = run('{{bin/console}} --version'); |
11 | 11 | preg_match_all('/(\d+\.?)+/', $result, $matches); |
12 | 12 | return $matches[0][0] ?? 5.0; |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | |
36 | 36 | set('bin/console', '{{bin/php}} {{release_or_current_path}}/bin/console'); |
37 | 37 | |
38 | -set('console_options', function () { |
|
38 | +set('console_options', function() { |
|
39 | 39 | return '--no-interaction'; |
40 | 40 | }); |
41 | 41 | |
42 | 42 | desc('Migrates database'); |
43 | -task('database:migrate', function () { |
|
43 | +task('database:migrate', function() { |
|
44 | 44 | $options = '--allow-no-migration'; |
45 | 45 | if (get('migrations_config') !== '') { |
46 | 46 | $options = "$options --configuration={{release_or_current_path}}/{{migrations_config}}"; |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | }); |
51 | 51 | |
52 | 52 | desc('Validate the Doctrine mapping files'); |
53 | -task('doctrine:schema:validate', function () { |
|
53 | +task('doctrine:schema:validate', function() { |
|
54 | 54 | run("cd {{release_or_current_path}} && {{bin/console}} doctrine:schema:validate {{doctrine_schema_validate_config}} {{console_options}}"); |
55 | 55 | }); |
56 | 56 | |
57 | 57 | desc('Clears cache'); |
58 | -task('deploy:cache:clear', function () { |
|
58 | +task('deploy:cache:clear', function() { |
|
59 | 59 | // composer install scripts usually clear and warmup symfony cache |
60 | 60 | // so we only need to do it if composer install was run with --no-scripts |
61 | 61 | if (false !== strpos(get('composer_options', ''), '--no-scripts')) { |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | }); |
65 | 65 | |
66 | 66 | desc('Optimize environment variables'); |
67 | -task('deploy:dump-env', function () { |
|
68 | - within('{{release_or_current_path}}', function () { |
|
67 | +task('deploy:dump-env', function() { |
|
68 | + within('{{release_or_current_path}}', function() { |
|
69 | 69 | run('{{bin/composer}} dump-env "${APP_ENV:-prod}"'); |
70 | 70 | }); |
71 | 71 | }); |
@@ -86,19 +86,19 @@ discard block |
||
86 | 86 | new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'Recipe file path'), |
87 | 87 | ); |
88 | 88 | |
89 | - $this['console'] = function () use ($console) { |
|
89 | + $this['console'] = function() use ($console) { |
|
90 | 90 | return $console; |
91 | 91 | }; |
92 | - $this['input'] = function () { |
|
92 | + $this['input'] = function() { |
|
93 | 93 | throw new \RuntimeException('Uninitialized "input" in Deployer container.'); |
94 | 94 | }; |
95 | - $this['output'] = function () { |
|
95 | + $this['output'] = function() { |
|
96 | 96 | throw new \RuntimeException('Uninitialized "output" in Deployer container.'); |
97 | 97 | }; |
98 | - $this['inputDefinition'] = function () { |
|
98 | + $this['inputDefinition'] = function() { |
|
99 | 99 | return new InputDefinition(); |
100 | 100 | }; |
101 | - $this['questionHelper'] = function () { |
|
101 | + $this['questionHelper'] = function() { |
|
102 | 102 | return $this->getHelper('question'); |
103 | 103 | }; |
104 | 104 | |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * Config * |
107 | 107 | ******************************/ |
108 | 108 | |
109 | - $this['config'] = function () { |
|
109 | + $this['config'] = function() { |
|
110 | 110 | return new Configuration(); |
111 | 111 | }; |
112 | 112 | // -l act as if it had been invoked as a login shell (i.e. source ~/.profile file) |
113 | 113 | // -s commands are read from the standard input (no arguments should remain after this option) |
114 | - $this->config['shell'] = function () { |
|
114 | + $this->config['shell'] = function() { |
|
115 | 115 | if (currentHost() instanceof Localhost) { |
116 | 116 | return 'bash -s'; // Non-login shell for localhost. |
117 | 117 | } |
@@ -124,37 +124,37 @@ discard block |
||
124 | 124 | * Core * |
125 | 125 | ******************************/ |
126 | 126 | |
127 | - $this['pop'] = function ($c) { |
|
127 | + $this['pop'] = function($c) { |
|
128 | 128 | return new Printer($c['output']); |
129 | 129 | }; |
130 | - $this['sshClient'] = function ($c) { |
|
130 | + $this['sshClient'] = function($c) { |
|
131 | 131 | return new SshClient($c['output'], $c['pop'], $c['logger']); |
132 | 132 | }; |
133 | - $this['rsync'] = function ($c) { |
|
133 | + $this['rsync'] = function($c) { |
|
134 | 134 | return new Rsync($c['pop'], $c['output']); |
135 | 135 | }; |
136 | - $this['processRunner'] = function ($c) { |
|
136 | + $this['processRunner'] = function($c) { |
|
137 | 137 | return new ProcessRunner($c['pop'], $c['logger']); |
138 | 138 | }; |
139 | - $this['tasks'] = function () { |
|
139 | + $this['tasks'] = function() { |
|
140 | 140 | return new TaskCollection(); |
141 | 141 | }; |
142 | - $this['hosts'] = function () { |
|
142 | + $this['hosts'] = function() { |
|
143 | 143 | return new HostCollection(); |
144 | 144 | }; |
145 | - $this['scriptManager'] = function ($c) { |
|
145 | + $this['scriptManager'] = function($c) { |
|
146 | 146 | return new ScriptManager($c['tasks']); |
147 | 147 | }; |
148 | - $this['selector'] = function ($c) { |
|
148 | + $this['selector'] = function($c) { |
|
149 | 149 | return new Selector($c['hosts']); |
150 | 150 | }; |
151 | - $this['fail'] = function () { |
|
151 | + $this['fail'] = function() { |
|
152 | 152 | return new Collection(); |
153 | 153 | }; |
154 | - $this['messenger'] = function ($c) { |
|
154 | + $this['messenger'] = function($c) { |
|
155 | 155 | return new Messenger($c['input'], $c['output'], $c['logger']); |
156 | 156 | }; |
157 | - $this['master'] = function ($c) { |
|
157 | + $this['master'] = function($c) { |
|
158 | 158 | return new Master( |
159 | 159 | $c['hosts'], |
160 | 160 | $c['input'], |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $c['messenger'], |
163 | 163 | ); |
164 | 164 | }; |
165 | - $this['importer'] = function () { |
|
165 | + $this['importer'] = function() { |
|
166 | 166 | return new Importer(); |
167 | 167 | }; |
168 | 168 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | * Logger * |
171 | 171 | ******************************/ |
172 | 172 | |
173 | - $this['log_handler'] = function () { |
|
173 | + $this['log_handler'] = function() { |
|
174 | 174 | return !empty($this['log']) |
175 | 175 | ? new FileHandler($this['log']) |
176 | 176 | : new NullHandler(); |
177 | 177 | }; |
178 | - $this['logger'] = function () { |
|
178 | + $this['logger'] = function() { |
|
179 | 179 | return new Logger($this['log_handler']); |
180 | 180 | }; |
181 | 181 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $output->writeln([ |
306 | 306 | "<fg=white;bg=red> {$class} </> <comment>in {$file} on line {$exception->getLine()}:</>", |
307 | 307 | "", |
308 | - implode("\n", array_map(function ($line) { |
|
308 | + implode("\n", array_map(function($line) { |
|
309 | 309 | return " " . $line; |
310 | 310 | }, explode("\n", $exception->getMessage()))), |
311 | 311 | "", |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | new InputOption('plan', null, InputOption::VALUE_NONE, 'Show execution plan'), |
21 | 21 | new InputOption('start-from', null, InputOption::VALUE_REQUIRED, 'Start execution from this task'), |
22 | 22 | new InputOption('log', null, InputOption::VALUE_REQUIRED, 'Write log to a file'), |
23 | - new InputOption('profile', null, InputOption::VALUE_REQUIRED, 'Write profile to a file', ), |
|
24 | - new InputOption('ansi', null, InputOption::VALUE_OPTIONAL, 'Force ANSI output', ), |
|
23 | + new InputOption('profile', null, InputOption::VALUE_REQUIRED, 'Write profile to a file',), |
|
24 | + new InputOption('ansi', null, InputOption::VALUE_OPTIONAL, 'Force ANSI output',), |
|
25 | 25 | ]); |
26 | 26 | |
27 | 27 | $args = IOArguments::collect( |
@@ -29,6 +29,6 @@ discard block |
||
29 | 29 | new ConsoleOutput(OutputInterface::VERBOSITY_DEBUG, false), |
30 | 30 | ); |
31 | 31 | |
32 | - self::assertEquals(['--option','env=prod', '--limit', '1', '-vvv'], $args); |
|
32 | + self::assertEquals(['--option', 'env=prod', '--limit', '1', '-vvv'], $args); |
|
33 | 33 | } |
34 | 34 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function callback(Host $host, bool $forceOutput): callable |
40 | 40 | { |
41 | - return function ($type, $buffer) use ($forceOutput, $host) { |
|
41 | + return function($type, $buffer) use ($forceOutput, $host) { |
|
42 | 42 | if ($this->output->isVerbose() || $forceOutput) { |
43 | 43 | $this->printBuffer($type, $host, $buffer); |
44 | 44 | } |
@@ -115,7 +115,7 @@ |
||
115 | 115 | { |
116 | 116 | if (is_string($value)) { |
117 | 117 | $normalizedValue = normalize_line_endings($value); |
118 | - return preg_replace_callback('/\{\{\s*([\w\.\/-]+)\s*\}\}/', function (array $matches) { |
|
118 | + return preg_replace_callback('/\{\{\s*([\w\.\/-]+)\s*\}\}/', function(array $matches) { |
|
119 | 119 | return $this->get($matches[1]); |
120 | 120 | }, $normalizedValue); |
121 | 121 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | function array_flatten(array $array): array |
14 | 14 | { |
15 | 15 | $flatten = []; |
16 | - array_walk_recursive($array, function ($value) use (&$flatten) { |
|
16 | + array_walk_recursive($array, function($value) use (&$flatten) { |
|
17 | 17 | $flatten[] = $value; |
18 | 18 | }); |
19 | 19 | return $flatten; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function env_stringify(array $array): string |
58 | 58 | { |
59 | 59 | return implode(' ', array_map( |
60 | - function ($key, $value) { |
|
60 | + function($key, $value) { |
|
61 | 61 | return sprintf("%s=%s", $key, escapeshellarg((string) $value)); |
62 | 62 | }, |
63 | 63 | array_keys($array), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | if (getenv('COLORTERM') === 'truecolor') { |
135 | - $hsv = function ($h, $s, $v) { |
|
135 | + $hsv = function($h, $s, $v) { |
|
136 | 136 | $r = $g = $b = $i = $f = $p = $q = $t = 0; |
137 | 137 | $i = floor($h * 6); |
138 | 138 | $f = $h * 6 - $i; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Deployer; |
4 | 4 | |
5 | -set('db_type', function () { |
|
5 | +set('db_type', function() { |
|
6 | 6 | $supportedDbTypes = [ |
7 | 7 | 'none', |
8 | 8 | 'mysql', |
@@ -12,20 +12,20 @@ discard block |
||
12 | 12 | return askChoice(' What DB to install? ', $supportedDbTypes, 0); |
13 | 13 | }); |
14 | 14 | |
15 | -set('db_name', function () { |
|
15 | +set('db_name', function() { |
|
16 | 16 | return ask(' DB name: ', 'prod'); |
17 | 17 | }); |
18 | 18 | |
19 | -set('db_user', function () { |
|
19 | +set('db_user', function() { |
|
20 | 20 | return ask(' DB user: ', 'deployer'); |
21 | 21 | }); |
22 | 22 | |
23 | -set('db_password', function () { |
|
23 | +set('db_password', function() { |
|
24 | 24 | return askHiddenResponse(' DB password: '); |
25 | 25 | }); |
26 | 26 | |
27 | 27 | desc('Provision databases'); |
28 | -task('provision:databases', function () { |
|
28 | +task('provision:databases', function() { |
|
29 | 29 | set('remote_user', get('provision_user')); |
30 | 30 | |
31 | 31 | $dbType = get('db_type'); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->limit(1); |
38 | 38 | |
39 | 39 | desc('Provision MySQL'); |
40 | -task('provision:mysql', function () { |
|
40 | +task('provision:mysql', function() { |
|
41 | 41 | run('apt-get install -y mysql-server', env: ['DEBIAN_FRONTEND' => 'noninteractive'], timeout: 900); |
42 | 42 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", secret: get('db_password')); |
43 | 43 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", secret: get('db_password')); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | }); |
49 | 49 | |
50 | 50 | desc('Provision MariaDB'); |
51 | -task('provision:mariadb', function () { |
|
51 | +task('provision:mariadb', function() { |
|
52 | 52 | run('apt-get install -y mariadb-server', env: ['DEBIAN_FRONTEND' => 'noninteractive'], timeout: 900); |
53 | 53 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", secret: get('db_password')); |
54 | 54 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", secret: get('db_password')); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | }); |
60 | 60 | |
61 | 61 | desc('Provision PostgreSQL'); |
62 | -task('provision:postgresql', function () { |
|
62 | +task('provision:postgresql', function() { |
|
63 | 63 | run('apt-get install -y postgresql postgresql-contrib', env: ['DEBIAN_FRONTEND' => 'noninteractive'], timeout: 900); |
64 | 64 | run("sudo -u postgres psql <<< $'CREATE DATABASE {{db_name}};'"); |
65 | 65 | run("sudo -u postgres psql <<< $'CREATE USER {{db_user}} WITH ENCRYPTED PASSWORD \'%secret%\';'", secret: get('db_password')); |
@@ -4,16 +4,16 @@ discard block |
||
4 | 4 | |
5 | 5 | namespace Deployer; |
6 | 6 | |
7 | -set('domain', function () { |
|
7 | +set('domain', function() { |
|
8 | 8 | return ask(' Domain: ', get('hostname')); |
9 | 9 | }); |
10 | 10 | |
11 | -set('public_path', function () { |
|
11 | +set('public_path', function() { |
|
12 | 12 | return ask(' Public path: ', 'public'); |
13 | 13 | }); |
14 | 14 | |
15 | 15 | desc('Configures a server'); |
16 | -task('provision:server', function () { |
|
16 | +task('provision:server', function() { |
|
17 | 17 | set('remote_user', get('provision_user')); |
18 | 18 | run('usermod -a -G www-data caddy'); |
19 | 19 | run("mkdir -p /var/deployer"); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | })->oncePerNode(); |
23 | 23 | |
24 | 24 | desc('Provision website'); |
25 | -task('provision:website', function () { |
|
25 | +task('provision:website', function() { |
|
26 | 26 | $restoreBecome = become('deployer'); |
27 | 27 | |
28 | 28 | run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}"); |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | })->limit(1); |
67 | 67 | |
68 | 68 | desc('Shows access logs'); |
69 | -task('logs:access', function () { |
|
69 | +task('logs:access', function() { |
|
70 | 70 | run('tail -f {{deploy_path}}/log/access.log'); |
71 | 71 | })->verbose(); |
72 | 72 | |
73 | 73 | desc('Shows caddy syslog'); |
74 | -task('logs:caddy', function () { |
|
74 | +task('logs:caddy', function() { |
|
75 | 75 | run('sudo journalctl -u caddy -f'); |
76 | 76 | })->verbose(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | // Name of lsb_release like: focal, bionic, etc. |
18 | 18 | // As only Ubuntu 20.04 LTS is supported for provision should be the `focal`. |
19 | -set('lsb_release', function () { |
|
19 | +set('lsb_release', function() { |
|
20 | 20 | return run("lsb_release -s -c"); |
21 | 21 | }); |
22 | 22 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | set('provision_user', 'root'); |
44 | 44 | |
45 | 45 | desc('Checks pre-required state'); |
46 | -task('provision:check', function () { |
|
46 | +task('provision:check', function() { |
|
47 | 47 | set('remote_user', get('provision_user')); |
48 | 48 | |
49 | 49 | $release = run('cat /etc/os-release'); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | })->oncePerNode(); |
69 | 69 | |
70 | 70 | desc('Collects required params'); |
71 | -task('provision:configure', function () { |
|
71 | +task('provision:configure', function() { |
|
72 | 72 | set('remote_user', get('provision_user')); |
73 | 73 | |
74 | 74 | $params = [ |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | |
122 | 122 | desc('Adds repositories and update'); |
123 | -task('provision:update', function () { |
|
123 | +task('provision:update', function() { |
|
124 | 124 | set('remote_user', get('provision_user')); |
125 | 125 | |
126 | 126 | // PHP |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | ->verbose(); |
138 | 138 | |
139 | 139 | desc('Upgrades all packages'); |
140 | -task('provision:upgrade', function () { |
|
140 | +task('provision:upgrade', function() { |
|
141 | 141 | set('remote_user', get('provision_user')); |
142 | 142 | run('apt-get upgrade -y', env: ['DEBIAN_FRONTEND' => 'noninteractive'], timeout: 900); |
143 | 143 | }) |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | ->verbose(); |
146 | 146 | |
147 | 147 | desc('Installs packages'); |
148 | -task('provision:install', function () { |
|
148 | +task('provision:install', function() { |
|
149 | 149 | set('remote_user', get('provision_user')); |
150 | 150 | $packages = [ |
151 | 151 | 'acl', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | ->oncePerNode(); |
181 | 181 | |
182 | 182 | desc('Configures the ssh'); |
183 | -task('provision:ssh', function () { |
|
183 | +task('provision:ssh', function() { |
|
184 | 184 | set('remote_user', get('provision_user')); |
185 | 185 | run("sed -i 's/PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config"); |
186 | 186 | run('ssh-keygen -A'); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | })->oncePerNode(); |
193 | 193 | |
194 | 194 | desc('Setups a firewall'); |
195 | -task('provision:firewall', function () { |
|
195 | +task('provision:firewall', function() { |
|
196 | 196 | set('remote_user', get('provision_user')); |
197 | 197 | run('ufw allow 22'); |
198 | 198 | run('ufw allow 80'); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | })->oncePerNode(); |
202 | 202 | |
203 | 203 | desc('Verifies what provision was successful'); |
204 | -task('provision:verify', function () { |
|
204 | +task('provision:verify', function() { |
|
205 | 205 | fetch('{{domain}}', 'get', [], null, $info, true); |
206 | 206 | if ($info['http_code'] === 404) { |
207 | 207 | info("provisioned successfully!"); |