Skip to content

Commit 7fcf1a8

Browse files
committed
chore(examples): Remove obsolete mu-plugin infrastructure and improve DRY
- Remove mu-plugin.php template and generation code - Use relative paths for plugin references (portable across machines) - Simplify npm scripts (inline npm install, remove wp:ensure) - Add .gitignore files to exclude generated files - Align both toolbar examples with consistent configuration
1 parent 4f090de commit 7fcf1a8

File tree

8 files changed

+42
-81
lines changed

8 files changed

+42
-81
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# WordPress environment
2+
wp-env/
3+
.wp-env.override.json
4+
5+
# Generated files
6+
.htaccess
7+
mu-plugin.php
8+
9+
# Dependencies
10+
node_modules/
11+
12+
# Environment
13+
.env
14+
.env.local
15+
16+
# OS
17+
.DS_Store

examples/next/toolbar-demo/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"scripts": {
77
"example:dev": "npm --prefix ./example-app run dev",
88
"example:build": "npm --prefix ./example-app run build",
9-
"example:start": "node scripts/setup-env.js && npm run wp:ensure && concurrently \"npm run wp:start\" \"sleep 5 && npm run example:dev\"",
9+
"example:start": "node scripts/setup-env.js && npm install && concurrently \"npm run wp:start\" \"sleep 5 && npm run example:dev\"",
1010
"example:stop": "npm run wp:stop",
11-
"wp:ensure": "npm install",
1211
"wp:start": "wp-env start",
1312
"wp:stop": "wp-env stop",
1413
"wp:destroy": "wp-env destroy"

examples/next/toolbar-demo/scripts/setup-env.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ fs.writeFileSync(wpEnvPath, JSON.stringify(wpEnvConfig, null, 2) + '\n');
6060

6161
console.log(`✓ Updated .wp-env.json`);
6262

63-
// Generate mu-plugin.php from template
64-
const muPluginTemplatePath = path.join(__dirname, '../../../../scripts/templates/mu-plugin.php');
65-
const muPluginTemplate = fs.readFileSync(muPluginTemplatePath, 'utf8');
66-
const muPluginContent = muPluginTemplate.replace(/{{FRONTEND_PORT}}/g, ports.FRONTEND_PORT);
67-
68-
const muPluginPath = path.join(__dirname, '../mu-plugin.php');
69-
fs.writeFileSync(muPluginPath, muPluginContent);
70-
console.log(`✓ Generated mu-plugin.php`);
71-
7263
// Copy .htaccess from template
7364
const htaccessTemplatePath = path.join(__dirname, '../../../../scripts/templates/.htaccess');
7465
const htaccessPath = path.join(__dirname, '../.htaccess');
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# WordPress environment
2+
wp-env/
3+
.wp-env.override.json
4+
5+
# Generated files
6+
.htaccess
7+
mu-plugin.php
8+
9+
# Dependencies
10+
node_modules/
11+
12+
# Environment
13+
.env
14+
.env.local
15+
16+
# OS
17+
.DS_Store

examples/vanilla/toolbar-demo/.wp-env.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"phpVersion": "8.3",
33
"plugins": [
44
"https://github.com/wp-graphql/wp-graphql/releases/latest/download/wp-graphql.zip",
5-
"/Users/joe.fusco/Documents/GitHub/hwptoolkit/plugins/hwp-cors-local",
6-
"/Users/joe.fusco/Documents/GitHub/hwptoolkit/plugins/hwp-frontend-links",
7-
"/Users/joe.fusco/Documents/GitHub/hwptoolkit/plugins/hwp-wp-env-helpers"
5+
"../../../../plugins/hwp-cors-local",
6+
"../../../../plugins/hwp-frontend-links",
7+
"../../../../plugins/hwp-wp-env-helpers"
88
],
99
"config": {
1010
"WP_DEBUG": true,

examples/vanilla/toolbar-demo/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
"scripts": {
66
"example:build": "npm run example:dev:install && npm run wp:start && npm run example:start",
77
"example:dev:install": "cd example-app && npm install && cd ..",
8-
"example:start": "node scripts/setup-env.js && npm run wp:ensure && concurrently \"npm run wp:start\" \"sleep 5 && npm run example:dev\"",
8+
"example:start": "node scripts/setup-env.js && npm install && concurrently \"npm run wp:start\" \"sleep 5 && npm run example:dev\"",
99
"example:stop": "npm run wp:stop",
1010
"example:prune": "wp-env destroy && npm run example:build && npm run example:start",
1111
"example:dev": "npm --prefix ./example-app run dev",
12-
"wp:ensure": "npm install",
1312
"wp:start": "wp-env start",
1413
"wp:stop": "wp-env stop",
1514
"wp:destroy": "wp-env destroy",

examples/vanilla/toolbar-demo/scripts/setup-env.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ console.log(` WordPress: ${ports.WP_PORT}`);
2828
console.log(` WP Test: ${ports.WP_TEST_PORT}`);
2929

3030
// Update .wp-env.json
31-
const pluginsDir = path.resolve(__dirname, '../../../../plugins');
3231
const wpEnvConfig = {
3332
phpVersion: '8.3',
3433
plugins: [
3534
'https://github.com/wp-graphql/wp-graphql/releases/latest/download/wp-graphql.zip',
36-
path.join(pluginsDir, 'hwp-cors-local'),
37-
path.join(pluginsDir, 'hwp-frontend-links'),
38-
path.join(pluginsDir, 'hwp-wp-env-helpers')
35+
'../../../../plugins/hwp-cors-local',
36+
'../../../../plugins/hwp-frontend-links',
37+
'../../../../plugins/hwp-wp-env-helpers'
3938
],
4039
config: {
4140
WP_DEBUG: true,
@@ -60,15 +59,6 @@ fs.writeFileSync(wpEnvPath, JSON.stringify(wpEnvConfig, null, 2) + '\n');
6059

6160
console.log(`✓ Updated .wp-env.json`);
6261

63-
// Generate mu-plugin.php from template
64-
const muPluginTemplatePath = path.join(__dirname, '../../../../scripts/templates/mu-plugin.php');
65-
const muPluginTemplate = fs.readFileSync(muPluginTemplatePath, 'utf8');
66-
const muPluginContent = muPluginTemplate.replace(/{{FRONTEND_PORT}}/g, ports.FRONTEND_PORT);
67-
68-
const muPluginPath = path.join(__dirname, '../mu-plugin.php');
69-
fs.writeFileSync(muPluginPath, muPluginContent);
70-
console.log(`✓ Generated mu-plugin.php`);
71-
7262
// Copy .htaccess from template
7363
const htaccessTemplatePath = path.join(__dirname, '../../../../scripts/templates/.htaccess');
7464
const htaccessPath = path.join(__dirname, '../.htaccess');

scripts/templates/mu-plugin.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)