Automattic / studio

Studio by WordPress.com, a free desktop app that helps developers streamline their local WordPress development workflow.
https://developer.wordpress.com/studio/
GNU General Public License v2.0
138 stars 12 forks source link

Studio: Fix wp-cli command for linux #257

Closed kozer closed 1 week ago

kozer commented 1 week ago

Related to https://github.com/Automattic/dotcom-forge/issues/7327

Proposed Changes

This PR fixes wp-cli execution for linux

Testing Instructions

  1. Ensure that opening a terminal both from bundled and development environment executes commands correctly

Pre-merge Checklist

kozer commented 1 week ago

I managed to set up a Linux instance and test this PR. I tested different commands both with the app running and without and worked as expected 🎊 . However, I noticed that running the CLI command wp, i.e. without any command results in an error:

What is supposed to do in that case @fluiddot ?

kozer commented 1 week ago

@fluiddot , I updated the script as it seems that the %q format specifier is not available in all versions of printf

It works now, but please take a look of it in MacOSX as well ( and do a final check on linux )

UPDATE: For some reason, lint fails, but running npm run lint locally, doesn't produce any errors. Can you please also check on mac os as well?

fluiddot commented 1 week ago

What is supposed to do in that case @fluiddot ?

wp should do the same as the command wp help.

kozer commented 1 week ago

What is supposed to do in that case @fluiddot ?

wp should do the same as the command wp help.

Yeah, I realized it after the first question, and I fixed it :smile:

fluiddot commented 1 week ago

UPDATE: For some reason, lint fails, but running npm run lint locally, doesn't produce any errors. Can you please also check on mac os as well?

Based on the output from CI:

curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)

Seems it might be a one-off failure, so retrying the jobs should work.

fluiddot commented 1 week ago

@fluiddot , I updated the script as it seems that the %q format specifier is not available in all versions of printf

It works now, but please take a look of it in MacOSX as well ( and do a final check on linux )

Great, thanks! I've reviewed this on both macOS and Linux and worked as expected.

For reference, the processing of the arguments (i.e. command printf '%q ' "$@") was needed for invoking commands with quotes like: