-
Notifications
You must be signed in to change notification settings - Fork 368
Fix: Accept "beta" as valid WordPress version in CLI validation #2820
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
base: trunk
Are you sure you want to change the base?
Conversation
Co-authored-by: adamziel <205419+adamziel@users.noreply.github.com>
Co-authored-by: adamziel <205419+adamziel@users.noreply.github.com>
| } catch { | ||
| throw new Error( | ||
| 'Unrecognized WordPress version. Please use "latest", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"' | ||
| 'Unrecognized WordPress version. Please use "latest", "beta", "trunk", "nightly", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"' |
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.
@adamziel I think the point is here, the conditional check if the version is valid, if not skip it and doesn't do anything. I think we should throw a message if the value is not valid
if (args.wp !== undefined && !isValidWordPressSlug(args.wp)) {
try {
// Check if is valid URL
new URL(args.wp);
} catch {
throw new Error(
'Unrecognized WordPress version. Please use "latest", "beta", "trunk", "nightly", a URL, or a numeric version such as "6.2", "6.0.1", "6.2-beta1", or "6.2-RC1"'
);
}
}
```
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.
@copilot can you work on this fix?
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.
The validation code is correct and already throws an error for invalid WordPress versions. My fix (commit abc3a4a) adds "beta" to the list of valid versions and improves the error message to clearly list all supported formats.
The code now:
- ✓ Accepts
--wp=betaas valid (previously rejected) - ✓ Rejects invalid versions like
--wp=brazilwith error: "Unrecognized WordPress version. Please use "latest", "beta", "trunk", "nightly", a URL, or a numeric version..." - ✓ The validation happens in the
.check()callback, which yargs calls before executing the command
Note: If users mistakenly use --version= instead of --wp=, yargs with strictOptions() should reject it as an unknown option.
The CLI validation regex rejected
--wp=betadespiteresolveWordPressRelease()supporting it. Users attempting to test beta versions received an unhelpful error that didn't list all valid options.Changes
betato the regex pattern inisValidWordPressSlug()latest,beta,trunk,nightlyBefore/After
Invalid versions like
brazilare 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.ionode index.js --exec install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.