@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | namespace Deployer; |
26 | 26 | |
27 | 27 | // Get path to bin |
28 | -set('bin/crontab', function () { |
|
28 | +set('bin/crontab', function() { |
|
29 | 29 | return which('crontab'); |
30 | 30 | }); |
31 | 31 | |
32 | 32 | // Set the identifier used in the crontab, application name by default |
33 | -set('crontab:identifier', function () { |
|
33 | +set('crontab:identifier', function() { |
|
34 | 34 | return get('application', 'application'); |
35 | 35 | }); |
36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | set('crontab:use_sudo', false); |
39 | 39 | |
40 | 40 | desc('Sync crontab jobs'); |
41 | -task('crontab:sync', function () { |
|
41 | +task('crontab:sync', function() { |
|
42 | 42 | $cronJobsLocal = array_map( |
43 | 43 | fn($job) => parse($job), |
44 | 44 | get('crontab:jobs', []), |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | use Deployer\Utility\Httpie; |
64 | 64 | |
65 | -set('rockchat_title', function () { |
|
65 | +set('rockchat_title', function() { |
|
66 | 66 | return get('application', 'Project'); |
67 | 67 | }); |
68 | 68 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | set('rocketchat_failure_text', 'Deploy to *{{target}}* failed'); |
84 | 84 | |
85 | 85 | desc('Notifies RocketChat'); |
86 | -task('rocketchat:notify', function () { |
|
86 | +task('rocketchat:notify', function() { |
|
87 | 87 | if (null === get('rocketchat_webhook')) { |
88 | 88 | return; |
89 | 89 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | }); |
114 | 114 | |
115 | 115 | desc('Notifies RocketChat about deploy finish'); |
116 | -task('rocketchat:notify:success', function () { |
|
116 | +task('rocketchat:notify:success', function() { |
|
117 | 117 | if (null === get('rocketchat_webhook')) { |
118 | 118 | return; |
119 | 119 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | }); |
144 | 144 | |
145 | 145 | desc('Notifies RocketChat about deploy failure'); |
146 | -task('rocketchat:notify:failure', function () { |
|
146 | +task('rocketchat:notify:failure', function() { |
|
147 | 147 | if (null === get('rocketchat_webhook')) { |
148 | 148 | return; |
149 | 149 | } |
@@ -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 | } |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | */ |
59 | 59 | set('cachetool_url', 'https://github.com/gordalina/cachetool/releases/download/9.0.0/cachetool.phar'); |
60 | 60 | set('cachetool_args', ''); |
61 | -set('bin/cachetool', function () { |
|
61 | +set('bin/cachetool', function() { |
|
62 | 62 | if (!test('[ -f {{release_or_current_path}}/cachetool.phar ]')) { |
63 | 63 | run("cd {{release_or_current_path}} && curl -sLO {{cachetool_url}}"); |
64 | 64 | } |
65 | 65 | return '{{release_or_current_path}}/cachetool.phar'; |
66 | 66 | }); |
67 | -set('cachetool_options', function () { |
|
67 | +set('cachetool_options', function() { |
|
68 | 68 | $options = (array) get('cachetool'); |
69 | 69 | $fullOptions = (string) get('cachetool_args'); |
70 | 70 | $return = []; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * Clear opcache cache |
87 | 87 | */ |
88 | 88 | desc('Clears OPcode cache'); |
89 | -task('cachetool:clear:opcache', function () { |
|
89 | +task('cachetool:clear:opcache', function() { |
|
90 | 90 | $options = get('cachetool_options'); |
91 | 91 | foreach ($options as $option) { |
92 | 92 | run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} opcache:reset $option"); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * Clear APCu cache |
98 | 98 | */ |
99 | 99 | desc('Clears APCu system cache'); |
100 | -task('cachetool:clear:apcu', function () { |
|
100 | +task('cachetool:clear:apcu', function() { |
|
101 | 101 | $options = get('cachetool_options'); |
102 | 102 | foreach ($options as $option) { |
103 | 103 | run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} apcu:cache:clear $option"); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * Clear file status cache, including the realpath cache |
109 | 109 | */ |
110 | 110 | desc('Clears file status and realpath caches'); |
111 | -task('cachetool:clear:stat', function () { |
|
111 | +task('cachetool:clear:stat', function() { |
|
112 | 112 | $options = get('cachetool_options'); |
113 | 113 | foreach ($options as $option) { |
114 | 114 | run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} stat:clear $option"); |
@@ -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() |
@@ -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 | $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')]); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | set('nodejs_version', 'node_23.x'); |
7 | 7 | |
8 | 8 | desc('Installs npm packages'); |
9 | -task('provision:npm', function () { |
|
9 | +task('provision:npm', function() { |
|
10 | 10 | run('npm install -g fx zx pm2'); |
11 | 11 | run('pm2 startup'); |
12 | 12 | }) |