Repository navigation
Expand file tree
/
Copy pathcomposer_update.php
More file actions
54 lines (44 loc) · 1.77 KB
/
Copy pathcomposer_update.php
File metadata and controls
54 lines (44 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
* This file is part of the "deployer-tools" Composer package.
*
* (c) Konrad Michalik <km@move-elevator.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Deployer;
task('dev:release:composer_update_app', static function () {
if (!checkStepIsEnabled('dev:release:composer_update_app')) {
return;
}
composerUpdate();
})->desc('Update composer dependencies for app');
task('dev:release:composer_update_ci', static function () {
if (!checkStepIsEnabled('dev:release:composer_update_ci')) {
return;
}
composerUpdate('ci');
})->desc('Update composer dependencies for ci');
function composerUpdate(string $mode = 'app'): void
{
info("composer update ($mode)");
runLocally('composer update --working-dir '.get("composer_path_$mode").' >> _tmp.txt 2>&1');
// @ToDo: why is the complete output not be generated by the runLocally command, only getting the last 500 chars, so need to perform this workaround to collection dependency information
$result = runLocally('cat _tmp.txt');
runLocally('rm -f _tmp.txt');
$message = get("dev_git_message_composer_update_$mode")."\n\n";
preg_match_all(get('dev_composer_regex'), $result, $matches);
if (empty($matches[1])) {
info('no composer updates found');
add('dev_empty_tasks', ["dev:release:composer_update_$mode"]);
return;
}
$matches[1] = array_unique($matches[1]);
foreach ($matches[1] as $index => $package) {
$message .= " - $package (".$matches[2][$index].")\n";
}
info($message);
info('commit updates');
commit($message, [get("composer_path_$mode").'/composer.json', get("composer_path_$mode").'/composer.lock']);
}