1 | <?php |
||
12 | final class Builder |
||
13 | { |
||
14 | const DOCKER = 'spiralscout/rr-build'; |
||
15 | |||
16 | /** |
||
17 | * Coloring. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected static $colors = [ |
||
22 | "reset" => "\e[0m", |
||
23 | "white" => "\033[1;38m", |
||
24 | "red" => "\033[0;31m", |
||
25 | "green" => "\033[0;32m", |
||
26 | "yellow" => "\033[1;93m", |
||
27 | "gray" => "\033[0;90m" |
||
28 | ]; |
||
29 | |||
30 | /** @var array */ |
||
31 | private $config; |
||
32 | |||
33 | /** |
||
34 | * @param array $config |
||
35 | */ |
||
36 | protected function __construct(array $config) |
||
40 | |||
41 | /** |
||
42 | * Validate the build configuration. |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | public function configErrors(): array |
||
63 | |||
64 | /** |
||
65 | * Build the application. |
||
66 | * |
||
67 | * @param string $directory |
||
68 | * @param string $template |
||
69 | * @param string $output |
||
70 | * @param string $version |
||
71 | */ |
||
72 | public function build(string $directory, string $template, string $output, string $version) |
||
102 | |||
103 | /** |
||
104 | * @param string $command |
||
105 | * @param bool $shadow |
||
106 | */ |
||
107 | protected function run(string $command, bool $shadow = false) |
||
113 | |||
114 | /** |
||
115 | * @param string $template |
||
116 | * @param string $filename |
||
117 | */ |
||
118 | protected function generate(string $template, string $filename) |
||
132 | |||
133 | /** |
||
134 | * @return string |
||
135 | */ |
||
136 | protected function getOS(): string |
||
150 | |||
151 | /** |
||
152 | * Create new builder using given config. |
||
153 | * |
||
154 | * @param string $config |
||
155 | * @return Builder|null |
||
156 | */ |
||
157 | public static function loadConfig(string $config): ?Builder |
||
170 | |||
171 | /** |
||
172 | * Make colored output. |
||
173 | * |
||
174 | * @param string $format |
||
175 | * @param mixed ...$args |
||
176 | */ |
||
177 | public static function cprintf(string $format, ...$args) |
||
189 | |||
190 | /** |
||
191 | * @return bool |
||
192 | */ |
||
193 | public static function isWindows(): bool |
||
197 | |||
198 | /** |
||
199 | * Returns true if the STDOUT supports colorization. |
||
200 | * |
||
201 | * @codeCoverageIgnore |
||
202 | * @link https://github.com/symfony/Console/blob/master/Output/StreamOutput.php#L94 |
||
203 | * @param mixed $stream |
||
204 | * @return bool |
||
205 | */ |
||
206 | public static function isColorsSupported($stream = STDOUT): bool |
||
237 | } |