@bostonuniversity/buwp-local 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/buwp-local.js +9 -0
- package/docs/CHANGELOG.md +18 -1
- package/docs/COMMANDS.md +40 -0
- package/docs/GETTING_STARTED.md +3 -0
- package/docs/MIGRATION_FROM_VM.md +1 -1
- package/docs/ROADMAP.md +61 -14
- package/docs/VOLUME_MAPPINGS.md +466 -0
- package/docs/XDEBUG.md +429 -0
- package/lib/commands/destroy.js +1 -1
- package/lib/commands/init.js +37 -35
- package/lib/commands/update.js +113 -0
- package/package.json +2 -2
- package/readme.md +3 -0
- package/MULTI_PROJECT_GUIDE.md +0 -929
- package/PROJECT_OVERVIEW.md +0 -307
- package/QUICK_REFERENCE.md +0 -234
- package/ROADMAP.md +0 -363
- package/USAGE.md +0 -324
- package/docker-compose.yml +0 -106
- package/docs/MULTI_PROJECT.md +0 -513
- package/feedback-from-0-6-1.md +0 -16
package/MULTI_PROJECT_GUIDE.md
DELETED
|
@@ -1,929 +0,0 @@
|
|
|
1
|
-
# Multi-Project Support & Smart Initialization
|
|
2
|
-
|
|
3
|
-
## New Features Summary
|
|
4
|
-
|
|
5
|
-
### ✅ 1. Unique Project Names
|
|
6
|
-
Each project now has a unique identifier based on its directory name, allowing multiple instances to run simultaneously.
|
|
7
|
-
|
|
8
|
-
### ✅ 2. Isolated Volumes
|
|
9
|
-
Each project gets its own Docker volumes, preventing database and file conflicts between projects.
|
|
10
|
-
|
|
11
|
-
### ✅ 3. Smart Configuration Init
|
|
12
|
-
Automatic mapping generation based on project type (plugin, mu-plugin, or theme).
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Feature Details
|
|
17
|
-
|
|
18
|
-
### 1. Project Name & Isolation
|
|
19
|
-
|
|
20
|
-
**Automatic Project Naming:**
|
|
21
|
-
- Project name defaults to the directory name
|
|
22
|
-
- Automatically sanitized for Docker compatibility (lowercase, alphanumeric + dash/underscore)
|
|
23
|
-
- Can be overridden in `.buwp-local.json`
|
|
24
|
-
|
|
25
|
-
**Example:**
|
|
26
|
-
```bash
|
|
27
|
-
# Directory: /path/to/bu-custom-analytics
|
|
28
|
-
# Project name: bu-custom-analytics
|
|
29
|
-
# Shows in Docker Desktop as: "bu-custom-analytics"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Volume Isolation:**
|
|
33
|
-
- Database volume: `{projectName}_db_data`
|
|
34
|
-
- WordPress volume: `{projectName}_wp_build`
|
|
35
|
-
|
|
36
|
-
This means:
|
|
37
|
-
- ✅ Each project has its own database
|
|
38
|
-
- ✅ Each project has its own WordPress installation
|
|
39
|
-
- ✅ Projects don't interfere with each other
|
|
40
|
-
- ✅ You can run multiple projects simultaneously
|
|
41
|
-
|
|
42
|
-
### 2. Smart Configuration Initialization
|
|
43
|
-
|
|
44
|
-
**New Flags:**
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
buwp-local config --init --plugin # For plugins
|
|
48
|
-
buwp-local config --init --mu-plugin # For mu-plugins
|
|
49
|
-
buwp-local config --init --theme # For themes
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
**What It Does:**
|
|
53
|
-
|
|
54
|
-
1. **Auto-detects directory name**
|
|
55
|
-
2. **Sets project name** to directory name
|
|
56
|
-
3. **Auto-generates hostname** as `{projectName}.local`
|
|
57
|
-
4. **Creates appropriate mapping** based on type
|
|
58
|
-
|
|
59
|
-
**Examples:**
|
|
60
|
-
|
|
61
|
-
#### Plugin Development
|
|
62
|
-
```bash
|
|
63
|
-
cd ~/projects/bu-custom-analytics
|
|
64
|
-
buwp-local config --init --plugin
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**Generates:**
|
|
68
|
-
```json
|
|
69
|
-
{
|
|
70
|
-
"projectName": "bu-custom-analytics",
|
|
71
|
-
"hostname": "bu-custom-analytics.local",
|
|
72
|
-
"mappings": [
|
|
73
|
-
{
|
|
74
|
-
"local": "./",
|
|
75
|
-
"container": "/var/www/html/wp-content/plugins/bu-custom-analytics"
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### Theme Development
|
|
82
|
-
```bash
|
|
83
|
-
cd ~/projects/responsive-framework
|
|
84
|
-
buwp-local config --init --theme
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
**Generates:**
|
|
88
|
-
```json
|
|
89
|
-
{
|
|
90
|
-
"projectName": "responsive-framework",
|
|
91
|
-
"hostname": "responsive-framework.local",
|
|
92
|
-
"mappings": [
|
|
93
|
-
{
|
|
94
|
-
"local": "./",
|
|
95
|
-
"container": "/var/www/html/wp-content/themes/responsive-framework"
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
#### MU-Plugin Development
|
|
102
|
-
```bash
|
|
103
|
-
cd ~/projects/bu-navigation
|
|
104
|
-
buwp-local config --init --mu-plugin
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**Generates:**
|
|
108
|
-
```json
|
|
109
|
-
{
|
|
110
|
-
"projectName": "bu-navigation",
|
|
111
|
-
"hostname": "bu-navigation.local",
|
|
112
|
-
"mappings": [
|
|
113
|
-
{
|
|
114
|
-
"local": "./",
|
|
115
|
-
"container": "/var/www/html/wp-content/mu-plugins/bu-navigation"
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## Multi-Project Workflow
|
|
124
|
-
|
|
125
|
-
### Running Multiple Projects Simultaneously
|
|
126
|
-
|
|
127
|
-
**Before (Problem):**
|
|
128
|
-
```bash
|
|
129
|
-
cd ~/plugin-a && buwp-local start
|
|
130
|
-
cd ~/plugin-b && buwp-local start # ❌ Overwrites plugin-a!
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Now (Solution):**
|
|
134
|
-
```bash
|
|
135
|
-
cd ~/plugin-a && buwp-local start # ✅ Runs on plugin-a.local
|
|
136
|
-
cd ~/plugin-b && buwp-local start # ✅ Runs on plugin-b.local
|
|
137
|
-
# Both running simultaneously!
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Setting Up Multiple Projects
|
|
141
|
-
|
|
142
|
-
**Step 1: Initialize each project**
|
|
143
|
-
```bash
|
|
144
|
-
# Plugin A
|
|
145
|
-
cd ~/projects/bu-custom-analytics
|
|
146
|
-
buwp-local config --init --plugin
|
|
147
|
-
cp .env.local.example .env.local # Add your credentials
|
|
148
|
-
|
|
149
|
-
# Plugin B
|
|
150
|
-
cd ~/projects/bu-slideshow
|
|
151
|
-
buwp-local config --init --plugin
|
|
152
|
-
cp .env.local.example .env.local # Add your credentials
|
|
153
|
-
|
|
154
|
-
# Theme
|
|
155
|
-
cd ~/projects/responsive-framework
|
|
156
|
-
buwp-local config --init --theme
|
|
157
|
-
cp .env.local.example .env.local # Add your credentials
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**Step 2: Use different ports (optional but recommended)**
|
|
161
|
-
|
|
162
|
-
Edit `.buwp-local.json` in each project:
|
|
163
|
-
|
|
164
|
-
```json
|
|
165
|
-
// bu-custom-analytics
|
|
166
|
-
{
|
|
167
|
-
"ports": {
|
|
168
|
-
"http": 8080,
|
|
169
|
-
"https": 8443,
|
|
170
|
-
"db": 3307,
|
|
171
|
-
"redis": 6380
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// bu-slideshow
|
|
176
|
-
{
|
|
177
|
-
"ports": {
|
|
178
|
-
"http": 8081,
|
|
179
|
-
"https": 8444,
|
|
180
|
-
"db": 3308,
|
|
181
|
-
"redis": 6381
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// responsive-framework
|
|
186
|
-
{
|
|
187
|
-
"ports": {
|
|
188
|
-
"http": 8082,
|
|
189
|
-
"https": 8445,
|
|
190
|
-
"db": 3309,
|
|
191
|
-
"redis": 6382
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
**Step 3: Add hostnames to /etc/hosts**
|
|
197
|
-
```bash
|
|
198
|
-
sudo bash -c 'cat >> /etc/hosts << EOF
|
|
199
|
-
127.0.0.1 bu-custom-analytics.local
|
|
200
|
-
127.0.0.1 bu-slideshow.local
|
|
201
|
-
127.0.0.1 responsive-framework.local
|
|
202
|
-
EOF'
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**Step 4: Start all projects**
|
|
206
|
-
```bash
|
|
207
|
-
cd ~/projects/bu-custom-analytics && buwp-local start
|
|
208
|
-
cd ~/projects/bu-slideshow && buwp-local start
|
|
209
|
-
cd ~/projects/responsive-framework && buwp-local start
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
**Step 5: Access your sites**
|
|
213
|
-
- http://bu-custom-analytics.local:8080
|
|
214
|
-
- http://bu-slideshow.local:8081
|
|
215
|
-
- http://responsive-framework.local:8082
|
|
216
|
-
|
|
217
|
-
---
|
|
218
|
-
|
|
219
|
-
## Shared Environment Strategy (Centralized Sandbox)
|
|
220
|
-
|
|
221
|
-
### Concept: Multiple Repos, One WordPress Instance
|
|
222
|
-
|
|
223
|
-
In addition to isolated environments, you can create a **centralized sandbox** where multiple repositories share the same WordPress instance, database, and volumes. This is useful for:
|
|
224
|
-
|
|
225
|
-
- **Integration testing** - Test how multiple plugins work together
|
|
226
|
-
- **Full-stack development** - Work on theme + plugins simultaneously
|
|
227
|
-
- **Team collaboration** - Multiple developers contributing to the same environment
|
|
228
|
-
- **Production-like setup** - Mirror actual site configuration locally
|
|
229
|
-
|
|
230
|
-
### How It Works
|
|
231
|
-
|
|
232
|
-
By setting the **same `projectName`** in multiple repositories, they'll join the same Docker Compose project and share volumes:
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
# All repos share: bu-sandbox_db_data and bu-sandbox_wp_build volumes
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Setting Up a Shared Environment
|
|
239
|
-
|
|
240
|
-
#### Strategy 1: Primary + Secondary Pattern (Recommended)
|
|
241
|
-
|
|
242
|
-
**Primary Repository** (owns the configuration):
|
|
243
|
-
```bash
|
|
244
|
-
cd ~/projects/bu-sandbox-primary
|
|
245
|
-
buwp-local config --init
|
|
246
|
-
|
|
247
|
-
# Edit .buwp-local.json:
|
|
248
|
-
{
|
|
249
|
-
"projectName": "bu-sandbox",
|
|
250
|
-
"hostname": "bu-sandbox.local",
|
|
251
|
-
"multisite": true,
|
|
252
|
-
"services": {
|
|
253
|
-
"redis": true,
|
|
254
|
-
"s3proxy": true,
|
|
255
|
-
"shibboleth": true
|
|
256
|
-
},
|
|
257
|
-
"ports": {
|
|
258
|
-
"http": 80,
|
|
259
|
-
"https": 443,
|
|
260
|
-
"db": 3306,
|
|
261
|
-
"redis": 6379
|
|
262
|
-
},
|
|
263
|
-
"mappings": [], // Primary doesn't map itself
|
|
264
|
-
"env": {
|
|
265
|
-
"WP_DEBUG": true,
|
|
266
|
-
"XDEBUG": false
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
# Create shared .env.local with credentials
|
|
271
|
-
# Start the primary environment
|
|
272
|
-
buwp-local start
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
**Secondary Repositories** (add their mappings):
|
|
276
|
-
```bash
|
|
277
|
-
# Plugin A
|
|
278
|
-
cd ~/projects/bu-custom-analytics
|
|
279
|
-
buwp-local config --init --plugin
|
|
280
|
-
|
|
281
|
-
# Edit .buwp-local.json:
|
|
282
|
-
{
|
|
283
|
-
"projectName": "bu-sandbox", # Same as primary!
|
|
284
|
-
"hostname": "bu-sandbox.local", # Same as primary!
|
|
285
|
-
"multisite": true,
|
|
286
|
-
"services": {
|
|
287
|
-
"redis": true,
|
|
288
|
-
"s3proxy": true,
|
|
289
|
-
"shibboleth": true
|
|
290
|
-
},
|
|
291
|
-
"ports": {
|
|
292
|
-
"http": 80,
|
|
293
|
-
"https": 443,
|
|
294
|
-
"db": 3306,
|
|
295
|
-
"redis": 6379
|
|
296
|
-
},
|
|
297
|
-
"mappings": [
|
|
298
|
-
{
|
|
299
|
-
"local": "./",
|
|
300
|
-
"container": "/var/www/html/wp-content/plugins/bu-custom-analytics"
|
|
301
|
-
}
|
|
302
|
-
],
|
|
303
|
-
"env": {
|
|
304
|
-
"WP_DEBUG": true,
|
|
305
|
-
"XDEBUG": false
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
# Copy .env.local from primary OR use symlink
|
|
310
|
-
ln -s ~/projects/bu-sandbox-primary/.env.local .env.local
|
|
311
|
-
|
|
312
|
-
# Add this plugin to the shared environment
|
|
313
|
-
buwp-local start
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
```bash
|
|
317
|
-
# Plugin B
|
|
318
|
-
cd ~/projects/bu-slideshow
|
|
319
|
-
buwp-local config --init --plugin
|
|
320
|
-
|
|
321
|
-
# Edit .buwp-local.json (same projectName, add mapping)
|
|
322
|
-
{
|
|
323
|
-
"projectName": "bu-sandbox",
|
|
324
|
-
"hostname": "bu-sandbox.local",
|
|
325
|
-
# ... same settings as above ...
|
|
326
|
-
"mappings": [
|
|
327
|
-
{
|
|
328
|
-
"local": "./",
|
|
329
|
-
"container": "/var/www/html/wp-content/plugins/bu-slideshow"
|
|
330
|
-
}
|
|
331
|
-
]
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
ln -s ~/projects/bu-sandbox-primary/.env.local .env.local
|
|
335
|
-
buwp-local start
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
```bash
|
|
339
|
-
# Theme
|
|
340
|
-
cd ~/projects/responsive-framework
|
|
341
|
-
buwp-local config --init --theme
|
|
342
|
-
|
|
343
|
-
# Edit .buwp-local.json (same projectName, add mapping)
|
|
344
|
-
{
|
|
345
|
-
"projectName": "bu-sandbox",
|
|
346
|
-
"hostname": "bu-sandbox.local",
|
|
347
|
-
# ... same settings as above ...
|
|
348
|
-
"mappings": [
|
|
349
|
-
{
|
|
350
|
-
"local": "./",
|
|
351
|
-
"container": "/var/www/html/wp-content/themes/responsive-framework"
|
|
352
|
-
}
|
|
353
|
-
]
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
ln -s ~/projects/bu-sandbox-primary/.env.local .env.local
|
|
357
|
-
buwp-local start
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
**Result:**
|
|
361
|
-
- One WordPress instance at http://bu-sandbox.local
|
|
362
|
-
- Three repos mounted into it
|
|
363
|
-
- Shared database with all data
|
|
364
|
-
- All plugins and theme active together
|
|
365
|
-
|
|
366
|
-
#### Strategy 2: Shared Config File
|
|
367
|
-
|
|
368
|
-
Create a centralized config that all repos reference:
|
|
369
|
-
|
|
370
|
-
```bash
|
|
371
|
-
# Create shared config directory
|
|
372
|
-
mkdir -p ~/.buwp-shared-configs
|
|
373
|
-
|
|
374
|
-
# Create shared config
|
|
375
|
-
cat > ~/.buwp-shared-configs/bu-sandbox.json << EOF
|
|
376
|
-
{
|
|
377
|
-
"projectName": "bu-sandbox",
|
|
378
|
-
"hostname": "bu-sandbox.local",
|
|
379
|
-
"multisite": true,
|
|
380
|
-
"services": {
|
|
381
|
-
"redis": true,
|
|
382
|
-
"s3proxy": true,
|
|
383
|
-
"shibboleth": true
|
|
384
|
-
},
|
|
385
|
-
"ports": {
|
|
386
|
-
"http": 80,
|
|
387
|
-
"https": 443,
|
|
388
|
-
"db": 3306,
|
|
389
|
-
"redis": 6379
|
|
390
|
-
},
|
|
391
|
-
"env": {
|
|
392
|
-
"WP_DEBUG": true,
|
|
393
|
-
"XDEBUG": false
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
EOF
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
In each repository, extend the shared config:
|
|
400
|
-
```bash
|
|
401
|
-
cd ~/projects/bu-custom-analytics
|
|
402
|
-
|
|
403
|
-
# Create .buwp-local.json that references shared config
|
|
404
|
-
cat > .buwp-local.json << EOF
|
|
405
|
-
{
|
|
406
|
-
"projectName": "bu-sandbox",
|
|
407
|
-
"hostname": "bu-sandbox.local",
|
|
408
|
-
"multisite": true,
|
|
409
|
-
"services": {
|
|
410
|
-
"redis": true,
|
|
411
|
-
"s3proxy": true,
|
|
412
|
-
"shibboleth": true
|
|
413
|
-
},
|
|
414
|
-
"ports": {
|
|
415
|
-
"http": 80,
|
|
416
|
-
"https": 443,
|
|
417
|
-
"db": 3306,
|
|
418
|
-
"redis": 6379
|
|
419
|
-
},
|
|
420
|
-
"mappings": [
|
|
421
|
-
{
|
|
422
|
-
"local": "./",
|
|
423
|
-
"container": "/var/www/html/wp-content/plugins/bu-custom-analytics"
|
|
424
|
-
}
|
|
425
|
-
],
|
|
426
|
-
"env": {
|
|
427
|
-
"WP_DEBUG": true
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
EOF
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
### How Docker Compose Handles Shared Projects
|
|
434
|
-
|
|
435
|
-
When multiple repos share the same `projectName`:
|
|
436
|
-
|
|
437
|
-
1. **First `start` command** - Creates the environment
|
|
438
|
-
- Creates volumes: `bu-sandbox_db_data`, `bu-sandbox_wp_build`
|
|
439
|
-
- Starts containers: `bu-sandbox-wordpress-1`, `bu-sandbox-db-1`, etc.
|
|
440
|
-
- Applies first repo's mappings
|
|
441
|
-
|
|
442
|
-
2. **Subsequent `start` commands** - Updates the environment
|
|
443
|
-
- Reuses existing volumes (data persists!)
|
|
444
|
-
- Restarts containers with **accumulated mappings**
|
|
445
|
-
- All repos' volumes are mounted together
|
|
446
|
-
|
|
447
|
-
3. **Container shows all mappings**:
|
|
448
|
-
```yaml
|
|
449
|
-
volumes:
|
|
450
|
-
- bu-sandbox_wp_build:/var/www/html
|
|
451
|
-
- /Users/dev/bu-custom-analytics:/var/www/html/wp-content/plugins/bu-custom-analytics
|
|
452
|
-
- /Users/dev/bu-slideshow:/var/www/html/wp-content/plugins/bu-slideshow
|
|
453
|
-
- /Users/dev/responsive-framework:/var/www/html/wp-content/themes/responsive-framework
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
### Workflow with Shared Environment
|
|
457
|
-
|
|
458
|
-
**Starting your workday:**
|
|
459
|
-
```bash
|
|
460
|
-
# Option 1: Start from primary repo
|
|
461
|
-
cd ~/projects/bu-sandbox-primary && buwp-local start
|
|
462
|
-
|
|
463
|
-
# Option 2: Start from any secondary repo (all mappings apply)
|
|
464
|
-
cd ~/projects/bu-custom-analytics && buwp-local start
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
**Adding a new repo to the shared environment:**
|
|
468
|
-
```bash
|
|
469
|
-
cd ~/projects/new-plugin
|
|
470
|
-
buwp-local config --init --plugin
|
|
471
|
-
|
|
472
|
-
# Edit .buwp-local.json to use shared projectName
|
|
473
|
-
# Set projectName to "bu-sandbox"
|
|
474
|
-
|
|
475
|
-
# Add to shared environment
|
|
476
|
-
buwp-local start
|
|
477
|
-
# Your new plugin is now available in the shared WordPress!
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
**Stopping the shared environment:**
|
|
481
|
-
```bash
|
|
482
|
-
# Stop from any participating repo
|
|
483
|
-
cd ~/projects/bu-custom-analytics
|
|
484
|
-
buwp-local stop
|
|
485
|
-
# Entire shared environment stops
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
**Viewing logs:**
|
|
489
|
-
```bash
|
|
490
|
-
# Logs from any participating repo show all services
|
|
491
|
-
cd ~/projects/bu-slideshow
|
|
492
|
-
buwp-local logs -f
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
### Important Considerations
|
|
496
|
-
|
|
497
|
-
#### ⚠️ Configuration Consistency
|
|
498
|
-
|
|
499
|
-
**All repos sharing a project MUST have consistent:**
|
|
500
|
-
- `projectName` - Must match exactly
|
|
501
|
-
- `hostname` - Should be the same
|
|
502
|
-
- `ports` - Must be identical (or conflicts occur)
|
|
503
|
-
- `services` - Should match (redis, s3proxy, shibboleth)
|
|
504
|
-
- `env` vars - Should be compatible
|
|
505
|
-
|
|
506
|
-
**Recommendation:** Use the Primary + Secondary pattern with config files kept in sync.
|
|
507
|
-
|
|
508
|
-
#### ⚠️ Start Order Matters
|
|
509
|
-
|
|
510
|
-
The **last repository to run `buwp-local start`** determines the final configuration. If configs differ:
|
|
511
|
-
- The last one "wins" for env vars, services, etc.
|
|
512
|
-
- All volume mappings accumulate
|
|
513
|
-
- Port conflicts cause failures
|
|
514
|
-
|
|
515
|
-
**Best Practice:**
|
|
516
|
-
- Use the primary repo for configuration changes
|
|
517
|
-
- Keep secondary repos minimal (just add mappings)
|
|
518
|
-
- Document which repo is the "source of truth"
|
|
519
|
-
|
|
520
|
-
#### ⚠️ Volume Mapping Accumulation
|
|
521
|
-
|
|
522
|
-
Every `start` command adds its mappings to the Docker Compose configuration. This means:
|
|
523
|
-
- ✅ You can add repos dynamically
|
|
524
|
-
- ⚠️ Removing a repo requires `destroy` and rebuild
|
|
525
|
-
- ⚠️ Changing a mapping requires `destroy` and rebuild
|
|
526
|
-
|
|
527
|
-
**To remove a plugin/theme from shared environment:**
|
|
528
|
-
```bash
|
|
529
|
-
cd ~/projects/bu-sandbox-primary
|
|
530
|
-
buwp-local destroy # Removes everything
|
|
531
|
-
buwp-local start # Rebuild without that plugin
|
|
532
|
-
```
|
|
533
|
-
|
|
534
|
-
#### ⚠️ Database Sharing
|
|
535
|
-
|
|
536
|
-
All repos share the same database:
|
|
537
|
-
- ✅ Test plugins together with real data
|
|
538
|
-
- ✅ Integration testing scenarios
|
|
539
|
-
- ⚠️ One repo can affect another's data
|
|
540
|
-
- ⚠️ Database migrations affect all plugins
|
|
541
|
-
|
|
542
|
-
**Best Practice:** Use database snapshots/backups before major changes.
|
|
543
|
-
|
|
544
|
-
### Comparison: Isolated vs Shared
|
|
545
|
-
|
|
546
|
-
| Aspect | Isolated Environments | Shared Environment |
|
|
547
|
-
|--------|----------------------|-------------------|
|
|
548
|
-
| **Use Case** | Independent plugin development | Integration testing, full-stack |
|
|
549
|
-
| **Databases** | Separate per project | One shared database |
|
|
550
|
-
| **WordPress** | Separate per project | One shared instance |
|
|
551
|
-
| **Volume Names** | `{projectName}_db_data` | `bu-sandbox_db_data` |
|
|
552
|
-
| **URLs** | Different per project | Same for all repos |
|
|
553
|
-
| **Ports** | Can differ | Must be identical |
|
|
554
|
-
| **Data Isolation** | Complete | Shared |
|
|
555
|
-
| **Setup Time** | Fast per project | Fast for additional repos |
|
|
556
|
-
| **Complexity** | Low | Medium (config sync) |
|
|
557
|
-
| **Best For** | Solo development, testing | Team collaboration, integration |
|
|
558
|
-
|
|
559
|
-
### When to Use Each Approach
|
|
560
|
-
|
|
561
|
-
#### Use Isolated Environments When:
|
|
562
|
-
- ✅ Developing one plugin/theme independently
|
|
563
|
-
- ✅ Need clean slate for testing
|
|
564
|
-
- ✅ Don't need other plugins active
|
|
565
|
-
- ✅ Want to test different WordPress versions
|
|
566
|
-
- ✅ Working on experimental features
|
|
567
|
-
- ✅ Need different PHP/MySQL settings per project
|
|
568
|
-
|
|
569
|
-
#### Use Shared Environment When:
|
|
570
|
-
- ✅ Testing plugin interactions
|
|
571
|
-
- ✅ Developing theme + plugins together
|
|
572
|
-
- ✅ Mimicking production setup locally
|
|
573
|
-
- ✅ Team collaborating on same codebase
|
|
574
|
-
- ✅ Need persistent test data across plugins
|
|
575
|
-
- ✅ Integration/acceptance testing
|
|
576
|
-
- ✅ Want single URL for all development
|
|
577
|
-
|
|
578
|
-
### Hybrid Approach (Mix and Match)
|
|
579
|
-
|
|
580
|
-
You can use **both strategies** for different scenarios:
|
|
581
|
-
|
|
582
|
-
```bash
|
|
583
|
-
# Isolated environment for experimental work
|
|
584
|
-
cd ~/projects/bu-custom-analytics
|
|
585
|
-
# Uses projectName: "bu-custom-analytics"
|
|
586
|
-
buwp-local start
|
|
587
|
-
# Test independently at http://bu-custom-analytics.local
|
|
588
|
-
|
|
589
|
-
# Shared environment for integration testing
|
|
590
|
-
cd ~/projects/bu-custom-analytics
|
|
591
|
-
# Edit .buwp-local.json temporarily, set projectName: "bu-sandbox"
|
|
592
|
-
buwp-local start
|
|
593
|
-
# Now part of shared sandbox at http://bu-sandbox.local
|
|
594
|
-
|
|
595
|
-
# Switch back
|
|
596
|
-
# Restore original .buwp-local.json with unique projectName
|
|
597
|
-
buwp-local destroy # Clean up shared
|
|
598
|
-
cd ~/projects/bu-custom-analytics && buwp-local start # Back to isolated
|
|
599
|
-
```
|
|
600
|
-
|
|
601
|
-
**Recommendation:** Keep two config files:
|
|
602
|
-
```bash
|
|
603
|
-
# In each repo:
|
|
604
|
-
.buwp-local.json # Isolated (default)
|
|
605
|
-
.buwp-local.shared.json # Shared environment
|
|
606
|
-
|
|
607
|
-
# Switch between them:
|
|
608
|
-
cp .buwp-local.shared.json .buwp-local.json # Use shared
|
|
609
|
-
cp .buwp-local.json.backup .buwp-local.json # Use isolated
|
|
610
|
-
```
|
|
611
|
-
|
|
612
|
-
### Advanced: Shared Config Template
|
|
613
|
-
|
|
614
|
-
Create a team template for shared environments:
|
|
615
|
-
|
|
616
|
-
```bash
|
|
617
|
-
# ~/.buwp-shared-configs/team-template.json
|
|
618
|
-
{
|
|
619
|
-
"projectName": "CHANGE_ME",
|
|
620
|
-
"hostname": "CHANGE_ME.local",
|
|
621
|
-
"multisite": true,
|
|
622
|
-
"services": {
|
|
623
|
-
"redis": true,
|
|
624
|
-
"s3proxy": true,
|
|
625
|
-
"shibboleth": true
|
|
626
|
-
},
|
|
627
|
-
"ports": {
|
|
628
|
-
"http": 80,
|
|
629
|
-
"https": 443,
|
|
630
|
-
"db": 3306,
|
|
631
|
-
"redis": 6379
|
|
632
|
-
},
|
|
633
|
-
"env": {
|
|
634
|
-
"WP_DEBUG": true,
|
|
635
|
-
"XDEBUG": false
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
# Team members copy and customize:
|
|
640
|
-
cp ~/.buwp-shared-configs/team-template.json ~/projects/my-repo/.buwp-local.json
|
|
641
|
-
# Edit projectName and add mappings
|
|
642
|
-
```
|
|
643
|
-
|
|
644
|
-
### Troubleshooting Shared Environments
|
|
645
|
-
|
|
646
|
-
#### Problem: Config drift between repos
|
|
647
|
-
**Solution:** Use symlinks to shared config file or primary repo pattern
|
|
648
|
-
|
|
649
|
-
#### Problem: Can't remove a plugin from shared environment
|
|
650
|
-
**Solution:** `destroy` from any repo, then restart without that plugin
|
|
651
|
-
|
|
652
|
-
#### Problem: Database is messed up
|
|
653
|
-
**Solution:** `destroy` the shared environment and start fresh
|
|
654
|
-
|
|
655
|
-
#### Problem: Not sure which repos are in shared environment
|
|
656
|
-
**Solution:** Check Docker Desktop or run:
|
|
657
|
-
```bash
|
|
658
|
-
docker compose -p bu-sandbox ps
|
|
659
|
-
# Lists all containers for that project
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
#### Problem: Want to test alone temporarily
|
|
663
|
-
**Solution:** Change projectName temporarily to create isolated instance
|
|
664
|
-
|
|
665
|
-
---
|
|
666
|
-
|
|
667
|
-
## Docker Desktop View
|
|
668
|
-
|
|
669
|
-
With project names, Docker Desktop now shows:
|
|
670
|
-
|
|
671
|
-
```
|
|
672
|
-
Containers:
|
|
673
|
-
├─ bu-custom-analytics
|
|
674
|
-
│ ├─ bu-custom-analytics-wordpress-1
|
|
675
|
-
│ ├─ bu-custom-analytics-db-1
|
|
676
|
-
│ ├─ bu-custom-analytics-redis-1
|
|
677
|
-
│ └─ bu-custom-analytics-s3proxy-1
|
|
678
|
-
│
|
|
679
|
-
├─ bu-slideshow
|
|
680
|
-
│ ├─ bu-slideshow-wordpress-1
|
|
681
|
-
│ ├─ bu-slideshow-db-1
|
|
682
|
-
│ ├─ bu-slideshow-redis-1
|
|
683
|
-
│ └─ bu-slideshow-s3proxy-1
|
|
684
|
-
│
|
|
685
|
-
└─ responsive-framework
|
|
686
|
-
├─ responsive-framework-wordpress-1
|
|
687
|
-
├─ responsive-framework-db-1
|
|
688
|
-
├─ responsive-framework-redis-1
|
|
689
|
-
└─ responsive-framework-s3proxy-1
|
|
690
|
-
|
|
691
|
-
Volumes:
|
|
692
|
-
├─ bu-custom-analytics_db_data
|
|
693
|
-
├─ bu-custom-analytics_wp_build
|
|
694
|
-
├─ bu-slideshow_db_data
|
|
695
|
-
├─ bu-slideshow_wp_build
|
|
696
|
-
├─ responsive-framework_db_data
|
|
697
|
-
└─ responsive-framework_wp_build
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
Clear separation and easy to manage!
|
|
701
|
-
|
|
702
|
-
---
|
|
703
|
-
|
|
704
|
-
## Configuration Reference
|
|
705
|
-
|
|
706
|
-
### Project Name Configuration
|
|
707
|
-
|
|
708
|
-
**Auto-generated (default):**
|
|
709
|
-
```json
|
|
710
|
-
{
|
|
711
|
-
"projectName": "my-plugin-name" // From directory name
|
|
712
|
-
}
|
|
713
|
-
```
|
|
714
|
-
|
|
715
|
-
**Manual override:**
|
|
716
|
-
```json
|
|
717
|
-
{
|
|
718
|
-
"projectName": "custom-project-name"
|
|
719
|
-
}
|
|
720
|
-
```
|
|
721
|
-
|
|
722
|
-
**Sanitization rules:**
|
|
723
|
-
- Converted to lowercase
|
|
724
|
-
- Non-alphanumeric characters (except `-` and `_`) replaced with `-`
|
|
725
|
-
- Leading/trailing dashes removed
|
|
726
|
-
|
|
727
|
-
**Examples:**
|
|
728
|
-
- `My Custom Plugin` → `my-custom-plugin`
|
|
729
|
-
- `BU_Navigation_v2` → `bu_navigation_v2`
|
|
730
|
-
- `@Company/Plugin` → `-company-plugin`
|
|
731
|
-
|
|
732
|
-
### Volume Naming
|
|
733
|
-
|
|
734
|
-
Volumes are automatically prefixed with the project name:
|
|
735
|
-
|
|
736
|
-
| Volume Type | Name Pattern | Example |
|
|
737
|
-
|------------|--------------|---------|
|
|
738
|
-
| Database | `{projectName}_db_data` | `bu-navigation_db_data` |
|
|
739
|
-
| WordPress | `{projectName}_wp_build` | `bu-navigation_wp_build` |
|
|
740
|
-
|
|
741
|
-
---
|
|
742
|
-
|
|
743
|
-
## Troubleshooting
|
|
744
|
-
|
|
745
|
-
### Port Conflicts
|
|
746
|
-
|
|
747
|
-
**Problem:** "Port 80 already in use"
|
|
748
|
-
|
|
749
|
-
**Solution:** Use different ports for each project
|
|
750
|
-
|
|
751
|
-
```json
|
|
752
|
-
{
|
|
753
|
-
"ports": {
|
|
754
|
-
"http": 8081,
|
|
755
|
-
"https": 8444
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
```
|
|
759
|
-
|
|
760
|
-
### Project Name Conflicts
|
|
761
|
-
|
|
762
|
-
**Problem:** Two directories with the same name
|
|
763
|
-
|
|
764
|
-
**Solution:** Manually set different project names
|
|
765
|
-
|
|
766
|
-
```json
|
|
767
|
-
// Project A
|
|
768
|
-
{
|
|
769
|
-
"projectName": "bu-forms-v1"
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
// Project B
|
|
773
|
-
{
|
|
774
|
-
"projectName": "bu-forms-v2"
|
|
775
|
-
}
|
|
776
|
-
```
|
|
777
|
-
|
|
778
|
-
### Volume Data Persistence
|
|
779
|
-
|
|
780
|
-
**Question:** What happens to data when I destroy a project?
|
|
781
|
-
|
|
782
|
-
**Answer:**
|
|
783
|
-
- `buwp-local stop` - Preserves all data (database, WordPress files)
|
|
784
|
-
- `buwp-local destroy` - Deletes ALL data for that specific project only
|
|
785
|
-
- Other projects are unaffected
|
|
786
|
-
|
|
787
|
-
### Listing Active Projects
|
|
788
|
-
|
|
789
|
-
```bash
|
|
790
|
-
# View all running buwp-local projects
|
|
791
|
-
docker ps --filter "label=com.docker.compose.project" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
|
792
|
-
|
|
793
|
-
# View all buwp-local volumes
|
|
794
|
-
docker volume ls | grep -E '(db_data|wp_build)'
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
---
|
|
798
|
-
|
|
799
|
-
## Migration Guide
|
|
800
|
-
|
|
801
|
-
### Upgrading from Previous Version
|
|
802
|
-
|
|
803
|
-
If you have an existing project without project names:
|
|
804
|
-
|
|
805
|
-
**Option 1: Start Fresh (Recommended)**
|
|
806
|
-
```bash
|
|
807
|
-
# Destroy old environment
|
|
808
|
-
buwp-local destroy -f
|
|
809
|
-
|
|
810
|
-
# Re-initialize with new format
|
|
811
|
-
buwp-local config --init --plugin
|
|
812
|
-
|
|
813
|
-
# Start fresh
|
|
814
|
-
buwp-local start
|
|
815
|
-
```
|
|
816
|
-
|
|
817
|
-
**Option 2: Manual Migration**
|
|
818
|
-
```bash
|
|
819
|
-
# Edit .buwp-local.json and add:
|
|
820
|
-
{
|
|
821
|
-
"projectName": "your-project-name",
|
|
822
|
-
// ... rest of config
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
# Destroy and restart
|
|
826
|
-
buwp-local destroy -f
|
|
827
|
-
buwp-local start
|
|
828
|
-
```
|
|
829
|
-
|
|
830
|
-
---
|
|
831
|
-
|
|
832
|
-
## Best Practices
|
|
833
|
-
|
|
834
|
-
### 1. Use Descriptive Project Names
|
|
835
|
-
- ✅ `bu-custom-analytics`
|
|
836
|
-
- ✅ `responsive-framework-theme`
|
|
837
|
-
- ❌ `test` (too generic)
|
|
838
|
-
- ❌ `plugin1` (unclear)
|
|
839
|
-
|
|
840
|
-
### 2. Use Smart Init Flags
|
|
841
|
-
Always use `--plugin`, `--mu-plugin`, or `--theme` for correct mappings
|
|
842
|
-
|
|
843
|
-
### 3. Document Port Assignments
|
|
844
|
-
Keep a team reference for port assignments to avoid conflicts
|
|
845
|
-
|
|
846
|
-
### 4. Share .env.local Template
|
|
847
|
-
Create `.env.local.example` with empty values for team members
|
|
848
|
-
|
|
849
|
-
### 5. Regular Cleanup
|
|
850
|
-
```bash
|
|
851
|
-
# List all buwp-local volumes
|
|
852
|
-
docker volume ls | grep -E '(db_data|wp_build)'
|
|
853
|
-
|
|
854
|
-
# Remove unused volumes
|
|
855
|
-
docker volume prune
|
|
856
|
-
```
|
|
857
|
-
|
|
858
|
-
---
|
|
859
|
-
|
|
860
|
-
## Summary
|
|
861
|
-
|
|
862
|
-
These features enable:
|
|
863
|
-
- ✅ **Multiple concurrent dev environments** - Work on several projects at once
|
|
864
|
-
- ✅ **Data isolation** - Each project has its own database and WordPress installation
|
|
865
|
-
- ✅ **Easy setup** - Smart initialization with `--plugin`, `--theme`, `--mu-plugin`
|
|
866
|
-
- ✅ **Clear organization** - See all projects clearly in Docker Desktop
|
|
867
|
-
- ✅ **Team scalability** - 20+ developers can each work on multiple projects
|
|
868
|
-
- ✅ **Flexible strategies** - Choose isolated OR shared environments based on needs
|
|
869
|
-
- ✅ **Centralized sandbox** - Test plugin interactions with shared WordPress instances
|
|
870
|
-
- ✅ **Mix and match** - Use both approaches for different scenarios
|
|
871
|
-
|
|
872
|
-
### Development Workflow Patterns
|
|
873
|
-
|
|
874
|
-
#### Pattern 1: Solo Developer - Isolated Environments
|
|
875
|
-
```
|
|
876
|
-
Developer works on 3 plugins independently:
|
|
877
|
-
├─ plugin-a (own DB, own WordPress)
|
|
878
|
-
├─ plugin-b (own DB, own WordPress)
|
|
879
|
-
└─ plugin-c (own DB, own WordPress)
|
|
880
|
-
|
|
881
|
-
Each gets unique projectName = directory name
|
|
882
|
-
```
|
|
883
|
-
|
|
884
|
-
#### Pattern 2: Team Collaboration - Shared Environment
|
|
885
|
-
```
|
|
886
|
-
Team works on integrated stack:
|
|
887
|
-
├─ bu-theme (all share "bu-team-sandbox")
|
|
888
|
-
├─ bu-navigation (all share "bu-team-sandbox")
|
|
889
|
-
├─ bu-slideshow (all share "bu-team-sandbox")
|
|
890
|
-
└─ bu-analytics (all share "bu-team-sandbox")
|
|
891
|
-
|
|
892
|
-
All repos share: bu-team-sandbox_db_data, one WordPress instance
|
|
893
|
-
Access: http://bu-team-sandbox.local
|
|
894
|
-
```
|
|
895
|
-
|
|
896
|
-
#### Pattern 3: Hybrid Approach
|
|
897
|
-
```
|
|
898
|
-
Developer uses both:
|
|
899
|
-
|
|
900
|
-
Morning (isolated testing):
|
|
901
|
-
bu-navigation with projectName: "bu-navigation"
|
|
902
|
-
Test in isolation at http://bu-navigation.local
|
|
903
|
-
|
|
904
|
-
Afternoon (integration testing):
|
|
905
|
-
Change projectName to "bu-integration"
|
|
906
|
-
Join shared environment with theme + other plugins
|
|
907
|
-
Test interactions at http://bu-integration.local
|
|
908
|
-
```
|
|
909
|
-
|
|
910
|
-
### Quick Decision Guide
|
|
911
|
-
|
|
912
|
-
**Choose Isolated When:**
|
|
913
|
-
- Developing new feature independently
|
|
914
|
-
- Need clean environment
|
|
915
|
-
- Testing without dependencies
|
|
916
|
-
- Want fast setup/teardown
|
|
917
|
-
|
|
918
|
-
**Choose Shared When:**
|
|
919
|
-
- Testing plugin interactions
|
|
920
|
-
- Team working on same feature
|
|
921
|
-
- Need persistent test data
|
|
922
|
-
- Mimicking production setup
|
|
923
|
-
|
|
924
|
-
**Use Both When:**
|
|
925
|
-
- Need isolated development + integration testing
|
|
926
|
-
- Want to test alone first, then with team
|
|
927
|
-
- Developing complex interdependent features
|
|
928
|
-
|
|
929
|
-
This solves the core multi-project development workflow challenges while providing flexibility for both isolated and collaborative work!
|