Skip to content

Commit 6cebd6f

Browse files
PWA-2165: Move functionality to require-commerce and drop web setup wizard support
1 parent 27b97b5 commit 6cebd6f

38 files changed

+1121
-1667
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Purpose of plugin
44

5-
The `magento/composer-root-update-plugin` Composer plugin resolves changes that need to be made to the root project `composer.json` file before updating to a new Magento metapackage requirement.
5+
The `magento/composer-root-update-plugin` Composer plugin resolves changes that need to be made to the root project `composer.json` file before updating to a new Magento metapackage requirement through the `composer require-commerce` command.
66

7-
This is accomplished by comparing the root `composer.json` file for the Magento project corresponding to the Magento version and edition in the current installation with the Magento project `composer.json` file for the target Magento metapackage when the `composer require` command runs and applying any deltas found between the two files if they do not conflict with the existing `composer.json` file in the Magento root directory.
7+
To accomplish this, it compares the default project `composer.json` file for the Magento Open Source or Adobe Commerce metapackage version in the current installation with the project `composer.json` file corresponding to the target metapackage. The command then applies any deltas found between the two files if they do not conflict with user customizations.
88

99
# Getting Started
1010

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
22
"type": "project",
33
"name": "magento/composer-root-update-plugin",
4-
"description": "Git source for the Magento root update lookahead composer plugin",
4+
"description": "Git source for the Magento Open Source/Adobe Commerce root update lookahead composer plugin",
55
"license": [
66
"OSL-3.0",
77
"AFL-3.0"
88
],
99
"require": {
10-
"composer/composer": "<1.11 || >=2.0.0 <2.1",
10+
"php": "~7.3.0||~7.4.0",
11+
"composer/composer": "^1.0 || ^2.0",
1112
"composer-plugin-api": "^1.0 || ^2.0"
1213
},
1314
"require-dev": {
14-
"phpunit/phpunit": "~6.5.0"
15+
"phpunit/phpunit": "~9.5.0"
1516
},
1617
"autoload": {
1718
"psr-4": {

docs/class_descriptions.md

Lines changed: 43 additions & 102 deletions
Large diffs are not rendered by default.

docs/process_flows.md

Lines changed: 19 additions & 92 deletions
Large diffs are not rendered by default.
-28.6 KB
Binary file not shown.
-17.3 KB
Binary file not shown.
-53.7 KB
Binary file not shown.

docs/resources/self_install_flow.png

-26.8 KB
Binary file not shown.

src/Magento/ComposerRootUpdatePlugin/ComposerReimplementation/ExtendableRequireCommand.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Composer\Semver\VersionParser;
1616
use Composer\Repository\CompositeRepository;
1717
use Composer\Repository\PlatformRepository;
18+
use Exception;
1819
use Symfony\Component\Console\Input\InputInterface;
1920

2021
/**
@@ -37,14 +38,14 @@ abstract class ExtendableRequireCommand extends RequireCommand
3738
protected $jsonFile;
3839

3940
/**
40-
* @var bool $mageNewlyCreated
41+
* @var bool $pluginNewlyCreated
4142
*/
42-
protected $mageNewlyCreated;
43+
protected $pluginNewlyCreated;
4344

4445
/**
45-
* @var bool|string $mageComposerBackup
46+
* @var bool|string $pluginComposerBackup
4647
*/
47-
protected $mageComposerBackup;
48+
protected $pluginComposerBackup;
4849

4950
/**
5051
* @var string $preferredStability
@@ -64,8 +65,8 @@ public function __construct(string $name = null)
6465
parent::__construct($name);
6566
$this->fileName = null;
6667
$this->jsonFile = null;
67-
$this->mageNewlyCreated = null;
68-
$this->mageComposerBackup = null;
68+
$this->pluginNewlyCreated = null;
69+
$this->pluginComposerBackup = null;
6970
$this->preferredStability = null;
7071
$this->phpVersion = null;
7172
}
@@ -80,7 +81,7 @@ public function __construct(string $name = null)
8081
* @param InputInterface $input
8182
* @return int|array
8283
*/
83-
protected function parseComposerJsonFile($input)
84+
protected function parseComposerJsonFile(InputInterface $input)
8485
{
8586
$file = Factory::getComposerFile();
8687
$io = $this->getIO();
@@ -129,8 +130,8 @@ protected function parseComposerJsonFile($input)
129130

130131
$this->fileName = $file;
131132
$this->jsonFile = $json;
132-
$this->mageNewlyCreated = $newlyCreated;
133-
$this->mageComposerBackup = $composerBackup;
133+
$this->pluginNewlyCreated = $newlyCreated;
134+
$this->pluginComposerBackup = $composerBackup;
134135
$this->preferredStability = $preferredStability;
135136
$this->phpVersion = $phpVersion;
136137
return 0;
@@ -140,17 +141,17 @@ protected function parseComposerJsonFile($input)
140141
* Interactively ask for the requirement arguments
141142
*
142143
* Copied second half of InitCommand::determineRequirements() without calling findBestVersionAndNameForPackage(),
143-
* which would try to use existing requirements before the plugin can update new Magento values
144+
* which would try to use existing requirements before the plugin can update new project values
144145
*
145146
* @see InitCommand::determineRequirements()
146147
*
147148
* @return array
148-
* @throws \Exception
149+
* @throws Exception
149150
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
150151
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
151152
* @SuppressWarnings(PHPMD.NPathComplexity)
152153
*/
153-
protected function getRequirementsInteractive()
154+
protected function getRequirementsInteractive(): array
154155
{
155156
$versionParser = new VersionParser();
156157
$io = $this->getIO();
@@ -215,7 +216,7 @@ protected function getRequirementsInteractive()
215216
return $pkgMatches['name'];
216217
}
217218

218-
throw new \Exception('Not a valid selection');
219+
throw new Exception('Not a valid selection');
219220
};
220221

221222
$package = $io->askAndValidate(
@@ -266,19 +267,19 @@ protected function getRequirementsInteractive()
266267
* @param string $message
267268
* @return void
268269
*/
269-
protected function revertMageComposerFile($message)
270+
protected function revertRootComposerFile(string $message)
270271
{
271272
$file = $this->fileName;
272273
$io = $this->getIO();
273-
if ($this->mageNewlyCreated) {
274+
if ($this->pluginNewlyCreated) {
274275
if (file_exists($this->jsonFile->getPath())) {
275276
$io->writeError("\n<error>$message, deleting $file.</error>");
276277
unlink($this->jsonFile->getPath());
277278
}
278279
} else {
279280
$io->writeError("\n<error>$message, " .
280-
"reverting $file to its original content from before the Magento root update.</error>");
281-
file_put_contents($this->jsonFile->getPath(), $this->mageComposerBackup);
281+
"reverting $file to its original content from before the magento/project root update.</error>");
282+
file_put_contents($this->jsonFile->getPath(), $this->pluginComposerBackup);
282283
}
283284
}
284285
}

src/Magento/ComposerRootUpdatePlugin/Plugin/CommandProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
namespace Magento\ComposerRootUpdatePlugin\Plugin;
88

99
use Composer\Plugin\Capability\CommandProvider as CommandProviderCapability;
10-
use Magento\ComposerRootUpdatePlugin\Plugin\Commands\MageRootRequireCommand;
10+
use Magento\ComposerRootUpdatePlugin\Plugin\Commands\OverrideRequireCommand;
11+
use Magento\ComposerRootUpdatePlugin\Plugin\Commands\RequireCommerceCommand;
1112
use Magento\ComposerRootUpdatePlugin\Plugin\Commands\UpdatePluginNamespaceCommands;
1213

1314
/**
@@ -20,6 +21,9 @@ class CommandProvider implements CommandProviderCapability
2021
*/
2122
public function getCommands()
2223
{
23-
return [new MageRootRequireCommand(), new UpdatePluginNamespaceCommands()];
24+
return [
25+
new OverrideRequireCommand(),
26+
new RequireCommerceCommand()
27+
];
2428
}
2529
}

0 commit comments

Comments
 (0)