Make WordPress Core

Opened 6 months ago

Closed 5 months ago

#63912 closed enhancement (fixed)

Make Composer available via npm run on host machine

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

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 6 months ago.
63912
63912-2.diff (789 bytes) - added by paulbonneau 6 months ago.
corrected diff for 63912-2.diff

Download all attachments as: .zip

Change History (9)

@paulbonneau
6 months ago

63912

@paulbonneau
6 months ago

corrected diff for 63912-2.diff

#1 follow-up: @SirLouen
6 months ago

  • Milestone Awaiting Review deleted
  • Version trunk deleted

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 6 months ago by SirLouen (previous) (diff)

#2 @SirLouen
6 months ago

  • Milestone set to Awaiting Review

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


6 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
6 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
6 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
5 months ago

  • Milestone changed from Awaiting Review to 6.9

#7 @SergeyBiryukov
5 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to 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.