-
Notifications
You must be signed in to change notification settings - Fork 385
[CLI] Add high-level start command for easy local WordPress development
#3040
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
Conversation
…ment Introduces a new `start` command that provides a simple, wp-now-style experience for running WordPress locally. While the existing `server` command offers powerful low-level options for advanced use cases, `start` is designed for developers who just want to run a command and get going. The command auto-detects project types (plugin, theme, wp-content, WordPress), enables auto-login by default, and opens the browser automatically. It accepts manual mounts via --mount and allows disabling auto-detection with --no-auto-detect for users who need more control.
|
i have this same issue Runtime error |
|
@Samiullahstanikzai would you open a new issue with more details and reproduction instructions? |
|
Could we make the command even shorter? Just: |
|
@akirk I think so! Or maybe even just |
| } | ||
|
|
||
| export function isPluginFilename(path: string): boolean { | ||
| export function isPluginDirectory(path: string): boolean { |
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.
this function accepts a directory path, let's call it accordingly
|
Well, I'll go ahead and merge |
|
That is great, @adamziel. I will document it and create a post about it. Is this the complete deprecation of |
|
@fellyph there's still one prominent difference –
It's not a lot of projects, but offering a migration path would be kind. Let me see if there's an easy way to offer that feature 👀 |
|
It wasn't that complicated so I just opened #3119. Once it's merged, we'll have a clear migration path from wp-now. Edit: It's merged! |
|
Looking forward to migrate once this is released |
## Motivation for the change, related issues Makes `npx @wp-playground/cli start` persist the created site – just like `wp-now` does. With this PR, Playground CLI has a feature parity with wp-cli and we can move forward with the `wp-now` deprecation. Follow-ups on #3040 ## Implementation details Whenever there's no mount specified for `/wordpress`, Playground CLI will mount the host path `~/.wordpress-playground/sites/<path hash>` at the `/wordpress` VFS location. There's also a `--reset` CLI flag that wipes out the stored files and starts a fresh site. That's the gist of it. This simple logic comes with a few caveats: * The `~/.wordpress-playground` mount will not happen if the user explicitly mounts `/my/cool/site` at `/wordpress`. We can't mount two host directories at `/wordpress` so the explicit path wins. * The `~/.wordpress-playground` mount will not happen if the auto mounting is enabled, and the `/my/project/path` contains a full WordPress installation. The reason is the same as above. * I've removed the "just mount `cwd` at `/wordpress`" fallback in the auto-mounting logic. It doesn't seem that useful and it also interfered with the `~/.wordpress-playground` mount. If we really need that logic in the future, we can restore it behind an explicit option. I've also moved the `start` command logic inside the `runCli()` function, it seems cleaner that way. Really, the CLI code could use some cleanup sooner than later to clearly separate the Typescript definitions for each command's args and clearly separate their handlers. But that's out of scope here. ## Testing Instructions (or ideally a Blueprint) * Run `nx dev playground-cli start` * Change site title or add a page * Kill the server * Run `nx dev playground-cli start` again * Confirm your changes are still there * Kill the server * Run `nx dev playground-cli start --reset-site` * Confirm you got a fresh new site
|
I'll see if I can get articles-adamziel-com#24 to work before releasing this. It would be nice to have a cleaner CLI output. |
Summary
This PR introduces a new
startcommand to Playground CLI that provides a simple, wp-now-style experience for running WordPress locally. It's designed to make the CLI accessible to developers who just want to run a command and get going, without needing to understand low-level options.The existing
servercommand remains available for advanced users who need fine-grained control over mounts, WordPress installation modes, and other low-level options.Migrating from wp-now
This change unlocks officially deprecating
@wp-now/wp-nowand recommending everyone switch to@wp-playground/cli. Here's how wp-now commands map to the newstartcommand:npx @wp-now/wp-now startnpx @wp-playground/cli startwp-now start --php=8.3playground start --php=8.3wp-now start --wp=6.7playground start --wp=6.7wp-now start --port=8000playground start --port=8000wp-now start --blueprint=bp.jsonplayground start --blueprint=bp.jsonwp-now start --path=./my-pluginplayground start --path=./my-pluginwp-now start --skip-browserplayground start --skip-browserwp-now start --resetplayground start --reset(implemented in #3119)The API is intentionally similar. Both tools automatically detect plugin, theme, wp-content, or WordPress directories. Both work with no additional flags.
Improvements over wp-now:
--skip-browserto disable)--mount /host/path:/vfs/pathfor additional mounts beyond auto-detection--no-auto-mountto disable auto-detection and manually control mounts--site-urlwhen you need a specific URLDifferences with wp-now:
Playground CLI does not persist sites in the same way as wp-now does. Inwp-now, you can runwp-now startin a directory, get a site, make some changes to that site, then close the server, come back the next day, start the server again, and continue working on that same site. Playground CLI doesn't do it. Every server is ephemeral. You can store your changes by explicitly mounting wp-content to a local directory, but there's no automation in place to do it for you. If the users will request this feature, we can consider adding it, but I'm skipping it in the initial rollout as it would add a lot of complexity that the Playground CLI tool was intentionally designed not to handle implicitly.^ This was implemented later on in #3119
Usage
CLI Flags Reference
--path--php8.37.2,7.3,7.4,8.0,8.1,8.2,8.3,8.4,8.5--wplatest--port9400--blueprint--logintrue--xdebugfalse--skip-browserfalse--quietfalse--site-urlhttp://127.0.0.1:<port>).--mount/host/path:/vfs/path. Use this for additional mounts beyond auto-detection.--no-auto-mountfalse--mountto manually specify mounts instead.Test plan
playground start --helpand verify options are displayed correctlyplayground startin a plugin directory and verify auto-detection works--skip-browsersuppresses browser opening