-
Notifications
You must be signed in to change notification settings - Fork 29
Chore: Configure the composer package for publishing #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR configures the WordPress Abilities API package for publication and consumption as a Composer package. The changes prepare the codebase for distribution by establishing proper autoloading, removing embedded hooks, and adding distribution configuration.
- Adds Composer autoload configuration with a bootstrap file for automatic class and function loading
- Removes embedded WordPress action hooks from library classes to allow consumer control
- Configures Git attributes to exclude development files from distributed packages
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
composer.json | Adds autoload configuration, updates metadata, and reorganizes structure for package distribution |
includes/bootstrap.php | New bootstrap file that conditionally loads core classes and functions for Composer autoloading |
abilities-api.php | Replaces direct file includes with Composer autoloader detection and moves hook registration |
includes/rest-api/class-wp-rest-abilities-init.php | Removes embedded WordPress action hook to allow consumer control |
.gitattributes | Configures export-ignore rules to exclude development files from distributed packages |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
"phpstan/extension-installer": true, | ||
"composer/installers": true | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved a few things around, so the order is similar to https://github.com/WordPress/php-ai-client/blob/trunk/composer.json. That made auditing easier for me.
The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick test of git archive
shows we're getting the desired outcome.
Some nits in the gitattributes that only matter if someone wants to use the file as prior art, but considering the 6.9 merge and that anybody using a release version and not a dev-*
branch will get the GH release .zip, they can probably be ignored.
git archive --format=tar HEAD -o repo.tar && tar -tf repo.tar
.wordpress-org/
CONTRIBUTING.md
LICENSE.md
README.md
abilities-api.php
composer.json
docs/
docs/1.intro.md
docs/2.getting-started.md
docs/3.registering-abilities.md
docs/4.using-abilities.md
includes/
includes/abilities-api.php
includes/abilities-api/
includes/abilities-api/class-wp-abilities-registry.php
includes/abilities-api/class-wp-ability.php
includes/bootstrap.php
includes/rest-api/
includes/rest-api/class-wp-rest-abilities-init.php
includes/rest-api/endpoints/
includes/rest-api/endpoints/class-wp-rest-abilities-list-controller.php
includes/rest-api/endpoints/class-wp-rest-abilities-run-controller.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gziolo Overall this looks solid to me, though I have a high level question about the approach in #13 (comment) - why do we want to publish this on Packagist (vs having it as a plugin on .org and thus also on wpackagist.org)?
c4d3c17
to
7fd57a3
Compare
I responded in the issue. The short version is that, for now, I was willing to replicate how WP Feature API was structured for distribution, and it turns out they offered a Composer library. I updated the config to reflect it in 55fab93. I addressed all the feedback. This is what I see in the archive fter executing ![]() Should we also exclude the top-level |
"license": "GPL-2.0-or-later", | ||
"type": "wordpress-plugin", | ||
"version": "0.1.0", | ||
"type": "library", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strongly disagree with this change. Nothing prevents anybody from using a wordpress-plugin
as a library. But if anybody (including MCP Adapter or Experiments) tries to test this using Composer as a plugin dependency, they can't if it's a library
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give me time to test using |
Our main goal for this in the Feature API was to make it possible for plugins to bundle the Feature API as a dependency, without the end user needing to install a separate plugin. This was the reason for the version loader as well. |
Felix, Jeff, and I had a chat about the wordpress-plugin vs library type discussion. Let's go with the library type to unblock things, mainly so other plugins like Elementor/Woo/Hosting MU etc can include this as a traditional package. This decision is made in part with the understanding that this will go core in 6.9, so we’re treating this as a transitional setup. We recognize the concern that calling it a library may limit some Composer use cases (e.g., plugin dependencies). However, since wordpress-plugin can still be consumed as a library but not always vice versa, we’ll document usage patterns clearly so consumers understand the intended workflows. If needed, we can revisit the package type once the 6.9 merge has landed and the distribution model stabilizes. For now, prioritizing unblock and compatibility with large plugin ecosystems outweighs the downside, and the configuration should make adoption easier in the short term while keeping a path open for refinement later. |
This is a false premise. Elementor/Woo/Hosting MU can all use something with a
To me this reads like a justification for using
This also seems like a false premise. What becomes "unblocked" or "compatible" by using "library" over "wordpress-plugin" , and how does the configuration make adoption easier in the short term? |
Added version definition for the plugin and improved comments.
20d46e2
to
0cad3fe
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #35 +/- ##
============================================
- Coverage 89.82% 88.43% -1.39%
Complexity 94 94
============================================
Files 7 8 +1
Lines 511 519 +8
============================================
Hits 459 459
- Misses 52 60 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I rebased this branch and applied a couple of small fixes based on the work shared by @justlevine in #42. Taking into account the decision to go with type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there anything missing in this PR before we land it
lgtm 🚀
and create a git tag with v0.1.0 release?
Not strictly necessary for a v0.1.0, but do you want me to backport the relevant doc changes from #42 into a new PR?
That would be very helpful! |
Prepare the composer package for publication and consumption by WordPress plugins.
For complete transparency, I reused some of the configurations from:
I also used AI (GitHub Copilot coding agent) extensively to configure everything so it works both as a WP plugin and shares only
includes
through Composer. I avoided using namespaces to keep things simplified and usedautoload.files
to bootstrap all necessary files.Testing
Some checks that I executed
Validate composer config
Result contained deprecation notices and a success message:
Files included in the git archive
Result