-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add local WordPress environment powered by wp-env #328
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
Changes from all commits
8bacfd4
bf10818
bad876e
4cf01b0
96d25d9
4266fe6
fb503f2
9f9bb44
d68d83a
078d60f
a4abfc9
8ba8ef6
1a5f3f7
2fa9100
5fbcf32
211db56
c570e4c
41394d8
7b5a3c9
a5fa298
51ee10f
aed566e
6a7868e
c41411d
2749cc7
6e240d5
d2dcec8
a91d5e2
c3685ff
8aaa756
7c8773d
5d74500
deb0034
8078719
d812fcb
8d56cc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "plugins": [ | ||
| "https://downloads.wordpress.org/plugin/gutenberg.zip", | ||
| "https://downloads.wordpress.org/plugin/jetpack.zip" | ||
| ], | ||
| "mappings": { | ||
| "wp-content/mu-plugins": "./wp-env/mu-plugins" | ||
| }, | ||
| "config": { | ||
| "WP_DEBUG": true, | ||
| "WP_DEBUG_LOG": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,6 +135,32 @@ dev-tools: npm-dependencies ## Start the React Developer Tools | |
| preview: npm-dependencies ## Preview the production build locally | ||
| npm run preview | ||
|
|
||
| ################################################################################ | ||
| # Local WordPress Environment Targets (wp-env) | ||
| ################################################################################ | ||
|
|
||
| .PHONY: wp-env-start | ||
| wp-env-start: npm-dependencies ## Start the local WordPress environment (requires Docker; RESET=1 to regenerate credentials) | ||
| npm run wp-env start | ||
| @RESET=$(RESET) bash bin/wp-env-setup.sh | ||
|
|
||
| .PHONY: wp-env-stop | ||
| wp-env-stop: ## Stop the local WordPress environment | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be worth calling
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean run That said, my approach so far with the Makefile is creating a simple interface for the project's common commands. One can always run and access the lower-level commands— If you find this approach confusing, I'm happy to revisit this, but I suggest we do so holistically in a separate pull request—potentially removing any/all WDYT?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good. |
||
| npm run wp-env stop | ||
|
|
||
| .PHONY: wp-env-clean | ||
| wp-env-clean: ## Stop wp-env and remove all data (fresh start) | ||
| npm run wp-env destroy | ||
| @rm -f .wp-env.credentials.json | ||
|
|
||
| .PHONY: wp-env-logs | ||
| wp-env-logs: ## Show wp-env WordPress logs | ||
| npm run wp-env logs | ||
|
|
||
| .PHONY: wp-env-cli | ||
| wp-env-cli: ## Run a WP-CLI command in wp-env (usage: make wp-env-cli CMD="post list") | ||
| npm run wp-env run cli wp $(CMD) | ||
|
|
||
| ################################################################################ | ||
| # Code Quality Targets | ||
| ################################################################################ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,6 +117,10 @@ data class EditorAssetBundle( | |
| * @return `true` if the asset has been cached locally. | ||
| */ | ||
| fun hasAssetData(url: String): Boolean { | ||
| if(this == empty) { | ||
| return false | ||
| } | ||
|
|
||
|
Comment on lines
+120
to
+123
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cherry picked from #326 to prevent empty bundle load error. |
||
| return assetDataPath(url).exists() | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.example.gutenbergkit | ||
|
|
||
| data class LocalWordPressCredentials( | ||
| val siteUrl: String, | ||
| val siteApiRoot: String, | ||
| val authHeader: String | ||
| ) { | ||
| companion object { | ||
| /** | ||
| * Loads credentials from BuildConfig fields populated at build time from | ||
| * `.wp-env.credentials.json`. Remaps `localhost` to `10.0.2.2` so the | ||
| * Android emulator can reach the host machine. | ||
| */ | ||
| fun load(): LocalWordPressCredentials? { | ||
| val siteUrl = BuildConfig.WP_ENV_SITE_URL | ||
| if (siteUrl.isEmpty()) return null | ||
|
|
||
| return LocalWordPressCredentials( | ||
| siteUrl = remapLocalhost(siteUrl), | ||
| siteApiRoot = remapLocalhost(BuildConfig.WP_ENV_SITE_API_ROOT), | ||
| authHeader = BuildConfig.WP_ENV_AUTH_HEADER | ||
| ) | ||
| } | ||
|
|
||
| private fun remapLocalhost(url: String): String = | ||
| url.replace("://localhost", "://10.0.2.2") | ||
| } | ||
| } |
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.
Are agents expected to run these commands for setting up docker and wp-env? If not, it probably doesn't belong to
AGENTS.md.Uh oh!
There was an error while loading. Please reload this page.
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.
Long term? Yes, to enable "E2E verification" that allows agents to verify their own work.
Today? Since we do not have an MCP for navigating the product in a simulator/emulator, E2E verification is not really possible. So, there is not really a context where an agent would use these today; it's more relevant to simply use the E2E test commands, which themselves set up the
wp-envenvironment.I do not believe we should remove this at this time. WDYT?