feature: Enhance bootstrap scripts with improved configuration handling and plugin management

This commit is contained in:
Keith Solomon
2025-11-01 11:01:57 -05:00
parent 06e4007b5e
commit 1f12dff4d2
3 changed files with 347 additions and 128 deletions

View File

@@ -1,67 +1,80 @@
# Easy WordPress Bootstrap (Herd + DBngin) — Windows Edition
# Easy WordPress Bootstrap (Windows + Herd)
This kit lets Windows devs spin up a new local WordPress project using **PowerShell only**.
PowerShell companion to the macOS bootstrap script. It provisions a full WordPress development site backed by Laravel Herd and DBngin (or any local MySQL/MariaDB server) with a single command.
## Includes
## Included Files
- `wp-bootstrap.ps1` main PowerShell script
- `bootstrap.bat` — one-click launcher
- `plugins.json` — minimal default plugin list (use file from repo root)
- `wp-bootstrap.ps1` main PowerShell script.
- `wp-cli.phar` bundled WP-CLI used by the script when `wp` is not installed globally.
- `plugins.json` default plugin manifest; copy/override per project if you need a different set.
## Prerequisites
- **PHP** installed and in PATH
- **MySQL client** (`mysql.exe`) in PATH (DBngin/MySQL installed and running)
- **Git** installed (for cloning the starter theme)
- **WP-CLI**: either installed globally as `wp`, **or** put `wp-cli.phar` next to this script and call with:
- `-WpCliPath "php .\wp-cli.phar"`
- Windows 10/11 with PowerShell 7 (`pwsh`) recommended.
- [Laravel Herd for Windows](https://herd.laravel.com/) installed so PHP is available (the script auto-detects Herds `php.exe`).
- DBngin or another MySQL/MariaDB server running locally, with `mysql.exe` available in `PATH`.
- Git for cloning the starter theme.
- Composer and npm in `PATH` so theme dependencies can be installed and built (the script warns and skips if they are missing).
## Quick Start
## First-Time Setup
1. Right-click **PowerShell***Run as Administrator* (first run only):
1. Allow local PowerShell scripts (only needs to be done once for your profile):
```powershell
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
```
2. Open a normal PowerShell in this folder and run:
2. Copy the sample rc file and adjust values that should become your defaults:
```powershell
.\wp-bootstrap.ps1 -ProjectName "Client Site"
Copy-Item ..\wp-bootstraprc.example $HOME\.wp-bootstraprc
```
or double-click `bootstrap.bat` and enter the project name when prompted.
3. Leave `wp-cli.phar` in the same folder as `wp-bootstrap.ps1` (or update the `WP_CLI_PHAR` entry in your rc file to point elsewhere).
### Optional parameters
## Running a Bootstrap
- `-AdminUser` (default: `vdidev`)
- `-AdminEmail` (default: `dev@vincentdesign.ca`)
- `-ThemeStarterRepo` (default: VDI starter theme)
- `-HerdWorkspace` (default: `"$HOME\Herd"`)
- `-LocalTld` (default: `test`)
- `-MysqlHost` / `-MysqlPort` / `-MysqlRootUser` / `-MysqlRootPass`
- `-WpCliPath` (set to `"php .\wp-cli.phar"` if not installed globally)
From this directory, run:
## What it does
```powershell
pwsh -File .\wp-bootstrap.ps1 -ProjectName "Client Site"
```
- Creates project folder under your Herd workspace
- Downloads WordPress core
- Creates database + user with random password
- Generates `wp-config.php`, shuffles salts
- Installs WordPress and sets the site/home URLs
- Creates **Home** and **News** pages, sets **front page**/**posts page**
- Sets permalinks to `/%postname%/` and flushes
- Clones the starter theme, strips history, re-initializes a clean repo, and activates it
- Installs and (optionally) activates plugins from `plugins.json`
- Prints and saves a summary (`bootstrap-summary.txt`)
Optional parameters (all may also be supplied via `~\.wp-bootstraprc`):
- `-AdminUser`
- `-AdminEmail`
- `-ThemeStarterRepo`
- `-HerdWorkspace`
- `-LocalTld`
- `-MysqlHost`
- `-MysqlPort`
- `-MysqlRootUser`
- `-MysqlRootPass`
Omit parameters to fall back to your rc defaults. The script prints the detected configuration before it runs and exits early if required inputs are still missing.
## What the Script Does
- Creates a sanitized project folder in your Herd workspace and reports the local URL.
- Validates MySQL root credentials, creates the database/user, and confirms the new user can connect.
- Downloads WordPress core, generates `wp-config.php`, shuffles salts, sets permalinks, creates Home/News pages, and assigns them.
- Ensures a standard `.htaccess` exists for Apache-friendly rewrites.
- Clones the starter theme with shallow history, strips `.git`, reinitializes the repo, sets an optional remote, and activates the theme.
- Installs/activates plugins pulled from `plugins.json`, preferring a project-local manifest when present.
- Runs `composer install`, `npm install`, and `npm run build` inside the theme when those tools are available.
- Writes a `bootstrap-summary.txt` to the project root and logs plugin installs to `wp-content/plugin-bootstrap.log`.
## Plugin Manifest Details
`plugins.json` entries can be WordPress.org slugs or zip URLs (including private artifacts). Place a tailored `plugins.json` in your project directory to override the repository default for a single site.
## Troubleshooting
- **WP-CLI not found**: pass `-WpCliPath "php .\wp-cli.phar"` (place `wp-cli.phar` beside this script).
- **MySQL not found**: ensure `mysql.exe` is in PATH. With DBngin, add the MySQL bin folder to PATH.
- **Access denied creating DB**: verify `-MysqlRootUser`/`-MysqlRootPass`, or create a dev-only MySQL user with `CREATE` privileges.
- **Herd not serving**: Add/link the folder in Herd and browse to `http://<slug>.test` (or your chosen TLD).
- **WP-CLI** ensure `wp-cli.phar` lives beside the script or set `WP_CLI_PHAR` in `~\.wp-bootstraprc` to an absolute path.
- **MySQL connectivity** verify the server is running, your root user matches the rc values, and Windows Firewall allows the connection.
- **Composer/NPM missing** install them via Scoop/winget/Homebrew on Windows, or remove their commands from the script if you do not build theme assets.
- **Permissions** confirm Herd has access to the project folder and that the execution policy change succeeded.
## Philosophy
DIY-first: keep `plugins.json` minimal. Only add big offtheshelf stacks (e.g., ecomm) when warranted.
---
DIY-first policy: keep `plugins.json` lean; add heavier stacks only when the project truly needs them.