Skip to content

Commit 65edb6e

Browse files
authored
Merge pull request #74 from magento-commerce/ACP2E-1963
ACP2E-1963: Add warning to the QPT CLI wizard/output in case patch has dependencies
2 parents 8554a71 + a75ef2a commit 65edb6e

File tree

11 files changed

+113
-11
lines changed

11 files changed

+113
-11
lines changed

src/Command/Process/Action/ConfirmRequiredAction.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
class ConfirmRequiredAction implements ActionInterface
2323
{
24+
const PATCH_INFO_URL = "https://experienceleague.adobe.com/tools/commerce-quality-patches/index.html";
25+
2426
/**
2527
* @var OptionalPool
2628
*/
@@ -76,10 +78,16 @@ function ($patch) {
7678
}
7779

7880
if ($requiredNotAppliedPatches) {
81+
$url = self::PATCH_INFO_URL . '?keyword=' . current($patchFilter);
82+
$output->writeln(
83+
'<info>Please double check patch details and requirements at ' .
84+
sprintf('<href=%1$s>%1$s</>', $url) .
85+
'</info>' .
86+
PHP_EOL
87+
);
7988
$output->writeln(
8089
'<info>Next patches are required by ' . implode(' ', $patchFilter) . ':</info>' . PHP_EOL
8190
);
82-
8391
$aggregatedPatches = $this->aggregator->aggregate($requiredNotAppliedPatches);
8492
$this->renderer->printTable($output, $aggregatedPatches);
8593

src/Command/Process/Renderer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ function ($item) {
220220
$details .= 'Affected components:' . $glue . implode($glue, $patch->getAffectedComponents());
221221
}
222222

223+
if ($patch->getRequirements()) {
224+
$requirements = rtrim(chunk_split($patch->getRequirements(), 50, PHP_EOL));
225+
$details .= PHP_EOL . '<comment>Requirements:</comment>' . PHP_EOL . ' - ' . $requirements;
226+
}
227+
223228
$id = $patch->getType() === PatchInterface::TYPE_CUSTOM ? 'N/A' : $patch->getId();
224229
$title = chunk_split($patch->getTitle(), 60, PHP_EOL);
225230

src/Command/Process/ShowStatus.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ private function getPatchCategories(array $patches): array
284284
*/
285285
private function printDetailsInfo(OutputInterface $output)
286286
{
287-
$supportUrl = 'https://support.magento.com';
288-
$releaseNotesUrl = 'https://devdocs.magento.com/quality-patches/release-notes.html';
287+
// phpcs:ignore
288+
$releaseNotesUrl = 'https://experienceleague.adobe.com/docs/commerce-operations/tools/quality-patches-tool/release-notes.html';
289+
$supportUrl = 'https://experienceleague.adobe.com/tools/commerce-quality-patches/index.html';
289290

290291
$output->writeln(
291292
'<info>Patch details you can find on </info>' .

src/Patch/AggregatedPatchFactory.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function create(
3636
$require = $this->getRequire($items);
3737
$replacedWith = $this->getReplacedWith($items);
3838
$isDeprecated = $this->isDeprecated($items);
39+
$requirements = $this->getRequirements($items);
3940

4041
return new AggregatedPatch(
4142
$id,
@@ -47,7 +48,8 @@ public function create(
4748
$require,
4849
$replacedWith,
4950
$isDeprecated,
50-
$items
51+
$items,
52+
$requirements
5153
);
5254
}
5355

@@ -189,4 +191,17 @@ private function isDeprecated(array $patches): bool
189191

190192
return false;
191193
}
194+
195+
/**
196+
* Returns aggregated patch requirements.
197+
*
198+
* @param PatchInterface[] $patches
199+
* @return string
200+
*/
201+
private function getRequirements(array $patches): string
202+
{
203+
$patch = reset($patches);
204+
205+
return $patch->getRequirements();
206+
}
192207
}

src/Patch/Collector/SupportCollector.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class SupportCollector implements CollectorInterface
5555

5656
const ORIGIN = 'Adobe Commerce Support';
5757

58+
const PROP_REQUIREMENTS = 'requirements';
59+
5860
/**
5961
* @var Package
6062
*/
@@ -113,6 +115,7 @@ public function collect(): array
113115
$category = !empty($patchGeneralConfig[self::PROP_CATEGORIES])
114116
? array_map('trim', $patchGeneralConfig[self::PROP_CATEGORIES])
115117
: ['Other'];
118+
$patchRequirements = $patchGeneralConfig[self::PROP_REQUIREMENTS] ?? '';
116119

117120
if ($this->package->matchConstraint($packageName, $packageConstraint)) {
118121
$result[] = $this->createPatch(
@@ -124,7 +127,8 @@ public function collect(): array
124127
$packageConstraint,
125128
$patchRequire,
126129
$patchReplacedWith,
127-
$patchDeprecated
130+
$patchDeprecated,
131+
$patchRequirements
128132
);
129133
}
130134
}
@@ -145,9 +149,11 @@ public function collect(): array
145149
* @param array $patchRequire
146150
* @param string $patchReplacedWith
147151
* @param bool $patchDeprecated
152+
* @param string $patchRequirements
148153
*
149154
* @return PatchInterface
150155
* @throws CollectorException
156+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
151157
*/
152158
private function createPatch(
153159
string $patchId,
@@ -158,7 +164,8 @@ private function createPatch(
158164
string $packageConstraint,
159165
array $patchRequire,
160166
string $patchReplacedWith,
161-
bool $patchDeprecated
167+
bool $patchDeprecated,
168+
string $patchRequirements
162169
): PatchInterface {
163170
try {
164171
$patchPath = $this->qualityPackage->getPatchesDirectoryPath() . '/' . $patchFile;
@@ -174,6 +181,7 @@ private function createPatch(
174181
$this->patchBuilder->setRequire($patchRequire);
175182
$this->patchBuilder->setReplacedWith($patchReplacedWith);
176183
$this->patchBuilder->setDeprecated($patchDeprecated);
184+
$this->patchBuilder->setRequirements($patchRequirements);
177185
$patch = $this->patchBuilder->build();
178186
} catch (PatchIntegrityException $e) {
179187
throw new CollectorException($e->getMessage(), $e->getCode(), $e);

src/Patch/Data/AggregatedPatch.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class AggregatedPatch implements AggregatedPatchInterface
6262
*/
6363
private $origin;
6464

65+
/**
66+
* @var string
67+
*/
68+
private $requirements = '';
69+
6570
/**
6671
* @param string $id
6772
* @param string $type
@@ -85,7 +90,8 @@ public function __construct(
8590
array $require,
8691
string $replacedWith,
8792
bool $isDeprecated,
88-
array $items
93+
array $items,
94+
string $requirements = ''
8995
) {
9096

9197
$this->id = $id;
@@ -98,6 +104,7 @@ public function __construct(
98104
$this->replacedWith = $replacedWith;
99105
$this->isDeprecated = $isDeprecated;
100106
$this->items = $items;
107+
$this->requirements = $requirements;
101108
}
102109

103110
/**
@@ -187,4 +194,11 @@ public function getItems(): array
187194
{
188195
return $this->items;
189196
}
197+
/**
198+
* @inheritDoc
199+
*/
200+
public function getRequirements(): string
201+
{
202+
return $this->requirements;
203+
}
190204
}

src/Patch/Data/AggregatedPatchInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,11 @@ public function isDeprecated(): bool;
8383
* @return PatchInterface[]
8484
*/
8585
public function getItems(): array;
86+
87+
/**
88+
* Patch requirements.
89+
*
90+
* @return string
91+
*/
92+
public function getRequirements(): string;
8693
}

src/Patch/Data/Patch.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ class Patch implements PatchInterface
7676
*/
7777
private $origin;
7878

79+
/**
80+
* @var string
81+
*/
82+
private $requirements = '';
83+
7984
/**
8085
* @param string $id
8186
* @param string $type
@@ -90,6 +95,7 @@ class Patch implements PatchInterface
9095
* @param string[] $require
9196
* @param string $replacedWith
9297
* @param bool $isDeprecated
98+
* @param string $requirements
9399
*
94100
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
95101
*/
@@ -106,7 +112,8 @@ public function __construct(
106112
array $affectedComponents,
107113
array $require,
108114
string $replacedWith,
109-
bool $isDeprecated
115+
bool $isDeprecated,
116+
string $requirements = ''
110117
) {
111118

112119
$this->id = $id;
@@ -122,6 +129,7 @@ public function __construct(
122129
$this->require = $require;
123130
$this->replacedWith = $replacedWith;
124131
$this->isDeprecated = $isDeprecated;
132+
$this->requirements = $requirements;
125133
}
126134

127135
/**
@@ -235,4 +243,12 @@ public function isDeprecated(): bool
235243
{
236244
return $this->isDeprecated;
237245
}
246+
247+
/**
248+
* @inheritDoc
249+
*/
250+
public function getRequirements(): string
251+
{
252+
return $this->requirements;
253+
}
238254
}

src/Patch/Data/PatchInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,11 @@ public function getReplacedWith(): string;
119119
* @return bool
120120
*/
121121
public function isDeprecated(): bool;
122+
123+
/**
124+
* Patch requirements.
125+
*
126+
* @return string
127+
*/
128+
public function getRequirements(): string;
122129
}

src/Patch/PatchBuilder.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ class PatchBuilder
8484
*/
8585
private $filesystem;
8686

87+
/**
88+
* @var string
89+
*/
90+
private $requirements = '';
91+
8792
/**
8893
* @param Filesystem $filesystem
8994
*/
@@ -226,6 +231,17 @@ public function setDeprecated(bool $deprecated)
226231
$this->deprecated = $deprecated;
227232
}
228233

234+
/**
235+
* Sets patch requirements.
236+
*
237+
* @param string $requirements
238+
* @return void
239+
*/
240+
public function setRequirements(string $requirements)
241+
{
242+
$this->requirements = $requirements;
243+
}
244+
229245
/**
230246
* Builds patch data object.
231247
*
@@ -250,7 +266,8 @@ public function build()
250266
$components,
251267
$this->require,
252268
$this->replacedWith,
253-
$this->deprecated
269+
$this->deprecated,
270+
$this->requirements
254271
);
255272
}
256273

0 commit comments

Comments
 (0)