symplify icon indicating copy to clipboard operation
symplify copied to clipboard

Repositories path merged to global composer.json wrongly

Open achristodoulou opened this issue 1 year ago • 5 comments

HI, I have the following setup

  • src\libs\library_one\src\composer.json
{
	"name": "xxx/library_one",
	"type": "library",
	"require": {
		"php": "^7.4"
	},
	"autoload": {
		"psr-4": {
			"XXX\\LibraryOne\\": "src"
		}
	},
	"minimum-stability": "stable"
}
  • src\apps\app_one\src\composer.json
{
	"name": "xxx/app_one",
	"require": {
		"php": "^7.4",
		"xxx/library_one": "self.version"
	},
	"autoload": {
		"psr-4": {
			"XXX\\AppOne\\": "src"
		}
	},
	"repositories": [
		{
			"type": "path",
			"url": "../../../src/libs/*/"
		}
	],
	"minimum-stability": "stable"
}

After running cmd php vendor/bin/monorepo-builder merge the global composer.json was updated as follows, notice that the repository paths have been copied exactly which is not valid when in root folder. Fyi, app_one is working fine when I did composer install within the app folder and execute its code but when I do composer install in root folder which contains the global composer.json it failed due to the path not being valid.

Please let me know if I am doing something wrong or if it is a bug. Thank you.

  • composer.json
{
    "require": {
        "php": "^7.4"
    },
    "require-dev": {
        "phpunit/phpunit": "^9.0",
        "symplify/monorepo-builder": "^11.1"
    },
    "autoload": {
        "psr-4": {
            "XXX\\AppOne\\": "src/apps/app_one/src",
            "XXX\\LibraryOne\\": "src/libs/library_one/src"
        }
    },
    "repositories": [
        {
            "type": "path",
            "url": "../../../src/libs/*/" <<<< The correct path should be `src/libs/*/`
        }
    ],
    "replace": {
        "xxx/app_one": "self.version",
        "xxx/library_one": "self.version"
    },
    "minimum-stability": "stable"
}

achristodoulou avatar Sep 16 '22 07:09 achristodoulou

Hi, thanks for reporting.

There is a similar service to handle this for paths in PSR-4 → autoload the same way. Could you send a fix with for repositories → url?

TomasVotruba avatar Sep 16 '22 13:09 TomasVotruba

Not sure, can you point me the exact file location that the fix needs to be applied.

achristodoulou avatar Sep 16 '22 14:09 achristodoulou

I'm not sure, but should be some service responsible for merging. Similar place where the PSR-4 paths are decorated.

TomasVotruba avatar Sep 16 '22 14:09 TomasVotruba

I have created the decorator but could not find how it can be called along with the other decorators. Could you tell me in which file it should be?

achristodoulou avatar Sep 17 '22 10:09 achristodoulou

Kind reminder

achristodoulou avatar Sep 19 '22 13:09 achristodoulou