Add wp-env project support: run partial sites (plugins/themes) from .wp-env.json#4079
Add wp-env project support: run partial sites (plugins/themes) from .wp-env.json#4079youknowriad wants to merge 2 commits into
Conversation
…wp-env.json Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
8c5f668 to
c4a581e
Compare
…t endpoint Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
On the CodeQL Assessment: these flag user-chosen folder paths flowing into filesystem reads. The reads are confined to fixed filenames ( Hardening applied in 2621740: Given the 9 previously dismissed alerts of this same rule in the repo, I'd suggest dismissing these four as won't fix (by design) — leaving that call to a maintainer. |
|
@jorgefilipecosta @talldan this might be of interest for you. I'm trying to make Studio CLI and Studio app support projects using .wp-env by default. I'd love some testing. @f This PR in theory allows plugin only and theme only projects (if a wp-env.json is provided in the folder). I guess it can be some kind of first step towards pressship kind of features. |
Related issues
How AI was used in this PR
Built end-to-end with Claude Code, iteratively directed and reviewed by @youknowriad: spike first (both runtimes verified live before any product code), then the translator library with unit tests, then command/UI wiring, followed by a dedicated self-review pass (simplification, removal of implementation-detail tests, audit for destructive paths). Every stage was verified against a real checkout of
WordPress/gutenberg.Proposed Changes
Studio currently requires every site folder to be (or become) a full WordPress install. This PR lets Studio run partial sites — a plugin repo, a theme, or a mix — driven by the standard
.wp-env.jsonspec, so projects like Gutenberg work out of the box:.wp-env.json, WordPress core is installed into a Studio-managed directory (~/.studio/wp-env/<siteId>) and the project'splugins/themes/mappingsare linked in — symlinks on the native runtime (reusing the existingopen_basedirsymlink allowlisting), VFS mounts on the Playground sandbox. The user's folder is never written to, and edits are live in the running site.coremaps to Studio WP versions (WordPress/WordPress→ nightly, release tags/zips → that version),phpVersionandportare honored,configbecomes wp-config constants, and start recomputes everything so.wp-env.jsonedits apply on restart. A conflicting--wpis refused (pointing at.wp-env.override.json, the wp-env-native escape hatch); PHP stays user-choosable with the divergence surfaced.studio ui) detect the folder, lock the WordPress version field, default PHP from the file, and show what the project contributes.statusshows the WordPress path and file-owned values.deletenever trashes the project folder (only the technical directory); sync/push/pull/export/import/copy are refused for wp-env sites until designed properly (they'd operate on the project folder or archive through symlinks).Trade-offs made (flagged for review):
core: "WordPress/WordPress"(trunk) maps to nightly — closest available equivalent.mappingsonto directories that already exist in the install (e.g.wp-content/mu-plugins, which holds Studio's SQLite integration) merge children instead of shadowing the directory as Docker wp-env does.multisite,lifecycleScripts,env.tests, remote sources, localcorecheckouts) warn or fail with explicit errors rather than being silently approximated.Scope note for reviewers: this crosses several boundaries — a new shared library (
packages/common/lib/wp-env/), CLI commands (create/start/status/config set+ guards), the Electron main process (folder-validation IPC), and both create forms (desktop renderer +apps/ui, including a newPOST /paths/inspectendpoint on the local web server for typed paths).Known follow-ups (not in this PR): remote plugin/theme sources, local core checkouts, sync/export support design, desktop wp-env badge/UX polish, verification of junctions on real Windows.
Testing Instructions
CLI (needs
npm run cli:build):node apps/cli/dist/cli/main.mjs create --path <gutenberg checkout>— expect "Using .wp-env.json: WordPress nightly…", plugin active in wp-admin, served from your checkout (edits are live).studio status --path <checkout>— expect aWordPress Pathrow and "(from .wp-env.json)" annotations.studio config set --path <checkout> --wp 6.8— expect refusal pointing at.wp-env.override.json.studio delete --path <checkout> --files— expect the checkout to survive; only~/.studio/wp-env/<id>is trashed..wp-env.jsonwith{ "plugins": [ "." ] }and a plugin file.UIs:
6. Desktop: Add site → pick a wp-env folder — expect the wp-env notice, a locked WordPress version field, PHP defaulted from the file; Sync and Import/Export tabs hidden for the created site.
7.
studio ui: create form → type the project path into Local path and blur — same adaptation (screenshot below).Pre-merge Checklist
🤖 Generated with Claude Code