From 2975aa7bca1cdc42ee9cb0f96ad3cdf5e9466bfe Mon Sep 17 00:00:00 2001 From: Misha Kulakovsky Date: Thu, 8 Feb 2024 11:38:29 +0400 Subject: [PATCH 1/4] fix jsonPath in ComposerScriptsConfigurator::update --- src/Configurator/ComposerScriptsConfigurator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Configurator/ComposerScriptsConfigurator.php b/src/Configurator/ComposerScriptsConfigurator.php index abdcefc80..73b9d7eb8 100644 --- a/src/Configurator/ComposerScriptsConfigurator.php +++ b/src/Configurator/ComposerScriptsConfigurator.php @@ -17,6 +17,7 @@ use Symfony\Flex\Lock; use Symfony\Flex\Recipe; use Symfony\Flex\Update\RecipeUpdate; +use Symfony\Component\Filesystem\Path; /** * @author Fabien Potencier @@ -49,7 +50,7 @@ public function unconfigure(Recipe $recipe, $scripts, Lock $lock) public function update(RecipeUpdate $recipeUpdate, array $originalConfig, array $newConfig): void { $json = new JsonFile(Factory::getComposerFile()); - $jsonPath = ltrim(str_replace($recipeUpdate->getRootDir(), '', $json->getPath()), '/\\'); + $jsonPath = Path::makeRelative($json->getPath(), $recipeUpdate->getRootDir()); $recipeUpdate->setOriginalFile( $jsonPath, From 8867a65386fb728b39a724f6f451fe90a7ebb903 Mon Sep 17 00:00:00 2001 From: Misha Kulakovsky Date: Thu, 8 Feb 2024 11:43:15 +0400 Subject: [PATCH 2/4] fix jsonPath in ComposerScriptsConfigurator::update (+coding standards fix) --- src/Configurator/ComposerScriptsConfigurator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Configurator/ComposerScriptsConfigurator.php b/src/Configurator/ComposerScriptsConfigurator.php index 73b9d7eb8..9e183f41f 100644 --- a/src/Configurator/ComposerScriptsConfigurator.php +++ b/src/Configurator/ComposerScriptsConfigurator.php @@ -14,10 +14,10 @@ use Composer\Factory; use Composer\Json\JsonFile; use Composer\Json\JsonManipulator; +use Symfony\Component\Filesystem\Path; use Symfony\Flex\Lock; use Symfony\Flex\Recipe; use Symfony\Flex\Update\RecipeUpdate; -use Symfony\Component\Filesystem\Path; /** * @author Fabien Potencier From 1d6cedc581a7d1c45adb37326efee519a65cbbb5 Mon Sep 17 00:00:00 2001 From: Misha Kulakovsky Date: Tue, 3 Dec 2024 20:40:54 +0000 Subject: [PATCH 3/4] fix jsonPath in ComposerScriptsConfigurator::update --- src/Configurator/ComposerScriptsConfigurator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Configurator/ComposerScriptsConfigurator.php b/src/Configurator/ComposerScriptsConfigurator.php index 9e183f41f..417e2c074 100644 --- a/src/Configurator/ComposerScriptsConfigurator.php +++ b/src/Configurator/ComposerScriptsConfigurator.php @@ -50,7 +50,11 @@ public function unconfigure(Recipe $recipe, $scripts, Lock $lock) public function update(RecipeUpdate $recipeUpdate, array $originalConfig, array $newConfig): void { $json = new JsonFile(Factory::getComposerFile()); - $jsonPath = Path::makeRelative($json->getPath(), $recipeUpdate->getRootDir()); + $jsonPath = $json->getPath(); + if (str_starts_with($jsonPath, $recipeUpdate->getRootDir())) { + $jsonPath = substr($jsonPath, strlen($recipeUpdate->getRootDir())); + } + $jsonPath = ltrim($jsonPath, '/\\'); $recipeUpdate->setOriginalFile( $jsonPath, From 7343ebf2e6131cb86ecf7a0911050b2e3fc78f42 Mon Sep 17 00:00:00 2001 From: Misha Kulakovsky Date: Tue, 3 Dec 2024 20:41:36 +0000 Subject: [PATCH 4/4] fabbot patch --- src/Configurator/ComposerScriptsConfigurator.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Configurator/ComposerScriptsConfigurator.php b/src/Configurator/ComposerScriptsConfigurator.php index 417e2c074..a230eda57 100644 --- a/src/Configurator/ComposerScriptsConfigurator.php +++ b/src/Configurator/ComposerScriptsConfigurator.php @@ -14,7 +14,6 @@ use Composer\Factory; use Composer\Json\JsonFile; use Composer\Json\JsonManipulator; -use Symfony\Component\Filesystem\Path; use Symfony\Flex\Lock; use Symfony\Flex\Recipe; use Symfony\Flex\Update\RecipeUpdate; @@ -52,9 +51,9 @@ public function update(RecipeUpdate $recipeUpdate, array $originalConfig, array $json = new JsonFile(Factory::getComposerFile()); $jsonPath = $json->getPath(); if (str_starts_with($jsonPath, $recipeUpdate->getRootDir())) { - $jsonPath = substr($jsonPath, strlen($recipeUpdate->getRootDir())); + $jsonPath = substr($jsonPath, \strlen($recipeUpdate->getRootDir())); } - $jsonPath = ltrim($jsonPath, '/\\'); + $jsonPath = ltrim($jsonPath, '/\\'); $recipeUpdate->setOriginalFile( $jsonPath,