-
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
@wordpress/env: A zero-config, self contained local WordPress environment for development and testing. #17724
Comments
Neat! I saw this comment on the original PR:
I ended up modifying version: '3.7'
services:
wordpress-develop:
volumes:
- '/Users/noah.allen/source/wp-calypso/apps/full-site-editing/full-site-editing-plugin:/var/www/${LOCAL_DIR-src}/wp-content/plugins/full-site-editing-plugin'
- '/Users/noah.allen/source/themes/varia/:/var/www/${LOCAL_DIR-src}/wp-content/themes/varia'
- '/Users/noah.allen/source/themes/maywood/:/var/www/${LOCAL_DIR-src}/wp-content/themes/maywood'
- '/Users/noah.allen/source/gutenberg:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg'
- '/Users/noah.allen/source/gutenberg/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins'
- '/Users/noah.allen/source/gutenberg/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins'
php:
volumes:
- '/Users/noah.allen/source/wp-calypso/apps/full-site-editing/full-site-editing-plugin:/var/www/${LOCAL_DIR-src}/wp-content/plugins/full-site-editing-plugin'
- '/Users/noah.allen/source/themes/varia/:/var/www/${LOCAL_DIR-src}/wp-content/themes/varia'
- '/Users/noah.allen/source/themes/maywood/:/var/www/${LOCAL_DIR-src}/wp-content/themes/maywood'
- '/Users/noah.allen/source/gutenberg:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg'
- '/Users/noah.allen/source/gutenberg/packages/e2e-tests/plugins:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg-test-plugins'
- '/Users/noah.allen/source/gutenberg/packages/e2e-tests/mu-plugins:/var/www/${LOCAL_DIR-src}/wp-content/mu-plugins'
cli:
volumes:
- '/Users/noah.allen/source/gutenberg:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg'
phpunit:
volumes:
- '/Users/noah.allen/source/gutenberg:/var/www/${LOCAL_DIR-src}/wp-content/plugins/gutenberg' |
Hi Noah, There are 2 ways you can do this:
Basically, the tool mounts the plugin or theme you run it on, but you can manually add more after that. |
Hm interesting. Do you mean manually dropping those folders in the right places in the WordPress install, like I don't know how feasible that is since our particular use case is 2 monorepos:
(and then, of course, it would be nice to also have access to gutenberg master at the same time :D) The use case is that developing a singular plugin in our case also means working with themes and some other items. I'm always a big fan of automation, so I wonder what something might like like to more easily specify which plugins/themes ought to be loaded? For example, maybe |
Yeah, I see how manually dropping them can get complicated. Could you set it to be the output of your build processes maybe? In any case, I think that this will be required by more people now so it makes sense to have a first class solution. I like those ideas. What if, we use environment variables What do you think? |
I think this is a cool idea! I think defining a {
"themes": {
"theme-name": "path-to-theme"
},
"plugins": {
"plugin-name": "path-to-plugin"
}
} or maybe with arrays: {
"themes": [
"path-to-theme",
],
"plugins": [
"path-to-plugin"
]
} I think these should also be linked instead of copied. Perhaps these could be added to the Docker volumes of the wp container? |
Let's go with that.
That's the plan 😄 |
What do you mean by a specific setup? I'm not fussed if Core and Gutenberg has seperate development tooling, but I do think that the approach that
|
E.g. They inject a custom NGINX config to handle some nuance around how things are served from either
Aren't those two the same thing? The thing is that What do you think about introducing a Or just keeping both tools? |
By switching between repos I mean running both at the same time—not necessarily using the same Docker container. For example, right now if you run
That's a good point regarding performance. I'd say a develop mode is worth exploring. Something like Another alternative might be to document somewhere how one can set up Core's
I don't think this is a good idea. We risk fragmenting the ecosystem, e.g. tutorials and resources for beginners would differ from one another. It also doesn't align with the WordPress philosophy of "decisions, not options." |
Right, but that's not an advantage of
It sounds like a What does everyone else think? @youknowriad @noahtallen |
I guess the question is: Is this hard enough for the people who need it, to warrant baking it into the tool? |
I've updated the task list accordingly. |
Hm it seems like it wouldn't affect my use case, right? I likely won't need to be debugging core WordPress, but I would be debugging Gutenberg and other plugins/themes. |
Yeah, you probably won't use the flag. And even without it, you can always tweak the local clone of |
I put up a PR which could add support for a .wpenv file as we discussed: #18121. Open to feedback! |
Was thinking a bit about this. How about, instead of a Some examples of different
{
"core": "WordPress/wordpress#master",
"plugins": [ "." ]
}
{
"core": null,
"plugins": [ "~/projects/gutenberg", "~/projects/advanced-custom-fields" ],
"themes": [ "~/projects/twentytwenty" ]
}
{
"core": "WordPress/wordpress#5.0",
"plugins": [ "~/projects/gutenberg", "~/projects/advanced-custom-fields" ],
"themes": [ "~/projects/twentytwenty" ]
}
{
"core": "~/projects/wordpress-develop/build",
"plugins": [ "~/projects/gutenberg" ]
} Similar to the dependencies field in npm-package.json, we can support all sorts of different paths and URLs in
When a local path is specified, it is mounted into the Docker container as-is. When a remote path is specified, it is cloned or downloaded into a temporary directory (maybe: SVN, ZIP and Tarball URLs are a nice-to-have and can be implemented further down the track. What do you think? |
This is great @noisysocks!
I like this, because we avoid having to deal with that in this tool.
Nice, this gets rid of the awkward |
Since I was using scripts to run some of the test commands, I want to make sure we can still use them with @wp-env. Here's a quick look at what might need changed in
Question: should we delete these commands entirely, or map them to their counterparts in There are a few test scripts in @wordpress/scripts that should probably stay there since it better fits the theme of the package. These are
This uses a config to give a url/username/password to puppeteer: gutenberg/packages/scripts/scripts/test-e2e.js Lines 55 to 59 in 15eb6d0
This behavior could stay the same, but it could also call back to
The code affected is: gutenberg/packages/scripts/scripts/env/lint-php.js Lines 17 to 21 in 15eb6d0
gutenberg/packages/scripts/scripts/env/test-php.js Lines 16 to 21 in 15eb6d0
Essentially, we need to make sure that these commands correctly execute on the plugin or theme at cwd, or we need to add something to the config file which lets us specify some sort of test configuration |
The old env scripts need to be deprecated and the test scripts need to be
rewritten to leverage wp-env in the best way possible.
|
We've iterated a lot on Thanks everyone! ❤️ |
#17668 was merged as the base for a new WordPress local environment CLI tool for development and testing that avoids the pitfalls of previous iterations.
Previous approaches were slow, required too much configuration, and/or did not work on certain machines/versions of Docker Engine.
wp-env
will be a zero config tool for developing plugins, themes, or Core, and it will replacenpm run env
. Its goal is WordPress development in general, but it doesn't achieve it at the cost of burdening plugin or Gutenberg developers with various configs, commands, and options. It will automatically infer what the user needs from the contents of the folder it is running on and act accordingly.The base PR supports plugin development, which includes Gutenberg. Here are the next steps needed to make this tool accessible to all types of WordPress developers:
--help
output.@wordpress/scripts
'snpm run env
withwp-env
.The text was updated successfully, but these errors were encountered: