@@ -13,13 +13,13 @@ |
||
13 | 13 | |
14 | 14 | namespace Deployer; |
15 | 15 | |
16 | -set('bin/yarn', function () { |
|
16 | +set('bin/yarn', function() { |
|
17 | 17 | return which('yarn'); |
18 | 18 | }); |
19 | 19 | |
20 | 20 | // In there is a {{previous_release}}, node_modules will be copied from it before installing deps with yarn. |
21 | 21 | desc('Installs Yarn packages'); |
22 | -task('yarn:install', function () { |
|
22 | +task('yarn:install', function() { |
|
23 | 23 | if (has('previous_release')) { |
24 | 24 | if (test('[ -d {{previous_release}}/node_modules ]')) { |
25 | 25 | run('cp -R {{previous_release}}/node_modules {{release_path}}'); |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | use Deployer\Utility\Httpie; |
62 | 62 | |
63 | 63 | // Title of project based on git repo |
64 | -set('cimonitor_title', function () { |
|
64 | +set('cimonitor_title', function() { |
|
65 | 65 | $repo = get('repository'); |
66 | 66 | $pattern = '/\w+\/\w+/'; |
67 | 67 | return preg_match($pattern, $repo, $titles) ? $titles[0] : $repo; |
68 | 68 | }); |
69 | -set('cimonitor_user', function () { |
|
69 | +set('cimonitor_user', function() { |
|
70 | 70 | return [ |
71 | 71 | 'name' => runLocally('git config --get user.name'), |
72 | 72 | 'email' => runLocally('git config --get user.email'), |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | set('cimonitor_job_state_success', get('cimonitor_status_success')); |
87 | 87 | |
88 | 88 | desc('Notifies CIMonitor'); |
89 | -task('cimonitor:notify', function () { |
|
89 | +task('cimonitor:notify', function() { |
|
90 | 90 | if (!get('cimonitor_webhook', false)) { |
91 | 91 | return; |
92 | 92 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ->hidden(); |
113 | 113 | |
114 | 114 | desc('Notifies CIMonitor about deploy finish'); |
115 | -task('cimonitor:notify:success', function () { |
|
115 | +task('cimonitor:notify:success', function() { |
|
116 | 116 | if (!get('cimonitor_webhook', false)) { |
117 | 117 | return; |
118 | 118 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ->hidden(); |
141 | 141 | |
142 | 142 | desc('Notifies CIMonitor about deploy failure'); |
143 | -task('cimonitor:notify:failure', function () { |
|
143 | +task('cimonitor:notify:failure', function() { |
|
144 | 144 | if (!get('cimonitor_webhook', false)) { |
145 | 145 | return; |
146 | 146 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | desc('Creates database though CPanel API'); |
196 | -task('cpanel:createdb', function () { |
|
196 | +task('cpanel:createdb', function() { |
|
197 | 197 | |
198 | 198 | $cpanel = getCPanel(); |
199 | 199 | $config = get('cpanel', []); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | }); |
222 | 222 | |
223 | 223 | desc('Creates addon domain though CPanel API'); |
224 | -task('cpanel:createaddondomain', function () { |
|
224 | +task('cpanel:createaddondomain', function() { |
|
225 | 225 | $cpanel = getCPanel(); |
226 | 226 | $config = get('cpanel', []); |
227 | 227 | $domain = getDomainInfo()['domain']; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | }); |
245 | 245 | |
246 | 246 | desc('Deletes addon domain though CPanel API'); |
247 | -task('cpanel:deleteaddondomain', function () { |
|
247 | +task('cpanel:deleteaddondomain', function() { |
|
248 | 248 | $cpanel = getCPanel(); |
249 | 249 | $config = get('cpanel', []); |
250 | 250 | $domain = getDomainInfo()['domain']; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | desc('Notifies Sentry of deployment'); |
66 | 66 | task( |
67 | 67 | 'deploy:sentry', |
68 | - static function () { |
|
68 | + static function() { |
|
69 | 69 | $now = date('c'); |
70 | 70 | |
71 | 71 | $defaultConfig = [ |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $config = array_merge($defaultConfig, (array) get('sentry')); |
88 | 88 | array_walk( |
89 | 89 | $config, |
90 | - static function (&$value) use ($config) { |
|
90 | + static function(&$value) use ($config) { |
|
91 | 91 | if (is_callable($value)) { |
92 | 92 | $value = $value($config); |
93 | 93 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | function getReleaseGitRef(): Closure |
224 | 224 | { |
225 | - return static function ($config = []): string { |
|
225 | + return static function($config = []): string { |
|
226 | 226 | if (get('update_code_strategy') === 'archive') { |
227 | 227 | if (isset($config['git_version_command'])) { |
228 | 228 | cd('{{deploy_path}}/.dep/repo'); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | function getGitCommitsRefs(): Closure |
247 | 247 | { |
248 | - return static function ($config = []): array { |
|
248 | + return static function($config = []): array { |
|
249 | 249 | $previousReleaseRevision = getPreviousReleaseRevision(); |
250 | 250 | $currentReleaseRevision = getCurrentReleaseRevision() ?: 'HEAD'; |
251 | 251 | |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | $lines = array_filter( |
267 | 267 | // limit number of commits for first release with many commits |
268 | 268 | array_map('trim', array_slice(explode("\n", $result), 0, 200)), |
269 | - static function (string $line): bool { |
|
269 | + static function(string $line): bool { |
|
270 | 270 | return !empty($line) && strpos($line, 'commit') !== 0; |
271 | 271 | }, |
272 | 272 | ); |
273 | 273 | |
274 | 274 | return array_map( |
275 | - static function (string $line): array { |
|
275 | + static function(string $line): array { |
|
276 | 276 | [$ref, $authorName, $authorEmail, $timestamp, $message] = explode('#', $line, 5); |
277 | 277 | |
278 | 278 | return [ |
@@ -35,7 +35,7 @@ |
||
35 | 35 | use Deployer\Utility\Httpie; |
36 | 36 | |
37 | 37 | desc('Creates Grafana annotation of deployment'); |
38 | -task('grafana:annotation', function () { |
|
38 | +task('grafana:annotation', function() { |
|
39 | 39 | $defaultConfig = [ |
40 | 40 | 'url' => null, |
41 | 41 | 'token' => null, |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | namespace Deployer; |
22 | 22 | |
23 | 23 | desc('Clears Cloudflare Cache'); |
24 | -task('deploy:cloudflare', function () { |
|
24 | +task('deploy:cloudflare', function() { |
|
25 | 25 | |
26 | 26 | $config = get('cloudflare', []); |
27 | 27 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $headers['Content-Type'] = 'application/json'; |
47 | 47 | |
48 | - $makeRequest = function ($url, $opts = []) use ($headers) { |
|
48 | + $makeRequest = function($url, $opts = []) use ($headers) { |
|
49 | 49 | $ch = curl_init("https://api.cloudflare.com/client/v4/$url"); |
50 | 50 | |
51 | 51 | $parsedHeaders = []; |
@@ -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 | }); |
@@ -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', []), |
@@ -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 | } |