66
77namespace MagentoHackathon \Composer \Magento \Command ;
88
9+ use Composer \Command \BaseCommand ;
910use MagentoHackathon \Composer \Magento \Deploy \Manager \Entry ;
1011use MagentoHackathon \Composer \Magento \DeployManager ;
12+ use MagentoHackathon \Composer \Magento \Installer ;
1113use Symfony \Component \Console \Input \InputInterface ;
12- use Symfony \Component \Console \Input \InputOption ;
1314use Symfony \Component \Console \Output \OutputInterface ;
14- use Composer \Downloader \VcsDownloader ;
15- use MagentoHackathon \Composer \Magento \Installer ;
1615
1716/**
1817 * @author Tiago Ribeiro <[email protected] > 1918 * @author Rui Marinho <[email protected] > 2019 */
21- class DeployCommand extends \ Composer \ Command \ BaseCommand
20+ class DeployCommand extends BaseCommand
2221{
22+ private const SUCCESS_EXIT_CODE = 0 ;
23+
24+ /**
25+ * @inheritdoc
26+ */
2327 protected function configure ()
2428 {
2529 $ this
@@ -28,70 +32,56 @@ protected function configure()
2832 ->setDefinition ([
2933 // we dont need to define verbose, because composer already defined it internal
3034 //new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
31- ])
35+ ])
3236 ->setHelp (<<<EOT
3337This command deploys all magento Modules
3438
3539EOT
36- )
37- ;
40+ );
3841 }
3942
43+ /**
44+ * @inheritdoc
45+ */
4046 protected function execute (InputInterface $ input , OutputInterface $ output )
4147 {
4248 // init repos
4349 $ composer = $ this ->getComposer ();
4450 $ installedRepo = $ composer ->getRepositoryManager ()->getLocalRepository ();
45-
46- $ dm = $ composer ->getDownloadManager ();
4751 $ im = $ composer ->getInstallationManager ();
4852
49- /**
50- * @var $moduleInstaller \MagentoHackathon\Composer\Magento\Installer
51- */
53+ /** @var $moduleInstaller Installer */
5254 $ moduleInstaller = $ im ->getInstaller ("magento-module " );
53-
54-
55- $ deployManager = new DeployManager ( $ this ->getIO () );
56-
57- $ extra = $ composer ->getPackage ()->getExtra ();
58- $ sortPriority = $ extra ['magento-deploy-sort-priority ' ] ?? [];
55+ $ deployManager = new DeployManager ($ this ->getIO ());
56+ $ extra = $ composer ->getPackage ()->getExtra ();
57+ $ sortPriority = $ extra ['magento-deploy-sort-priority ' ] ?? [];
5958 $ deployManager ->setSortPriority ( $ sortPriority );
60-
61-
62-
6359 $ moduleInstaller ->setDeployManager ( $ deployManager );
64-
6560
6661 foreach ($ installedRepo ->getPackages () as $ package ) {
67-
6862 if ($ input ->getOption ('verbose ' )) {
69- $ output ->writeln ( $ package ->getName () );
70- $ output ->writeln ( $ package ->getType () );
63+ $ output ->writeln ($ package ->getName ());
64+ $ output ->writeln ($ package ->getType ());
7165 }
72-
73- if ( $ package ->getType () != "magento-module " ){
66+ if ($ package ->getType () != "magento-module " ){
7467 continue ;
7568 }
7669 if ($ input ->getOption ('verbose ' )) {
7770 $ output ->writeln ("package {$ package ->getName ()} recognized " );
7871 }
79-
8072 $ strategy = $ moduleInstaller ->getDeployStrategy ($ package );
73+
8174 if ($ input ->getOption ('verbose ' )) {
8275 $ output ->writeln ("used " . get_class ($ strategy ) . " as deploy strategy " );
8376 }
8477 $ strategy ->setMappings ($ moduleInstaller ->getParser ($ package )->getMappings ());
85-
8678 $ deployManagerEntry = new Entry ();
8779 $ deployManagerEntry ->setPackageName ($ package ->getName ());
8880 $ deployManagerEntry ->setDeployStrategy ($ strategy );
8981 $ deployManager ->addPackage ($ deployManagerEntry );
90-
9182 }
92-
9383 $ deployManager ->doDeploy ();
9484
95- return ;
85+ return self :: SUCCESS_EXIT_CODE ;
9686 }
9787}
0 commit comments