Skip to content

Commit d4140df

Browse files
committed
MC-36033: Split ece-patches and magento-patches application
1 parent d6081b6 commit d4140df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1684
-402
lines changed

bin/ece-patches

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
define('IS_CLOUD', true);
78
$container = require __DIR__ . '/../bootstrap.php';
89

9-
$application = new Magento\CloudPatches\Application($container);
10+
$application = new Magento\CloudPatches\ApplicationEce($container);
1011
$application->run();

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"symfony/dependency-injection": "^3.3||^4.3",
1515
"symfony/process": "^2.1||^4.1",
1616
"symfony/proxy-manager-bridge": "^3.3||^4.3",
17+
"symfony/yaml": "^3.3||^4.0",
1718
"monolog/monolog": "^1.16",
1819
"magento/quality-patches": "^1.0.0"
1920
},

config/services.xml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828
<service id="Magento\CloudPatches\Patch\Pool\RequiredPool" lazy="true"/>
2929
<service id="Magento\CloudPatches\Patch\Pool\LocalPool" lazy="true"/>
3030
<service id="Magento\CloudPatches\Patch\Status\StatusPool" autowire="false"/>
31-
<service id="statusOptionalPool" class="Magento\CloudPatches\Patch\Status\StatusPool" lazy="true">
32-
<argument key="$resolvers" type="collection">
33-
<argument type="service" id="Magento\CloudPatches\Patch\Status\OptionalResolver"/>
34-
</argument>
35-
</service>
3631
<service id="statusPool" class="Magento\CloudPatches\Patch\Status\StatusPool" lazy="true">
3732
<argument key="$resolvers" type="collection">
3833
<argument type="service" id="Magento\CloudPatches\Patch\Status\LocalResolver"/>
@@ -42,26 +37,29 @@
4237
<service id="Magento\CloudPatches\Command\Process\ShowStatus">
4338
<argument key="$statusPool" type="service" id="statusPool"/>
4439
</service>
40+
<service id="Magento\CloudPatches\Command\Process\RevertEce">
41+
<argument key="$statusPool" type="service" id="statusPool"/>
42+
</service>
4543
<service id="Magento\CloudPatches\Command\Process\Action\ApplyOptionalAction">
46-
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
44+
<argument key="$statusPool" type="service" id="statusPool"/>
4745
</service>
4846
<service id="Magento\CloudPatches\Command\Process\Action\RevertAction">
49-
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
47+
<argument key="$statusPool" type="service" id="statusPool"/>
5048
</service>
5149
<service id="Magento\CloudPatches\Command\Process\Action\ConfirmRequiredAction">
52-
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
50+
<argument key="$statusPool" type="service" id="statusPool"/>
5351
</service>
5452
<service id="Magento\CloudPatches\Command\Process\Action\ProcessDeprecatedAction">
55-
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
53+
<argument key="$statusPool" type="service" id="statusPool"/>
5654
</service>
5755
<service id="Magento\CloudPatches\Command\Process\Action\ReviewAppliedAction">
58-
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
56+
<argument key="$statusPool" type="service" id="statusPool"/>
5957
</service>
6058
<service id="Magento\CloudPatches\Patch\RevertValidator">
61-
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
59+
<argument key="$statusPool" type="service" id="statusPool"/>
6260
</service>
6361
<service id="Magento\CloudPatches\Command\Process\Renderer">
64-
<argument key="$statusPool" type="service" id="statusOptionalPool"/>
62+
<argument key="$statusPool" type="service" id="statusPool"/>
6563
</service>
6664
<service id="Magento\CloudPatches\Command\Process\Action\ActionPool" autowire="false"/>
6765
<service id="ApplyOptionalActionPool" class="Magento\CloudPatches\Command\Process\Action\ActionPool">
@@ -75,6 +73,9 @@
7573
<service id="Magento\CloudPatches\Command\Process\ApplyOptional">
7674
<argument key="$actionPool" type="service" id="ApplyOptionalActionPool"/>
7775
</service>
76+
<service id="Magento\CloudPatches\Command\Process\ApplyOptionalEce">
77+
<argument key="$actionPool" type="service" id="ApplyOptionalActionPool"/>
78+
</service>
7879
<service id="Magento\CloudPatches\Patch\PatchBuilder" shared="false"/>
7980
</services>
8081
</container>

src/ApplicationEce.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches;
9+
10+
use Composer\Composer;
11+
use Magento\CloudPatches\Command;
12+
use Psr\Container\ContainerInterface;
13+
14+
/**
15+
* @inheritdoc
16+
*/
17+
class ApplicationEce extends \Symfony\Component\Console\Application
18+
{
19+
/**
20+
* @var ContainerInterface
21+
*/
22+
private $container;
23+
24+
/**
25+
* @param ContainerInterface $container
26+
*/
27+
public function __construct(ContainerInterface $container)
28+
{
29+
$this->container = $container;
30+
31+
parent::__construct(
32+
$container->get(Composer::class)->getPackage()->getPrettyName(),
33+
$container->get(Composer::class)->getPackage()->getPrettyVersion()
34+
);
35+
}
36+
37+
/**
38+
* @inheritdoc
39+
*/
40+
protected function getDefaultCommands()
41+
{
42+
return array_merge(parent::getDefaultCommands(), [
43+
$this->container->get(Command\ApplyEce::class),
44+
$this->container->get(Command\RevertEce::class),
45+
$this->container->get(Command\Status::class)
46+
]);
47+
}
48+
}

src/Command/Apply.php

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,15 @@
88
namespace Magento\CloudPatches\Command;
99

1010
use Magento\CloudPatches\App\RuntimeException;
11-
use Magento\CloudPatches\Command\Process\ApplyLocal;
1211
use Magento\CloudPatches\Command\Process\ApplyOptional;
13-
use Magento\CloudPatches\Command\Process\ApplyRequired;
1412
use Magento\CloudPatches\Composer\MagentoVersion;
15-
use Magento\CloudPatches\Patch\Environment;
1613
use Psr\Log\LoggerInterface;
1714
use Symfony\Component\Console\Input\InputArgument;
1815
use Symfony\Component\Console\Input\InputInterface;
19-
use Symfony\Component\Console\Input\InputOption;
2016
use Symfony\Component\Console\Output\OutputInterface;
2117

2218
/**
23-
* Patch apply command.
19+
* Patch apply command (OnPrem).
2420
*/
2521
class Apply extends AbstractCommand
2622
{
@@ -29,11 +25,6 @@ class Apply extends AbstractCommand
2925
*/
3026
const NAME = 'apply';
3127

32-
/**
33-
* Defines whether Magento is installed from Git.
34-
*/
35-
const OPT_GIT_INSTALLATION = 'git-installation';
36-
3728
/**
3829
* List of quality patches to apply.
3930
*/
@@ -44,21 +35,6 @@ class Apply extends AbstractCommand
4435
*/
4536
private $applyOptional;
4637

47-
/**
48-
* @var ApplyRequired
49-
*/
50-
private $applyRequired;
51-
52-
/**
53-
* @var ApplyLocal
54-
*/
55-
private $applyLocal;
56-
57-
/**
58-
* @var Environment
59-
*/
60-
private $environment;
61-
6238
/**
6339
* @var LoggerInterface
6440
*/
@@ -70,25 +46,16 @@ class Apply extends AbstractCommand
7046
private $magentoVersion;
7147

7248
/**
73-
* @param ApplyRequired $applyRequired
7449
* @param ApplyOptional $applyOptional
75-
* @param ApplyLocal $applyLocal
76-
* @param Environment $environment
7750
* @param LoggerInterface $logger
7851
* @param MagentoVersion $magentoVersion
7952
*/
8053
public function __construct(
81-
ApplyRequired $applyRequired,
8254
ApplyOptional $applyOptional,
83-
ApplyLocal $applyLocal,
84-
Environment $environment,
8555
LoggerInterface $logger,
8656
MagentoVersion $magentoVersion
8757
) {
88-
$this->applyRequired = $applyRequired;
8958
$this->applyOptional = $applyOptional;
90-
$this->applyLocal = $applyLocal;
91-
$this->environment = $environment;
9259
$this->logger = $logger;
9360
$this->magentoVersion = $magentoVersion;
9461

@@ -101,17 +68,11 @@ public function __construct(
10168
protected function configure()
10269
{
10370
$this->setName(self::NAME)
104-
->setDescription('Apply patches')
71+
->setDescription('Applies patches. The list of patches should pass as a command argument')
10572
->addArgument(
10673
self::ARG_QUALITY_PATCHES,
107-
InputArgument::IS_ARRAY,
108-
'List of quality patches to apply'
109-
)->addOption(
110-
self::OPT_GIT_INSTALLATION,
111-
null,
112-
InputOption::VALUE_OPTIONAL,
113-
'Is git installation',
114-
false
74+
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
75+
'List of patches to apply'
11576
);
11677

11778
parent::configure();
@@ -122,23 +83,10 @@ protected function configure()
12283
*/
12384
public function execute(InputInterface $input, OutputInterface $output)
12485
{
125-
$deployedFromGit = $input->getOption(Apply::OPT_GIT_INSTALLATION);
126-
if ($deployedFromGit) {
127-
$output->writeln('<info>Git-based installation. Skipping patches applying.</info>');
128-
129-
return self::RETURN_SUCCESS;
130-
}
131-
13286
$this->logger->notice($this->magentoVersion->get());
13387

13488
try {
135-
if ($this->environment->isCloud()) {
136-
$this->applyRequired->run($input, $output);
137-
$this->applyOptional->run($input, $output);
138-
$this->applyLocal->run($input, $output);
139-
} else {
140-
$this->applyOptional->run($input, $output);
141-
}
89+
$this->applyOptional->run($input, $output);
14290
} catch (RuntimeException $e) {
14391
$output->writeln('<error>' . $e->getMessage() . '</error>');
14492
$this->logger->error($e->getMessage());

src/Command/ApplyEce.php

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches\Command;
9+
10+
use Magento\CloudPatches\App\RuntimeException;
11+
use Magento\CloudPatches\Command\Process\ApplyLocal;
12+
use Magento\CloudPatches\Command\Process\ApplyOptionalEce;
13+
use Magento\CloudPatches\Command\Process\ApplyRequired;
14+
use Magento\CloudPatches\Composer\MagentoVersion;
15+
use Psr\Log\LoggerInterface;
16+
use Symfony\Component\Console\Input\InputInterface;
17+
use Symfony\Component\Console\Output\OutputInterface;
18+
19+
/**
20+
* Patch apply command (Cloud).
21+
*/
22+
class ApplyEce extends AbstractCommand
23+
{
24+
/**
25+
* Command name.
26+
*/
27+
const NAME = 'apply';
28+
29+
/**
30+
* @var ApplyOptionalEce
31+
*/
32+
private $applyOptionalEce;
33+
34+
/**
35+
* @var ApplyRequired
36+
*/
37+
private $applyRequired;
38+
39+
/**
40+
* @var ApplyLocal
41+
*/
42+
private $applyLocal;
43+
44+
/**
45+
* @var LoggerInterface
46+
*/
47+
private $logger;
48+
49+
/**
50+
* @var MagentoVersion
51+
*/
52+
private $magentoVersion;
53+
54+
/**
55+
* @param ApplyRequired $applyRequired
56+
* @param ApplyOptionalEce $applyOptionalEce
57+
* @param ApplyLocal $applyLocal
58+
* @param LoggerInterface $logger
59+
* @param MagentoVersion $magentoVersion
60+
*/
61+
public function __construct(
62+
ApplyRequired $applyRequired,
63+
ApplyOptionalEce $applyOptionalEce,
64+
ApplyLocal $applyLocal,
65+
LoggerInterface $logger,
66+
MagentoVersion $magentoVersion
67+
) {
68+
$this->applyRequired = $applyRequired;
69+
$this->applyOptionalEce = $applyOptionalEce;
70+
$this->applyLocal = $applyLocal;
71+
$this->logger = $logger;
72+
$this->magentoVersion = $magentoVersion;
73+
74+
parent::__construct(self::NAME);
75+
}
76+
77+
/**
78+
* @inheritDoc
79+
*/
80+
protected function configure()
81+
{
82+
$this->setName(self::NAME)
83+
->setDescription('Applies patches (Magento Cloud only)');
84+
85+
parent::configure();
86+
}
87+
88+
/**
89+
* @inheritDoc
90+
*/
91+
public function execute(InputInterface $input, OutputInterface $output)
92+
{
93+
$this->logger->notice($this->magentoVersion->get());
94+
95+
try {
96+
$this->applyRequired->run($input, $output);
97+
$this->applyOptionalEce->run($input, $output);
98+
$this->applyLocal->run($input, $output);
99+
} catch (RuntimeException $e) {
100+
$output->writeln('<error>' . $e->getMessage() . '</error>');
101+
$this->logger->error($e->getMessage());
102+
103+
return self::RETURN_FAILURE;
104+
} catch (\Exception $e) {
105+
$this->logger->critical($e);
106+
107+
throw $e;
108+
}
109+
110+
return self::RETURN_SUCCESS;
111+
}
112+
}

0 commit comments

Comments
 (0)