Skip to content

Link specified packages automatically from the extra section in composer.json #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Andrii-Antoniuk opened this issue Feb 11, 2025 · 3 comments · May be fixed by #79
Open

Link specified packages automatically from the extra section in composer.json #78

Andrii-Antoniuk opened this issue Feb 11, 2025 · 3 comments · May be fixed by #79
Labels
enhancement New feature or request

Comments

@Andrii-Antoniuk
Copy link

Andrii-Antoniuk commented Feb 11, 2025

Hello!

First of all - thank you for creating & maintaining this amazing package! 🥳

I'd like to keep the linked-packages.json inside the version control system, but I don't want to add to vcs any files inside vendor folder (as during installation if hash mismatches it will change files anyways, AFAIK).

For this I believe that $storageFile can be defined as following:

 $storageFile = dirname($this->composer->getConfig()->get('vendor-dir')) . DIRECTORY_SEPARATOR . 'linked-packages.json';

Was this ever considered or are there any reasons why not to? Could be a config if needed, or just keep it there.
This will help with automation of setup, since 0 extra steps would be needed to re-link packages on every environment/local setup.

@SanderSander
Copy link
Owner

SanderSander commented Feb 11, 2025

Hey,

I think this is a bit related to #20
The issue is a bit old, and the content a bit outdated and I had time to think it a bit more out.

But I do understand the need to be able to always link specified packages from source control. (For example setting up development environments quickly for multiple developers, or whatever else).

The file linked-packages.json was simply created to store data somewhere and was not intended to be commit in source control, and I rather keep it that way because in the future it can happen that it will contain data that could break another environment when commited in source control. (Think about absolute paths etc, what already is possible for packages that are linked with composer global link).

But that doesn't make it impossible to get what we want ;).

I was thinking about defining packages in composer.json itself that should be linked automatically.

Something in the lines of:

{
  "require-dev": {
    "sandersander/composer-link": "^0.5"
  },
  "config": {
    "allow-plugins": {
      "sandersander/composer-link": true
    }
  },
  "extra": {
    "link": {
      "paths": [
        "../package-a",
        "../package-b"
      ]
    }
  }
}
}

This makes sure that on a composer install everything is linked and with a composer install --no-dev nothing would be linked.

This also gives the developer freedom over his environment and the ability to simple unlink a package through the command line, but without changing the composer.json because it will be registered in locked-packages.json on his environment.

@Andrii-Antoniuk
Copy link
Author

Yes, that's also exactly what I'm thinking about as well.
Sure, I agree that the format doesn't really matter, only the end feature 🫡🙃

Since, for example, cweagans composer patches are also using extra that should be fine to use, mb with package name ("composer-link") so won't be confused/conflicted

Thanks for the reply, hopefully we get it as part of future releases, will follow the repo 🫡🙂

For now, I created a patch for my needs with exact code from issue

@SanderSander
Copy link
Owner

SanderSander commented Feb 11, 2025

You're lucky because I need this feature as well 🙈 I hope to have this in 0.5.1 this week.

@SanderSander SanderSander changed the title Move linked-packages.json outside of vendor Link specified packages automatically from the extra section in composer.json Feb 11, 2025
@SanderSander SanderSander added the enhancement New feature or request label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants