[CLI] @wp-playground/cli start persist sites
#3119
Merged
+324
−69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for the change, related issues
Makes
npx @wp-playground/cli startpersist the created site – just likewp-nowdoes. With this PR, Playground CLI has a feature parity with wp-cli and we can move forward with thewp-nowdeprecation.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/wordpressVFS location.There's also a
--resetCLI 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:
~/.wordpress-playgroundmount will not happen if the user explicitly mounts/my/cool/siteat/wordpress. We can't mount two host directories at/wordpressso the explicit path wins.~/.wordpress-playgroundmount will not happen if the auto mounting is enabled, and the/my/project/pathcontains a full WordPress installation. The reason is the same as above.cwdat/wordpress" fallback in the auto-mounting logic. It doesn't seem that useful and it also interfered with the~/.wordpress-playgroundmount. If we really need that logic in the future, we can restore it behind an explicit option.I've also moved the
startcommand logic inside therunCli()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)
nx dev playground-cli startnx dev playground-cli startagainnx dev playground-cli start --reset-site