|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Th3Mouk\OpenAPIGenerator\Command; |
|
6
|
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Command\Command; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
10
|
|
|
use Th3Mouk\OpenAPIGenerator\PathHelper; |
|
11
|
|
|
|
|
12
|
|
|
final class ScaffoldCommand extends Command |
|
13
|
|
|
{ |
|
14
|
|
|
protected function configure(): void |
|
15
|
|
|
{ |
|
16
|
|
|
$this |
|
17
|
|
|
->setName('scaffold') |
|
18
|
|
|
->setDescription('Scaffold all directories'); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
|
22
|
|
|
{ |
|
23
|
|
|
$base_path = getRootPath(); |
|
24
|
|
|
|
|
25
|
|
|
if (!file_exists($base_path . PathHelper::PATHS)) { |
|
26
|
|
|
mkdir($base_path . PathHelper::PATHS); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
if (!file_exists($base_path . PathHelper::COMPONENTS)) { |
|
30
|
|
|
mkdir($base_path . PathHelper::COMPONENTS); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
if (!file_exists($base_path . PathHelper::SCHEMAS)) { |
|
34
|
|
|
mkdir($base_path . PathHelper::SCHEMAS); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if (!file_exists($base_path . PathHelper::RESPONSES)) { |
|
38
|
|
|
mkdir($base_path . PathHelper::RESPONSES); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
if (!file_exists($base_path . PathHelper::PARAMETERS)) { |
|
42
|
|
|
mkdir($base_path . PathHelper::PARAMETERS); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
if (!file_exists($base_path . PathHelper::EXAMPLES)) { |
|
46
|
|
|
mkdir($base_path . PathHelper::EXAMPLES); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
if (!file_exists($base_path . PathHelper::REQUEST_BODIES)) { |
|
50
|
|
|
mkdir($base_path . PathHelper::REQUEST_BODIES); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
if (!file_exists($base_path . PathHelper::HEADERS)) { |
|
54
|
|
|
mkdir($base_path . PathHelper::HEADERS); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if (!file_exists($base_path . PathHelper::SECURITY_SCHEMES)) { |
|
58
|
|
|
mkdir($base_path . PathHelper::SECURITY_SCHEMES); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
if (!file_exists($base_path . PathHelper::LINKS)) { |
|
62
|
|
|
mkdir($base_path . PathHelper::LINKS); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if (!file_exists($base_path . PathHelper::CALLBACKS)) { |
|
66
|
|
|
mkdir($base_path . PathHelper::CALLBACKS); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
echo 'scaffolded' . PHP_EOL; |
|
70
|
|
|
|
|
71
|
|
|
return 0; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|