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-now: Make it possible to use WP-CLI #25

Open
danielbachhuber opened this issue May 9, 2023 · 4 comments · May be fixed by #212
Open

wp-now: Make it possible to use WP-CLI #25

danielbachhuber opened this issue May 9, 2023 · 4 comments · May be fixed by #212
Assignees
Labels

Comments

@danielbachhuber
Copy link
Member

Once WordPress/wordpress-playground#242 is done, we should add some convenient shorthand for WP-CLI.

Done is:

  • wp-now cli executes WP-CLI.
  • If WP-CLI hasn't been downloaded yet, wp-now downloads it to its magical hidden folder.
@danielbachhuber
Copy link
Member Author

Once WP-CLI is available, we can use it to handle downloading WordPress too.

@adamziel
Copy link
Collaborator

adamziel commented May 15, 2023

@danielbachhuber
Copy link
Member Author

Another angle on this that's come up: what if I want to run my existing wp executable against a wp-now site (i.e. the user already has PHP and WP-CLI installed on their system)?

It might not actually be too difficult — we may just need to tell WP-CLI where to find the WordPress files, SQLite database, and project files. At the moment however, the knowledge of this only exists in the virtualized filesystem.

danielbachhuber referenced this issue in WordPress/wordpress-playground May 25, 2023
Fixes #438

## What?

Removes the magic WordPress loading for the `wp-now php` command.

## Why?

It's not particularly intuitive that you get WordPress when you run
`wp-now php`. It's more intuitive that WordPress will load if you run
WP-CLI, so let's keep the behavior for that feature
(https://github.com/WordPress/wordpress-playground/issues/269).

## Testing Instructions

Tests should pass.
adamziel referenced this issue in WordPress/wordpress-playground May 30, 2023
…395)

## What?

- Add the `executeWPCli` function to download and execute `wp-cli. 
- In the future, we may include the command `wp-now wp`. Currently, we
drop it out until we improve the pthreads execution. Currently a PR in
progress: #346
- Surface `emscriptenOptions` to catch print and print error for
`wp-cli` execution.

## Why?

- See https://github.com/WordPress/wordpress-playground/issues/269

## How?

It downloads the wp-cli.phar file if the file doesn't exist, then uses
`php.cli()` to execute it.
There are some limitations in the `wp-cli` features. Some of them may
not work.

## Testing Instructions

-  Check out this branch.
- Copy your path to your theme or plugin
- After installing and building the project, run:
- Run the tests `npx nx test wp-now`
- Observe the tests pass.

<!--details>
<summary>~`WP_NOW_PROJECT_PATH=/path/to/your-theme-or-plugin npx nx
preview wp-now wp user list`~ </summary>

```
> nx run wp-now:preview wp user list

+----+------------+--------------+--------------+--------------+---------------+
| ID | user_login | display_name | user_email   | user_registe | roles         |
|    |            |              |              | red          |               |
+----+------------+--------------+--------------+--------------+---------------+
| 1  | admin      | admin        | admin@localh | 2023-05-19 1 | administrator |
|    |            |              | ost.com      | 7:33:35      |               |
+----+------------+--------------+--------------+--------------+---------------+

  >  NX   Successfully ran target preview for project wp-now and 12 tasks it depends on (10s)
 
         With additional flags:
           wp user list
```
</details!-->

---------

Co-authored-by: Daniel Bachhuber <[email protected]>
@danielbachhuber danielbachhuber transferred this issue from WordPress/wordpress-playground May 31, 2023
@adamziel
Copy link
Collaborator

adamziel commented Jun 25, 2023

Turns out supporting pthreads offers no clear benefit. What would actually help is proc_open support.

@danielbachhuber danielbachhuber changed the title Local Environment: Make it possible to use WP-CLI wp-now: Make it possible to use WP-CLI Nov 9, 2023
@sejas sejas self-assigned this Apr 3, 2024
@sejas sejas linked a pull request Apr 3, 2024 that will close this issue
johnhooks pushed a commit to johnhooks/playground-tools that referenced this issue Oct 11, 2024
I reorganizes the `dev` and `build` scripts in `package.json` for more internal consistency and less duplication. The new structure is:

- dev - Alias for dev:web
  - dev:web - Runs dev:web:\* in parallel
    - dev:web:app
    - dev:web:html
    - dev:web:serve
    - dev:web:service-worker
    - dev:web:web-worker
  - dev:node
- build - Alias for build:web
  - build:web - Runs build:web:\* in parallel
    - build:web:app
    - build:web:html
    - build:web:service-worker
    - build:web:web-worker
  - build:node
  - build:php - Runs build:php:\* sequentially
    - build:php:web
    - build:php:node
  - build:wp
  - build:app - Runs build:web and build:node sequentially
- clean - Runs clean:\* in parallel
  - clean:php
  - clean:wp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants