Make WordPress Core

#63912 closed enhancement (fixed)

Make Composer available via npm run on host machine

Reported by: paulbonneau Owned by: SergeyBiryukov
Priority: normal Milestone: 6.9
Component: Build/Test Tools Version:
Severity: trivial Keywords: has-patch
Cc: Focuses:

Description

Context

Working on a ticket on my wordpress-develop cloned instance, I wanted to lint and format my code but :

  • I couldn't find the command in composer.json in order to do so;
  • I didn't want to install composer nor phpcs on my host machine because those tools are already available in the container spawned.

Solutions

To lint my code I used this command : node ./tools/local-env/scripts/docker.js run -T --rm php composer lint [my_file]

@SirLouen suggested to create a new custom script in package.json enabling developers to directly invoke the composer instance of the wordpressdevelop/php container from their host machine. Implementing this will simplifies future call to composer specific scripts from host machine (linting, formating etc ...).

You will find the modified package.json in the attached .diff and the PR related to this ticket.

Attachments (2)

63912.diff​ (3.9 KB ) - added by paulbonneau 15 months ago.
63912
63912-2.diff​ (789 bytes ) - added by paulbonneau 15 months ago.
corrected diff for 63912-2.diff

Download all attachments as: .zip

Change History (9)

@paulbonneau
15 months ago

corrected diff for 63912-2.diff

#1 follow-up: @SirLouen
15 months ago

  • Milestone Awaiting Review
  • Version trunk

Hey @paulbonneau
Why not using a similar format as the current env:cli command like:

node ./tools/local-env/scripts/docker.js exec php composer
Last edited 15 months ago by SirLouen (previous) (diff)

#2 @SirLouen
15 months ago

  • Milestone → Awaiting Review

This ticket was mentioned in ​PR #9713 on ​WordPress/wordpress-develop by ​@paulbonneau.


15 months ago
#3

## Context
Working on a ticket on my wordpress-develop cloned instance, I wanted to lint and format my code but :

  • I couldn't find the command in composer.json in order to do so;
  • I didn't want to install composer nor phpcs on my host machine because those tools are already available in the container spawned.

##Solutions
To lint my code I used this command : node ./tools/local-env/scripts/docker.js run -T --rm php composer lint [my_file]

​@SirLouen suggested to create a new custom script in package.json enabling developers to directly invoke the composer instance of the wordpressdevelop/php container from their host machine. Implementing this will simplifies future call to composer specific scripts from host machine (linting, formating etc ...).

Trac ticket: (https://core.trac.wordpress.org/ticket/63912)

#4 in reply to: ↑ 1 ; follow-up: @paulbonneau
15 months ago

Replying to SirLouen:

Hey @paulbonneau
Why not using a similar format as the current env:cli command like:

node ./tools/local-env/scripts/docker.js exec php composer

Hello @SirLouen !
I kept docker run over docker exec because it enables the container to be spawned specifically at the command runtime meaning that you can for example, lint your code, even if wordpressdevelop/php container is off.

Thank for your review !

#5 in reply to: ↑ 4 @SirLouen
15 months ago

Replying to paulbonneau:

I kept docker run over docker exec because it enables the container to be spawned specifically at the command runtime meaning that you can for example, lint your code, even if wordpressdevelop/php container is off.

Good idea. I think this is good to go.

#6 @SergeyBiryukov
14 months ago

  • Milestone Awaiting Review → 6.9

#7 @SergeyBiryukov
14 months ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 60803:

Build/Test Tools: Make Composer available via npm run on the host machine.

This enables developers to directly invoke the Composer instance of the wordpressdevelop/php container from their host machine, making it easier to call Composer-specific scripts: linting, formatting, etc.

Props paulbonneau, SirLouen.
Fixes #63912.

Note: See TracTickets for help on using tickets.