@imwz/wp-pattern-sentinel 1.2.0 → 1.2.1

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.
Files changed (3) hide show
  1. package/README.md +12 -3
  2. package/package.json +1 -1
  3. package/src/args.js +16 -0
package/README.md CHANGED
@@ -14,7 +14,7 @@ WordPress block validation is a JavaScript concern. The editor's `save()` functi
14
14
 
15
15
  Credentials are resolved in this order — the first match wins:
16
16
 
17
- 1. **`--trellis` flag** — reads directly from Roots Trellis vault + `wordpress_sites.yml`
17
+ 1. **`--trellis` flag** — reads directly from Roots Trellis vault + `wordpress_sites.yml` (`--user` / `--pass` still override the username and password)
18
18
  2. **CLI flags** — `--url`, `--user`, `--pass`
19
19
  3. **Environment variables** — `WP_URL`, `WP_USER`, `WP_PASS`
20
20
  4. **`.env` file** — placed in the directory where you run sentinel
@@ -63,6 +63,15 @@ Sentinel auto-discovers the Trellis directory by walking up from the current wor
63
63
 
64
64
  **Bedrock support:** When `--trellis` is used, sentinel auto-detects Bedrock installs by reading `WP_SITEURL` from the site's `.env` file. Bedrock puts WordPress core in `/wp/`, so admin URLs become `/wp/wp-admin/` instead of `/wp-admin/`. No extra flags needed — this is handled automatically.
65
65
 
66
+ **Different admin user:** Trellis provisions a WordPress user named `admin`, and that is the username Sentinel logs in with. If the local database was pulled from production, `admin` may not exist and login fails with "The username admin is not registered on this site". Pass the real admin with `--user`. Add `--pass` if that user's password differs from the vault's `admin_password`. URL and Bedrock detection still come from Trellis.
67
+
68
+ ```bash
69
+ sentinel --trellis --site=example.com --user=jane path/to/patterns/
70
+
71
+ # Password from your shell rather than the command line history; an empty value keeps the vault password
72
+ sentinel --trellis --site=example.com --user=jane --pass="$WP_PASS" path/to/patterns/
73
+ ```
74
+
66
75
  ---
67
76
 
68
77
  ## Quickstart with `.env`
@@ -154,8 +163,8 @@ A block that renders `InnerBlocks` with a `template` and `templateLock: "all"` o
154
163
  | Flag | Default | Description |
155
164
  |------|---------|-------------|
156
165
  | `--url` | `http://localhost` | WordPress site URL |
157
- | `--user` | `admin` | Admin username |
158
- | `--pass` | `password` | Admin password |
166
+ | `--user` | `admin` | Admin username. Overrides the Trellis username when used with `--trellis` |
167
+ | `--pass` | `password` | Admin password. Overrides the vault password when used with `--trellis` |
159
168
  | `--wp-subdir` | — | WP core subdir when not using `--trellis` (e.g. `wp` for Bedrock). Sets admin URL to `{url}/{subdir}`. Auto-detected from `WP_SITEURL` when `--trellis` is used. |
160
169
  | `--headless` | `true` | Run browser headless |
161
170
  | `--concurrency` | `4` | Parallel workers |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imwz/wp-pattern-sentinel",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Browser-based WordPress block pattern validator using Playwright",
5
5
  "type": "module",
6
6
  "engines": {
package/src/args.js CHANGED
@@ -7,6 +7,7 @@ import { findTrellisDir, loadTrellisCredentials } from './trellis.js';
7
7
  /**
8
8
  * Credential resolution priority:
9
9
  * 1. --trellis flag → reads Roots Trellis vault + wordpress_sites.yml
10
+ * (--user / --pass still override the vault values)
10
11
  * 2. CLI flags → --url, --user, --pass
11
12
  * 3. Env vars → WP_URL, WP_USER, WP_PASS
12
13
  * 4. .env file → loaded from cwd automatically
@@ -64,6 +65,19 @@ function loadDotEnv() {
64
65
  }
65
66
  }
66
67
 
68
+ /**
69
+ * Let --user / --pass override credentials read from Trellis. Trellis
70
+ * provisions the WordPress user "admin", but a site whose database was pulled
71
+ * from production only has that site's real admin, so explicit flags win. An
72
+ * empty flag (`--pass="$UNSET_VAR"` in an npm script) keeps the vault value.
73
+ */
74
+ export function applyCredentialFlags({ user, pass }, values) {
75
+ return {
76
+ user: values.user || user,
77
+ pass: values.pass || pass,
78
+ };
79
+ }
80
+
67
81
  export async function parseArgs(args) {
68
82
  loadDotEnv();
69
83
 
@@ -88,6 +102,8 @@ export async function parseArgs(args) {
88
102
  subsite: values.subsite ?? null,
89
103
  }));
90
104
 
105
+ ({ user, pass } = applyCredentialFlags({ user, pass }, values));
106
+
91
107
  } else {
92
108
  // --- Source 2: CLI flags ---
93
109
  url = values.url;