162 lines
5.5 KiB
Markdown
162 lines
5.5 KiB
Markdown
# CHRNX WordPress Theme
|
|
|
|
Custom WordPress theme for chrnx.dev. This repository currently contains the
|
|
approved design materials and a reproducible local development scaffold.
|
|
|
|
## Prerequisites
|
|
|
|
- Node.js 22 (use `nvm use`)
|
|
- npm
|
|
- Docker through Colima on macOS
|
|
- Docker Compose v2 available as a Docker CLI plugin
|
|
|
|
## Local setup
|
|
|
|
```sh
|
|
nvm use
|
|
npm ci
|
|
npx playwright install chromium firefox webkit
|
|
colima start
|
|
PATH="/opt/homebrew/opt/docker/bin:$PATH" npm run env:start
|
|
PATH="/opt/homebrew/opt/docker/bin:$PATH" npm run composer -- install
|
|
```
|
|
|
|
Composer is provided by the wp-env CLI container; no host Composer installation
|
|
is required.
|
|
|
|
The local WordPress site is available at <http://localhost:8888>. Once the
|
|
theme implementation exists, activate it with `npm run env:activate`.
|
|
|
|
Run the configuration smoke test with:
|
|
|
|
```sh
|
|
npm run test:smoke
|
|
```
|
|
|
|
## Local visual review
|
|
|
|
Seed the local `wp-env` site with deterministic review content:
|
|
|
|
```sh
|
|
./scripts/seed-test-content.sh
|
|
```
|
|
|
|
The script accepts only `localhost` or `127.0.0.1`. It updates records marked
|
|
with `_chrnx_fixture_key` and leaves unrelated local content alone. Repeated
|
|
runs reuse the same pages and posts. Before its first normal seed, it snapshots
|
|
the exact local values for `sticky_posts`, site title/tagline, front/posts Page
|
|
settings, permalink structure, the Subscribe Page pointer, and an existing
|
|
fixture-owned Subscribe Page status. Fixture stickies are merged with unrelated
|
|
sticky IDs instead of replacing them.
|
|
|
|
Use an allowlisted local edge scenario, then restore the default dataset:
|
|
|
|
```sh
|
|
./scripts/seed-test-content.sh featured-1
|
|
./scripts/seed-test-content.sh featured-2
|
|
./scripts/seed-test-content.sh featured-3
|
|
./scripts/seed-test-content.sh subscribe-unpublished
|
|
./scripts/seed-test-content.sh subscribe-unavailable
|
|
./scripts/seed-test-content.sh default
|
|
./scripts/seed-test-content.sh restore
|
|
```
|
|
|
|
`default` restores the fixture presentation after an edge scenario; it does not
|
|
discard the pre-fixture snapshot. Run `restore` explicitly to reinstate the
|
|
captured option values and owned Subscribe status byte-for-byte and remove the
|
|
snapshot. Fixture pages/posts remain local and reusable.
|
|
|
|
Rebuild the responsive portrait derivatives on macOS with `sips`, `cwebp`, and
|
|
`avifenc`:
|
|
|
|
```sh
|
|
./scripts/build-responsive-images.sh
|
|
```
|
|
|
|
For a non-destructive reproducibility check, create a named direct child of the
|
|
system temporary directory and pass its explicit absolute path:
|
|
|
|
```sh
|
|
responsive_output=$(mktemp -d "${TMPDIR:-/tmp}/chrnx-responsive.XXXXXX")
|
|
./scripts/build-responsive-images.sh "$responsive_output"
|
|
```
|
|
|
|
The rebuild rejects symlinks, nested paths, nonexistent paths, and destinations
|
|
outside the canonical system temporary directory. The automated smoke test
|
|
byte-compares all 40 outputs, validates their formats and dimensions, and
|
|
enforces 160 KiB per derivative, 400 KiB for the collage family, and a 2.1 MiB
|
|
total inventory bound.
|
|
|
|
The source masters remain unchanged. WordPress serves 384 px and 768 px AVIF or
|
|
WebP sources, with the original source as a fallback.
|
|
|
|
Capture the approved local review routes with Chromium:
|
|
|
|
Create the ignored local override `.wp-env.override.json` so this checkout stays
|
|
isolated from the root environment:
|
|
|
|
```json
|
|
{
|
|
"port": 8908,
|
|
"testsPort": 8909
|
|
}
|
|
```
|
|
|
|
Then start WordPress, activate the theme, and seed the deterministic fixtures:
|
|
|
|
```sh
|
|
npm run env:start
|
|
npm run env:activate
|
|
./scripts/seed-test-content.sh
|
|
```
|
|
|
|
Capture only after those commands succeed:
|
|
|
|
```sh
|
|
CHRNX_REVIEW_URL=http://localhost:8908 node scripts/capture-visual-review.mjs
|
|
```
|
|
|
|
The capture script rejects public hosts and writes its screenshots to
|
|
`tmp/imagegen/grunge-stage-review.png/`, which Git ignores. The directory's
|
|
`.png` suffix intentionally matches the existing review-artifact ignore rule;
|
|
the script builds all 24 files in a private staging directory, validates the
|
|
complete inventory, and publishes the directory as one fresh set; a failed
|
|
capture leaves the prior published set unchanged. It captures the rendered
|
|
Music and Podcasts pages at 375, 768, 1440, and 2560 px in light and dark themes.
|
|
The long-copy Podcast state changes only the rendered latest-card title and
|
|
excerpt; it does not write to the database. Source masters remain authoritative,
|
|
and responsive media must be rebuilt with `scripts/build-responsive-images.sh`
|
|
after any approved source change. Treat these screenshots as disposable review
|
|
evidence: keep them uncommitted, obtain visual approval before committing this
|
|
stage, and do not begin the next visual task until that approval is recorded.
|
|
|
|
PHPUnit always runs through wp-env's isolated `tests-cli` database. The browser
|
|
suite uses the separate development `cli` database; its serial scenario project
|
|
restores the default 7-page/12-post fixture dataset before exiting.
|
|
|
|
Use `npm run env:stop` to stop the local WordPress environment.
|
|
|
|
If Homebrew's Docker CLI cannot find an existing standalone Compose v2 binary,
|
|
link it into Docker's per-user plugin directory before starting wp-env:
|
|
|
|
```sh
|
|
compose_source="$(command -v docker-compose)" || {
|
|
echo "docker-compose is not installed" >&2
|
|
exit 1
|
|
}
|
|
docker-compose version
|
|
plugin_dir="${DOCKER_CONFIG:-$HOME/.docker}/cli-plugins"
|
|
plugin_path="$plugin_dir/docker-compose"
|
|
if [ -e "$plugin_path" ] || [ -L "$plugin_path" ]; then
|
|
echo "Refusing to replace existing $plugin_path" >&2
|
|
exit 1
|
|
fi
|
|
mkdir -p -- "$plugin_dir"
|
|
ln -s -- "$compose_source" "$plugin_path"
|
|
```
|
|
|
|
## Deployment boundary
|
|
|
|
This setup is local-only. It does not create or configure a production
|
|
deployment, publish the theme, or mutate chrnx.dev.
|