-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add config file support to @wordpress/env #18121
Add config file support to @wordpress/env #18121
Conversation
We will use this info to build the docker config object
It resolves the dependencies from the .wpenv file and returns them in the same "context" format as detect-context.
Autopopulates the docker config with volume mappings for the dependency contexts.
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.
Great work here, almost ready to merge!
- Rename pathName to pathBasename - Use .wp-env instead of .wpenv - Inline useless function - Clarify default param in jsdoc for detectContext
Thanks @epiqueras! I resolved your feedback and added dependency activation to the clean command. Ready for another look now :) |
I might be a bit late here but I wonder about supporting the generic I believe we already make use of environment variables in some of these configs, so it seems like a natural fit? |
@noahtallen Thanks for the iteration, one last thing to fix. @youknowriad Using environment variables for arrays is really hard to wrangle and is a ripe incompatibility and conflict area in different OSs. Furthermore, I wouldn't be surprised if WP requires us to add a lot more options down the road. What I do think we should do is add the |
@epiqueras Something like |
I removed dependency activation for the test environment |
Exactly. What do you think? It seems like most tools are gravitating towards this now to be explicit. Just looking at other config files in this repo supports this. |
docker-compose and docker are already relying on I see two main pros:
I agree that arrays are difficult but there are workarounds (comma separation...). |
Docker uses YAML files.
We would also have to prefix every variable to avoid conflicts. It's just not practical. |
@noahtallen Let's go with JSON for the detection reasons. |
done |
Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com>
@epiqueras Feel free to merge :) (I don't have access) |
We need to update the README for this. |
@epiqueras true! Here it is: #18643 |
Thank you! |
This PR needs a post-merge update of its description to reflect the correct filename instead of |
I've updated the description to use |
Description
With this PR, a user can specify a
wp-env.json
file with local dependencies for the tool to load. The goal is to make life easier for plugin devs who need to be working on multiple plugins and/or themes at the same time.wp-env start
command, look in the local directory for awp-env.json
file.plugins
andthemes
array.detect-context
to create context objects for each dependency path. This is the same format used for the local context, which makes things easy. I also added the absolute path to the dependency and basname of the path to the context object so that they can be reused easily.Here is a JSON file I used to test this:
wp-calypso/apps/full-site-editing/full-site-editing-plugin/wp-env.json
That's pretty nasty with the relative paths, but I wanted all developers of the plugin to use it if the repos are in the same top-level directory. For me this is source/gutenberg, source/wp-calypso, etc. Home paths (i.e.
~/source
) don't work since the tilde is not supported infs
, and absolute paths wouldn't be flexible for other devs. I'm open to a better approach here if folks have ideas. :)How has this been tested?
I verified locally that the specified plugins and themes in the wp-env.json file were loaded into the local WordPress install created by
wp-env start
.Types of changes
New Feature.
Checklist:
cc @epiqueras
See here: #17724 (comment)