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

Data carrying-over between instances in VS Code extension - "Playground" mode #1184

Open
flexseth opened this issue Apr 3, 2024 · 4 comments

Comments

@flexseth
Copy link
Collaborator

flexseth commented Apr 3, 2024

Issue description

I made a Playground to start working on documentation. When I make another playground that's in a blank folder (aka "Playground mode") - the new Playground thinks it's the same website as a the previously edited instance. Meaning the posts from the other instance I made are available in this installation, and even the site title has been changed.

Since it's in a blank folder, shouldn't this make a brand new instance (IE: no posts except Hello World?)

Proof of issue

First start by making a new playground..

  • Download and install the VS Code Extension
  • Make a new playground & enter the directory
    • mkdir ~/Desktop/new-playground1 && cd $_
  • Open VS Code in this folder
    • code .
  • Start WordPress Server (click the button)
  • Create a couple of posts
  • Stop WordPress Server...

Make another playground

  • mkdir ~/Desktop/new-playground2 && cd $_
  • code .
  • Start WordPress Server

You should see the posts have persisted from new-playground1 to new-playground2 instances

Caveats?

Is this a known limitation, IE:

The extension currently expects that the command is run while within a file in the root directory of the plugin. A WordPress playground will still be created and mounted, but the plugin will not be functional if the command is run from an unintended directory.

From the VS Code Extension's Known Issues

Questions

  • Also, what is an "unintended directory" ...?
  • What does Playground do if it lands in an empty directory? - Clarify
  • My understanding is that in Playground mode you'd get a new playground?
  • Do I need to edit something in wp-config.php or create a new database?
  • How does this work under the hood?
  • How to destroy this playground and start a new?

This seems to work as intended if you're in a folder that contains a plugin or theme, but not a blank folder.

The idea of being able to start scratch in a blank folder probably has a lot of use cases..

Importance

Being able to easily use the VS Code interface with Playground could be huge.
Let's look at how to better document how this works.

Labeling this issue

This is a good candidate for the interfacing label - how something works with Playground

Conclusion

Look out for more VS Code Extension questions / thoughts! They should be easy to find in the repo...

Please let me know if it makes more sense to do a master tracking list for VS Code in lieu of individual tickets..

@flexseth
Copy link
Collaborator Author

flexseth commented Apr 3, 2024

Possible blueprint for running multiple instances


for Playground1

{
	"steps": [
		{
			"step": "defineWpConfigConsts",
			"consts": {
				"WP_HOME": "http://new-playground1.wpnow:8885",
				"WP_SITEURL": "http://new-playground1.wpnow:8885"
			},
			"method": "define-before-run"
		}
	]
}

for Playground2

{
	"steps": [
		{
			"step": "defineWpConfigConsts",
			"consts": {
				"WP_HOME": "http://new-playground2.wpnow:8886",
				"WP_SITEURL": "http://new-playground2.wpnow:8886"
			},
			"method": "define-before-run"
		}
	]
}

@bgrgicak
Copy link
Collaborator

bgrgicak commented Apr 3, 2024

Since it's in a blank folder, shouldn't this make a brand new instance (IE: no posts except Hello World?)

Blank mode always falls back to the same instance. This is by design.
I think that it's confusing, when I first started using wp-now I expected that running the command in a folder will just start a new instance with the folder content.

@adamziel
Copy link
Collaborator

adamziel commented Apr 3, 2024

This interaction definitely needs rethinking, I also keep getting confused.

@flexseth
Copy link
Collaborator Author

flexseth commented Apr 4, 2024

This interaction definitely needs rethinking, I also keep getting confused.

While I'm working on docs I'll put together some ideas on clarifying the various Playground modes in VS Code and also the wp-now NPM package. I have some notes now but will continue to refine those over the next few days, stay tuned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: No status
Development

No branches or pull requests

3 participants