-
Notifications
You must be signed in to change notification settings - Fork 268
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
Blueprints: wp-cli step #1017
Blueprints: wp-cli step #1017
Conversation
Adds a new step to the blueprints that allows to run WP-CLI commands. Example: ```ts { "landingPage": "/wp-admin/post.php", "login": true, "steps": [ { "step": "wp-cli", "command": "wp post create --post_title='Test post' --post_excerpt='Some content' --no-color" } ] } ``` The command may also be an array of strings to ease dealing with quotes: ```ts { "landingPage": "/wp-admin/post.php", "login": true, "steps": [ { "step": "wp-cli", "command": ["wp", "post", "create", "--post_title=Test post", "--post_excerpt=Some content", "--no-color"] } ] } ``` ## Trade-offs * WP-CLI requires ~7MB of additional downloads: 1.4MB for the compressed WP-CLI.phar, and 5.6MB for the kitchen-sink PHP extensions bundle. ## Implementation * Whenever the Blueprints compiler finds a `wp-cli` step, it: * Downloads the wp-cli.phar file * Forces the `kitchen-sink` PHP extensions bundle as WP-CLI requires mbstring and iconv * `wp-cli.phar` is shipped at playground.wordpress.net. Downloading the official release from raw.githubusercontent.com transfers 7MB, while downloading the pre-compressed version from playground.wordpress.net only transfers 1.4MB. * playground.wordpress.net now always sets the `PHP_SAPI` constant to `cli` to ensure this check in WP-CLI passes: https://github.com/wp-cli/wp-cli-bundle/blob/970d0d4c22d4a89ca890def26ec82e559625abc6/php/boot-phar.php#L3-L10 ## Future work * Minify wp-cli.phar to reduce its size even further. We can remove redundant whitespaces and comments, remove the JavaScript parser library that is unlikely to be useful in Playground, remove parts of the Composer library, and perhaps more. cc @schlessera @swissspidy @danielbachhuber * Move the hardcoded WP-CLI-related parts of the Blueprint `compile()` function into a separate, modular function associated with the `wp-cli` step. ## Testing instructions * Confirm the CI checks pass * Run the local dev server, [click here](http://localhost:5400/website-server/#{%20%22landingPage%22:%20%22/wp-admin/post.php%22,%20%22login%22:%20true,%20%22steps%22:%20[%20{%20%22step%22:%20%22wp-cli%22,%20%22command%22:%20[%22wp%22,%20%22post%22,%20%22create%22,%20%22--post_title=Test%20post%22,%20%22--post_excerpt=Some%20content%22,%20%22--no-color%22]%20}%20]%20}), and confirm that a new post is created in the WordPress admin. CC @dmsnell @bgrgicak @sejas @eliot-akira
`choice and load the kitchen-sink PHP extensions bundle to prevent the WP-CLI step from failing. ` | ||
); | ||
} | ||
blueprint.steps?.splice(wpCliStepIndex, 0, { |
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.
Let's only trigger this request if wp-cli.phar
doesn't yet exist in VFS, or else running this Blueprint step in wp-now
will always trigger fetch()
.
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.
The step works on the web. Let's figure out node.js in a follow-up PR.
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.
Great work on getting this out so fast!
Adds a new step to the blueprints that allows to run WP-CLI commands.
Example:
The command may also be an array of strings to ease dealing with quotes:
Trade-offs
Implementation
wp-cli
step, it:kitchen-sink
PHP extensions bundle as WP-CLI requires mbstring and iconvwp-cli.phar
is shipped from playground.wordpress.net. Downloading the official release from raw.githubusercontent.com transfers 7MB, while downloading the pre-compressed version from playground.wordpress.net only transfers 1.4MB.PHP_SAPI
constant tocli
to ensure this check in WP-CLI passes: https://github.com/wp-cli/wp-cli-bundle/blob/970d0d4c22d4a89ca890def26ec82e559625abc6/php/boot-phar.php#L3-L10Future work
compile()
function into a separate, modular function associated with thewp-cli
step.Testing instructions
CC @dmsnell @bgrgicak @sejas @eliot-akira