@@ -5,7 +5,7 @@ |
||
| 5 | 5 | set('nodejs_version', 'node_20.x'); |
| 6 | 6 | |
| 7 | 7 | desc('Installs npm packages'); |
| 8 | -task('provision:npm', function () { |
|
| 8 | +task('provision:npm', function() { |
|
| 9 | 9 | run('npm install -g fx zx pm2'); |
| 10 | 10 | run('pm2 startup'); |
| 11 | 11 | }) |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | 'storage/statamic', |
| 13 | 13 | ]); |
| 14 | 14 | |
| 15 | -set('statamic_version', function () { |
|
| 15 | +set('statamic_version', function() { |
|
| 16 | 16 | $result = run('{{bin/php}} {{release_or_current_path}}/please --version'); |
| 17 | 17 | preg_match_all('/(\d+\.?)+/', $result, $matches); |
| 18 | 18 | return $matches[0][0] ?? 'unknown'; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | set('roadrunner_path', '{{release_or_current_path}}'); |
| 17 | 17 | |
| 18 | 18 | desc('Create .env file if it doesn\'t exist'); |
| 19 | -task('deploy:environment', function (): void { |
|
| 19 | +task('deploy:environment', function(): void { |
|
| 20 | 20 | run('cd {{release_or_current_path}} && [ ! -f .env ] && cp .env.sample .env'); |
| 21 | 21 | }); |
| 22 | 22 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | function command(string $command, array $options = []): \Closure |
| 30 | 30 | { |
| 31 | - return function () use ($command, $options): void { |
|
| 31 | + return function() use ($command, $options): void { |
|
| 32 | 32 | $output = run("cd {{release_or_current_path}} && {{bin/php}} app.php $command"); |
| 33 | 33 | |
| 34 | 34 | if (\in_array('showOutput', $options, true)) { |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | function rr(string $command, array $options = []): \Closure |
| 47 | 47 | { |
| 48 | - return function () use ($command, $options): void { |
|
| 48 | + return function() use ($command, $options): void { |
|
| 49 | 49 | $output = run("cd {{roadrunner_path}} && ./rr $command"); |
| 50 | 50 | |
| 51 | 51 | if (\in_array('showOutput', $options, true)) { |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * RoadRunner console commands |
| 113 | 113 | */ |
| 114 | 114 | desc('Start RoadRunner server'); |
| 115 | -task('roadrunner:serve', function (): void { |
|
| 115 | +task('roadrunner:serve', function(): void { |
|
| 116 | 116 | exec(parse('cd {{roadrunner_path}} && ./rr serve -p > /dev/null 2>&1 &')); |
| 117 | 117 | }); |
| 118 | 118 | |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | * Download and restart RoadRunner |
| 127 | 127 | */ |
| 128 | 128 | desc('Download RoadRunner'); |
| 129 | -task('deploy:download-rr', function (): void { |
|
| 129 | +task('deploy:download-rr', function(): void { |
|
| 130 | 130 | $output = run("cd {{release_or_current_path}} && {{bin/php}} ./vendor/bin/rr get-binary -l {{roadrunner_path}}"); |
| 131 | 131 | writeln("<info>$output</info>"); |
| 132 | 132 | }); |
| 133 | 133 | |
| 134 | 134 | desc('Restart RoadRunner'); |
| 135 | -task('deploy:restart-rr', function (): void { |
|
| 135 | +task('deploy:restart-rr', function(): void { |
|
| 136 | 136 | try { |
| 137 | 137 | invoke('roadrunner:reset'); |
| 138 | 138 | writeln("<info>Roadrunner successfully restarted.</info>"); |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | /** |
| 25 | 25 | * Create plugins' symlinks |
| 26 | 26 | */ |
| 27 | -task('deploy:init', function () { |
|
| 27 | +task('deploy:init', function() { |
|
| 28 | 28 | run('{{bin/php}} {{release_or_current_path}}/bin/cake.php plugin assets symlink'); |
| 29 | 29 | })->desc('Initialization'); |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Run migrations |
| 33 | 33 | */ |
| 34 | -task('deploy:run_migrations', function () { |
|
| 34 | +task('deploy:run_migrations', function() { |
|
| 35 | 35 | run('{{bin/php}} {{release_or_current_path}}/bin/cake.php migrations migrate --no-lock'); |
| 36 | 36 | run('{{bin/php}} {{release_or_current_path}}/bin/cake.php schema_cache build'); |
| 37 | 37 | })->desc('Run migrations'); |
@@ -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!"); |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | * Clear cache |
| 23 | 23 | */ |
| 24 | 24 | desc('Clears cache'); |
| 25 | -task('deploy:cache:clear', function () { |
|
| 25 | +task('deploy:cache:clear', function() { |
|
| 26 | 26 | run("cd {{release_or_current_path}} && php -r \"require_once 'app/Mage.php'; umask(0); Mage::app()->cleanCache();\""); |
| 27 | 27 | }); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Remove files that can be used to compromise Magento |
| 31 | 31 | */ |
| 32 | -task('deploy:clear_version', function () { |
|
| 32 | +task('deploy:clear_version', function() { |
|
| 33 | 33 | run("rm -f {{release_or_current_path}}/LICENSE.html"); |
| 34 | 34 | run("rm -f {{release_or_current_path}}/LICENSE.txt"); |
| 35 | 35 | run("rm -f {{release_or_current_path}}/LICENSE_AFL.txt"); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | // Name of current user who is running deploy. |
| 27 | 27 | // If not set will try automatically get git user name, |
| 28 | 28 | // otherwise output of `whoami` command. |
| 29 | -set('user', function () { |
|
| 29 | +set('user', function() { |
|
| 30 | 30 | if (getenv('CI') !== false) { |
| 31 | 31 | return 'ci'; |
| 32 | 32 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * set('deploy_path', '~/{{alias}}'); |
| 87 | 87 | * ``` |
| 88 | 88 | */ |
| 89 | -set('deploy_path', function () { |
|
| 89 | +set('deploy_path', function() { |
|
| 90 | 90 | throw new ConfigurationException('Please, specify `deploy_path`.'); |
| 91 | 91 | }); |
| 92 | 92 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | set('current_path', '{{deploy_path}}/current'); |
| 100 | 100 | |
| 101 | 101 | // Path to the `php` bin. |
| 102 | -set('bin/php', function () { |
|
| 102 | +set('bin/php', function() { |
|
| 103 | 103 | if (currentHost()->hasOwn('php_version')) { |
| 104 | 104 | return '/usr/bin/php{{php_version}}'; |
| 105 | 105 | } |
@@ -107,25 +107,25 @@ discard block |
||
| 107 | 107 | }); |
| 108 | 108 | |
| 109 | 109 | // Path to the `git` bin. |
| 110 | -set('bin/git', function () { |
|
| 110 | +set('bin/git', function() { |
|
| 111 | 111 | return which('git'); |
| 112 | 112 | }); |
| 113 | 113 | |
| 114 | 114 | // Should {{bin/symlink}} use `--relative` option or not. Will detect |
| 115 | 115 | // automatically. |
| 116 | -set('use_relative_symlink', function () { |
|
| 116 | +set('use_relative_symlink', function() { |
|
| 117 | 117 | return commandSupportsOption('ln', '--relative'); |
| 118 | 118 | }); |
| 119 | 119 | |
| 120 | 120 | // Path to the `ln` bin. With predefined options `-nfs`. |
| 121 | -set('bin/symlink', function () { |
|
| 121 | +set('bin/symlink', function() { |
|
| 122 | 122 | return get('use_relative_symlink') ? 'ln -nfs --relative' : 'ln -nfs'; |
| 123 | 123 | }); |
| 124 | 124 | |
| 125 | 125 | // Path to a file which will store temp script with sudo password. |
| 126 | 126 | // Defaults to `.dep/sudo_pass`. This script is only temporary and will be deleted after |
| 127 | 127 | // sudo command executed. |
| 128 | -set('sudo_askpass', function () { |
|
| 128 | +set('sudo_askpass', function() { |
|
| 129 | 129 | if (test('[ -d {{deploy_path}}/.dep ]')) { |
| 130 | 130 | return '{{deploy_path}}/.dep/sudo_pass'; |
| 131 | 131 | } else { |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * Prints success message |
| 164 | 164 | */ |
| 165 | -task('deploy:success', function () { |
|
| 165 | +task('deploy:success', function() { |
|
| 166 | 166 | info('successfully deployed!'); |
| 167 | 167 | }) |
| 168 | 168 | ->hidden(); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | /** |
| 172 | 172 | * Hook on deploy failure. |
| 173 | 173 | */ |
| 174 | -task('deploy:failed', function () { |
|
| 174 | +task('deploy:failed', function() { |
|
| 175 | 175 | }) |
| 176 | 176 | ->hidden(); |
| 177 | 177 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * Follows latest application logs. |
| 182 | 182 | */ |
| 183 | 183 | desc('Shows application logs'); |
| 184 | -task('logs:app', function () { |
|
| 184 | +task('logs:app', function() { |
|
| 185 | 185 | if (!has('log_files')) { |
| 186 | 186 | warning("Please, specify \"log_files\" option."); |
| 187 | 187 | return; |
@@ -9,22 +9,22 @@ |
||
| 9 | 9 | |
| 10 | 10 | add('writable_dirs', ['public/uploads']); |
| 11 | 11 | |
| 12 | -set('bin/websiteconsole', function () { |
|
| 12 | +set('bin/websiteconsole', function() { |
|
| 13 | 13 | return parse('{{bin/php}} {{release_or_current_path}}/bin/websiteconsole --no-interaction'); |
| 14 | 14 | }); |
| 15 | 15 | |
| 16 | 16 | desc('Migrates PHPCR'); |
| 17 | -task('phpcr:migrate', function () { |
|
| 17 | +task('phpcr:migrate', function() { |
|
| 18 | 18 | run('{{bin/console}} phpcr:migrations:migrate'); |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | 21 | desc('Clears cache'); |
| 22 | -task('deploy:website:cache:clear', function () { |
|
| 22 | +task('deploy:website:cache:clear', function() { |
|
| 23 | 23 | run('{{bin/websiteconsole}} cache:clear --no-warmup'); |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | 26 | desc('Warmups cache'); |
| 27 | -task('deploy:website:cache:warmup', function () { |
|
| 27 | +task('deploy:website:cache:warmup', function() { |
|
| 28 | 28 | run('{{bin/websiteconsole}} cache:warmup'); |
| 29 | 29 | }); |
| 30 | 30 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | set('writable_dirs', ['runtime']); |
| 13 | 13 | |
| 14 | 14 | desc('Runs Yii2 migrations for your project'); |
| 15 | -task('deploy:migrate', function () { |
|
| 15 | +task('deploy:migrate', function() { |
|
| 16 | 16 | run('cd {{release_or_current_path}} && {{bin/php}} yii migrate --interactive=0'); |
| 17 | 17 | }); |
| 18 | 18 | |