1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of `Composer as a service`. |
5
|
|
|
* |
6
|
|
|
* (c) Pascal Borreli <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ayaline\Bundle\ComposerBundle\Consumer\Step; |
13
|
|
|
|
14
|
|
|
use Sonata\NotificationBundle\Consumer\ConsumerEvent; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Hubert Moutot <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class ComposerUpdateStep extends AbstractStep |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
*/ |
24
|
|
|
public function execute(ConsumerEvent $event, $directory) |
25
|
|
|
{ |
26
|
|
|
$this->triggerNewStep($event, ['message' => './composer update']); |
27
|
|
|
|
28
|
|
|
$output = null; |
29
|
|
|
$workingDirectory = $this->workingTempPath.'/'.$directory; |
30
|
|
|
|
31
|
|
|
$hasDevDeps = $event->getMessage()->getValue('hasDevDependencies'); |
32
|
|
|
$requireDevOption = true === $hasDevDeps ? '--dev' : '--no-dev'; |
33
|
|
|
|
34
|
|
|
$commandLine = sprintf('%s update %s', $this->composerBinPath, $requireDevOption); |
35
|
|
|
$commandLine .= ' --no-interaction --no-autoloader --no-scripts --prefer-dist --no-progress --no-plugins --ignore-platform-reqs --no-custom-installers'; |
36
|
|
|
|
37
|
|
|
$process = $this->runProcess($commandLine, $workingDirectory, $output); |
38
|
|
|
|
39
|
|
|
if (!$process->isSuccessful()) { |
40
|
|
|
$this->triggerError($event, ['message' => nl2br($output)]); |
41
|
|
|
$this->triggerStepError($event, ['message' => 'Composer failed']); |
42
|
|
|
|
43
|
|
|
return 1; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
if (!is_dir($this->workingTempPath.'/'.$directory.'/vendor') |
47
|
|
|
|| !is_file($this->workingTempPath.'/'.$directory.'/composer.lock')) { |
48
|
|
|
$this->triggerStepError($event, ['message' => 'Fatal error during composer update']); |
49
|
|
|
|
50
|
|
|
return 1; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$this->triggerComposerOutput($event, ['message' => $process->getOutput()]); |
54
|
|
|
|
55
|
|
|
return 0; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|