Skip to content

Commit

Permalink
Use mage-os as vendor-name for composer info (#48)
Browse files Browse the repository at this point in the history
The ComposerInformation class is used to extract information about the
current installation from the project root composer.json and
composer.lock files, for example the Magento version.
To find the relevant information, it looks at the package names, using a
vendor name magento.
Without this change, the installed version is reported as "UNKNOWN" in
the Magento admin when the mage-os/project-community-edition package is
used. This change fixes the regex so it correctly identifies the
installed version.

In future, it may be worth generalizing this so it is easier to switch
the project vendor for other distributions based on Mage-OS.

Fixes issue #42.
  • Loading branch information
Vinai committed Oct 8, 2023
1 parent 7be2613 commit 66a9194
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "magento/magento2ce",
"name": "mage-os/magento2ce",
"description": "Magento 2 (Community Edition)",
"type": "project",
"license": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "magento/project-community-edition",
"name": "mage-os/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getRequiredPhpVersion()
foreach ($packages as $package) {
if ($package instanceof CompletePackageInterface) {
$packageName = $package->getPrettyName();
if ($packageName === 'magento/product-community-edition') {
if ($packageName === 'mage-os/product-community-edition') {
$phpRequirementLink = $package->getRequires()['php'];
if ($phpRequirementLink instanceof Link) {
$requiredPhpVersion = $phpRequirementLink->getPrettyConstraint();
Expand Down Expand Up @@ -261,7 +261,7 @@ public function getSystemPackages()
*/
public function isSystemPackage($packageName = '')
{
if (preg_match('/magento\/product-.*?-edition/', $packageName) == 1) {
if (preg_match('/mage-os\/product-.*?-edition/', $packageName) == 1) {
return true;
}
return false;
Expand All @@ -276,7 +276,7 @@ public function isMagentoRoot()
{
$rootPackage = $this->getComposer()->getPackage();

return (boolean)preg_match('/magento\/magento2...?/', $rootPackage->getName());
return (boolean)preg_match('/mage-os\/magento2...?/', $rootPackage->getName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ protected function setUp(): void
$this->packageMock = $this->getMockForAbstractClass(CompletePackageInterface::class);
$this->lockerMock->method('getLockedRepository')->willReturn($this->lockerRepositoryMock);
$this->packageMock->method('getType')->willReturn('metapackage');
$this->packageMock->method('getPrettyName')->willReturn('magento/product-test-package-name-edition');
$this->packageMock->method('getName')->willReturn('magento/product-test-package-name-edition');
$this->packageMock->method('getPrettyName')->willReturn('mage-os/product-test-package-name-edition');
$this->packageMock->method('getName')->willReturn('mage-os/product-test-package-name-edition');
$this->packageMock->method('getPrettyVersion')->willReturn('123.456.789');
$this->lockerRepositoryMock->method('getPackages')->willReturn([$this->packageMock]);

Expand All @@ -78,8 +78,8 @@ protected function setUp(): void
public function testGetSystemPackages()
{
$expected = [
'magento/product-test-package-name-edition' => [
'name' => 'magento/product-test-package-name-edition',
'mage-os/product-test-package-name-edition' => [
'name' => 'mage-os/product-test-package-name-edition',
'type' => 'metapackage',
'version' => '123.456.789'
]
Expand Down Expand Up @@ -113,8 +113,8 @@ public function testIsMagentoRoot($packageName, $expected)
public function isMagentoRootDataProvider()
{
return [
['magento/magento2ce', true],
['magento/magento2ee', true],
['mage-os/magento2ce', true],
['mage-os/magento2ee', true],
['namespace/package', false],
];
}
Expand Down

0 comments on commit 66a9194

Please sign in to comment.