You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Blueprints] Rewrite paths in the wp-cli step. Improve error reporting. (#2406)
## Motivation for the change, related issues
Playground have recently changed cwd from / to /wordpress to mimic what
nginx, apache, and other webservers do. Unfortunately, many Blueprints
use root-based relative paths in the `wp-cli` step. This PR detects
them, rewrites them as absolute paths, and explains the problem in an
error message. This PR follows up on
#2268
## Testing Instructions (or ideally a Blueprint)
Confirm the following behavior:
**Before this PR:**
```
$ node --experimental-wasm-jspi --loader=./packages/meta/src/node-es-module-loader/loader.mts ./packages/playground/cli/src/cli.ts server -blueprint=https://raw.githubusercontent.com/wordpress/blueprints/refs/heads/trunk/blueprints/wpcli-post-with-image/blueprint.json
Starting a PHP server...
Setting up WordPress latest
Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.2.zip
Fetching SQLite integration plugin...
Booting WordPress...
Booted!
Running the Blueprint...
Downloading wp-cli.phar – 83%PHP.run() output was: #!/usr/bin/env php
PHPExecutionFailureError: PHP.run() failed with exit code 1 and the following output: Warning: Unable to import file 'wordpress/wp-content/Select-storage-method.png'. Reason: File doesn't exist.
```
**After this PR:**
```
$ Starting a PHP server...
Resolved WordPress release URL: https://downloads.w.org/release/wordpress-6.8.2.zip
Fetching SQLite integration plugin...
Booting WordPress...
Booted!
Running the Blueprint...
Downloading wp-cli.phar – 66%The wp-cli step in your Blueprint refers to a relative path.
Playground recently changed the working directory from '/' to '/wordpress' to better mimic
how real web servers work. This means relative paths that used to work may no longer
point to the correct location.
Playground automatically updated the path for you, but at one point path rewriting will be removed. Please
update your code to use an absolute path instead:
Instead of:
{
"step": "wp-cli",
"command": "wp media import wordpress/wp-content/Select-storage-method.png --post_id=4 --title='Select your storage method' --featured_image"
}
Use:
{
"step": "wp-cli",
"command": "wp media import /wordpress/wp-content/Select-storage-method.png --post_id=4 --title='Select your storage method' --featured_image"
}
This will ensure your code works reliably regardless of the current working directory.
Downloading wp-cli.phar – 100%
Logging in – 100%
Finished running the blueprint
WordPress is running on http://127.0.0.1:9400
```
Also, the error reporting was improved so, without the path rewriting,
the error message would now be:
```
Error when executing the blueprint step #4 ({"step":"wp-cli","command":"wp media import wordpress/wp-content/Select-storage-method.png --post_id=4 --title='Select your storage method' --featured_image"}) : Comlink method call failed > caused by > Comlink method call failed > caused by > PHP.run() failed with exit code 1.
=== Stdout ===
#!/usr/bin/env php
=== Stderr ===
Warning: Unable to import file 'wordpress/wp-content/Select-storage-method.png'. Reason: File doesn't exist.
Error: No images imported.
```
0 commit comments