fix: harden CHRNX theme tooling

This commit is contained in:
chrnx committed 2026-08-11 13:43:57 -05:00
1 parent 2cd629a709
commit f23b40edba
5 files changed
+55 -256

No files matched your search

+17 -4
View File
@@ -7,7 +7,6 @@ approved design materials and a reproducible local development scaffold.
- Node.js 22 (use `nvm use`)
- npm
- Composer dependencies are installed inside the wp-env CLI container
- Docker through Colima on macOS
- Docker Compose v2 available as a Docker CLI plugin
@@ -15,13 +14,16 @@ approved design materials and a reproducible local development scaffold.
```sh
nvm use
npm install
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`.
@@ -37,8 +39,19 @@ 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
mkdir -p "$HOME/.docker/cli-plugins"
ln -s /usr/local/bin/docker-compose "$HOME/.docker/cli-plugins/docker-compose"
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
-250
View File
@@ -14872,16 +14872,6 @@
"dev": true,
"license": "BSD-2-Clause"
},
"node_modules/data-uri-to-buffer": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-8.0.0.tgz",
"integrity": "sha512-6UHfyCux51b8PTGDgveqtz1tvphBku5DrMKKJbFAZAJOI2zsjDpDoYE1+QGj7FOMS4BdTFNJsJiR3zEB0xH0yQ==",
"extraneous": true,
"license": "MIT",
"engines": {
"node": ">= 20"
}
},
"node_modules/data-urls": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz",
@@ -15189,24 +15179,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/degenerator": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/degenerator/-/degenerator-7.0.1.tgz",
"integrity": "sha512-ABErK0IefDSyHjlPH7WUEenIAX2rPPnrDcDM+TS3z3+zu9TfyKKi07BQM+8rmxpdE2y1v5fjjdoAS/x4D2U60w==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"ast-types": "^0.13.4",
"escodegen": "^2.1.0",
"esprima": "^4.0.1"
},
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"quickjs-wasi": "^2.2.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
@@ -17564,21 +17536,6 @@
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
}
},
"node_modules/get-uri": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/get-uri/-/get-uri-8.0.1.tgz",
"integrity": "sha512-/5N/P4Lrh0p/mDwlDRi7Y1+P2o/OyzZI3l6Iz1Ov6XXwwm1y3RlZLuo3gVgML99djrEDtV980bBxSuOeHLk8ww==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"basic-ftp": "^5.3.1",
"data-uri-to-buffer": "8.0.0",
"debug": "^4.3.4"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/gettext-parser": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.4.0.tgz",
@@ -22385,83 +22342,6 @@
"node": ">=6"
}
},
"node_modules/pac-proxy-agent": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-9.1.0.tgz",
"integrity": "sha512-1aU+1mpj3DrQPfo3gh+3Gap3G5x+axnMx1P/y0ZF2ch7kb2meyOCAH8K2k9d27ROsTE7TnAerzxqF9aon2jqnA==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"agent-base": "9.0.0",
"debug": "^4.3.4",
"get-uri": "8.0.1",
"http-proxy-agent": "9.1.0",
"https-proxy-agent": "9.1.0",
"pac-resolver": "9.0.1",
"quickjs-wasi": "^2.2.0",
"socks-proxy-agent": "10.1.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/pac-proxy-agent/node_modules/agent-base": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-9.0.0.tgz",
"integrity": "sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==",
"extraneous": true,
"license": "MIT",
"engines": {
"node": ">= 20"
}
},
"node_modules/pac-proxy-agent/node_modules/http-proxy-agent": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-9.1.0.tgz",
"integrity": "sha512-2NxoveTT58mjYT4n3RPTEfCZGLMbidoO8XEieXfpSYxu+PQJ1qpx4ypwH6N+uF9twBPIvRRgvkvW5HUTYWENig==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"agent-base": "9.0.0",
"debug": "^4.3.4",
"proxy-agent-negotiate": "1.1.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/pac-proxy-agent/node_modules/https-proxy-agent": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-9.1.0.tgz",
"integrity": "sha512-ag87y7cJJ9/3+GxFr8Oy4O5faDsGRGnBGsJj/YjOSsSx/5eadKLYTMPlzuR6obgoCDDm0abAAZitXXQkMOPSpA==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"agent-base": "9.0.0",
"debug": "^4.3.4",
"proxy-agent-negotiate": "1.1.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/pac-resolver": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-9.0.1.tgz",
"integrity": "sha512-lJbS008tmkj08VhoM8Hzuv/VE5tK9MS0OIQ/7+s0lIF+BYhiQWFYzkSpML7lXs9iBu2jfmzBTLzhe9n6BX+dYw==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"degenerator": "7.0.1",
"netmask": "^2.0.2"
},
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"quickjs-wasi": "^2.2.0"
}
},
"node_modules/package-json-from-dist": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
@@ -23859,104 +23739,6 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-agent": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-8.0.2.tgz",
"integrity": "sha512-idLLRewuemWd7GH/BDJzGiB0dWGfT2SQs3jy6NtZtGWU9uPTTSdeC1/cdbqLwgzhfv027daGFuXX426e2Eg20A==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"agent-base": "9.0.0",
"debug": "^4.3.4",
"http-proxy-agent": "9.1.0",
"https-proxy-agent": "9.1.0",
"lru-cache": "^7.14.1",
"pac-proxy-agent": "9.1.0",
"proxy-from-env": "^2.0.0",
"socks-proxy-agent": "10.1.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/proxy-agent-negotiate": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-agent-negotiate/-/proxy-agent-negotiate-1.1.0.tgz",
"integrity": "sha512-N8IBcM3UgCVzz2L2Lqv8DVntDnnC8/hiV4nEDUPkqq72TPUgYWjQc+bdZlBPZK9LzPAvOY//gAt0S0DApoOXWQ==",
"extraneous": true,
"license": "MIT",
"engines": {
"node": ">= 20"
},
"peerDependencies": {
"kerberos": "^2.0.0"
},
"peerDependenciesMeta": {
"kerberos": {
"optional": true
}
}
},
"node_modules/proxy-agent/node_modules/agent-base": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-9.0.0.tgz",
"integrity": "sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==",
"extraneous": true,
"license": "MIT",
"engines": {
"node": ">= 20"
}
},
"node_modules/proxy-agent/node_modules/http-proxy-agent": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-9.1.0.tgz",
"integrity": "sha512-2NxoveTT58mjYT4n3RPTEfCZGLMbidoO8XEieXfpSYxu+PQJ1qpx4ypwH6N+uF9twBPIvRRgvkvW5HUTYWENig==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"agent-base": "9.0.0",
"debug": "^4.3.4",
"proxy-agent-negotiate": "1.1.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/proxy-agent/node_modules/https-proxy-agent": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-9.1.0.tgz",
"integrity": "sha512-ag87y7cJJ9/3+GxFr8Oy4O5faDsGRGnBGsJj/YjOSsSx/5eadKLYTMPlzuR6obgoCDDm0abAAZitXXQkMOPSpA==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"agent-base": "9.0.0",
"debug": "^4.3.4",
"proxy-agent-negotiate": "1.1.0"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/proxy-agent/node_modules/lru-cache": {
"version": "7.18.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
"integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==",
"extraneous": true,
"license": "ISC",
"engines": {
"node": ">=12"
}
},
"node_modules/proxy-from-env": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz",
"integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==",
"extraneous": true,
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/pump": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz",
@@ -24133,13 +23915,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/quickjs-wasi": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/quickjs-wasi/-/quickjs-wasi-2.2.0.tgz",
"integrity": "sha512-zQxXmQMrEoD3S+jQdYsloq4qAuaxKFHZj6hHqOYGwB2iQZH+q9e/lf5zQPXCKOk0WJuAjzRFbO4KwHIp2D05Iw==",
"extraneous": true,
"license": "MIT"
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@@ -25601,31 +25376,6 @@
"npm": ">= 3.0.0"
}
},
"node_modules/socks-proxy-agent": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-10.1.0.tgz",
"integrity": "sha512-WlMj/67cEJ6MDI1OcsnjuYKDNDoyPCCYZ249kuuXPiMDw9F8PXkVaQ7YWu3siTydfQ/4BEZcvGzu+aYvz7dDCQ==",
"extraneous": true,
"license": "MIT",
"dependencies": {
"agent-base": "9.0.0",
"debug": "^4.3.4",
"socks": "^2.8.3"
},
"engines": {
"node": ">= 20"
}
},
"node_modules/socks-proxy-agent/node_modules/agent-base": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-9.0.0.tgz",
"integrity": "sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==",
"extraneous": true,
"license": "MIT",
"engines": {
"node": ">= 20"
}
},
"node_modules/source-map": {
"version": "0.7.6",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz",
+1
View File
@@ -2,6 +2,7 @@
"name": "chrnx-wordpress-theme",
"version": "0.1.0",
"private": true,
"packageManager": "npm@11.17.0",
"engines": {
"node": ">=22 <27"
},
+8 -2
View File
@@ -1,8 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" failOnWarning="true" failOnRisky="true">
<phpunit
bootstrap="tests/php/bootstrap.php"
colors="true"
failOnEmptyTestSuite="true"
failOnRisky="true"
failOnWarning="true"
>
<testsuites>
<testsuite name="CHRNX theme tests">
<directory suffix="Test.php">tests/php</directory>
<directory suffix=".php">tests/php</directory>
</testsuite>
</testsuites>
</phpunit>
+29
View File
@@ -6,11 +6,40 @@ test('tooling is pinned and wp-env maps this repo as chrnx', async () => {
const pkg = JSON.parse(await readFile('package.json', 'utf8'));
const env = JSON.parse(await readFile('.wp-env.json', 'utf8'));
assert.equal(pkg.engines.node, '>=22 <27');
assert.equal(pkg.packageManager, 'npm@11.17.0');
assert.equal(pkg.devDependencies['@wordpress/env'], '11.12.0');
assert.equal(pkg.devDependencies['@wordpress/scripts'], '34.0.0');
assert.equal(pkg.devDependencies['@playwright/test'], '1.62.1');
assert.equal(pkg.devDependencies.lighthouse, '13.4.1');
assert.equal(env.core, 'https://wordpress.org/wordpress-6.9.6.zip');
assert.equal(env.phpVersion, '8.3');
assert.equal(env.autoPort, false);
assert.equal(env.port, 8888);
assert.equal(env.config.WP_DEBUG, true);
assert.equal(env.config.SCRIPT_DEBUG, true);
assert.equal(env.mappings['wp-content/themes/chrnx'], '.');
});
test('scripts activate chrnx and run Composer from the mapped theme', async () => {
const pkg = JSON.parse(await readFile('package.json', 'utf8'));
assert.equal(pkg.scripts['env:activate'], 'wp-env run cli wp theme activate chrnx');
assert.equal(
pkg.scripts.composer,
'wp-env run cli --env-cwd=wp-content/themes/chrnx composer',
);
});
test('PHP quality tools enforce the CHRNX conventions and cannot pass an empty suite', async () => {
const phpcs = await readFile('phpcs.xml.dist', 'utf8');
const phpunit = await readFile('phpunit.xml.dist', 'utf8');
assert.match(phpcs, /<rule ref="WordPress-Core"\/>/);
assert.match(phpcs, /<rule ref="WordPress-Extra"\/>/);
assert.match(phpcs, /name="text_domain"[^>]+value="chrnx"/);
assert.match(phpcs, /name="prefixes"[^>]+value="chrnx_"/);
assert.match(phpunit, /bootstrap="tests\/php\/bootstrap\.php"/);
assert.match(phpunit, /failOnEmptyTestSuite="true"/);
assert.match(phpunit, /<directory suffix="\.php">tests\/php<\/directory>/);
});