Coder Social home page Coder Social logo

Comments (4)

theofidry avatar theofidry commented on June 6, 2024 1

Hi! Glad to find this issue as I was about to open one about it :)

Disclaimer: I'm the current maintainer of https://github.com/bamarni/composer-bin-plugin.


First of all, for clarification an introduction to the plugin: it is only but a tiny wrapper to do a cd before calling composer:

$ composer bin phpstan install phpstan/phpstan
> parses the composer command to see if it starts with "bin "
> parses the namespace (here "phpstan")
> creates the directory "vendor-bin/phpstan" if does not already exist
> do "cd vendor-bin/phpstan"
> strip the command from the bin directory, i.e. the new command is "composer install phpstan/phpstan"
> execute this new composer command (in the directory)

I may have forgotten a detail or two but this is what it boils down to and it doesn't do more because I don't want to start to temper with more internal Composer code/behaviour.


A current possible solution, as highlighted by @Aerendir is to leverage the working-directory option:

            -   name: Install Composer PHPStan dependencies
                uses: ramsey/composer-install@v1
                with:
                    working-directory: 'vendor-bin/phpstan'

will work just fine.

The downside however is the symlinks but as you can see in bamarni/composer-bin-plugin#60 (comment) relying on the symlinks is a bad idea IMO. In fact I always disable symlinks whenever I use this plugin and I'm definitely gonna remove it in 2.0.


Regarding @Aerendir issue: I don't get the autoload part. You can check bamarni/composer-bin-plugin#57 for more details but there is no autoload concatenation of any sort.


In the current form, to support such a plugin, the best way to do it in the most "generic" way would be to offer a way to add a prefix option, for example:

            -   name: Install Composer dependencies
                uses: ramsey/composer-install@v1
                with:
                    composer-prefix-option: 'bin phpstan'

However I must say it does not look very elegant and IMO this is due to the design of this GitHub Actions that adds a layer of abstraction on what command to execute (the "locked", "highest" and "lowest" options). If instead you let the user pass the options, i.e. instead of "lowest" you do:

            -   name: Install Composer dependencies
                uses: ramsey/composer-install@v1
                with:
                    command: 'update'
                    composer-options: '--prefer-lowest'

The adding support for the plugin is already done:

            -   name: Install Composer dependencies
                uses: ramsey/composer-install@v1
                with:
                    command: 'bin phpstan update'
                    composer-options: '--prefer-lowest'

from composer-install.

ramsey avatar ramsey commented on June 6, 2024 1

I think providing a command argument might work. If it's present, it would override dependency-versions, and users would need to use composer-options to specify whether to prefer lowest, etc., but this could be made clear in the documentation.

I'll think on this a bit and ask any questions I have on this thread.

from composer-install.

ramsey avatar ramsey commented on June 6, 2024

Hi! Thanks for the feature request.

I've never used bamarni/composer-bin-plugin, nor am I familiar with it. I hesitate to add support for a Composer plugin like this, since it means I'll need to maintain support for something I don't use and, therefore, I won't be able to do a good job supporting it.

It sounds like your workflow falls outside the scope of this tool and requires more customization than most users will need. Have you considered forking this action, instead?

from composer-install.

Aerendir avatar Aerendir commented on June 6, 2024

First of all, thank you for the fast reply :)

I understand well your point and agree with it.

I've not considered to fork this action as I'm not able to maintain it as I'm not very versed in its language... Actually I don't know it, so I'm not able to modify it to adapt to my use case.

For what I saw, I think it is simply an if condition to check if the key bin is passed and, if it is, add it to command.

If it may help you deciding, I can tell you that the plugin has a very simple "frontend": it only requires to use bin [folder] and nothing else: no options nor parameters, so, also the maintaining is very easy in the long run.

I would appreciate much a direct support for it as I know it is very used in projects that relies on a lot of dev dependencies (rector, phan, phpstan, php cs fixer, etc.).

I'm in your hands! 😬

from composer-install.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.