-
Notifications
You must be signed in to change notification settings - Fork 34
dev: Composer polish #42
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
dev: Composer polish #42
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 polishes the Abilities API to function as both a WordPress plugin and a Composer library, providing flexible installation and usage options. The changes allow developers to either install the complete plugin with REST API endpoints or include just the core classes as a dependency.
- Switched composer type back to
wordpress-pluginto enable plugin installation via Composer - Removed autoload configuration in favor of manual
require_oncefor better control over loading - Added comprehensive installation and usage documentation covering multiple scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| composer.json | Changed type to wordpress-plugin and removed autoload configuration |
| includes/bootstrap.php | Added version constant and updated documentation for library usage |
| docs/2.getting-started.md | Added comprehensive installation guides for plugin and dependency usage |
| abilities-api.php | Minor formatting cleanup (removed extra blank line) |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## update/composer-configuration #42 +/- ##
================================================================
Coverage ? 91.61%
Complexity ? 93
================================================================
Files ? 8
Lines ? 513
Branches ? 0
================================================================
Hits ? 470
Misses ? 43
Partials ? 0
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:
|
| # 2. Getting Started | ||
|
|
||
| ## Installation Options | ||
| ## Installation |
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.
Personally I'd make this a separate INSTALLATION.md doc, but because the doc-files are # prefixed, I didnt want to blow up the diff here.
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.
We can update that part after the package is available on Packagist.
|
|
||
| ### As a plugin | ||
|
|
||
| The best and easiest way to try and use the Abilities API is to install it as a plugin by downloading the latest release from the [GitHub Releases page](https://github.com/WordPress/abilities-api/releases/latest). |
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.
This requires us to cut a release (but so does composer). Can use the path to trunk in the interim, I just didn't want to rewrite something that's anyway needs to be rewritten by a competent docs writer
|
|
||
| Plugin authors and developers may wish to rely on the Abilities API as a dependency in their own projects, before it is merged into core. You can do that in one of the following ways. | ||
|
|
||
| #### As a Plugin Dependency (Recommended) |
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.
Even without it being on .org (and therefore available to autoinstall), I believe this should still be Recommended , since we want to ensure people are testing with the latest versions for the next few months, and not some potentially-deconflicted library.
But if you disagree, drop it.
|
|
||
| Until the plugin is available on Packagist, you will need to add the repository to your `composer.json` file. | ||
|
|
||
| ```jsonc | ||
| { | ||
| "repositories": [ | ||
| { | ||
| "type": "vcs", | ||
| "url": "https://github.com/WordPress/abilities-api.git" | ||
| } | ||
| // ... other repositories. | ||
| ], | ||
| // ... rest of your composer.json. | ||
| } | ||
| ``` |
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.
Removed once we're on packagist.
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.
Mainly just cleaning up the composer specific comments.
| * Useful to confirm you're using the latest version of the Abilities API. | ||
| */ | ||
| if ( ! defined( 'WP_ABILITIES_API_VERSION' ) ) { | ||
| define( 'WP_ABILITIES_API_VERSION', '0.1.0' ); |
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.
Not sure if this was intentionally removed, but we need it for MCP Adapter / Experiments for the next 3 months if we want to be able to allow this library to evolve.
| "installer-paths": { | ||
| // This should match your WordPress+Composer setup. | ||
| "wp-content/plugins/{$name}/": [ | ||
| "type:wordpress-plugin" |
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.
This is what we lose by making type: library instead of wordpress-plugin. We gain nothing.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
NOTE: This is only here for reviewers because there seems to be some confusion about WordPress Plugins and composer usage (also in MCP Adapter... ) so I wanted clear illustration I could point to. Would recommend @jonathanbossenger or someone else better than I to review before final merge.
20d46e2 to
0cad3fe
Compare
What
This PR polishes up #35 , making it usable as both a WordPress plugin and a Composer library.
How
wordpress-plugin, allowing for plugin installation usingcomposer.json:extra.composer.json:autoloadprop in favor of manuallyrequire_once, depending on if the user wants the REST API endpoints (and the rest of the plugin) or just the API classes and functions.WP_ABILITIES_API_VERSIONconst for version targeting, moved intobootstrap.phpMore specific comments inline.
Additional notes
I'm not entirely sure the use case of wanting to
require_oncethe classes but not hook the REST API endpoints. Without it, we dont need a separate "library vs plugin" bootstrap, devs can can justrequire_oncethe same rootabilities-api.phpas WordPress core would do if it was located inwp-content/pluginsinstead ofmy-plugin/vendor/*.Left it in this PR to respect the Chesterton fence (though I'm like 95% sure it's just an artifact of from the prior art and not relevant here).