1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PWWEB\Artomator\Commands; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Command; |
6
|
|
|
use InfyOm\Generator\Generators\API\APIControllerGenerator; |
7
|
|
|
use InfyOm\Generator\Generators\API\APIRequestGenerator; |
8
|
|
|
use InfyOm\Generator\Generators\API\APIRoutesGenerator; |
9
|
|
|
use InfyOm\Generator\Generators\API\APITestGenerator; |
10
|
|
|
use InfyOm\Generator\Generators\MigrationGenerator; |
11
|
|
|
use InfyOm\Generator\Generators\ModelGenerator; |
12
|
|
|
use InfyOm\Generator\Generators\RepositoryGenerator; |
13
|
|
|
use InfyOm\Generator\Generators\RepositoryTestGenerator; |
14
|
|
|
use InfyOm\Generator\Generators\Scaffold\ControllerGenerator; |
15
|
|
|
use InfyOm\Generator\Generators\Scaffold\MenuGenerator; |
16
|
|
|
use InfyOm\Generator\Generators\Scaffold\RequestGenerator; |
17
|
|
|
use InfyOm\Generator\Generators\Scaffold\RoutesGenerator; |
18
|
|
|
use InfyOm\Generator\Generators\Scaffold\ViewGenerator; |
19
|
|
|
use PWWEB\Artomator\Common\CommandData; |
20
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
21
|
|
|
use Symfony\Component\Console\Input\InputOption; |
22
|
|
|
|
23
|
|
|
class RollbackGeneratorCommand extends Command |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* The command Data. |
27
|
|
|
* |
28
|
|
|
* @var CommandData |
29
|
|
|
*/ |
30
|
|
|
public $commandData; |
31
|
|
|
/** |
32
|
|
|
* The console command name. |
33
|
|
|
* |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $name = 'artomator:rollback'; |
37
|
|
|
/** |
38
|
|
|
* The console command description. |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $description = 'Rollback a full CRUD API and Scaffold for given model'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var Composer |
|
|
|
|
46
|
|
|
*/ |
47
|
|
|
public $composer; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Create a new command instance. |
51
|
|
|
*/ |
52
|
|
|
public function __construct() |
53
|
|
|
{ |
54
|
|
|
parent::__construct(); |
55
|
|
|
|
56
|
|
|
$this->composer = app()['composer']; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Execute the command. |
61
|
|
|
* |
62
|
|
|
* @return void |
63
|
|
|
*/ |
64
|
|
|
public function handle() |
65
|
|
|
{ |
66
|
|
|
if (! in_array($this->argument('type'), [ |
67
|
|
|
CommandData::$COMMAND_TYPE_API, |
68
|
|
|
CommandData::$COMMAND_TYPE_SCAFFOLD, |
69
|
|
|
CommandData::$COMMAND_TYPE_API_SCAFFOLD, |
70
|
|
|
CommandData::$COMMAND_TYPE_GRAPHQL, |
71
|
|
|
])) { |
72
|
|
|
$this->error('invalid rollback type'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$this->commandData = new CommandData($this, $this->argument('type')); |
|
|
|
|
76
|
|
|
$this->commandData->config->mName = $this->commandData->modelName = $this->argument('model'); |
|
|
|
|
77
|
|
|
|
78
|
|
|
$this->commandData->config->init($this->commandData, ['tableName', 'prefix', 'plural', 'views']); |
79
|
|
|
|
80
|
|
|
$views = $this->commandData->getOption('views'); |
81
|
|
|
if (! empty($views)) { |
82
|
|
|
$views = explode(',', $views); |
83
|
|
|
$viewGenerator = new ViewGenerator($this->commandData); |
84
|
|
|
$viewGenerator->rollback($views); |
85
|
|
|
|
86
|
|
|
$this->info('Generating autoload files'); |
87
|
|
|
$this->composer->dumpOptimized(); |
88
|
|
|
|
89
|
|
|
return; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$migrationGenerator = new MigrationGenerator($this->commandData); |
93
|
|
|
$migrationGenerator->rollback(); |
94
|
|
|
|
95
|
|
|
$modelGenerator = new ModelGenerator($this->commandData); |
96
|
|
|
$modelGenerator->rollback(); |
97
|
|
|
|
98
|
|
|
$repositoryGenerator = new RepositoryGenerator($this->commandData); |
99
|
|
|
$repositoryGenerator->rollback(); |
100
|
|
|
|
101
|
|
|
$requestGenerator = new APIRequestGenerator($this->commandData); |
102
|
|
|
$requestGenerator->rollback(); |
103
|
|
|
|
104
|
|
|
$controllerGenerator = new APIControllerGenerator($this->commandData); |
105
|
|
|
$controllerGenerator->rollback(); |
106
|
|
|
|
107
|
|
|
$routesGenerator = new APIRoutesGenerator($this->commandData); |
108
|
|
|
$routesGenerator->rollback(); |
109
|
|
|
|
110
|
|
|
$requestGenerator = new RequestGenerator($this->commandData); |
111
|
|
|
$requestGenerator->rollback(); |
112
|
|
|
|
113
|
|
|
$controllerGenerator = new ControllerGenerator($this->commandData); |
114
|
|
|
$controllerGenerator->rollback(); |
115
|
|
|
|
116
|
|
|
$viewGenerator = new ViewGenerator($this->commandData); |
117
|
|
|
$viewGenerator->rollback(); |
118
|
|
|
|
119
|
|
|
$routeGenerator = new RoutesGenerator($this->commandData); |
120
|
|
|
$routeGenerator->rollback(); |
121
|
|
|
|
122
|
|
|
if ($this->commandData->getAddOn('tests')) { |
123
|
|
|
$repositoryTestGenerator = new RepositoryTestGenerator($this->commandData); |
124
|
|
|
$repositoryTestGenerator->rollback(); |
125
|
|
|
|
126
|
|
|
$apiTestGenerator = new APITestGenerator($this->commandData); |
127
|
|
|
$apiTestGenerator->rollback(); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
if ($this->commandData->config->getAddOn('menu.enabled')) { |
131
|
|
|
$menuGenerator = new MenuGenerator($this->commandData); |
132
|
|
|
$menuGenerator->rollback(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
// TODO: Add rollback for the graphql files too. |
136
|
|
|
|
137
|
|
|
$this->info('Generating autoload files'); |
138
|
|
|
$this->composer->dumpOptimized(); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Get the console command options. |
143
|
|
|
* |
144
|
|
|
* @return array |
145
|
|
|
*/ |
146
|
|
|
public function getOptions() |
147
|
|
|
{ |
148
|
|
|
return [ |
149
|
|
|
['tableName', null, InputOption::VALUE_REQUIRED, 'Table Name'], |
150
|
|
|
['prefix', null, InputOption::VALUE_REQUIRED, 'Prefix for all files'], |
151
|
|
|
['plural', null, InputOption::VALUE_REQUIRED, 'Plural Model name'], |
152
|
|
|
['views', null, InputOption::VALUE_REQUIRED, 'Views to rollback'], |
153
|
|
|
]; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Get the console command arguments. |
158
|
|
|
* |
159
|
|
|
* @return array |
160
|
|
|
*/ |
161
|
|
|
protected function getArguments() |
162
|
|
|
{ |
163
|
|
|
return [ |
164
|
|
|
['model', InputArgument::REQUIRED, 'Singular Model name'], |
165
|
|
|
['type', InputArgument::REQUIRED, 'Rollback type: (api / scaffold / api_scaffold)'], |
166
|
|
|
]; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|
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