@bostonuniversity/buwp-local 0.5.2 → 0.6.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.
@@ -0,0 +1,149 @@
1
+ # Changelog
2
+
3
+ All notable changes to buwp-local will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - Credential validation on `start` command with interactive setup prompt
12
+ - Documentation consolidation in `docs/` directory
13
+ - Comprehensive guides: GETTING_STARTED.md, COMMANDS.md, CREDENTIALS.md, MULTI_PROJECT.md, ARCHITECTURE.md
14
+
15
+ ## [0.5.3]
16
+
17
+ ### Fixed
18
+ - Fixed newline escaping in `createSecureTempEnvFile()` to properly handle multiline credentials
19
+ - Changed regex from `/\\n/g` to `/\n/g` to escape actual newline characters instead of literal backslash-n strings
20
+
21
+ ### Changed
22
+ - Improved temp env file generation to correctly format multiline values for Docker Compose
23
+
24
+ ## [0.5.2]
25
+
26
+ ### Added
27
+ - Automatic hex decoding for legacy multiline credentials in Keychain
28
+ - `isHexEncoded()` helper function to detect hex-encoded credential values
29
+ - Transparent decoding of Shibboleth certificates and keys stored as hex strings
30
+
31
+ ### Fixed
32
+ - SHIB_SP_KEY and SHIB_SP_CERT now properly decode from hex format when retrieved from Keychain
33
+ - Credentials that were stored as "2d2d2d2d2d..." now correctly appear as "-----BEGIN..."
34
+
35
+ ## [0.5.1]
36
+
37
+ ### Added
38
+ - Source file deletion prompt after successful Keychain import
39
+ - `promptToDeleteSourceFile()` function for secure cleanup of plaintext credential files
40
+ - Security improvement to reduce attack surface by removing credential files after import
41
+
42
+ ### Changed
43
+ - `keychain setup` command now prompts to delete source JSON file after successful import
44
+ - Enhanced security workflow for credential management
45
+
46
+ ## [0.5.0]
47
+
48
+ ### Added
49
+ - **macOS Keychain integration** for secure credential storage
50
+ - `keychain` command group with subcommands:
51
+ - `setup --file <path>` - Import credentials from JSON file
52
+ - `get <name>` - Retrieve specific credential
53
+ - `set <name> <value>` - Update or create credential
54
+ - `delete <name>` - Remove credential
55
+ - `list` - Show all stored credentials
56
+ - `test` - Verify Keychain access
57
+ - Hybrid credential loading: `.env.local` overrides Keychain
58
+ - Secure temporary environment file generation with 0600 permissions
59
+ - Automatic cleanup of temporary credential files
60
+
61
+ ### Changed
62
+ - Credential loading now checks `.env.local` first, then falls back to Keychain
63
+ - Enhanced security model with encrypted credential storage
64
+ - Improved documentation for credential management workflows
65
+
66
+ ### Security
67
+ - Credentials no longer require plaintext `.env.local` files in every project
68
+ - Global credential storage in macOS Keychain with encryption
69
+ - Temporary files used for Docker Compose with strict permissions
70
+
71
+ ## [0.4.0]
72
+
73
+ ### Added
74
+ - Interactive `init` command with guided setup wizard
75
+ - Smart project type detection (plugin, theme, mu-plugin, sandbox)
76
+ - Real-time input validation during interactive setup
77
+ - Automatic volume mapping generation based on project type
78
+ - Non-interactive mode with `--plugin`, `--mu-plugin`, `--theme` flags
79
+
80
+ ### Changed
81
+ - Replaced `config --init` with dedicated `init` command
82
+ - Enhanced user experience with prompts library
83
+ - Improved default value suggestions
84
+
85
+ ## [0.3.0]
86
+
87
+ ### Added
88
+ - Multi-project support with unique project names
89
+ - Isolated Docker volumes per project (`{projectName}_db_data`, `{projectName}_wp_build`)
90
+ - Automatic project name generation from directory name
91
+ - Support for running multiple projects simultaneously
92
+ - Shared environment strategy (same projectName across repos)
93
+
94
+ ### Changed
95
+ - Docker Compose now uses `--project-name` flag for isolation
96
+ - Volume names include project identifier
97
+ - Container names prefixed with project name
98
+
99
+ ### Fixed
100
+ - Port conflicts between multiple running projects
101
+ - Database conflicts when running multiple instances
102
+
103
+ ## [0.2.0]
104
+
105
+ ### Added
106
+ - `wp` command for WP-CLI proxy
107
+ - Support for all WP-CLI commands via pass-through
108
+ - `logs` command with service filtering
109
+ - `--follow` flag for real-time log streaming
110
+ - Configuration validation with `config --validate`
111
+ - Configuration display with `config --show` (credentials masked)
112
+
113
+ ### Changed
114
+ - Improved error messages for Docker failures
115
+ - Enhanced logging output with timestamps
116
+ - Better handling of missing Docker dependencies
117
+
118
+ ## [0.1.0]
119
+
120
+ ### Added
121
+ - Initial release of buwp-local CLI tool
122
+ - Basic Docker Compose generation and management
123
+ - `start`, `stop`, `destroy` commands
124
+ - Configuration file support (`.buwp-local.json`)
125
+ - Environment variable support (`.env.local`)
126
+ - Service toggles for Redis, S3 proxy, Shibboleth
127
+ - Port configuration (HTTP, HTTPS, database, Redis)
128
+ - Volume mappings for local code
129
+ - Support for BU WordPress Docker image
130
+ - MySQL 8.0 database service
131
+ - Redis cache service (optional)
132
+ - S3 proxy service (optional)
133
+ - Shibboleth SSO integration (optional)
134
+
135
+ ### Documentation
136
+ - Basic README with quickstart guide
137
+ - Usage documentation with examples
138
+ - Configuration reference
139
+ - Environment variable documentation
140
+
141
+ ---
142
+
143
+ ## Version History
144
+
145
+ - **0.5.x** - Keychain integration and credential management enhancements
146
+ - **0.4.x** - Interactive initialization and improved UX
147
+ - **0.3.x** - Multi-project support and isolation
148
+ - **0.2.x** - WP-CLI integration and enhanced commands
149
+ - **0.1.x** - Initial release with core functionality
@@ -0,0 +1,462 @@
1
+ # Command Reference
2
+
3
+ Complete reference for all `buwp-local` CLI commands.
4
+
5
+ ## Core Commands
6
+
7
+ ### `init`
8
+
9
+ Initialize a new project configuration with an interactive assistant.
10
+
11
+ ```bash
12
+ npx buwp-local init [options]
13
+ ```
14
+
15
+ **Options:**
16
+ - `--no-interactive` - Use non-interactive mode with defaults
17
+ - `--plugin` - Non-interactive: initialize as plugin project
18
+ - `--mu-plugin` - Non-interactive: initialize as mu-plugin project
19
+ - `--theme` - Non-interactive: initialize as theme project
20
+ - `-f, --force` - Overwrite existing configuration file
21
+
22
+ **Examples:**
23
+ ```bash
24
+ # Interactive mode (recommended)
25
+ npx buwp-local init
26
+
27
+ # Non-interactive modes
28
+ npx buwp-local init --plugin
29
+ npx buwp-local init --mu-plugin --force
30
+ npx buwp-local init --theme --no-interactive
31
+ ```
32
+
33
+ **What it does:**
34
+ - Creates `.buwp-local.json` configuration file
35
+ - Auto-detects project type from directory structure
36
+ - Generates hostname from directory name
37
+ - Creates appropriate volume mappings for plugin/theme/mu-plugin types
38
+ - Configures services (Redis, S3, Shibboleth)
39
+ - Sets up port mappings
40
+
41
+ ---
42
+
43
+ ### `start`
44
+
45
+ Start the Docker Compose environment for your project.
46
+
47
+ ```bash
48
+ npx buwp-local start [options]
49
+ ```
50
+
51
+ **Options:**
52
+ - `--xdebug` - Enable Xdebug for debugging
53
+
54
+ **Examples:**
55
+ ```bash
56
+ # Standard start
57
+ npx buwp-local start
58
+
59
+ # Start with Xdebug enabled
60
+ npx buwp-local start --xdebug
61
+ ```
62
+
63
+ **What it does:**
64
+ - Validates credentials (Keychain or `.env.local`)
65
+ - Prompts for credential setup if missing
66
+ - Generates Docker Compose configuration
67
+ - Creates secure temporary environment file
68
+ - Starts Docker containers
69
+ - Shows service URLs and status
70
+
71
+ ---
72
+
73
+ ### `stop`
74
+
75
+ Stop all running containers for the current project.
76
+
77
+ ```bash
78
+ npx buwp-local stop
79
+ ```
80
+
81
+ **What it does:**
82
+ - Stops all Docker containers
83
+ - Preserves volumes (database and WordPress files remain intact)
84
+ - Cleans up temporary environment files
85
+
86
+ ---
87
+
88
+ ### `destroy`
89
+
90
+ Destroy the entire environment including volumes.
91
+
92
+ ```bash
93
+ npx buwp-local destroy [options]
94
+ ```
95
+
96
+ **Options:**
97
+ - `-f, --force` - Skip confirmation prompt
98
+
99
+ **Examples:**
100
+ ```bash
101
+ # With confirmation prompt
102
+ npx buwp-local destroy
103
+
104
+ # Force destroy without confirmation
105
+ npx buwp-local destroy --force
106
+ ```
107
+
108
+ **What it does:**
109
+ - Stops all containers
110
+ - Removes all containers
111
+ - **Deletes all volumes** (database and WordPress files are lost!)
112
+ - Cleans up temporary files
113
+
114
+ **⚠️ Warning:** This permanently deletes your local database and WordPress installation. Cannot be undone.
115
+
116
+ ---
117
+
118
+ ### `logs`
119
+
120
+ View logs from Docker containers.
121
+
122
+ ```bash
123
+ npx buwp-local logs
124
+ ```
125
+
126
+ **Options:**
127
+ - `-f, --follow` - Follow log output
128
+
129
+ **Examples:**
130
+ ```bash
131
+ # View all logs
132
+ npx buwp-local logs
133
+
134
+ # Follow logs in real-time
135
+ npx buwp-local logs --follow
136
+ ```
137
+
138
+ ---
139
+
140
+ ### `config`
141
+
142
+ Manage project configuration.
143
+
144
+ ```bash
145
+ npx buwp-local config [options]
146
+ ```
147
+
148
+ **Options:**
149
+ - `--init` - Initialize new configuration file (legacy, use `init` instead)
150
+ - `--validate` - Validate existing configuration file
151
+ - `--show` - Display resolved configuration with masked secrets
152
+
153
+ **Examples:**
154
+ ```bash
155
+ # Validate configuration
156
+ npx buwp-local config --validate
157
+
158
+ # Show current configuration (credentials masked)
159
+ npx buwp-local config --show
160
+ ```
161
+
162
+ **What it does:**
163
+ - `--validate`: Checks `.buwp-local.json` for errors
164
+ - `--show`: Displays merged configuration (file + environment variables) with secrets masked
165
+
166
+ ---
167
+
168
+ ### `wp`
169
+
170
+ Run WP-CLI commands inside the WordPress container.
171
+
172
+ ```bash
173
+ npx buwp-local wp <wp-cli-command> [args...]
174
+ ```
175
+
176
+ **Examples:**
177
+ ```bash
178
+ # User management
179
+ npx buwp-local wp user list
180
+ npx buwp-local wp user create username user@bu.edu --role=administrator
181
+ npx buwp-local wp super-admin add username@bu.edu
182
+
183
+ # Plugin management
184
+ npx buwp-local wp plugin list
185
+ npx buwp-local wp plugin activate akismet
186
+ npx buwp-local wp plugin deactivate hello
187
+
188
+ # Post management
189
+ npx buwp-local wp post list
190
+ npx buwp-local wp post create --post_title="Test Post" --post_status=publish
191
+
192
+ # Database operations
193
+ npx buwp-local wp db export backup.sql
194
+ npx buwp-local wp db query "SELECT * FROM wp_users LIMIT 5"
195
+
196
+ # Cache operations
197
+ npx buwp-local wp cache flush
198
+ npx buwp-local wp transient delete --all
199
+
200
+ # Site management
201
+ npx buwp-local wp site-manager snapshot-pull \
202
+ --source=https://www.bu.edu/admissions/ \
203
+ --destination=http://myproject.local/admissions
204
+ ```
205
+
206
+ **What it does:**
207
+ - Executes WP-CLI commands inside the running WordPress container
208
+ - Passes through all arguments and options
209
+ - Requires containers to be running (`start` first)
210
+
211
+ **Full WP-CLI documentation:** https://developer.wordpress.org/cli/commands/
212
+
213
+ ---
214
+
215
+ ## Credential Management
216
+
217
+ ### `keychain setup`
218
+
219
+ Import credentials into macOS Keychain from a JSON file.
220
+
221
+ ```bash
222
+ npx buwp-local keychain setup --file <path-to-json>
223
+ ```
224
+
225
+ Can also be used interactively by omitting the `--file` option, but shibboleth-related credentials that are multiline have to be provided via external files.
226
+
227
+ **Options:**
228
+ - `--file <path>` - Path to credentials JSON file (required)
229
+
230
+ **Example:**
231
+ ```bash
232
+ npx buwp-local keychain setup --file ~/Downloads/buwp-local-credentials.json
233
+ ```
234
+
235
+ **What it does:**
236
+ - Reads credentials from JSON file
237
+ - Stores each credential securely in macOS Keychain
238
+ - Validates credential format
239
+ - Prompts to delete source file after import (security best practice)
240
+ - Credentials become available to all buwp-local projects
241
+
242
+ **JSON file format:**
243
+ ```json
244
+ {
245
+ "WORDPRESS_DB_PASSWORD": "password",
246
+ "DB_ROOT_PASSWORD": "rootpassword",
247
+ "SP_ENTITY_ID": "https://your-sp-entity-id",
248
+ "SHIB_SP_KEY": "-----BEGIN PRIVATE KEY-----\n...",
249
+ "SHIB_SP_CERT": "-----BEGIN CERTIFICATE-----\n...",
250
+ "S3_UPLOADS_BUCKET": "your-bucket",
251
+ "S3_UPLOADS_ACCESS_KEY_ID": "your-access-key",
252
+ "S3_UPLOADS_SECRET_ACCESS_KEY": "your-secret-key"
253
+ }
254
+ ```
255
+
256
+ ---
257
+
258
+ ### `keychain get`
259
+
260
+ Retrieve a specific credential from macOS Keychain.
261
+
262
+ ```bash
263
+ npx buwp-local keychain get <credential-name>
264
+ ```
265
+
266
+ **Example:**
267
+ ```bash
268
+ npx buwp-local keychain get WORDPRESS_DB_PASSWORD
269
+ npx buwp-local keychain get S3_UPLOADS_BUCKET
270
+ ```
271
+
272
+ **What it does:**
273
+ - Fetches the specified credential from Keychain
274
+ - Displays the value (use with caution in shared terminals)
275
+ - Returns error if credential not found
276
+
277
+ ---
278
+
279
+ ### `keychain set`
280
+
281
+ Set a single credential in macOS Keychain.
282
+
283
+ ```bash
284
+ npx buwp-local keychain set <credential-name> <value>
285
+ ```
286
+
287
+ **Example:**
288
+ ```bash
289
+ npx buwp-local keychain set WORDPRESS_DB_PASSWORD "new-password"
290
+ npx buwp-local keychain set S3_UPLOADS_BUCKET "my-bucket"
291
+ ```
292
+
293
+ **What it does:**
294
+ - Stores or updates a credential in Keychain
295
+ - Creates new entry if it doesn't exist
296
+ - Updates existing entry if it does
297
+
298
+ ---
299
+
300
+ ### `keychain delete`
301
+
302
+ Delete a credential from macOS Keychain.
303
+
304
+ ```bash
305
+ npx buwp-local keychain delete <credential-name>
306
+ ```
307
+
308
+ **Example:**
309
+ ```bash
310
+ npx buwp-local keychain delete WORDPRESS_DB_PASSWORD
311
+ ```
312
+
313
+ **What it does:**
314
+ - Removes the specified credential from Keychain
315
+ - Prompts for confirmation before deletion
316
+
317
+ ---
318
+
319
+ ### `keychain list`
320
+
321
+ List all stored credentials in macOS Keychain.
322
+
323
+ ```bash
324
+ npx buwp-local keychain list
325
+ ```
326
+
327
+ **What it does:**
328
+ - Displays all credential names (not values) stored in Keychain
329
+ - Shows which of the 15 credential types are configured
330
+ - Useful for auditing what's stored
331
+
332
+ ---
333
+
334
+ ### `keychain status`
335
+
336
+ Test Keychain access and credential loading.
337
+
338
+ ```bash
339
+ npx buwp-local keychain status
340
+ ```
341
+
342
+ **What it does:**
343
+ - Verifies Keychain is accessible
344
+ - Tests reading sample credentials
345
+ - Reports any permission or access issues
346
+ - Useful for troubleshooting Keychain integration
347
+
348
+ ---
349
+
350
+ ### `keychain clear`
351
+
352
+ Clear all stored credentials from macOS Keychain.
353
+
354
+ ```bash
355
+ npx buwp-local keychain clear [--force]
356
+ ```
357
+
358
+ **What it does:**
359
+ - Deletes all 15 buwp-local credentials from Keychain
360
+ - Prompts for confirmation unless `--force` is used
361
+
362
+ ---
363
+
364
+ ## Global Options
365
+
366
+ These options work with all commands:
367
+
368
+ - `-h, --help` - Display help for command
369
+ - `-v, --version` - Display version number
370
+
371
+ **Examples:**
372
+ ```bash
373
+ npx buwp-local --version
374
+ npx buwp-local start --help
375
+ npx buwp-local keychain --help
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Environment Variables
381
+
382
+ Commands respect these environment variables:
383
+
384
+ - `BUWP_CONFIG_FILE` - Path to config file (default: `.buwp-local.json`)
385
+ - `BUWP_ENV_FILE` - Path to environment file (default: `.env.local`)
386
+ - `NODE_ENV` - Node environment (`development`, `production`)
387
+
388
+ **Example:**
389
+ ```bash
390
+ BUWP_CONFIG_FILE=.buwp-local.staging.json npx buwp-local start
391
+ ```
392
+
393
+ ---
394
+
395
+ ## Exit Codes
396
+
397
+ Commands return standard exit codes:
398
+
399
+ - `0` - Success
400
+ - `1` - General error
401
+ - `2` - Configuration error
402
+ - `3` - Docker error
403
+ - `4` - Credential error
404
+
405
+ Use in scripts:
406
+ ```bash
407
+ npx buwp-local start
408
+ if [ $? -eq 0 ]; then
409
+ echo "Started successfully"
410
+ else
411
+ echo "Failed to start"
412
+ fi
413
+ ```
414
+
415
+ ---
416
+
417
+ ## Tips & Best Practices
418
+
419
+ ### Running Multiple Projects
420
+
421
+ Each project is isolated by its `projectName`. You can run multiple projects simultaneously:
422
+
423
+ ```bash
424
+ cd ~/project-a && npx buwp-local start
425
+ cd ~/project-b && npx buwp-local start
426
+ # Both running at the same time!
427
+ ```
428
+
429
+ See [Multi-Project Setup](MULTI_PROJECT.md) for details (upcoming).
430
+
431
+ ### Debugging
432
+
433
+ Enable Xdebug and configure your IDE:
434
+
435
+ ```bash
436
+ npx buwp-local start --xdebug
437
+ ```
438
+
439
+ Xdebug connects on port 9003 by default.
440
+
441
+ ### WP-CLI Shortcuts
442
+
443
+ Create shell aliases for common commands:
444
+
445
+ ```bash
446
+ # Add to ~/.zshrc or ~/.bashrc
447
+ alias buwp='npx buwp-local'
448
+ alias buwp-wp='npx buwp-local wp'
449
+
450
+ # Then use:
451
+ buwp start
452
+ buwp-wp plugin list
453
+ ```
454
+
455
+ ---
456
+
457
+ ## See Also
458
+
459
+ - [Getting Started](GETTING_STARTED.md) - Initial setup guide
460
+ - [Credentials Management](CREDENTIALS.md) - Detailed credential guide
461
+ - [Multi-Project Setup](MULTI_PROJECT.md) - Running multiple projects
462
+ - [Architecture](ARCHITECTURE.md) - How buwp-local works