@wordpress/env: Allow temporarily overriding settings in .wp-env.json
#20324
Labels
[Status] In Progress
Tracking issues with work in progress
[Tool] Env
/packages/env
[Type] Enhancement
A suggestion for improvement.
It is useful while working on Gutenberg to run the development environment using a different setup to the one provided by default in Gutenberg's
~/.wp-env.json
configuration.Some examples:
"core": "~/path/to/wordpress-develop/build"
."core": null
."core": "WordPress/WordPress#5.2.0"
.gutenberg-starter-theme
theme.Here, I propose two approaches for accomplishing this. I think that we could implement one or both approaches.
Approach 1: Command line arguments
wp-env start
could be modified to accept command line arguments that, if specified, override the associated values that are in.wp-env.json
.With this approach, you could start the development server using the latest production version of Gutenberg by running:
Starting the development server with different plugins and themes would work similarly:
Considerations:
--core
would accept a string, and--plugins
and--themes
would accept an array of strings.--core null
will technically causeyargs
to parsecore
as the literal string'null'
. We'll need to modify the source parser to treat'null'
as a special string literal which meansnull
.wp-env
with these command line arguments in a directory that is not a WordPress installation, plugin or theme; or in a directory does not contain a.wp-env.json
file.--plugins
and--themes
overrides the setting in.wp-env.json
or appends to the setting in.wp-env.json
.Approach 2:
.wp-env.override.json
wp-env start
could be modified to look for a file called.wp-env.override.json
which, if it it exists, will be merged with the.wp-env.json
file. This is similar todocker-compose.override.yml
.Gutenberg would then add
.wp-env.override.json
to its.gitignore
file, meaning that developers can configure their environment exactly how they like it without worrying about stashing and re-stashing changes.Fields in
.wp-env.override.json
would take precedence over fields in.wp-env.json
using the same semantics as the object spread operator ({ ...config, ...overrides }
).That is, if one has the following
.wp-env.json
:And the following
.wp-env.override.json
:The final configuration would be:
cc. @epiqueras @noahtallen
The text was updated successfully, but these errors were encountered: