Skip to content
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

[Playground CLI] wp-cli blueprint steps broken #2132

Open
ellatrix opened this issue Jan 23, 2025 · 5 comments
Open

[Playground CLI] wp-cli blueprint steps broken #2132

ellatrix opened this issue Jan 23, 2025 · 5 comments

Comments

@ellatrix
Copy link
Member

I run the following command:

npx @wp-playground/cli server --blueprint=blueprint.json

I have the following step:

{
  "step": "wp-cli",
  "command": "wp post create --post_title='Test post' --post_excerpt='Some content'"
}

I get the following error:

Error: PHP Deprecated:  WP_CLI\Runner::get_subcommand_suggestion(): Implicitly marking parameter $root_command as nullable is deprecated, the explicit nullable type must be used instead in phar:///tmp/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php on line 1958

    at Object.Ar [as wp-cli] (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:643:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async d (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12472:30)
    at async Object.run (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12403:23)
    at async ns (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12507:3)
    at async Object.onBind (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/cli/cli.js:20:568)
    at async T (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/cli/cli.js:1:1159)
file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12406
            throw fe.error(b), new Error(
                               ^

Error: Error when executing the blueprint step #3 ({"step":"wp-cli","command":"wp post create --post_title='Test post' --post_excerpt='Some content'"}) : PHP Deprecated:  WP_CLI\Runner::get_subcommand_suggestion(): Implicitly marking parameter $root_command as nullable is deprecated, the explicit nullable type must be used instead in phar:///tmp/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php on line 1958

    at Object.run (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12406:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ns (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12507:3)
    at async Object.onBind (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/cli/cli.js:20:568)
    at async T (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/cli/cli.js:1:1159) {
  [cause]: Error: PHP Deprecated:  WP_CLI\Runner::get_subcommand_suggestion(): Implicitly marking parameter $root_command as nullable is deprecated, the explicit nullable type must be used instead in phar:///tmp/wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php on line 1958
  
      at Object.Ar [as wp-cli] (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:643:11)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async d (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12472:30)
      at async Object.run (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12403:23)
      at async ns (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/blueprints/index.js:12507:3)
      at async Object.onBind (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/cli/cli.js:20:568)
      at async T (file:///Users/e/.npm/_npx/8ab79f7a2a3f35a4/node_modules/@wp-playground/cli/cli.js:1:1159)
}

Node.js v20.18.2
@swissspidy
Copy link
Member

swissspidy commented Jan 23, 2025

The version of WP-CLI used by Playground is outdated, it should better use the latest nightly.

@ellatrix
Copy link
Member Author

Why nightly and not stable?

@adamziel
Copy link
Collaborator

As Pascal noted, we'll need to revisit how we ship the WP CLI binary. Right now it’s always the same prebuilt phar file I’ve minified a year ago:

export const defaultWpCliResource: FileReference = {

I've done that to save the transfer size. The official WP-CLI distribution was AFAIR around 20MB also served uncompressed. The one Playground uses is minified PHP code and pruned of some libraries which made it 7MB, or 1.5MB gzipped.

At a very least, we should have auto updates like we have for core WordPress releases. Ideally, we’d also do minification – same as we do for the pre-bundled WordPress core releases. In a perfect world, we’d also tree shake the release. I don’t think there are any tools to do that automatically in PHP, but at least we could hardcode removing the same large libraries I did in that minified build. AFAIR I was able to remove something related to parsing PHP and some polyfills for the missing PHP extensions since the Playground ships them.

@swissspidy
Copy link
Member

@ellatrix Because we haven't released a new stable yet that includes those fixes :)

@adamziel Let me know if there's anything we can do on the WP-CLI side to facilitate that.

@bph
Copy link
Collaborator

bph commented Jan 24, 2025

The three blueprints in the gallery using various wp-cli commands still seem to work, though.

Use wp-cli command to add posts
using

	"step": "wp-cli",
	"command": "wp post generate --count=12 --post_type=post --post_date=1999-01-04"
		}

Use wp-cli to add a post with image
with two wp-cli commands

{
    "step": "wp-cli",
    "command": "wp post create --post_title='Welcome to Playground' --post_status='published' /wordpress/wp-content/postcontent.md"
},
{
    "step": "wp-cli",
    "command": "wp media import wordpress/wp-content/Select-storage-method.png --post_id=4 --title='Select your storage method' --featured_image"
}

Demo of Twenty-Twenty-Five theme

{
    "step": "wp-cli",
    "command": "wp site empty --yes"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Inbox
Development

No branches or pull requests

4 participants