1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PiouPiou\RibsAdminBundle\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Command\Command; |
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
10
|
|
|
use Symfony\Component\Process\Exception\ProcessFailedException; |
|
|
|
|
11
|
|
|
use Symfony\Component\Process\Process; |
|
|
|
|
12
|
|
|
|
13
|
|
|
class ChangePackageVersionCommand extends Command |
14
|
|
|
{ |
15
|
|
|
protected function configure() |
16
|
|
|
{ |
17
|
|
|
$this |
18
|
|
|
->setName('ribsadmin:change-package-version') |
19
|
|
|
->setDescription('Change a package version') |
20
|
|
|
->addArgument( |
21
|
|
|
'package-name', |
22
|
|
|
InputArgument::REQUIRED, |
23
|
|
|
'Name of composer package to import with version (example : piou/piou/test-bundle:1.0.0)' |
24
|
|
|
) |
25
|
|
|
; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
29
|
|
|
{ |
30
|
|
|
$fs = new Filesystem(); |
31
|
|
|
$cd = ""; |
32
|
|
|
|
33
|
|
|
if (!$fs->exists("composer.json") && $fs->exists("index.php")) { |
34
|
|
|
$cd = "cd .. && "; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
$package_name = $input->getArgument('package-name'); |
38
|
|
|
|
39
|
|
|
$process = Process::fromShellCommandline("echo Start composer require " . $package_name); |
|
|
|
|
40
|
|
|
$process->run(function ($type, $buffer) { |
41
|
|
|
echo $buffer; |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
$process = Process::fromShellCommandline($cd . "chmod 777 composer.json"); |
45
|
|
|
$process->run(function ($type, $buffer) { |
46
|
|
|
echo $buffer; |
47
|
|
|
}); |
48
|
|
|
|
49
|
|
|
$process = Process::fromShellCommandline($cd . "composer require " . $package_name); |
50
|
|
|
$process->run(function ($type, $buffer) { |
51
|
|
|
echo $buffer; |
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
if (!$process->isSuccessful()) { |
55
|
|
|
throw new ProcessFailedException($process); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$process = Process::fromShellCommandline($cd . "chmod 644 composer.json"); |
59
|
|
|
$process->run(function ($type, $buffer) { |
60
|
|
|
echo $buffer; |
61
|
|
|
}); |
62
|
|
|
|
63
|
|
|
$process = Process::fromShellCommandline("echo Change version of " . $package_name . " is finished."); |
64
|
|
|
$process->run(function ($type, $buffer) { |
65
|
|
|
echo $buffer; |
66
|
|
|
}); |
67
|
|
|
|
68
|
|
|
return 0; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths