1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace PhpTaskman\Core; |
6
|
|
|
|
7
|
|
|
use Composer\Autoload\ClassLoader; |
8
|
|
|
use League\Container\Container; |
9
|
|
|
use League\Container\ContainerInterface; |
10
|
|
|
use PhpTaskman\Core\Services\Composer; |
|
|
|
|
11
|
|
|
use Robo\Application; |
12
|
|
|
use Robo\Config\Config; |
13
|
|
|
use Robo\Robo; |
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
15
|
|
|
use Symfony\Component\Console\Input\InputOption; |
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class Taskman. |
20
|
|
|
*/ |
21
|
|
|
final class Taskman |
22
|
|
|
{ |
23
|
|
|
public const APPLICATION_NAME = 'Taskman'; |
24
|
|
|
public const VERSION = 'dev-master'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Create default configuration. |
28
|
|
|
* |
29
|
|
|
* @param null|mixed $workingDir |
30
|
|
|
* @param mixed $paths |
31
|
|
|
* |
32
|
|
|
* @return Config |
33
|
|
|
*/ |
34
|
3 |
|
public static function createConfiguration($paths, $workingDir = null) |
35
|
|
|
{ |
36
|
3 |
|
$workingDir = $workingDir ?? \getcwd(); |
37
|
|
|
|
38
|
|
|
// Create a default configuration. |
39
|
3 |
|
$config = Robo::createConfiguration($paths); |
40
|
|
|
|
41
|
|
|
// Set the variable working_dir. |
42
|
3 |
|
if (false === $workingDir = \realpath($workingDir)) { |
43
|
1 |
|
return $config; |
44
|
|
|
} |
45
|
|
|
|
46
|
3 |
|
$config->set('taskman.working_dir', \realpath($workingDir)); |
47
|
|
|
|
48
|
|
|
// Load the configuration. |
49
|
3 |
|
Robo::loadConfiguration( |
50
|
3 |
|
\PhpTaskman\Core\Config\Config::findFilesToIncludeInConfiguration($workingDir), |
51
|
|
|
$config |
52
|
|
|
); |
53
|
|
|
|
54
|
3 |
|
return $config; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Create and configure container. |
59
|
|
|
* |
60
|
|
|
* @param InputInterface $input |
61
|
|
|
* @param OutputInterface $output |
62
|
|
|
* @param Application $application |
63
|
|
|
* @param Config $config |
64
|
|
|
* @param ClassLoader $classLoader |
65
|
|
|
* |
66
|
|
|
* @return Container|\League\Container\ContainerInterface |
67
|
|
|
*/ |
68
|
2 |
|
public static function createContainer( |
69
|
|
|
InputInterface $input, |
70
|
|
|
OutputInterface $output, |
71
|
|
|
Application $application, |
72
|
|
|
Config $config, |
73
|
|
|
ClassLoader $classLoader |
74
|
|
|
) { |
75
|
2 |
|
$container = Robo::createDefaultContainer($input, $output, $application, $config, $classLoader); |
76
|
2 |
|
$container->get('commandFactory')->setIncludeAllPublicMethods(false); |
77
|
|
|
|
78
|
2 |
|
return $container; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param null|string $appName |
83
|
|
|
* @param null|string $appVersion |
84
|
|
|
* @param null|string $workingDir |
85
|
|
|
* |
86
|
|
|
* @return Application |
87
|
|
|
*/ |
88
|
2 |
|
public static function createDefaultApplication($appName = null, $appVersion = null, $workingDir = null) |
89
|
|
|
{ |
90
|
2 |
|
$workingDir = $workingDir ?? \getcwd(); |
91
|
2 |
|
$appName = $appName ?? self::APPLICATION_NAME; |
92
|
2 |
|
$appVersion = $appVersion ?? self::VERSION; |
93
|
|
|
|
94
|
2 |
|
$app = Robo::createDefaultApplication($appName, $appVersion); |
95
|
|
|
|
96
|
|
|
$app |
97
|
2 |
|
->getDefinition() |
98
|
2 |
|
->addOption( |
99
|
2 |
|
new InputOption( |
100
|
2 |
|
'--working-dir', |
101
|
2 |
|
null, |
102
|
2 |
|
InputOption::VALUE_REQUIRED, |
103
|
2 |
|
'Working directory, defaults to current working directory.', |
104
|
2 |
|
\realpath($workingDir) |
105
|
|
|
) |
106
|
|
|
); |
107
|
|
|
|
108
|
2 |
|
$app->setAutoExit(false); |
109
|
|
|
|
110
|
2 |
|
return $app; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param ContainerInterface $container |
115
|
|
|
* |
116
|
|
|
* @return \Robo\Runner |
117
|
|
|
*/ |
118
|
1 |
|
public static function createDefaultRunner(ContainerInterface $container) |
119
|
|
|
{ |
120
|
1 |
|
return (new \Robo\Runner()) |
121
|
1 |
|
->setRelativePluginNamespace('Robo\Plugin') |
122
|
1 |
|
->setContainer($container); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param string $path |
127
|
|
|
* The directory |
128
|
|
|
* |
129
|
|
|
* @return \Robo\Config\Config |
130
|
|
|
* The composer object. |
131
|
|
|
*/ |
132
|
3 |
|
public static function getComposerFromDirectory($path) |
133
|
|
|
{ |
134
|
3 |
|
$composerFile = \realpath($path . '/composer.json'); |
135
|
|
|
|
136
|
3 |
|
if (false === $composerFile) { |
137
|
|
|
return false; |
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
140
|
3 |
|
$content = \json_decode(\file_get_contents($composerFile), true); |
141
|
|
|
|
142
|
3 |
|
return new Config($content); |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
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