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