Fix: Accept "beta" as valid WordPress version in CLI validation
The CLI validation regex rejected --wp=beta despite resolveWordPressRelease() supporting it. Users attempting to test beta versions received an unhelpful error that didn't list all valid options.
Changes
-
Validation: Added
betato the regex pattern inisValidWordPressSlug() -
Error message: Updated to explicitly list all keyword versions:
latest,beta,trunk,nightly - Tests: Added unit and integration tests for version validation
Before/After
# Before
$ wp-playground server --wp=beta
Error: Unrecognized WordPress version. Please use "latest", a URL, or a numeric version...
# After
$ wp-playground server --wp=beta
Starting a PHP server...
Setting up WordPress beta
Resolved WordPress release URL: https://wordpress.org/wordpress-6.8-beta1.zip
Invalid versions like brazil are still rejected, now with clearer guidance on valid formats.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
download.cypress.io
- Triggering command:
node index.js --exec install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>[CLI] Throws a message for invalid WordPress version</issue_title> <issue_description>### Prerequisites
- [x] I have carried out troubleshooting steps and I believe I have found a bug.
- [x] I have searched for similar bugs in both open and closed issues and cannot find a duplicate.
Describe the bug
When an invalid value is passed to the flag
--wpon playground CLI, it loads the latest version without notifying the users. It can be confusing if the user passes an invalid flag.for example, I have requested the beta version, similar behavior to the web version of the playground, and it downloads version 6.8.3:
npx @wp-playground/cli@latest server --version=beta Starting a PHP server... Setting up WordPress latest Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.3.zip Fetching SQLite integration plugin... Booting WordPress... PHP.request() is deprecated. Please use the new PHPRequestHandler() instead. Booted! Running the Blueprint... Running the Blueprint – 100% Finished running the blueprint WordPress is running on http://127.0.0.1:9400 with 1 worker(s)First, I was confused it was a bug on the CLI related to the beta version, later I realized beta is not a valid value for the flag
--wp:npx @wp-playground/cli@latest server --version=brazil Starting a PHP server... Setting up WordPress latest Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.3.zip Fetching SQLite integration plugin... Booting WordPress... PHP.request() is deprecated. Please use new PHPRequestHandler() instead. Booted! Running the Blueprint... Running the Blueprint – 100% Finished running the blueprint WordPress is running on http://127.0.0.1:9400 with 1 worker(s)Expected behavior
The CLI should notify the user that the flag is not valid
- Ideally, suggest one of the valid versions without crashing
Actual behavior
The CLI is loading the latest version without notifying users that the flag has an invalid value
Steps to reproduce
- Go to the terminal
- Run
npx @wp-playground/cli@latest server --version=brazil- Check the output
Isolating the problem
- [ ] I have deactivated other plugins and confirmed this bug occurs when only this plugin is active.
- [ ] This bug happens with a default WordPress theme active.
- [ ] I can reproduce this bug consistently using the steps above.</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes WordPress/wordpress-playground#2816
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.