Skip to content

Commit be2939c

Browse files
committed
AC-3208: Fixed return types for deploy command
1 parent 0c1987b commit be2939c

File tree

4 files changed

+24
-72
lines changed

4 files changed

+24
-72
lines changed

n98-magerun.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/MagentoHackathon/Composer/Magento/Command/DeployCommand.php

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@
66

77
namespace MagentoHackathon\Composer\Magento\Command;
88

9+
use Composer\Command\BaseCommand;
910
use MagentoHackathon\Composer\Magento\Deploy\Manager\Entry;
1011
use MagentoHackathon\Composer\Magento\DeployManager;
12+
use MagentoHackathon\Composer\Magento\Installer;
1113
use Symfony\Component\Console\Input\InputInterface;
12-
use Symfony\Component\Console\Input\InputOption;
1314
use 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
3337
This command deploys all magento Modules
3438
3539
EOT
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
}

src/MagentoHackathon/Composer/Magento/Plugin.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ protected function deployLibraries()
215215
}
216216
return;
217217
}
218-
219-
220218
$vendorDir = rtrim($this->composer->getConfig()->get('vendor-dir'), '/');
221219

222220
$filesystem = $this->filesystem;
@@ -255,7 +253,8 @@ protected function deployLibraries()
255253
if ($this->io->isDebug()) {
256254
$this->io->write('Magento deployLibraries executes autoload generator');
257255
}
258-
$process = new Process($executable . " -o {$libraryPath}/autoload.php " . implode(' ', $autoloadDirectories));
256+
$command = $executable . " -o {$libraryPath}/autoload.php " . implode(' ', $autoloadDirectories);
257+
$process = method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process($command);
259258
$process->run();
260259
} else {
261260
if ($this->io->isDebug()) {
@@ -264,8 +263,6 @@ protected function deployLibraries()
264263

265264
}
266265
}
267-
268-
269266
}
270267

271268

src/MagentoHackathon/Composer/Magerun/DeployCommand.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)