Skip to content

Commit 1968838

Browse files
authored
Merge pull request #10 from magento-atwix-pyrrans/AC-3208-symfony-upgrade
[Pyrrans] AC-3208: Fixed return types for deploy command
2 parents 0c1987b + 6da6dd1 commit 1968838

File tree

12 files changed

+32
-81
lines changed

12 files changed

+32
-81
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/Deploystrategy/Symlink.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ public function getRelativePath($from, $to)
141141
}
142142

143143
// magento_dir/targetdir/childdir => ../../module_dir/sourcedir/childdir
144-
$relativePath = str_repeat('../', count($dir)) . implode('/', $file);
145-
return $relativePath;
144+
return str_repeat('../', count($dir) - 1) . implode('/', $file);
146145
}
147146
}

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.

tests/FullStackTest/home/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
}
77
],
88
"require": {
9-
"magento/magento-composer-installer": "*"
9+
"magento/magento-composer-installer": "*",
10+
"magento/magento2-base-mock": "*"
1011
},
1112
"extra": {
1213
"magento-root-dir": "root"

tests/MagentoHackathon/Composer/Magento/FullStack/AbstractTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function setUpBeforeClass(): void
4848
@unlink(self::getBasePath().'/magento-modules/vendor/theseer/directoryscanner/tests/_data/nested/empty');
4949

5050
$process = Process::fromShellCommandline(
51-
self::getComposerCommand().' archive --format=zip --dir="tests/FullStackTest/artifact" -vvv',
51+
'./' . self::getComposerCommand().' archive --format=zip --dir="tests/FullStackTest/artifact" -vvv',
5252
self::getProjectRoot()
5353
);
5454
$process->run();
@@ -118,7 +118,7 @@ protected static function logProcessOutput(Process $process, $name = null){
118118
$name . '_Output.log'
119119
]);
120120
if (!is_dir(dirname($logPath))) {
121-
mkdir(dirname($logPath));
121+
mkdir(dirname($logPath), 0777, true);
122122
}
123123
file_put_contents(
124124
$logPath,
@@ -135,4 +135,4 @@ public function assertProcess(Process $process)
135135
$message .= PHP_EOL.'Output:'.PHP_EOL.$process->getOutput();
136136
$this->assertEquals(0, $process->getExitCode(), $message);
137137
}
138-
}
138+
}

tests/MagentoHackathon/Composer/Magento/FullStack/GlobalPluginTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
class GlobalPluginTest extends AbstractTest
99
{
10-
1110
protected static $processLogCounter = 1;
1211

1312
protected function setUp(): void
@@ -31,7 +30,7 @@ protected function prepareCleanDirectories()
3130
public function testGlobalInstall()
3231
{
3332
$process = Process::fromShellCommandline(
34-
self::getComposerCommand() . ' global install',
33+
'./' . self::getComposerCommand() . ' global install',
3534
self::getProjectRoot(),
3635
['COMPOSER_HOME' => self::getBasePath() . '/home']
3736
);
@@ -43,7 +42,7 @@ public function testGlobalInstall()
4342
public function testGlobalUpdate()
4443
{
4544
$process = Process::fromShellCommandline(
46-
self::getComposerCommand() . ' global update',
45+
'./' . self::getComposerCommand() . ' global update',
4746
self::getProjectRoot(),
4847
['COMPOSER_HOME' => self::getBasePath() . '/home']
4948
);

tests/res/packages/magento2-base/app/code/.gitkeep

Whitespace-only changes.

tests/res/packages/magento2-base/app/design/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)