Skip to content

Conversation

@justinbeaty
Copy link
Contributor

@justinbeaty justinbeaty commented Aug 21, 2022

Description (*)

There were a few issues with the merge of #2400

  1. Hardcoded vendor dir (minor issue, ref)
  2. Bash syntax caused an error on Windows (ref)
  3. Global PHP version is called even if you do something like /usr/local/opt/[email protected]/bin/php composer install (ref)

I fixed this by making a PHP script that should be platform independent and fix all three issues.

Related Pull Requests

#2400

Fixed Issues (if relevant)

Manual testing scenarios (*)

  1. Make sure it installs correctly on Linux as it did before -- @sreichel please check this, I don't know how to verify
  2. Make sure composer install doesn't throw an error on Windows -- @addison74 please check this
  3. Make sure composer install works correctly when calling with a non-system php install -- @fballiano please check this

Questions or comments

I added the dev/scripts directory and an autoload entry in composer.json. The new directory could be used for other composer scripts.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added the composer Relates to composer.json label Aug 21, 2022
@sreichel
Copy link
Contributor

Nice! For me it works.

Only downside is that exec() is possibly disabled on shared hosts.

@justinbeaty
Copy link
Contributor Author

Nice! For me it works.

Only downside is that exec() is possibly disabled on shared hosts.

I put a check for exec so we don't terminate the script if it's not available (for example if we did other stuff in that PHP file).

The only thing we could do to get around exec being disabled is if PHP_CS has a PHP API we could call. Not sure it's needed unless people will be running dev tools on shared hosting, though.

sreichel
sreichel previously approved these changes Aug 21, 2022
@sreichel
Copy link
Contributor

Just an idea ...

  • rename class Devel to SetupPhpCs
  • change method name to run(Event $event) and maybe add an interface
interface ScriptInterface
{
    public static function run(Event $event);
}

@justinbeaty
Copy link
Contributor Author

@sreichel The interface is a good idea. I had named it Devel in case we wanted to do other things there without making tons of PHP files, but I'm okay with either way. You'll probably know more about what sort of tools might need to be initialized in the future.

It's getting late here so I'll make the changes tomorrow (or a maintainer is free to push).

@sreichel
Copy link
Contributor

in case we wanted to do other things there without making tons of PHP files, but I'm okay with either way.

This is what i really like from M2 ... Single Responsibility for each class.

@justinbeaty
Copy link
Contributor Author

justinbeaty commented Aug 22, 2022

👍 on all the changes!

sreichel
sreichel previously approved these changes Aug 22, 2022
@sreichel sreichel dismissed their stale review August 22, 2022 07:25

Better use composer plugin?

@fballiano
Copy link
Contributor

This scripts will for sure be used for some other tasks but I think now we should go with #2470 :-)

@fballiano fballiano closed this Aug 22, 2022
@sreichel
Copy link
Contributor

This scripts will for sure be used for some other tasks

Definitly! 👍

@addison74
Copy link
Contributor

@justinbeaty's work must be appreciated. Since my finding yesterday and until today there have been constructive discussions. The approach in this PR is interesting and shows that the use of Composer is extremely powerful for this project.

@justinbeaty
Copy link
Contributor Author

#2470 is better :)

At least we have a framework set up in the case we need custom composer scripts that aren't handled by a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

composer Relates to composer.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants