Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#43558 closed enhancement (fixed)

Add `composer.json` file for development dependencies

Reported by: clarinetlord's profile clarinetlord Owned by: pento's profile pento
Milestone: 5.1 Priority: normal
Severity: normal Version: 5.1
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

I understand #43449 and why a composer.json isn't part of the release package or part of https://github.com/WordPress/Wordpress, but I don't see any reason why a basic composer.json file couldn't be a part of the core project.

It would live at the root alongside all the other config files, and wouldn't need any dependencies (yet). The main benefit at present would be for it to show up in https://github.com/WordPress/wordpress-develop so others (like myself) can use it more easily in composer-built projects ran against the core test suite, like for plugin development.

Attachments (2)

43558.diff (7.7 KB) - added by netweb 6 years ago.
43558.2.diff (1.0 KB) - added by netweb 6 years ago.

Download all attachments as: .zip

Change History (14)

#1 follow-up: @swissspidy
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #23912.

#2 in reply to: ↑ 1 @clarinetlord
7 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Replying to swissspidy:

Duplicate of #23912.

This ticket that you marked mine a duplicate of is different than mine. I'm not proposing adding composer.json to the distribution package as #23912 is discussing. I think @JohnPBloch's mirror works just fine for production WordPress dependency management. I'm suggesting only adding a composer file to the root of the develop repo, alongside package.json and the other config/meta files.

#3 @SergeyBiryukov
6 years ago

  • Milestone set to Awaiting Review

#4 follow-up: @netweb
6 years ago

Copying in @GaryJ's ticket:23912#comment:98 for further context:

Treating WordPress as a dependency of a site may not be the prevalent use case across all WP installs, but it is popular and handy for those that have taken that approach. I personally use WPStarter but other wrappers of WP are available too.

Something not mentioned so far, and that has changed since this ticket has started, is the use of PHP_CodeSniffer. Obviously, PHPUnit has been in use since before this ticket as well.

These core development dependencies should be documented in the composer.json require-dev section, so that we explicitly declare and isolate dependencies. Running versions earlier than PHP_CodeSniffer 3.2 will cause different results than 3.2+, for instance. WP should not be relying on globally installed dependencies of varying versions.

The .travis.yml files shows PHPUnit can be used at version 4, 5 or 6, depending on the PHP version available - and that's great, but get it down in a composer.json, and a composer install means that the switch statement can be dropped, and developers working locally can get the right version too.

Whatever the rest of the composer.json does or doesn't do for the external benefit of those consuming this package, having a simple composer.json which lists the development dependencies gives internal benefit to contributors and automated tools.

@netweb
6 years ago

#5 @netweb
6 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to pento
  • Status changed from reopened to reviewing
  • Summary changed from Add composer.json file to Add `composer.json` file for development dependencies

I discussed this with @pento today, and we are both in agreement in landing this for WP 5.0

The 43558.diff patch installs the following require-dev packages:

  • squizlabs/php_codesniffer - PHPCS
  • wp-coding-standards/wpcs WordPress PHP Coding Standards for - PHPCS
  • dealerdirect/phpcodesniffer-composer-installer - PHPCS ruleset installer

Additional Composer require-dev packages can be considered in new tickets on a case-by-case basis.

Related: #43218 PHPUnit 7.x support

Related: 41057-grunt.diff

#6 @pento
6 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 42960:

Build Tools: Add a composer.json for development environments.

This allows Core developers to more easily run coding standards checks on PHP code.

Props netweb.
Fixes #43558.

#7 @pento
6 years ago

@netweb: could you open a new ticket for:

  • Fixing the coding standards issues that compose run-script format finds.
  • Adding a grunt precommit task to run the format script.
  • Adding a new Travis job that checks that running the format script doesn't change anything.

#8 @ocean90
6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Minor, but can we update the description to match the new tagline on w.org?

WordPress is open source software you can use to create a beautiful website, blog, or app.

#9 @pento
6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 42961:

Build Tools: Update the description in package.json and composer.json.

The description now matches the tagline on the front page of WordPress.org.

Props ocean90.
Fixes #43558.

@netweb
6 years ago

#10 in reply to: ↑ 4 @johnbillion
6 years ago

Replying to netweb:

Copying in @GaryJ's ticket:23912#comment:98 for further context:

The .travis.yml files shows PHPUnit can be used at version 4, 5 or 6, depending on the PHP version available - and that's great, but get it down in a composer.json, and a composer install means that the switch statement can be dropped, and developers working locally can get the right version too.

A note for anyone who tries to tackle this: The concept of conditional dependencies does not exist in Composer, which is why this logic is in .travis.yml and why (AFAIK) we can't add PHPUnit as a Composer dependency.

#11 @kasparsd
6 years ago

Could we add https://github.com/WordPress/wordpress-develop to the wordpress vendor on Packagist? Who has access to do that?

#12 @jorbin
6 years ago

  • Milestone changed from 5.0 to 5.1
Note: See TracTickets for help on using tickets.