3636use WordPress \CLI \CLI ;
3737use WordPress \Blueprints \DataReference \AbsoluteLocalPath ;
3838use WordPress \Blueprints \DataReference \DataReference ;
39+ use WordPress \Blueprints \DataReference \ExecutionContextPath ;
3940use WordPress \Blueprints \Exception \BlueprintExecutionException ;
4041use WordPress \Blueprints \Exception \PermissionsException ;
4142use WordPress \Blueprints \Logger \CLILogger ;
@@ -255,7 +256,7 @@ function createProgressReporter(): ProgressReporter {
255256 'site-url ' => [ 'u ' , true , null , 'Public site URL (https://example.com) ' ],
256257 'site-path ' => [ null , true , null , 'Target directory with WordPress install context) ' ],
257258 'execution-context ' => [ 'x ' , true , null , 'Source directory with Blueprint context files ' ],
258- 'mode ' => [ 'm ' , true , 'create-new-site ' , 'Execution mode (create|apply) ' ],
259+ 'mode ' => [ 'm ' , true , 'create-new-site ' , 'Execution mode (create-new-site |apply-to-existing-site ) ' ],
259260 'db-engine ' => [ 'd ' , true , 'mysql ' , 'Database engine (mysql|sqlite) ' ],
260261 'db-host ' => [ null , true , '127.0.0.1 ' , 'MySQL host ' ],
261262 'db-user ' => [ null , true , 'root ' , 'MySQL user ' ],
@@ -279,7 +280,7 @@ function createProgressReporter(): ProgressReporter {
279280 ] ),
280281 'examples ' => [
281282 'php blueprint.php exec my-blueprint.json --site-url https://mysite.test --site-path /var/www/mysite.com ' ,
282- 'php blueprint.php exec my-blueprint.json --execution-context /var/www --site-url https://mysite.test --mode apply --site-path ./site ' ,
283+ 'php blueprint.php exec my-blueprint.json --execution-context /var/www --site-url https://mysite.test --mode apply-to-existing-site --site-path ./site ' ,
283284 'php blueprint.php exec my-blueprint.json --site-url https://mysite.test --site-path ./mysite --truncate-new-site-directory ' ,
284285 ],
285286 'aliases ' => [ 'run ' ],
@@ -397,9 +398,10 @@ function cliArgsToRunnerConfiguration( array $positionalArgs, array $options ):
397398 $ blueprint_reference = $ positionalArgs [0 ];
398399 $ config ->setBlueprint ( DataReference::create ( $ blueprint_reference , [
399400 AbsoluteLocalPath::class,
401+ ExecutionContextPath::class,
400402 ] ) );
401403 } catch ( InvalidArgumentException $ e ) {
402- throw new InvalidArgumentException ( "Invalid Blueprint reference: " . $ positionalArgs [0 ] );
404+ throw new InvalidArgumentException ( sprintf ( "Invalid Blueprint reference: %s. Hint: paths must start with ./ or /. URLs must start with http:// or https://. " , $ positionalArgs [0 ] ) );
403405 }
404406
405407 if ( ! empty ( $ options ['mode ' ] ) ) {
@@ -409,6 +411,9 @@ function cliArgsToRunnerConfiguration( array $positionalArgs, array $options ):
409411 $ config ->setExecutionMode ( 'create-new-site ' );
410412 } elseif ( $ mode === 'apply-to-existing-site ' ) {
411413 $ config ->setExecutionMode ( 'apply-to-existing-site ' );
414+ if (!empty ($ options ['wp ' ])) {
415+ throw new InvalidArgumentException ( "The --wp option cannot be used with --mode=apply-to-existing-site. The WordPress version is whatever the existing site has. " );
416+ }
412417 } else {
413418 throw new InvalidArgumentException ( "Invalid execution mode: {$ mode }. Supported modes are: create-new-site, apply-to-existing-site " );
414419 }
0 commit comments