diff --git a/environments/README.md b/environments/README.md index 9c4ad6279c..efaed0c041 100644 --- a/environments/README.md +++ b/environments/README.md @@ -71,6 +71,18 @@ npm run jobs:env start npm run jobs:env -- run cli -- wp ``` +### Browse Happy + +A local instance of [browsehappy.com](https://browsehappy.com) with the theme. + +**Start:** + +```bash +npm run browsehappy:env start +``` + +**Access:** `http://localhost:8888` + ### Handbook (in-plugin) The Handbook plugin has its own `.wp-env.json` in `wordpress.org/public_html/wp-content/plugins/handbook/`. diff --git a/environments/browsehappy/.wp-env.json b/environments/browsehappy/.wp-env.json new file mode 100644 index 0000000000..431d17a27d --- /dev/null +++ b/environments/browsehappy/.wp-env.json @@ -0,0 +1,12 @@ +{ + "core": "WordPress/WordPress#master", + "phpVersion": "8.4", + "testsEnvironment": false, + "themes": ["../browsehappy.com/public_html"], + "lifecycleScripts": { + "afterStart": "bash browsehappy/bin/after-start.sh" + }, + "config": { + "WP_DEBUG": true + } +} diff --git a/environments/browsehappy/bin/after-start.sh b/environments/browsehappy/bin/after-start.sh new file mode 100644 index 0000000000..d120f7623c --- /dev/null +++ b/environments/browsehappy/bin/after-start.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Runs after wp-env start. Sets site name, description and activates the +# Browse Happy theme. + +CONFIG="--config browsehappy/.wp-env.json" +WP="npx wp-env $CONFIG run cli --" + +# Set site title and description to match the public site. +$WP wp option update blogname 'Browse Happy' +$WP wp option update blogdescription 'Online. Worry free. Upgrade your browser today!' + +# Activate the browsehappy theme. +# wp-env uses the last path segment as the theme slug, so the slug is 'public_html' +# rather than 'browsehappy' (from "themes": ["../browsehappy.com/public_html"]). +# This theme is not pushed to the svn repo in wp-content/themes as per other sites. +$WP wp theme activate public_html + +echo "Browse Happy environment ready!" \ No newline at end of file diff --git a/environments/package.json b/environments/package.json index de8d95639c..5f4c15da12 100644 --- a/environments/package.json +++ b/environments/package.json @@ -11,7 +11,8 @@ "plugins:refresh": "npm run plugins:env -- run cli -- wp option delete wporg_env_imported && npm run plugins:env -- run cli wp eval-file wp-content/env-bin/import-plugins.php", "plugins:test:env": "wp-env --config plugin-directory/.wp-env.test.json", "plugins:test": "npm run plugins:test:env -- start && npm run plugins:test:env -- run tests-cli --env-cwd=wp-content/plugins/plugin-directory phpunit", - "jobs:env": "wp-env --config jobs/.wp-env.json" + "jobs:env": "wp-env --config jobs/.wp-env.json", + "browsehappy:env": "wp-env --config browsehappy/.wp-env.json" }, "devDependencies": { "@wordpress/env": "^11"