File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace AppBundle \Command ;
4+
5+ use AppBundle \Entity \Repository \ProjectRepository ;
6+ use AppBundle \ProjectImport \ImportProjectTask ;
7+ use Symfony \Component \Console \Command \Command ;
8+ use Symfony \Component \Console \Input \InputArgument ;
9+ use Symfony \Component \Console \Input \InputInterface ;
10+ use Symfony \Component \Console \Output \OutputInterface ;
11+
12+ class ReimportAllProjectsCommand extends Command
13+ {
14+
15+ public function __construct (
16+ private readonly ImportProjectTask $ importProjectTask ,
17+ private readonly ProjectRepository $ projectRepository ,
18+ )
19+ {
20+ parent ::__construct ();
21+ }
22+
23+ protected function configure ()
24+ {
25+ $ this
26+ ->setName ('app:reimport-all-projects ' )
27+ ->setDescription ('Re-Imports all projects that have already been imported and updates metadata and relevant composer dependency information. ' );
28+ }
29+
30+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
31+ {
32+ $ errorCode = 0 ;
33+
34+ $ projects = $ this ->projectRepository ->findAll ();
35+
36+ foreach ($ projects as $ project ) {
37+ $ importSuccess = $ this ->importProjectTask ->run ($ project ->getVcsUrl ());
38+
39+ if ($ importSuccess ) {
40+ $ output ->writeln ('Successfully re-imported ' .$ project ->getVcsUrl ());
41+ } else {
42+ $ output ->writeln ('Re-import failed for ' .$ project ->getVcsUrl ().'. Make sure you have sufficient repository access and that it contains a composer.lock file. See logs for details. ' );
43+ $ errorCode = 1 ;
44+ }
45+ }
46+
47+ return $ errorCode ;
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments