Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ npm run build # Production build
- `/lib/` - PHP code
- `/lib/compat/wordpress-X.Y/` - Version-specific features (new PHP features usually go here)
- `/phpunit/` - PHP tests
- `/schemas/json/` - JSON Schemas for `block.json`, `theme.json`, `font-collection.json`, and `wp-env.json` (published to `schemas.wp.org`; tests in `/test/integration/`)
- `/docs/` - Documentation
- `/docs/contributors/` - Contributing guides
- `/docs/explanations/architecture/` - System architecture docs
Expand Down
9 changes: 9 additions & 0 deletions packages/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,15 @@ Options:

You can customize the WordPress installation, plugins and themes that the development environment will use by specifying a `.wp-env.json` file in the directory that you run `wp-env` from.

To enable editor autocomplete and validation, add a `$schema` key:

```json
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"plugins": [ "." ]
}
```

Comment on lines +589 to +597

Copy link
Copy Markdown
Member

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 👍🏻

`.wp-env.json` supports the following fields:

| Field | Type | Default | Description |
Expand Down
10 changes: 9 additions & 1 deletion schemas/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Schemas

The collection of schemas used in WordPress, including the `theme.json`, `block.json` and `font-collection.json` schemas.
The collection of schemas used in WordPress, including the `theme.json`, `block.json`, `font-collection.json`, and `wp-env.json` schemas.

JSON schemas are used by code editors to offer tooltips, autocomplete, and validation.

Expand Down Expand Up @@ -32,6 +32,14 @@ Or in your `font-collection.json`:
}
```

Or in your `.wp-env.json`:

```json
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json"
}
```

For a specific version of the schema, replace `trunk` with `wp/X.X`:

```json
Expand Down
52 changes: 50 additions & 2 deletions schemas/json/wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"description": "The PHP version to use. If null is specified, wp-env will use the default version used with production release of WordPress.",
"oneOf": [
{
"type": "string"
"type": "string",
"pattern": "^[0-9]+\\.[0-9]+$"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wondering if this should match the runtime validator regex in checkVersion

This is a bit stricter, allowing x.x, but not x.x.x for example.

I'm looking at version_compare for examples.

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thorough review! All three items addressed:

  • Added allowUnionTypes: true to the test AJV options
  • Updated port minimum to 0 to match the runtime checkPort validator — you're right it's a non-issue in practice but might as well match
  • Updated phpVersion pattern to ^[0-9]+(?:\.[0-9]+)*$ to match the runtime checkVersion regex, accepting "X", "X.X", and "X.X.X" formats

},
{
"type": "null"
Expand All @@ -51,16 +52,37 @@
"port": {
"description": "The primary port number to use for the installation. You'll access the instance through the port: http://localhost:8888",
"type": "integer",
"minimum": 1,
"maximum": 65535,
"default": 8888
},
"mysqlPort": {
"description": "The port number for the MySQL database. If null, the port is not exposed.",
"oneOf": [
{
"type": "integer",
"minimum": 1,
"maximum": 65535
},
{
"type": "null"
}
]
},
"config": {
"description": "Mapping of wp-config.php constants to their desired values.",
"type": "object",
"additionalProperties": {
"type": [ "string", "number", "boolean" ]
Comment thread
kraftbj marked this conversation as resolved.
Resolved
},
"default": {}
},
"mappings": {
"description": "Mapping of WordPress directories to local directories to be mounted in the WordPress instance.",
"type": "object",
"additionalProperties": {
"type": "string"
},
"default": {}
},
"phpmyadmin": {
Expand All @@ -70,7 +92,16 @@
},
"phpmyadminPort": {
"description": "The port number to access phpMyAdmin. Setting this also enables phpMyAdmin.",
"type": "integer"
"oneOf": [
{
"type": "integer",
"minimum": 1,
Comment thread
kraftbj marked this conversation as resolved.
Resolved
"maximum": 65535
},
{
"type": "null"
}
]
},
"multisite": {
"description": "Whether to set up a multisite installation.",
Expand All @@ -85,6 +116,7 @@
"plugins",
"themes",
"port",
"mysqlPort",
"config",
"mappings",
"phpmyadmin",
Expand Down Expand Up @@ -124,13 +156,20 @@
"testsPort": {
"description": "The port number for the test site. You'll access the instance through the port: http://localhost:8889",
"type": "integer",
"minimum": 1,
"maximum": 65535,
"default": 8889
},
"testsEnvironment": {
"description": "Whether to create the tests environment. Set to false to skip creating test containers, saving resources.",
"type": "boolean",
"default": true
},
"autoPort": {
"description": "Whether to automatically find available HTTP ports when configured ports are busy.",
"type": "boolean",
"default": false
},
"lifecycleScripts": {
"description": "Mapping of commands that should be executed at certain points in the lifecycle.",
"type": "object",
Expand All @@ -144,6 +183,14 @@
"description": "Runs after wp-env clean has finished cleaning the environment.",
"type": "string"
},
"afterReset": {
"description": "Runs after wp-env reset has finished resetting the environment.",
"type": "string"
},
"afterCleanup": {
"description": "Runs after wp-env cleanup has finished cleaning up the environment.",
"type": "string"
},
"afterDestroy": {
"description": "Runs after wp-env destroy has destroyed the environment.",
"type": "string"
Expand All @@ -165,6 +212,7 @@
"env",
"testsPort",
"testsEnvironment",
"autoPort",
"lifecycleScripts"
]
}
Expand Down
Loading