@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | namespace Deployer; |
| 16 | 16 | |
| 17 | -set('bin/npm', function () { |
|
| 17 | +set('bin/npm', function() { |
|
| 18 | 18 | return which('npm'); |
| 19 | 19 | }); |
| 20 | 20 | |
@@ -24,6 +24,6 @@ discard block |
||
| 24 | 24 | // any situation where you want to make sure you're doing a clean |
| 25 | 25 | // install of your dependencies. |
| 26 | 26 | desc('Installs npm packages'); |
| 27 | -task('npm:install', function () { |
|
| 27 | +task('npm:install', function() { |
|
| 28 | 28 | run("cd {{release_path}} && {{bin/npm}} ci"); |
| 29 | 29 | }); |
@@ -90,13 +90,13 @@ discard block |
||
| 90 | 90 | use Deployer\Utility\Httpie; |
| 91 | 91 | |
| 92 | 92 | // Chatwork settings |
| 93 | -set('chatwork_token', function () { |
|
| 93 | +set('chatwork_token', function() { |
|
| 94 | 94 | throw new \RuntimeException('Please configure "chatwork_token" parameter.'); |
| 95 | 95 | }); |
| 96 | -set('chatwork_room_id', function () { |
|
| 96 | +set('chatwork_room_id', function() { |
|
| 97 | 97 | throw new \RuntimeException('Please configure "chatwork_room_id" parameter.'); |
| 98 | 98 | }); |
| 99 | -set('chatwork_api', function () { |
|
| 99 | +set('chatwork_api', function() { |
|
| 100 | 100 | return 'https://api.chatwork.com/v2/rooms/' . get('chatwork_room_id') . '/messages'; |
| 101 | 101 | }); |
| 102 | 102 | |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | set('chatwork_failure_text', "[info]\n[title](*) Deployment Status: Failed[/title]\nRepo: {{repository}}\nBranch: {{branch}}\nServer: {{hostname}}\nRelease Path: {{release_path}}\nCurrent Path: {{current_path}}\n[/info]"); |
| 107 | 107 | |
| 108 | 108 | // Helpers |
| 109 | -task('chatwork_send_message', function () { |
|
| 109 | +task('chatwork_send_message', function() { |
|
| 110 | 110 | Httpie::post(get('chatwork_api')) |
| 111 | - ->query(['body' => get('chatwork_message'),]) |
|
| 111 | + ->query(['body' => get('chatwork_message'), ]) |
|
| 112 | 112 | ->header("X-ChatWorkToken", get('chatwork_token')) |
| 113 | 113 | ->send(); |
| 114 | 114 | }); |
| 115 | 115 | |
| 116 | 116 | // Tasks |
| 117 | 117 | desc('Tests messages'); |
| 118 | -task('chatwork:test', function () { |
|
| 118 | +task('chatwork:test', function() { |
|
| 119 | 119 | set('chatwork_message', get('chatwork_notify_text')); |
| 120 | 120 | invoke('chatwork_send_message'); |
| 121 | 121 | set('chatwork_message', get('chatwork_success_text')); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | ->once(); |
| 127 | 127 | |
| 128 | 128 | desc('Notifies Chatwork'); |
| 129 | -task('chatwork:notify', function () { |
|
| 129 | +task('chatwork:notify', function() { |
|
| 130 | 130 | if (!get('chatwork_token', false)) { |
| 131 | 131 | return; |
| 132 | 132 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | ->hidden(); |
| 142 | 142 | |
| 143 | 143 | desc('Notifies Chatwork about deploy finish'); |
| 144 | -task('chatwork:notify:success', function () { |
|
| 144 | +task('chatwork:notify:success', function() { |
|
| 145 | 145 | if (!get('chatwork_token', false)) { |
| 146 | 146 | return; |
| 147 | 147 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | ->hidden(); |
| 158 | 158 | |
| 159 | 159 | desc('Notifies Chatwork about deploy failure'); |
| 160 | -task('chatwork:notify:failure', function () { |
|
| 160 | +task('chatwork:notify:failure', function() { |
|
| 161 | 161 | if (!get('chatwork_token', false)) { |
| 162 | 162 | return; |
| 163 | 163 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | desc('Creates a database on DirectAdmin'); |
| 76 | -task('directadmin:createdb', function () { |
|
| 76 | +task('directadmin:createdb', function() { |
|
| 77 | 77 | $config = getDirectAdminConfig(); |
| 78 | 78 | |
| 79 | 79 | if (!is_array($config) || |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | }); |
| 94 | 94 | |
| 95 | 95 | desc('Deletes a database on DirectAdmin'); |
| 96 | -task('directadmin:deletedb', function () { |
|
| 96 | +task('directadmin:deletedb', function() { |
|
| 97 | 97 | $config = getDirectAdminConfig(); |
| 98 | 98 | |
| 99 | 99 | if (!is_array($config) || |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | }); |
| 109 | 109 | |
| 110 | 110 | desc('Creates a domain on DirectAdmin'); |
| 111 | -task('directadmin:createdomain', function () { |
|
| 111 | +task('directadmin:createdomain', function() { |
|
| 112 | 112 | $config = getDirectAdminConfig(); |
| 113 | 113 | |
| 114 | 114 | if (!is_array($config) || |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | }); |
| 127 | 127 | |
| 128 | 128 | desc('Deletes a domain on DirectAdmin'); |
| 129 | -task('directadmin:deletedomain', function () { |
|
| 129 | +task('directadmin:deletedomain', function() { |
|
| 130 | 130 | $config = getDirectAdminConfig(); |
| 131 | 131 | |
| 132 | 132 | if (!is_array($config) || |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | }); |
| 143 | 143 | |
| 144 | 144 | desc('Symlink your private_html to public_html'); |
| 145 | -task('directadmin:symlink-private-html', function () { |
|
| 145 | +task('directadmin:symlink-private-html', function() { |
|
| 146 | 146 | $config = getDirectAdminConfig(); |
| 147 | 147 | |
| 148 | 148 | if (!is_array($config) || |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | }); |
| 159 | 159 | |
| 160 | 160 | desc('Changes the PHP version from a domain'); |
| 161 | -task('directadmin:php-version', function () { |
|
| 161 | +task('directadmin:php-version', function() { |
|
| 162 | 162 | $config = getDirectAdminConfig(); |
| 163 | 163 | |
| 164 | 164 | if (!is_array($config) || |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $m = []; |
| 68 | - $match = function ($regexp) use ($line, &$m) { |
|
| 68 | + $match = function($regexp) use ($line, &$m) { |
|
| 69 | 69 | return preg_match("#$regexp#", $line, $m); |
| 70 | 70 | }; |
| 71 | 71 | switch ($state) { |
@@ -73,13 +73,13 @@ |
||
| 73 | 73 | self::assertEquals([$a, $b, $c], $scriptManager->getTasks('group')); |
| 74 | 74 | self::assertNull($a->getSelector()); |
| 75 | 75 | self::assertEquals([[['=', 'stage', ['beta']]]], $b->getSelector()); |
| 76 | - self::assertEquals([[['=', 'stage', ['alpha', 'beta']],['=', 'role', ['db']]]], $c->getSelector()); |
|
| 76 | + self::assertEquals([[['=', 'stage', ['alpha', 'beta']], ['=', 'role', ['db']]]], $c->getSelector()); |
|
| 77 | 77 | |
| 78 | 78 | $group->select('role=prod'); |
| 79 | 79 | self::assertEquals([$a, $b, $c], $scriptManager->getTasks('group')); |
| 80 | 80 | self::assertEquals([[['=', 'role', ['prod']]]], $a->getSelector()); |
| 81 | - self::assertEquals([[['=', 'stage', ['beta']]],[['=', 'role', ['prod']]]], $b->getSelector()); |
|
| 82 | - self::assertEquals([[['=', 'stage', ['alpha', 'beta']],['=', 'role', ['db']]],[['=', 'role', ['prod']]]], $c->getSelector()); |
|
| 81 | + self::assertEquals([[['=', 'stage', ['beta']]], [['=', 'role', ['prod']]]], $b->getSelector()); |
|
| 82 | + self::assertEquals([[['=', 'stage', ['alpha', 'beta']], ['=', 'role', ['db']]], [['=', 'role', ['prod']]]], $c->getSelector()); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | public function testThrowsExceptionIfTaskCollectionEmpty() |
@@ -4,13 +4,13 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use function Deployer\Support\parse_home_dir; |
| 6 | 6 | |
| 7 | -set('sudo_password', function () { |
|
| 7 | +set('sudo_password', function() { |
|
| 8 | 8 | return askHiddenResponse(' Password for sudo: '); |
| 9 | 9 | }); |
| 10 | 10 | |
| 11 | 11 | |
| 12 | 12 | desc('Setups a deployer user'); |
| 13 | -task('provision:user', function () { |
|
| 13 | +task('provision:user', function() { |
|
| 14 | 14 | set('remote_user', get('provision_user')); |
| 15 | 15 | |
| 16 | 16 | if (test('id deployer >/dev/null 2>&1')) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | desc('Copy public key to remote server'); |
| 55 | -task('provision:ssh_copy_id', function () { |
|
| 55 | +task('provision:ssh_copy_id', function() { |
|
| 56 | 56 | $defaultKeys = [ |
| 57 | 57 | '~/.ssh/id_rsa.pub', |
| 58 | 58 | '~/.ssh/id_ed25519.pub', |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | set('node_version', '23.x'); |
| 9 | 9 | |
| 10 | 10 | desc('Installs npm packages'); |
| 11 | -task('provision:node', function () { |
|
| 11 | +task('provision:node', function() { |
|
| 12 | 12 | set('remote_user', get('provision_user')); |
| 13 | 13 | |
| 14 | 14 | if (has('nodejs_version')) { |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace Deployer; |
| 4 | 4 | |
| 5 | -set('php_version', function () { |
|
| 5 | +set('php_version', function() { |
|
| 6 | 6 | $defaultPhpVersion = file_exists('composer.json') |
| 7 | 7 | ? explode('|', preg_replace('/[^0-9.|]+/', '', json_decode(file_get_contents('composer.json'), true)['require']['php'] ?? '8.3'))[0] |
| 8 | 8 | : '8.3'; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | }); |
| 11 | 11 | |
| 12 | 12 | desc('Installs PHP packages'); |
| 13 | -task('provision:php', function () { |
|
| 13 | +task('provision:php', function() { |
|
| 14 | 14 | set('remote_user', get('provision_user')); |
| 15 | 15 | |
| 16 | 16 | $version = get('php_version'); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ->limit(1); |
| 66 | 66 | |
| 67 | 67 | desc('Shows php-fpm logs'); |
| 68 | -task('logs:php-fpm', function () { |
|
| 68 | +task('logs:php-fpm', function() { |
|
| 69 | 69 | $fpmLogs = run("ls -1 /var/log | grep fpm"); |
| 70 | 70 | if (empty($fpmLogs)) { |
| 71 | 71 | throw new \RuntimeException('No PHP-FPM logs found.'); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | })->verbose(); |
| 75 | 75 | |
| 76 | 76 | desc('Installs Composer'); |
| 77 | -task('provision:composer', function () { |
|
| 77 | +task('provision:composer', function() { |
|
| 78 | 78 | run('curl -sS https://getcomposer.org/installer | php'); |
| 79 | 79 | run('mv composer.phar /usr/local/bin/composer'); |
| 80 | 80 | })->oncePerNode(); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | // Defines "what" text for the 'deploy:info' task. |
| 6 | 6 | // Uses one of the following sources: |
| 7 | 7 | // 1. Repository name |
| 8 | -set('what', function () { |
|
| 8 | +set('what', function() { |
|
| 9 | 9 | $repo = get('repository'); |
| 10 | 10 | if (!empty($repo)) { |
| 11 | 11 | return preg_replace('/\.git$/', '', basename($repo)); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | // Uses one of the following sources: |
| 18 | 18 | // 1. Host's stage label |
| 19 | 19 | // 2. Host's alias |
| 20 | -set('where', function () { |
|
| 20 | +set('where', function() { |
|
| 21 | 21 | $labels = get('labels'); |
| 22 | 22 | if (isset($labels['stage'])) { |
| 23 | 23 | return $labels['stage']; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | }); |
| 27 | 27 | |
| 28 | 28 | desc('Displays info about deployment'); |
| 29 | -task('deploy:info', function () { |
|
| 29 | +task('deploy:info', function() { |
|
| 30 | 30 | $releaseName = test('[ -d {{deploy_path}}/.dep ]') ? get('release_name') : 1; |
| 31 | 31 | |
| 32 | 32 | info("deploying <fg=green;options=bold>{{what}}</> to <fg=magenta;options=bold>{{where}}</> (release <fg=magenta;options=bold>{$releaseName}</>)"); |