From a6831adc1d65c3c8c58c986e545e392f642348a5 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 13 Feb 2026 16:47:53 +0100 Subject: [PATCH] wp-env Playground: improve mapping and core source handling Remove unnecessary type restrictions on custom mappings (all source types can be mounted after downloading/extraction) and add smarter core source handling: zip URLs use Playground's native --wp flag, git sources pass version refs, and local sources use --wordpress-install-mode. Co-Authored-By: Claude Opus 4.6 --- .../runtime/playground/blueprint-builder.js | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/env/lib/runtime/playground/blueprint-builder.js b/packages/env/lib/runtime/playground/blueprint-builder.js index 704d70c479679e..89c1e61a709dc6 100644 --- a/packages/env/lib/runtime/playground/blueprint-builder.js +++ b/packages/env/lib/runtime/playground/blueprint-builder.js @@ -117,34 +117,34 @@ function getMountArgs( config ) { } // Mount custom mappings + // All source types (local, git, zip) can be mounted after downloading/extraction for ( const [ wpDir, source ] of Object.entries( envConfig.mappings || {} ) ) { - if ( source.type === 'local' || source.type === 'git' ) { - args.push( '--mount-dir', source.path, `/wordpress/${ wpDir }` ); - } else { - throw new Error( - `Mapping source "${ source.path }" for "${ wpDir }" of type "${ source.type }" ` + - `is not supported with Playground runtime. Only local and git mappings are supported.` - ); - } + args.push( '--mount-dir', source.path, `/wordpress/${ wpDir }` ); } - // Mount core source if specified + // Translate core source to Playground's --wp flag or mount it. if ( envConfig.coreSource ) { - if ( - envConfig.coreSource.type === 'local' || - envConfig.coreSource.type === 'git' - ) { + if ( envConfig.coreSource.type === 'zip' && envConfig.coreSource.url ) { + // For zip URLs, let Playground download WordPress natively. + args.push( '--wp', envConfig.coreSource.url ); + } else if ( envConfig.coreSource.type === 'git' ) { + // For git sources, pass the version ref to Playground's --wp flag. + // e.g., WordPress/WordPress#6.5 → --wp 6.5 + // WordPress/WordPress (no ref) → default "latest", no flag needed. + if ( envConfig.coreSource.ref ) { + args.push( '--wp', envConfig.coreSource.ref ); + } + } else { + // For local sources, mount the directory and tell Playground to + // use the existing files instead of downloading its own copy. args.push( '--mount-dir-before-install', envConfig.coreSource.path, - '/wordpress' - ); - } else { - throw new Error( - `Core source of type "${ envConfig.coreSource.type }" is not supported ` + - `with Playground runtime. Only local and git core sources are supported.` + '/wordpress', + '--wordpress-install-mode', + 'install-from-existing-files-if-needed' ); } }