From 3c844e59f7dc54d6f9a6201289eef50cf270d0ad Mon Sep 17 00:00:00 2001 From: Michael Telgmann Date: Tue, 24 Feb 2026 16:09:13 +0100 Subject: [PATCH] feat: Update commercial if it is also installed --- Services/ProjectComposerJsonUpdater.php | 6 +++++ .../ProjectComposerJsonUpdaterTest.php | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Services/ProjectComposerJsonUpdater.php b/Services/ProjectComposerJsonUpdater.php index 546d588..698232a 100644 --- a/Services/ProjectComposerJsonUpdater.php +++ b/Services/ProjectComposerJsonUpdater.php @@ -56,6 +56,12 @@ public function update(string $file, string $latestVersion): void $composerJson['require'][$shopwarePackage] = $version; } + if (isset($composerJson['require']['shopware/commercial'])) { + // If commercial is installed, also update it directly as part of the core update to keep them in sync + // Remove leading "(v)6." from Shopware version to match commercial release versions + $composerJson['require']['shopware/commercial'] = substr($version, strpos($version, '.') + 1); + } + $composerJson = $this->configureRepositories($composerJson); file_put_contents($file, json_encode($composerJson, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)); diff --git a/Tests/Services/ProjectComposerJsonUpdaterTest.php b/Tests/Services/ProjectComposerJsonUpdaterTest.php index db4b9bd..9cf4af4 100644 --- a/Tests/Services/ProjectComposerJsonUpdaterTest.php +++ b/Tests/Services/ProjectComposerJsonUpdaterTest.php @@ -149,6 +149,33 @@ public function testUpdateWithFixVersionAndBranchSame(): void ); } + public function testUpdateWithCommercialRequirement(): void + { + file_put_contents($this->json, json_encode([ + 'require' => [ + 'shopware/core' => '1.2.3', + 'shopware/commercial' => '1.2.3', + ], + ], \JSON_THROW_ON_ERROR)); + + (new ProjectComposerJsonUpdater(new MockHttpClient([$this->getEmptyVersionsResponse()])))->update( + $this->json, + '6.7.6.0' + ); + + $composerJson = json_decode((string) file_get_contents($this->json), true, 512, \JSON_THROW_ON_ERROR); + + static::assertSame( + [ + 'require' => [ + 'shopware/core' => '6.7.6.0', + 'shopware/commercial' => '7.6.0', + ], + ], + $composerJson + ); + } + public function testUpdateWithSymfonyRuntimeRequirement(): void { file_put_contents($this->json, json_encode([