-
Notifications
You must be signed in to change notification settings - Fork 34
Magento Quality Patches - improvement of dev experience #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9d25311
d6081b6
65837e0
008df20
24cdf11
8c2e9f5
6ddb1fe
1113e58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| "name": "magento/magento-cloud-patches", | ||
| "description": "Provides critical fixes for Magento 2 Enterprise Edition", | ||
| "type": "magento2-component", | ||
| "version": "1.0.5", | ||
| "version": "1.0.6", | ||
| "license": "OSL-3.0", | ||
| "require": { | ||
| "php": "^7.0", | ||
|
|
@@ -14,6 +14,7 @@ | |
| "symfony/dependency-injection": "^3.3||^4.3", | ||
| "symfony/process": "^2.1||^4.1", | ||
| "symfony/proxy-manager-bridge": "^3.3||^4.3", | ||
| "symfony/yaml": "^3.3||^4.0", | ||
| "monolog/monolog": "^1.16", | ||
| "magento/quality-patches": "^1.0.0" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This causes circular dependency and must be moved to another package
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The packages have a dependency on each other and the composer resolves them without issues. Why it should be moved?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having circular dependency is never good idea, in some cases, it lead to neverending dependency resolving and other problems. This may be either included in ECE-Tools or MCC
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And circular dependency consieded as "bad smell" from Architecture Design standpoint
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree with you, in case of recursive read it can lead to neverending resolving.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "magento/quality-patches" dependency was moved to suggest section |
||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\CloudPatches; | ||
|
|
||
| use Composer\Composer; | ||
| use Magento\CloudPatches\Command; | ||
| use Psr\Container\ContainerInterface; | ||
|
|
||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| class ApplicationEce extends \Symfony\Component\Console\Application | ||
| { | ||
| /** | ||
| * @var ContainerInterface | ||
| */ | ||
| private $container; | ||
|
|
||
| /** | ||
| * @param ContainerInterface $container | ||
| */ | ||
| public function __construct(ContainerInterface $container) | ||
| { | ||
| $this->container = $container; | ||
|
|
||
| parent::__construct( | ||
| $container->get(Composer::class)->getPackage()->getPrettyName(), | ||
| $container->get(Composer::class)->getPackage()->getPrettyVersion() | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| protected function getDefaultCommands() | ||
| { | ||
| return array_merge(parent::getDefaultCommands(), [ | ||
| $this->container->get(Command\Ece\Apply::class), | ||
| $this->container->get(Command\Ece\Revert::class), | ||
| $this->container->get(Command\Status::class) | ||
| ]); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,19 +8,15 @@ | |
| namespace Magento\CloudPatches\Command; | ||
|
|
||
| use Magento\CloudPatches\App\RuntimeException; | ||
| use Magento\CloudPatches\Command\Process\ApplyLocal; | ||
| use Magento\CloudPatches\Command\Process\ApplyOptional; | ||
| use Magento\CloudPatches\Command\Process\ApplyRequired; | ||
| use Magento\CloudPatches\Composer\MagentoVersion; | ||
| use Magento\CloudPatches\Patch\Environment; | ||
| use Psr\Log\LoggerInterface; | ||
| use Symfony\Component\Console\Input\InputArgument; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| /** | ||
| * Patch apply command. | ||
| * Patch apply command (OnPrem). | ||
| */ | ||
| class Apply extends AbstractCommand | ||
| { | ||
|
|
@@ -30,35 +26,15 @@ class Apply extends AbstractCommand | |
| const NAME = 'apply'; | ||
|
|
||
| /** | ||
| * Defines whether Magento is installed from Git. | ||
| * List of patches to apply. | ||
| */ | ||
| const OPT_GIT_INSTALLATION = 'git-installation'; | ||
|
|
||
| /** | ||
| * List of quality patches to apply. | ||
| */ | ||
| const ARG_QUALITY_PATCHES = 'quality-patches'; | ||
| const ARG_LIST_OF_PATCHES = 'list-of-patches'; | ||
|
|
||
| /** | ||
| * @var ApplyOptional | ||
| */ | ||
| private $applyOptional; | ||
|
|
||
| /** | ||
| * @var ApplyRequired | ||
| */ | ||
| private $applyRequired; | ||
|
|
||
| /** | ||
| * @var ApplyLocal | ||
| */ | ||
| private $applyLocal; | ||
|
|
||
| /** | ||
| * @var Environment | ||
| */ | ||
| private $environment; | ||
|
|
||
| /** | ||
| * @var LoggerInterface | ||
| */ | ||
|
|
@@ -70,25 +46,16 @@ class Apply extends AbstractCommand | |
| private $magentoVersion; | ||
|
|
||
| /** | ||
| * @param ApplyRequired $applyRequired | ||
| * @param ApplyOptional $applyOptional | ||
| * @param ApplyLocal $applyLocal | ||
| * @param Environment $environment | ||
| * @param LoggerInterface $logger | ||
| * @param MagentoVersion $magentoVersion | ||
| */ | ||
| public function __construct( | ||
| ApplyRequired $applyRequired, | ||
| ApplyOptional $applyOptional, | ||
| ApplyLocal $applyLocal, | ||
| Environment $environment, | ||
| LoggerInterface $logger, | ||
| MagentoVersion $magentoVersion | ||
| ) { | ||
| $this->applyRequired = $applyRequired; | ||
| $this->applyOptional = $applyOptional; | ||
| $this->applyLocal = $applyLocal; | ||
| $this->environment = $environment; | ||
| $this->logger = $logger; | ||
| $this->magentoVersion = $magentoVersion; | ||
|
|
||
|
|
@@ -101,17 +68,11 @@ public function __construct( | |
| protected function configure() | ||
| { | ||
| $this->setName(self::NAME) | ||
| ->setDescription('Apply patches') | ||
| ->setDescription('Applies patches. The list of patches should pass as a command argument') | ||
| ->addArgument( | ||
| self::ARG_QUALITY_PATCHES, | ||
| InputArgument::IS_ARRAY, | ||
| 'List of quality patches to apply' | ||
| )->addOption( | ||
| self::OPT_GIT_INSTALLATION, | ||
| null, | ||
| InputOption::VALUE_OPTIONAL, | ||
| 'Is git installation', | ||
| false | ||
| self::ARG_LIST_OF_PATCHES, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is BC change, it should not go into patch version release
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a new command - ./magento-patches apply,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shiftedreality or you mean removing of --git-installation option? |
||
| InputArgument::IS_ARRAY | InputArgument::REQUIRED, | ||
| 'List of patches to apply' | ||
| ); | ||
|
|
||
| parent::configure(); | ||
|
|
@@ -122,23 +83,10 @@ protected function configure() | |
| */ | ||
| public function execute(InputInterface $input, OutputInterface $output) | ||
| { | ||
| $deployedFromGit = $input->getOption(Apply::OPT_GIT_INSTALLATION); | ||
| if ($deployedFromGit) { | ||
| $output->writeln('<info>Git-based installation. Skipping patches applying.</info>'); | ||
|
|
||
| return self::RETURN_SUCCESS; | ||
| } | ||
|
|
||
| $this->logger->notice($this->magentoVersion->get()); | ||
|
|
||
| try { | ||
| if ($this->environment->isCloud()) { | ||
| $this->applyRequired->run($input, $output); | ||
| $this->applyOptional->run($input, $output); | ||
| $this->applyLocal->run($input, $output); | ||
| } else { | ||
| $this->applyOptional->run($input, $output); | ||
| } | ||
| $this->applyOptional->run($input, $output); | ||
| } catch (RuntimeException $e) { | ||
| $output->writeln('<error>' . $e->getMessage() . '</error>'); | ||
| $this->logger->error($e->getMessage()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\CloudPatches\Command\Ece; | ||
|
|
||
| use Magento\CloudPatches\App\RuntimeException; | ||
| use Magento\CloudPatches\Command\AbstractCommand; | ||
| use Magento\CloudPatches\Command\Process\ApplyLocal; | ||
| use Magento\CloudPatches\Command\Process\Ece\ApplyOptional; | ||
| use Magento\CloudPatches\Command\Process\ApplyRequired; | ||
| use Magento\CloudPatches\Composer\MagentoVersion; | ||
| use Psr\Log\LoggerInterface; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
||
| /** | ||
| * Patch apply command (Cloud). | ||
| */ | ||
| class Apply extends AbstractCommand | ||
| { | ||
| /** | ||
| * Command name. | ||
| */ | ||
| const NAME = 'apply'; | ||
|
|
||
| /** | ||
| * @var ApplyOptional | ||
| */ | ||
| private $applyOptional; | ||
|
|
||
| /** | ||
| * @var ApplyRequired | ||
| */ | ||
| private $applyRequired; | ||
|
|
||
| /** | ||
| * @var ApplyLocal | ||
| */ | ||
| private $applyLocal; | ||
|
|
||
| /** | ||
| * @var LoggerInterface | ||
| */ | ||
| private $logger; | ||
|
|
||
| /** | ||
| * @var MagentoVersion | ||
| */ | ||
| private $magentoVersion; | ||
|
|
||
| /** | ||
| * @param ApplyRequired $applyRequired | ||
| * @param ApplyOptional $applyOptional | ||
| * @param ApplyLocal $applyLocal | ||
| * @param LoggerInterface $logger | ||
| * @param MagentoVersion $magentoVersion | ||
| */ | ||
| public function __construct( | ||
| ApplyRequired $applyRequired, | ||
| ApplyOptional $applyOptional, | ||
| ApplyLocal $applyLocal, | ||
| LoggerInterface $logger, | ||
| MagentoVersion $magentoVersion | ||
| ) { | ||
| $this->applyRequired = $applyRequired; | ||
| $this->applyOptional = $applyOptional; | ||
| $this->applyLocal = $applyLocal; | ||
| $this->logger = $logger; | ||
| $this->magentoVersion = $magentoVersion; | ||
|
|
||
| parent::__construct(self::NAME); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| protected function configure() | ||
| { | ||
| $this->setName(self::NAME) | ||
| ->setDescription('Applies patches (Magento Cloud only)'); | ||
|
|
||
| parent::configure(); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| public function execute(InputInterface $input, OutputInterface $output) | ||
| { | ||
| $this->logger->notice($this->magentoVersion->get()); | ||
|
|
||
| try { | ||
| $this->applyRequired->run($input, $output); | ||
| $this->applyOptional->run($input, $output); | ||
| $this->applyLocal->run($input, $output); | ||
| } catch (RuntimeException $e) { | ||
| $output->writeln('<error>' . $e->getMessage() . '</error>'); | ||
| $this->logger->error($e->getMessage()); | ||
|
|
||
| return self::RETURN_FAILURE; | ||
| } catch (\Exception $e) { | ||
| $this->logger->critical($e); | ||
|
|
||
| throw $e; | ||
| } | ||
|
|
||
| return self::RETURN_SUCCESS; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant since ApplicationEce already Cloud-aware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but there is CloudCollector service that is used by both applications and we need to define what is the environment to set patch type optional or required https://github.com/magento-mpi/magento-cloud-patches/blob/65837e0a187dfa282e47be67c7dc1cd349643709/src/Patch/Collector/CloudCollector.php#L94