From 0a0b2dd951fadae1468551cd860de705fe8ca75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Fri, 25 Jan 2019 03:51:39 +0100 Subject: [PATCH 1/6] Improved quality build --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index a207873..e026896 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ composer require prestashop/composer-script-handler --dev In your Shop, you can now declare modules into "prestashop.modules" in the "extras" section of Composer. -Once you do that, on "install" and "update" processes, every module will be installed -so you will always get the most "up to date" version of each module! +Once you do that, on "install" and "update" processes, every module will be installed so you will always get the most "up to date" version of each module! > This project is under MIT license From 1f3e26223b2194d0e84bfdbaa26380a92249652f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Fri, 25 Jan 2019 03:59:41 +0100 Subject: [PATCH 2/6] Added missing Process Manager Interface --- src/Contracts/ProcessManagerInterface.php | 24 +++++++++++++++++++++++ src/ProcessManager/ProcessManager.php | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/src/Contracts/ProcessManagerInterface.php b/src/Contracts/ProcessManagerInterface.php index e69de29..e5b29d0 100644 --- a/src/Contracts/ProcessManagerInterface.php +++ b/src/Contracts/ProcessManagerInterface.php @@ -0,0 +1,24 @@ +maxParallelProcesses = $maxParallelProcesses; } + /** + * {@inheritdoc} + */ public function add($command, $location) { $this->processes[] = (new Process($command)) @@ -44,6 +47,9 @@ public function add($command, $location) ; } + /** + * {@inheritdoc} + */ public function run() { $batchOfProcesses = array_chunk($this->processes, $this->maxParallelProcesses); From 5b6853ffd36daa04277fd3f17fdbb0a5dc2d6ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Fri, 25 Jan 2019 04:09:53 +0100 Subject: [PATCH 3/6] Fixed PHP QA --- src/ProcessManager/ProcessManager.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/ProcessManager/ProcessManager.php b/src/ProcessManager/ProcessManager.php index 0004427..ec432bc 100644 --- a/src/ProcessManager/ProcessManager.php +++ b/src/ProcessManager/ProcessManager.php @@ -26,11 +26,6 @@ final class ProcessManager implements ProcessManagerInterface */ private $processes; - /** - * @var int - */ - private $runningProcesses; - public function __construct($timestamp, $maxParallelProcesses) { $this->timestamp = $timestamp; From 0512d30cb5fec3ac424c0f2bb19a517d12e8bbcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Fri, 25 Jan 2019 04:16:39 +0100 Subject: [PATCH 4/6] Improved maintainability --- tests/Actions/CreateProjectTest.php | 15 +++++++++++---- tests/Actions/UpdateTest.php | 22 ++++++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/Actions/CreateProjectTest.php b/tests/Actions/CreateProjectTest.php index 2694b15..744ca21 100644 --- a/tests/Actions/CreateProjectTest.php +++ b/tests/Actions/CreateProjectTest.php @@ -22,16 +22,23 @@ public function testGetName() $this->assertSame('create-project', $action->getName()); } - public function testGetArguments() + public function testGetArgumentsWithoutArguments() { $actionsWithoutArguments = new CreateProject(); - - $this->assertSame([ + $currentArgs = [ '--no-scripts', '--no-progress', '--no-interaction', - ], $actionsWithoutArguments->getArguments()); + ]; + + $this->assertSame( + $currentArgs, + $actionsWithoutArguments->getArguments() + ); + } + public function testGetArguments() + { $action = new CreateProject(['foo' => 'bar']); $this->assertSame(['foo' => 'bar'], $action->getArguments()); diff --git a/tests/Actions/UpdateTest.php b/tests/Actions/UpdateTest.php index d84b070..ac9fd17 100644 --- a/tests/Actions/UpdateTest.php +++ b/tests/Actions/UpdateTest.php @@ -10,9 +10,12 @@ final class UpdateTest extends TestCase public function testCreation() { $this->assertInstanceOf(Update::class, new Update()); - $this->assertInstanceOf(Update::class, new Update( - ['foo' => 'bar'] - )); + $arguments = ['foo' => 'bar']; + + $this->assertInstanceOf( + Update::class, + new Update($arguments) + ); } public function testGetName() @@ -22,14 +25,21 @@ public function testGetName() $this->assertSame('update', $action->getName()); } - public function testGetArguments() + public function testGetArgumentsWithoutArguments() { $actionsWithoutArguments = new Update(); $this->assertSame([], $actionsWithoutArguments->getArguments()); + } - $action = new Update(['foo' => 'bar']); + public function testGetArguments() + { + $arguments = ['foo' => 'bar']; + $action = new Update($arguments); - $this->assertSame(['foo' => 'bar'], $action->getArguments()); + $this->assertSame( + $arguments, + $action->getArguments() + ); } } From df453313a9075c53426c8cd9cbd4563d7ad1d2e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Fri, 25 Jan 2019 04:20:43 +0100 Subject: [PATCH 5/6] Fixed typo --- src/Contracts/ProcessManagerInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Contracts/ProcessManagerInterface.php b/src/Contracts/ProcessManagerInterface.php index e5b29d0..6f8b9f0 100644 --- a/src/Contracts/ProcessManagerInterface.php +++ b/src/Contracts/ProcessManagerInterface.php @@ -7,7 +7,7 @@ * multiple calls of Process, for performance * mainly. */ -interface ProcessManagerInterace +interface ProcessManagerInterface { /** * @param string $command the Process command to execute From c60f3d2b2f1a47a5356beaf2d16e6fcf2bf75329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Andrieu?= Date: Fri, 25 Jan 2019 04:26:15 +0100 Subject: [PATCH 6/6] Fixed Psalm --- src/ConfigurationProcessor.php | 2 +- src/ProcessManager/ProcessManager.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ConfigurationProcessor.php b/src/ConfigurationProcessor.php index 8c18af2..08271ea 100644 --- a/src/ConfigurationProcessor.php +++ b/src/ConfigurationProcessor.php @@ -79,6 +79,6 @@ public function processInstallation(array $configuration) $processManager->add($command, $this->modulesLocation); } - $processManager->run(); + $this->io->write($processManager->run()); } } diff --git a/src/ProcessManager/ProcessManager.php b/src/ProcessManager/ProcessManager.php index ec432bc..3b04fbd 100644 --- a/src/ProcessManager/ProcessManager.php +++ b/src/ProcessManager/ProcessManager.php @@ -48,15 +48,19 @@ public function add($command, $location) public function run() { $batchOfProcesses = array_chunk($this->processes, $this->maxParallelProcesses); + $output = ''; foreach ($batchOfProcesses as $processes) { - $this->runProcesses($processes); + $output .= $this->runProcesses($processes); } + + return $output; } private function runProcesses(array $processes) { $runningProcesses = count($processes); + $outputResult = ''; foreach ($processes as $process) { $process->start(); @@ -71,5 +75,11 @@ private function runProcesses(array $processes) usleep($this->timestamp); } } + + foreach ($processes as $process) { + $outputResult = $process->getOutput(); + } + + return $outputResult; } }