Skip to content
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

wp-env: $schema property is not allowed #62619

Closed
sirreal opened this issue Jun 17, 2024 · 4 comments · Fixed by #62626
Closed

wp-env: $schema property is not allowed #62619

sirreal opened this issue Jun 17, 2024 · 4 comments · Fixed by #62626
Assignees
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Tool] Env /packages/env [Type] Enhancement A suggestion for improvement.

Comments

@sirreal
Copy link
Member

sirreal commented Jun 17, 2024

#36276 added a JSON schema for wp-env, but if the $schema property appears in wp-env configuration, it throws an error:

Invalid /Users/jonsurrell/a8c/wordpress-develop/trunk/.wp-env.json: "$schema" is not a configuration option.

It should allow that property, or possibly even better use the schema to parse configuration.

Originally posted by @sirreal in #36276 (comment)

@sirreal sirreal added [Tool] Env /packages/env [Type] Enhancement A suggestion for improvement. labels Jun 17, 2024
@t-hamano
Copy link
Contributor

Perhaps we need to submit a PR to the Schema Store repository, as was done by theme.json and block.json?

For example, if I directly reference the schema in the Gutenberg repository, it works correctly.

image

However, if I use the same format as block.json or theme.json, it doesn't work.

image

Maybe @ajlende or @gziolo know something about this.

@sirreal
Copy link
Member Author

sirreal commented Jun 17, 2024

Perhaps we need to submit a PR to the Schema Store repository, as was done by theme.json and block.json?

Yes, we should do that, but that's just for inclusion in that directory of schemas.

The issue here is that the tool itself rejects configuration values that it does not recognize:

for ( const key in config ) {
if ( DEFAULT_ENVIRONMENT_CONFIG[ key ] !== undefined ) {
continue;
}
// We should also check root-only options for the root config
// because these aren't part of the above defaults but are
// configuration options that we will parse.
switch ( key ) {
case 'testsPort':
case 'lifecycleScripts':
case 'env': {
if ( options.rootConfig ) {
continue;
}
break;
}
}
throw new ValidationError(
`Invalid ${ configFile }: "${ environmentPrefix }${ key }" is not a configuration option.`
);
}

@sirreal sirreal added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label Jun 17, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jun 17, 2024
@ajlende
Copy link
Contributor

ajlende commented Jun 17, 2024

However, if I use the same format as block.json or theme.json, it doesn't work.

There must be a whitelist for the wp.org redirects somewhere. We made a systems request for the initial JSON Schema. I don't seems to have access to make a systems request, so I'm asking around to get it fixed.

@ajlende
Copy link
Contributor

ajlende commented Jun 17, 2024

I think I know what's going on. The redirects probably don't support dotfiles. I checked the schemastore website and they don't do dotfiles either. I think we should follow their lead and use wp-env.json for the filename instead.

EDIT: Opened #62634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Tool] Env /packages/env [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants