@@ -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(); |
@@ -8,14 +8,14 @@ |
||
| 8 | 8 | 'VAR' => 'global', |
| 9 | 9 | ]); |
| 10 | 10 | |
| 11 | -task('test', function () { |
|
| 11 | +task('test', function() { |
|
| 12 | 12 | info('global=' . run('echo $VAR')); |
| 13 | 13 | info('local=' . run('echo $VAR', env: ['VAR' => 'local'])); |
| 14 | 14 | info('dotenv=' . run('echo $KEY')); |
| 15 | 15 | info('dotenv=' . run('echo $KEY', env: ['KEY' => 'local'])); |
| 16 | 16 | }); |
| 17 | 17 | |
| 18 | -before('test', function () { |
|
| 18 | +before('test', function() { |
|
| 19 | 19 | run('mkdir -p {{deploy_path}}'); |
| 20 | 20 | run('echo KEY="\'Hello, world!\'" > {{deploy_path}}/.env'); |
| 21 | 21 | set('dotenv', '{{deploy_path}}/.env'); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * }); |
| 51 | 51 | * ``` |
| 52 | 52 | */ |
| 53 | -function host(string ...$hostname): Host|ObjectProxy |
|
| 53 | +function host(string ...$hostname): Host | ObjectProxy |
|
| 54 | 54 | { |
| 55 | 55 | $deployer = Deployer::get(); |
| 56 | 56 | if (count($hostname) === 1 && $deployer->hosts->has($hostname[0])) { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $deployer->hosts->set($aliases[0], $host); |
| 71 | 71 | return $host; |
| 72 | 72 | } else { |
| 73 | - $hosts = array_map(function ($hostname) use ($deployer): Host { |
|
| 73 | + $hosts = array_map(function($hostname) use ($deployer): Host { |
|
| 74 | 74 | $host = new Host($hostname); |
| 75 | 75 | $deployer->hosts->set($hostname, $host); |
| 76 | 76 | return $host; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * localhost('ci'); // Alias and hostname will be "ci". |
| 88 | 88 | * ``` |
| 89 | 89 | */ |
| 90 | -function localhost(string ...$hostnames): Localhost|ObjectProxy |
|
| 90 | +function localhost(string ...$hostnames): Localhost | ObjectProxy |
|
| 91 | 91 | { |
| 92 | 92 | $deployer = Deployer::get(); |
| 93 | 93 | $hostnames = Range::expand($hostnames); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $deployer->hosts->set($host->getAlias(), $host); |
| 98 | 98 | return $host; |
| 99 | 99 | } else { |
| 100 | - $hosts = array_map(function ($hostname) use ($deployer): Localhost { |
|
| 100 | + $hosts = array_map(function($hostname) use ($deployer): Localhost { |
|
| 101 | 101 | $host = new Localhost($hostname); |
| 102 | 102 | $deployer->hosts->set($host->getAlias(), $host); |
| 103 | 103 | return $host; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param callable|array|null $body Callable task, array of other tasks names or nothing to get a defined tasks |
| 184 | 184 | * @return Task |
| 185 | 185 | */ |
| 186 | -function task(string $name, callable|array|null $body = null): Task |
|
| 186 | +function task(string $name, callable | array | null $body = null): Task |
|
| 187 | 187 | { |
| 188 | 188 | $deployer = Deployer::get(); |
| 189 | 189 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return ?Task |
| 237 | 237 | */ |
| 238 | -function before(string $task, string|callable $do): ?Task |
|
| 238 | +function before(string $task, string | callable $do): ?Task |
|
| 239 | 239 | { |
| 240 | 240 | if (is_closure($do)) { |
| 241 | 241 | $newTask = task("before:$task", $do); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @return ?Task |
| 257 | 257 | */ |
| 258 | -function after(string $task, string|callable $do): ?Task |
|
| 258 | +function after(string $task, string | callable $do): ?Task |
|
| 259 | 259 | { |
| 260 | 260 | if (is_closure($do)) { |
| 261 | 261 | $newTask = task("after:$task", $do); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return ?Task |
| 278 | 278 | */ |
| 279 | -function fail(string $task, string|callable $do): ?Task |
|
| 279 | +function fail(string $task, string | callable $do): ?Task |
|
| 280 | 280 | { |
| 281 | 281 | if (is_callable($do)) { |
| 282 | 282 | $newTask = task("fail:$task", $do); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | { |
| 338 | 338 | $currentBecome = get('become'); |
| 339 | 339 | set('become', $user); |
| 340 | - return function () use ($currentBecome) { |
|
| 340 | + return function() use ($currentBecome) { |
|
| 341 | 341 | set('become', $currentBecome); |
| 342 | 342 | }; |
| 343 | 343 | } |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | ?int $idleTimeout = null, |
| 401 | 401 | ): string { |
| 402 | 402 | $runParams = new RunParams( |
| 403 | - shell: currentHost()->getShell(), |
|
| 404 | - cwd: $cwd ?? has('working_path') ? get('working_path') : null, |
|
| 405 | - env: array_merge_alternate(get('env', []), $env ?? []), |
|
| 406 | - nothrow: $nothrow, |
|
| 407 | - timeout: $timeout ?? get('default_timeout', 300), |
|
| 408 | - idleTimeout: $idleTimeout, |
|
| 409 | - forceOutput: $forceOutput, |
|
| 410 | - secrets: empty($secret) ? null : ['secret' => $secret], |
|
| 403 | + shell : currentHost()->getShell(), |
|
| 404 | + cwd : $cwd ?? has('working_path') ? get('working_path') : null, |
|
| 405 | + env : array_merge_alternate(get('env', []), $env ?? []), |
|
| 406 | + nothrow : $nothrow, |
|
| 407 | + timeout : $timeout ?? get('default_timeout', 300), |
|
| 408 | + idleTimeout : $idleTimeout, |
|
| 409 | + forceOutput : $forceOutput, |
|
| 410 | + secrets : empty($secret) ? null : ['secret' => $secret], |
|
| 411 | 411 | ); |
| 412 | 412 | |
| 413 | 413 | $dotenv = get('dotenv', false); |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | $runParams->dotenv = $dotenv; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - $run = function (string $command, ?RunParams $params = null) use ($runParams): string { |
|
| 418 | + $run = function(string $command, ?RunParams $params = null) use ($runParams) : string { |
|
| 419 | 419 | $params = $params ?? $runParams; |
| 420 | 420 | $host = currentHost(); |
| 421 | 421 | $command = parse($command); |
@@ -490,14 +490,14 @@ discard block |
||
| 490 | 490 | ?string $shell = null, |
| 491 | 491 | ): string { |
| 492 | 492 | $runParams = new RunParams( |
| 493 | - shell: $shell ?? 'bash -s', |
|
| 494 | - cwd: $cwd, |
|
| 495 | - env: $env, |
|
| 496 | - nothrow: $nothrow, |
|
| 497 | - timeout: $timeout, |
|
| 498 | - idleTimeout: $idleTimeout, |
|
| 499 | - forceOutput: $forceOutput, |
|
| 500 | - secrets: empty($secret) ? null : ['secret' => $secret], |
|
| 493 | + shell : $shell ?? 'bash -s', |
|
| 494 | + cwd : $cwd, |
|
| 495 | + env : $env, |
|
| 496 | + nothrow : $nothrow, |
|
| 497 | + timeout : $timeout, |
|
| 498 | + idleTimeout : $idleTimeout, |
|
| 499 | + forceOutput : $forceOutput, |
|
| 500 | + secrets : empty($secret) ? null : ['secret' => $secret], |
|
| 501 | 501 | ); |
| 502 | 502 | |
| 503 | 503 | $process = Deployer::get()->processRunner; |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | $this->pop->command($host, 'run', $command); |
| 39 | 39 | |
| 40 | 40 | $terminalOutput = $this->pop->callback($host, $params->forceOutput); |
| 41 | - $callback = function ($type, $buffer) use ($host, $terminalOutput) { |
|
| 41 | + $callback = function($type, $buffer) use ($host, $terminalOutput) { |
|
| 42 | 42 | $this->logger->printBuffer($host, $type, $buffer); |
| 43 | 43 | $terminalOutput($type, $buffer); |
| 44 | 44 | }; |