@@ -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}}; |
@@ -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: '); |
| 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 | $dbType = get('db_type'); |
| 30 | 30 | if ($dbType === 'none') { |
| 31 | 31 | return; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | ->limit(1); |
| 36 | 36 | |
| 37 | 37 | desc('Provision MySQL'); |
| 38 | -task('provision:mysql', function () { |
|
| 38 | +task('provision:mysql', function() { |
|
| 39 | 39 | run('apt-get install -y mysql-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
| 40 | 40 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
| 41 | 41 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | 48 | desc('Provision MariaDB'); |
| 49 | -task('provision:mariadb', function () { |
|
| 49 | +task('provision:mariadb', function() { |
|
| 50 | 50 | run('apt-get install -y mariadb-server', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
| 51 | 51 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'0.0.0.0' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
| 52 | 52 | run("mysql --user=\"root\" -e \"CREATE USER IF NOT EXISTS '{{db_user}}'@'%' IDENTIFIED BY '%secret%';\"", ['secret' => get('db_password')]); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | }); |
| 58 | 58 | |
| 59 | 59 | desc('Provision PostgreSQL'); |
| 60 | -task('provision:postgresql', function () { |
|
| 60 | +task('provision:postgresql', function() { |
|
| 61 | 61 | run('apt-get install -y postgresql postgresql-contrib', ['env' => ['DEBIAN_FRONTEND' => 'noninteractive'], 'timeout' => 900]); |
| 62 | 62 | run("sudo -u postgres psql <<< $'CREATE DATABASE {{db_name}};'"); |
| 63 | 63 | run("sudo -u postgres psql <<< $'CREATE USER {{db_user}} WITH ENCRYPTED PASSWORD \'%secret%\';'", ['secret' => get('db_password')]); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | //Create and upload Drupal 7 settings.php using values from secrets |
| 34 | -task('drupal:settings', function () { |
|
| 34 | +task('drupal:settings', function() { |
|
| 35 | 35 | if (askConfirmation('Are you sure to generate and upload settings.php file?')) { |
| 36 | 36 | |
| 37 | 37 | //Get template |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | }); |
| 74 | 74 | |
| 75 | 75 | //Upload Drupal 7 files folder |
| 76 | -task('drupal:upload_files', function () { |
|
| 76 | +task('drupal:upload_files', function() { |
|
| 77 | 77 | if (askConfirmation('Are you sure?')) { |
| 78 | 78 | upload('sites/{{drupal_site}}/files', '{{deploy_path}}/shared/sites/{{drupal_site}}/files'); |
| 79 | 79 | } |
@@ -36,13 +36,13 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | function craft($command, $options = []) |
| 38 | 38 | { |
| 39 | - return function () use ($command, $options) { |
|
| 40 | - if (! test('[ -s {{release_path}}/.env ]')) { |
|
| 39 | + return function() use ($command, $options) { |
|
| 40 | + if (!test('[ -s {{release_path}}/.env ]')) { |
|
| 41 | 41 | throw new \Exception('Your .env file is empty! Cannot proceed.'); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // By default we don't want any command to be interactive |
| 45 | - if (! in_array('interactive', $options)) { |
|
| 45 | + if (!in_array('interactive', $options)) { |
|
| 46 | 46 | $command .= ' --interactive=0'; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | // Update using: `set('static_content_jobs', '1');` |
| 65 | 65 | set('static_content_jobs', '1'); |
| 66 | 66 | |
| 67 | -set('content_version', function () { |
|
| 67 | +set('content_version', function() { |
|
| 68 | 68 | return time(); |
| 69 | 69 | }); |
| 70 | 70 | |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | set('bin/magento', '{{release_or_current_path}}/{{magento_dir}}/bin/magento'); |
| 111 | 111 | |
| 112 | -set('magento_version', function () { |
|
| 112 | +set('magento_version', function() { |
|
| 113 | 113 | // detect version |
| 114 | 114 | $versionOutput = run('{{bin/php}} {{bin/magento}} --version'); |
| 115 | 115 | preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches); |
| 116 | 116 | return $matches[0] ?? '2.0'; |
| 117 | 117 | }); |
| 118 | 118 | |
| 119 | -set('config_import_needed', function () { |
|
| 119 | +set('config_import_needed', function() { |
|
| 120 | 120 | // detect if app:config:import is needed |
| 121 | 121 | try { |
| 122 | 122 | run('{{bin/php}} {{bin/magento}} app:config:status'); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | return false; |
| 131 | 131 | }); |
| 132 | 132 | |
| 133 | -set('database_upgrade_needed', function () { |
|
| 133 | +set('database_upgrade_needed', function() { |
|
| 134 | 134 | // detect if setup:upgrade is needed |
| 135 | 135 | try { |
| 136 | 136 | run('{{bin/php}} {{bin/magento}} setup:db:status'); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | // 'MAGE_MODE' => 'production' |
| 166 | 166 | // ``` |
| 167 | 167 | desc('Compiles magento di'); |
| 168 | -task('magento:compile', function () { |
|
| 168 | +task('magento:compile', function() { |
|
| 169 | 169 | run("{{bin/php}} {{bin/magento}} setup:di:compile"); |
| 170 | 170 | run('cd {{release_or_current_path}}/{{magento_dir}} && {{bin/composer}} dump-autoload -o'); |
| 171 | 171 | }); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | // ] |
| 192 | 192 | // ``` |
| 193 | 193 | desc('Deploys assets'); |
| 194 | -task('magento:deploy:assets', function () { |
|
| 194 | +task('magento:deploy:assets', function() { |
|
| 195 | 195 | $themesToCompile = ''; |
| 196 | 196 | if (get('split_static_deployment')) { |
| 197 | 197 | invoke('magento:deploy:assets:adminhtml'); |
@@ -208,12 +208,12 @@ discard block |
||
| 208 | 208 | }); |
| 209 | 209 | |
| 210 | 210 | desc('Deploys assets for backend only'); |
| 211 | -task('magento:deploy:assets:adminhtml', function () { |
|
| 211 | +task('magento:deploy:assets:adminhtml', function() { |
|
| 212 | 212 | magentoDeployAssetsSplit('backend'); |
| 213 | 213 | }); |
| 214 | 214 | |
| 215 | 215 | desc('Deploys assets for frontend only'); |
| 216 | -task('magento:deploy:assets:frontend', function () { |
|
| 216 | +task('magento:deploy:assets:frontend', function() { |
|
| 217 | 217 | magentoDeployAssetsSplit('frontend'); |
| 218 | 218 | }); |
| 219 | 219 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | desc('Syncs content version'); |
| 264 | -task('magento:sync:content_version', function () { |
|
| 264 | +task('magento:sync:content_version', function() { |
|
| 265 | 265 | $timestamp = time(); |
| 266 | - on(select('all'), function (Host $host) use ($timestamp) { |
|
| 266 | + on(select('all'), function(Host $host) use ($timestamp) { |
|
| 267 | 267 | $host->set('content_version', $timestamp); |
| 268 | 268 | }); |
| 269 | 269 | })->once(); |
@@ -271,26 +271,25 @@ discard block |
||
| 271 | 271 | before('magento:deploy:assets', 'magento:sync:content_version'); |
| 272 | 272 | |
| 273 | 273 | desc('Enables maintenance mode'); |
| 274 | -task('magento:maintenance:enable', function () { |
|
| 274 | +task('magento:maintenance:enable', function() { |
|
| 275 | 275 | // do not use {{bin/magento}} because it would be in "release" but the maintenance mode must be set in "current" |
| 276 | 276 | run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento maintenance:enable; fi"); |
| 277 | 277 | }); |
| 278 | 278 | |
| 279 | 279 | desc('Disables maintenance mode'); |
| 280 | -task('magento:maintenance:disable', function () { |
|
| 280 | +task('magento:maintenance:disable', function() { |
|
| 281 | 281 | // do not use {{bin/magento}} because it would be in "release" but the maintenance mode must be set in "current" |
| 282 | 282 | run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/{{magento_dir}}/bin/magento maintenance:disable; fi"); |
| 283 | 283 | }); |
| 284 | 284 | |
| 285 | 285 | desc('Set maintenance mode if needed'); |
| 286 | -task('magento:maintenance:enable-if-needed', function () { |
|
| 287 | - ! get('enable_zerodowntime') || get('database_upgrade_needed') || get('config_import_needed') ? |
|
| 288 | - invoke('magento:maintenance:enable') : |
|
| 289 | - writeln('Config and database up to date => no maintenance mode'); |
|
| 286 | +task('magento:maintenance:enable-if-needed', function() { |
|
| 287 | + !get('enable_zerodowntime') || get('database_upgrade_needed') || get('config_import_needed') ? |
|
| 288 | + invoke('magento:maintenance:enable') : writeln('Config and database up to date => no maintenance mode'); |
|
| 290 | 289 | }); |
| 291 | 290 | |
| 292 | 291 | desc('Config Import'); |
| 293 | -task('magento:config:import', function () { |
|
| 292 | +task('magento:config:import', function() { |
|
| 294 | 293 | if (get('config_import_needed')) { |
| 295 | 294 | run('{{bin/php}} {{bin/magento}} app:config:import --no-interaction'); |
| 296 | 295 | } else { |
@@ -299,7 +298,7 @@ discard block |
||
| 299 | 298 | }); |
| 300 | 299 | |
| 301 | 300 | desc('Upgrades magento database'); |
| 302 | -task('magento:upgrade:db', function () { |
|
| 301 | +task('magento:upgrade:db', function() { |
|
| 303 | 302 | if (get('database_upgrade_needed')) { |
| 304 | 303 | run("{{bin/php}} {{bin/magento}} setup:db-schema:upgrade --no-interaction"); |
| 305 | 304 | run("{{bin/php}} {{bin/magento}} setup:db-data:upgrade --no-interaction"); |
@@ -309,7 +308,7 @@ discard block |
||
| 309 | 308 | })->once(); |
| 310 | 309 | |
| 311 | 310 | desc('Flushes Magento Cache'); |
| 312 | -task('magento:cache:flush', function () { |
|
| 311 | +task('magento:cache:flush', function() { |
|
| 313 | 312 | run("{{bin/php}} {{bin/magento}} cache:flush"); |
| 314 | 313 | }); |
| 315 | 314 | |
@@ -360,7 +359,7 @@ discard block |
||
| 360 | 359 | set('repository', null); |
| 361 | 360 | |
| 362 | 361 | // The relative path to the artifact file. If the directory does not exist, it will be created |
| 363 | -set('artifact_path', function () { |
|
| 362 | +set('artifact_path', function() { |
|
| 364 | 363 | if (!testLocally('[ -d {{artifact_dir}} ]')) { |
| 365 | 364 | runLocally('mkdir -p {{artifact_dir}}'); |
| 366 | 365 | } |
@@ -368,7 +367,7 @@ discard block |
||
| 368 | 367 | }); |
| 369 | 368 | |
| 370 | 369 | // The location of the tar command. On MacOS you should have installed gtar, as it supports the required settings |
| 371 | -set('bin/tar', function () { |
|
| 370 | +set('bin/tar', function() { |
|
| 372 | 371 | if (commandExist('gtar')) { |
| 373 | 372 | return which('gtar'); |
| 374 | 373 | } else { |
@@ -379,7 +378,7 @@ discard block |
||
| 379 | 378 | // tasks section |
| 380 | 379 | |
| 381 | 380 | desc('Packages all relevant files in an artifact.'); |
| 382 | -task('artifact:package', function () { |
|
| 381 | +task('artifact:package', function() { |
|
| 383 | 382 | if (!test('[ -f {{artifact_excludes_file}} ]')) { |
| 384 | 383 | throw new GracefulShutdownException( |
| 385 | 384 | "No artifact excludes file provided, provide one at artifacts/excludes or change location", |
@@ -389,23 +388,23 @@ discard block |
||
| 389 | 388 | }); |
| 390 | 389 | |
| 391 | 390 | desc('Uploads artifact in release folder for extraction.'); |
| 392 | -task('artifact:upload', function () { |
|
| 391 | +task('artifact:upload', function() { |
|
| 393 | 392 | upload(get('artifact_path'), '{{release_path}}'); |
| 394 | 393 | }); |
| 395 | 394 | |
| 396 | 395 | desc('Extracts artifact in release path.'); |
| 397 | -task('artifact:extract', function () { |
|
| 396 | +task('artifact:extract', function() { |
|
| 398 | 397 | run('{{bin/tar}} -xzpf {{release_path}}/{{artifact_file}} -C {{release_path}}'); |
| 399 | 398 | run('rm -rf {{release_path}}/{{artifact_file}}'); |
| 400 | 399 | }); |
| 401 | 400 | |
| 402 | 401 | desc('Clears generated files prior to building.'); |
| 403 | -task('build:remove-generated', function () { |
|
| 402 | +task('build:remove-generated', function() { |
|
| 404 | 403 | run('rm -rf generated/*'); |
| 405 | 404 | }); |
| 406 | 405 | |
| 407 | 406 | desc('Prepare local artifact build'); |
| 408 | -task('build:prepare', function () { |
|
| 407 | +task('build:prepare', function() { |
|
| 409 | 408 | if (!currentHost()->get('local')) { |
| 410 | 409 | throw new GracefulShutdownException('Artifact can only be built locally, you provided a non local host'); |
| 411 | 410 | } |
@@ -446,7 +445,7 @@ discard block |
||
| 446 | 445 | |
| 447 | 446 | |
| 448 | 447 | desc('Adds additional files and dirs to the list of shared files and dirs'); |
| 449 | -task('deploy:additional-shared', function () { |
|
| 448 | +task('deploy:additional-shared', function() { |
|
| 450 | 449 | add('shared_files', get('additional_shared_files')); |
| 451 | 450 | add('shared_dirs', get('additional_shared_dirs')); |
| 452 | 451 | }); |
@@ -461,7 +460,7 @@ discard block |
||
| 461 | 460 | * ``` |
| 462 | 461 | **/ |
| 463 | 462 | desc('Update cache id_prefix'); |
| 464 | -task('magento:set_cache_prefix', function () { |
|
| 463 | +task('magento:set_cache_prefix', function() { |
|
| 465 | 464 | //download current env config |
| 466 | 465 | $tmpConfigFile = tempnam(sys_get_temp_dir(), 'deployer_config'); |
| 467 | 466 | download('{{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH, $tmpConfigFile); |
@@ -501,7 +500,7 @@ discard block |
||
| 501 | 500 | * After successful deployment, move the tmp_env.php file to env.php ready for next deployment |
| 502 | 501 | */ |
| 503 | 502 | desc('Cleanup cache id_prefix env files'); |
| 504 | -task('magento:cleanup_cache_prefix', function () { |
|
| 503 | +task('magento:cleanup_cache_prefix', function() { |
|
| 505 | 504 | run('rm {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); |
| 506 | 505 | run('rm {{release_or_current_path}}/' . ENV_CONFIG_FILE_PATH); |
| 507 | 506 | run('mv {{deploy_path}}/shared/' . TMP_ENV_CONFIG_FILE_PATH . ' {{deploy_path}}/shared/' . ENV_CONFIG_FILE_PATH); |
@@ -517,7 +516,7 @@ discard block |
||
| 517 | 516 | * ``` |
| 518 | 517 | */ |
| 519 | 518 | desc('Remove cron from crontab and kill running cron jobs'); |
| 520 | -task('magento:cron:stop', function () { |
|
| 519 | +task('magento:cron:stop', function() { |
|
| 521 | 520 | if (has('previous_release')) { |
| 522 | 521 | run('{{bin/php}} {{previous_release}}/{{magento_dir}}/bin/magento cron:remove'); |
| 523 | 522 | } |
@@ -533,7 +532,7 @@ discard block |
||
| 533 | 532 | * ``` |
| 534 | 533 | */ |
| 535 | 534 | desc('Install cron in crontab'); |
| 536 | -task('magento:cron:install', function () { |
|
| 535 | +task('magento:cron:install', function() { |
|
| 537 | 536 | run('cd {{release_or_current_path}}'); |
| 538 | 537 | run('{{bin/php}} {{bin/magento}} cron:install'); |
| 539 | 538 | }); |