soyuka / pmu

PHP Monorepo Utility
MIT License
55 stars 2 forks source link

Find a way to avoid `@dev || xx` constraint for local packages #4

Closed soyuka closed 2 months ago

soyuka commented 8 months ago

Tried:

        $requires = [];
        $package = $composer->getPackage();
        foreach ($package->getRequires() as $key => $require) {
            if (in_array($require->getTarget(), $packages, true)) {
                $constraint = $require->getConstraint();
                $prettyString = '*@dev || ' . $constraint->getPrettyString();
                $newConstraint = new MultiConstraint([new MatchAllConstraint(), $constraint], false);
                $newConstraint->setPrettyString($prettyString);
                $require = new Link($require->getSource(), $require->getTarget(), $newConstraint, Link::TYPE_REQUIRE, $prettyString);
            }

            $requires[$key] = $require;
        }

        $package->setRequires($requires);

But it doesn't work, it says 20240229_18h24m48s_grim

CrochetFeve0251 commented 2 weeks ago

Hey @soyuka, I am not sure it is exactly the same issue as here, but it is similar: image

Let me provide you some context about this screenshot.

This is from Launchpad, a WordPress framework I am working on and which is extremely modular, and due to that it became really hard to keep it stable, and this is why I decided to move to a mono repository.

Inside the repo I have tons of dependencies but lets focus only on the ones important here.

What I succeeded to isolate to recreate the bug is to install the following packages in my mono repo:

Then, when you run the command composer all install or composer all update, it should raise the error mentioned when the libraries are normally working together without any issues.

I created a repo to reproduce the issue with less dependencies: https://github.com/CrochetFeve0251/mono-repo-problem

soyuka commented 2 weeks ago

Use link with this plugin instead :)

CrochetFeve0251 commented 2 weeks ago

@soyuka Thanks I think I finally got it.

I was trying to reproduce what you had done in your test example. I didn't get that what you added on the root composer.json wasn't dependencies used by other libraries inside the monorepo but instead the top level library themselves, so then they could have the "minimum-stability": "dev", being shared to them and the all-automation work.

Errata I forgot some "minimum-stability": "dev", inside of my main library which made it work, but now I removed it, it still doesn't work even if I tried to use the command link on the repo as the minimum-stability attribute still refuses dev dependencies :')