Skip to content

Add wp-env setup for this repo - #265

Merged
MaggieCabrera merged 6 commits into
trunkfrom
add-wp-env
Mar 9, 2026
Merged

Add wp-env setup for this repo#265
MaggieCabrera merged 6 commits into
trunkfrom
add-wp-env

Conversation

@MaggieCabrera

@MaggieCabrera MaggieCabrera commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

Adds a local development environment powered by wp-env. All themes in the repo are available out of the box.

  • Auto-detects a free port starting from 8888, avoiding conflicts with other services
  • --theme <slug> activates a theme after startup; if the environment is already running, it skips startup
    and just switches the active theme
  • env:stop and env:destroy read the saved port from .wp-env-port to always target the correct instance
  • Theme activation is verified against WP-CLI output. A success message is only shown when the theme was
    actually switched

How to test

  1. Fresh start
    npm run env:start -- --theme blue-note
  1. Switch theme on a running env
    npm run env:start -- --theme archivist
  • Should skip startup, just switch the theme
  • Confirm Archivist is now active (no restart required)
  1. Invalid theme slug
    npm run env:start -- --theme this-does-not-exist
  • Should print an error and exit with a non-zero code
  • Should NOT show a success message
  1. Start with no theme flag
    npm run env:stop
    npm run env:start
  • Should start normally, no theme activation step
  1. Stop and restart with a different theme
    npm run env:stop
    npm run env:start -- --theme blue-note
  • Should start the existing environment (not create a new one)
  • Confirm Blue Note is active at http://localhost:8888
  1. Destroy
    npm run env:destroy
  • Containers and volumes removed, .wp-env-port file deleted
  • Running npm run env:start after this should boot a clean instance

@MaggieCabrera MaggieCabrera changed the title Add wp-envsetup for this repo Add wp-env setup for this repo Mar 6, 2026
Comment thread .wp-env.gutenberg.json
{
"core": "WordPress/WordPress",
"plugins": [ "https://downloads.wordpress.org/plugin/gutenberg.latest-stable.zip" ],
"themes": [ "https://downloads.wordpress.org/theme/twentytwentythree.latest-stable.zip" ],

@MaggieCabrera MaggieCabrera Mar 6, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atlas needs TT3 as a dependency

@mikachan mikachan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I ran npm run env:start -- --theme blue-note, the env started fine, and I saw this success:

Image

But it tried to activate Twenty Twenty-Five instead, which doesn't exist here. I could still manually switch to Blue Note afterwards, which worked fine.

And when I stopped the env and then ran npm run env:start -- --theme archivist, I saw the same success message again:

Image

But Blue Note was still active.

Otherwise, the test environment is working well for me.

Comment thread env.mjs Outdated
Comment on lines +30 to +31
const port = await findFreePort();
const testsPort = await findFreePort( port + 1 );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These port checks are called for env:start, but we don't use anything similar for env:stop or env:destroy. Should the port that's being used be checked for these commands? I'm wondering if wp-env might accidentally stop or destroy the wrong instance if it hasn't checked the port.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole thing might be more trouble than anything, I'll see what I can do

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm making it so that we store the active port in a file, and if we re run the env with a new theme it just changes it instead of destroying it/starting a new one again.

@mikachan mikachan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running npm run env:start -- --theme blue-note is working well for me now. Thanks! 🚢

@MaggieCabrera
MaggieCabrera merged commit 324b6d8 into trunk Mar 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants