Repository navigation
wp-env: Update JSON Schema with missing properties and add README docs #76115
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0c80e5b
wp-env: Add JSON Schema for .wp-env.json configuration
kraftbj 02cf17b
wp-env: Update existing schema instead of adding a duplicate
kraftbj 38fdeab
Merge remote-tracking branch 'origin/trunk' into env-client-json-schema
kraftbj a256c5c
wp-env: Address schema review feedback
kraftbj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| 'use strict'; | ||
|
|
||
| const Ajv = require( 'ajv' ); | ||
| const schema = require( '../wp-env.schema.json' ); | ||
|
|
||
| describe( 'wp-env schema', () => { | ||
| const ajv = new Ajv( { allErrors: true } ); | ||
| const validate = ajv.compile( schema ); | ||
|
|
||
| it( 'accepts a valid root and env configuration', () => { | ||
| const config = { | ||
| $schema: 'https://schemas.wordpress.org/wp-env.schema.json', | ||
| core: 'WordPress/WordPress#6.8', | ||
| phpVersion: '8.2', | ||
| plugins: [ '.' ], | ||
| port: 8888, | ||
| autoPort: true, | ||
| phpmyadmin: true, | ||
| phpmyadminPort: 3307, | ||
| config: { | ||
| WP_HOME: 'http://localhost:8888', | ||
| WP_SITEURL: 'http://localhost:8888', | ||
| WP_DEBUG: true, | ||
| }, | ||
| env: { | ||
| tests: { | ||
| port: 8889, | ||
| config: { | ||
| WP_DEBUG: false, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| expect( validate( config ) ).toBe( true ); | ||
| } ); | ||
|
|
||
| it( 'rejects unknown root and environment keys', () => { | ||
| const config = { | ||
| port: 8888, | ||
| unknownRootOption: true, | ||
| env: { | ||
| development: { | ||
| testsPort: 9999, | ||
| autoPort: true, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| expect( validate( config ) ).toBe( false ); | ||
| expect( validate.errors ).toEqual( | ||
| expect.arrayContaining( [ | ||
| expect.objectContaining( { | ||
| keyword: 'additionalProperties', | ||
| params: expect.objectContaining( { | ||
| additionalProperty: 'unknownRootOption', | ||
| } ), | ||
| } ), | ||
| expect.objectContaining( { | ||
| keyword: 'additionalProperties', | ||
| params: expect.objectContaining( { | ||
| additionalProperty: 'testsPort', | ||
| } ), | ||
| } ), | ||
| expect.objectContaining( { | ||
| keyword: 'additionalProperties', | ||
| params: expect.objectContaining( { | ||
| additionalProperty: 'autoPort', | ||
| } ), | ||
| } ), | ||
| ] ) | ||
| ); | ||
| } ); | ||
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
|
kraftbj marked this conversation as resolved.
Resolved
|
||
| "$id": "https://schemas.wordpress.org/wp-env.schema.json", | ||
| "title": "wp-env config", | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "$schema": { | ||
| "type": "string" | ||
| }, | ||
| "core": { | ||
| "type": [ "string", "null" ] | ||
| }, | ||
| "phpVersion": { | ||
| "type": [ "string", "null" ], | ||
| "pattern": "^[0-9]+\\.[0-9]+$" | ||
| }, | ||
| "plugins": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "themes": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "port": { | ||
| "type": "integer", | ||
| "minimum": 1, | ||
| "maximum": 65535 | ||
| }, | ||
| "testsPort": { | ||
| "type": "integer", | ||
| "minimum": 1, | ||
| "maximum": 65535 | ||
| }, | ||
| "mysqlPort": { | ||
| "type": [ "integer", "null" ], | ||
| "minimum": 1, | ||
| "maximum": 65535 | ||
| }, | ||
| "phpmyadmin": { | ||
| "type": "boolean" | ||
| }, | ||
| "phpmyadminPort": { | ||
| "type": [ "integer", "null" ], | ||
| "minimum": 1, | ||
| "maximum": 65535 | ||
| }, | ||
| "multisite": { | ||
| "type": "boolean" | ||
| }, | ||
| "testsEnvironment": { | ||
| "type": "boolean" | ||
| }, | ||
| "autoPort": { | ||
| "type": "boolean" | ||
| }, | ||
| "config": { | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "type": [ "string", "number", "boolean" ] | ||
| } | ||
| }, | ||
| "mappings": { | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "lifecycleScripts": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "afterStart": { | ||
| "type": [ "string", "null" ] | ||
| }, | ||
| "afterClean": { | ||
| "type": [ "string", "null" ] | ||
| }, | ||
| "afterReset": { | ||
| "type": [ "string", "null" ] | ||
| }, | ||
| "afterCleanup": { | ||
| "type": [ "string", "null" ] | ||
| }, | ||
| "afterDestroy": { | ||
| "type": [ "string", "null" ] | ||
| } | ||
| } | ||
| }, | ||
| "env": { | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "$ref": "#/definitions/environmentConfig" | ||
| } | ||
| } | ||
| }, | ||
| "definitions": { | ||
| "environmentConfig": { | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "$schema": { | ||
| "type": "string" | ||
| }, | ||
| "core": { | ||
| "type": [ "string", "null" ] | ||
| }, | ||
| "phpVersion": { | ||
| "type": [ "string", "null" ], | ||
| "pattern": "^[0-9]+\\.[0-9]+$" | ||
| }, | ||
| "plugins": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "themes": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "port": { | ||
| "type": "integer", | ||
| "minimum": 1, | ||
| "maximum": 65535 | ||
| }, | ||
| "mysqlPort": { | ||
| "type": [ "integer", "null" ], | ||
| "minimum": 1, | ||
| "maximum": 65535 | ||
| }, | ||
| "phpmyadmin": { | ||
| "type": "boolean" | ||
| }, | ||
| "phpmyadminPort": { | ||
| "type": [ "integer", "null" ], | ||
| "minimum": 1, | ||
| "maximum": 65535 | ||
| }, | ||
| "multisite": { | ||
| "type": "boolean" | ||
| }, | ||
| "config": { | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "type": [ "string", "number", "boolean" ] | ||
| } | ||
| }, | ||
| "mappings": { | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this is a good to have regardless of whether we have a new schema doc or keep on using
https://schemas.wp.org/trunk/wp-env.json👍🏻