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

wp-cli: combine two writeFile calles to one writeFiles step. #107

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

bph
Copy link
Collaborator

@bph bph commented Feb 3, 2025

Fixes #104

Copy link

github-actions bot commented Feb 3, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@bph
Copy link
Collaborator Author

bph commented Feb 3, 2025

Using above test link, Playground ran into theses errors:

[03-Feb-2025 14:59:16 UTC] PHP Fatal: PHP.run() failed with exit code 1 and the following output: �[31;1mError:�[0m Unable to read content from '/wordpress/wp-content/postcontent.md'.
 Error: PHP.run() failed with exit code 1 and the following output: �[31;1mError:�[0m Unable to read content from '/wordpress/wp-content/postcontent.md'.

    at PHP.run (https://playground.wordpress.net/worker-thread-4d378c80.js:53:1888)
    at async PlaygroundWorkerEndpoint.run (https://playground.wordpress.net/worker-thread-4d378c80.js:4:9449)
[03-Feb-2025 14:59:16 UTC] JavaScript Error: PHP.run() failed with exit code 1 and the following output: �[31;1mError:�[0m Unable to read content from '/wordpress/wp-content/postcontent.md'.
Error: PHP.run() failed with exit code 1 and the following output: �[31;1mError:�[0m Unable to read content from '/wordpress/wp-content/postcontent.md'.

    at PHP.run (https://playground.wordpress.net/worker-thread-4d378c80.js:53:1888)
    at async PlaygroundWorkerEndpoint.run (https://playground.wordpress.net/worker-thread-4d378c80.js:4:9449)
[03-Feb-2025 14:59:16 UTC] JavaScript Error: Error when executing the blueprint step #2 ({"step":"wp-cli","command":"wp post create --post_title='Welcome to Playground' --post_status='published' /wordpress/wp-content/postcontent.md"}) : PHP.run() failed with exit code 1 and the following output: �[31;1mError:�[0m Unable to read content from '/wordpress/wp-content/postcontent.md'.
Error: Error when executing the blueprint step #2 ({"step":"wp-cli","command":"wp post create --post_title='Welcome to Playground' --post_status='published' /wordpress/wp-content/postcontent.md"}) : PHP.run() failed with exit code 1 and the following output: �[31;1mError:�[0m Unable to read content from '/wordpress/wp-content/postcontent.md'.

    at Object.run (https://playground.wordpress.net/assets/index-7eeeccac.js:905:146713)
    at async Vu (https://playground.wordpress.net/assets/index-7eeeccac.js:905:148232)
    at async nc (https://playground.wordpress.net/assets/index-7eeeccac.js:905:149113)
    at async https://playground.wordpress.net/assets/main-eaa04db9.js:151:2437

@adamziel any idea what I am missing?

@bph bph changed the title combine two writeFile calles to one writeFiles step. wp-cli: combine two writeFile calles to one writeFiles step. Feb 3, 2025
@bph
Copy link
Collaborator Author

bph commented Feb 4, 2025

returned to writeFile usage.

Tested again and it now works.

@bgrgicak
Copy link
Contributor

bgrgicak commented Feb 5, 2025

Using above test link, Playground ran into theses errors:

@bph this looks like a bug to me. The files are added to the filesystem if I check with await playground.listFiles('/wordpress/wp-content/'), but the CLI command can't find these files.

Could you please open an issue for this?

@bph bph merged commit 7986abb into trunk Feb 5, 2025
2 checks passed
@bph bph deleted the update-wpcli-post branch February 5, 2025 15:51
@bgrgicak
Copy link
Contributor

bgrgicak commented Feb 7, 2025

@bph this looks like a bug to me. The files are added to the filesystem if I check with await playground.listFiles('/wordpress/wp-content/'), but the CLI command can't find these files.

I took another look at this @bph.

Your original Blueprint created a directory with the name postcontent.md and added files named resource and url to the directory.
Screenshot 2025-02-07 at 09 31 27

This behavior matches our implementation of writeFile where a file can only be a literal value or another file tree (represented as a JSON object in the Blueprint).

It would be mindblowing if we could append resource types like URLs in the way you attempted it, so it might be worth submitting a feature request to start a discussion.

@bph
Copy link
Collaborator Author

bph commented Feb 11, 2025

Thank you @bgrgicak for the sleuthing and encouragement. I added the feature request on the Playground repo
Feature: Add resource type URL to writeFiles step
Please look at it if I captured the issue correctly.

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

Successfully merging this pull request may close these issues.

Update wp-cli add post w/ featured image write two files in one step
2 participants