@imwz/wp-pattern-sentinel 0.3.0 → 1.0.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.
- package/README.md +12 -0
- package/package.json +1 -1
- package/src/main.js +6 -1
- package/src/validation.js +12 -1
package/README.md
CHANGED
|
@@ -192,6 +192,18 @@ Commit `.sentinel-cache.json` to track validated state across sessions. Add it t
|
|
|
192
192
|
|
|
193
193
|
When any pattern fails, sentinel automatically writes a `sentinel-<timestamp>.log.json` file in the current working directory and prints the path after the summary. This preserves error details for later inspection without needing to re-run. Use `--log` to write the file even on a fully-passing run.
|
|
194
194
|
|
|
195
|
+
Failing results include a `savedContent` field — the editor's serialized output — so you can diff it directly against the source file:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
node -e "
|
|
199
|
+
const log = JSON.parse(require('fs').readFileSync('sentinel-*.log.json'));
|
|
200
|
+
const r = log.results.find(r => !r.passed);
|
|
201
|
+
console.log(r.savedContent);
|
|
202
|
+
" | diff - patterns/my-pattern.php
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`block_validation` errors also surface Gutenberg's human-readable issue messages (e.g. `"Expected attribute 'class' of value '…' but got '…'"`), so you no longer need to open the browser console to identify what failed.
|
|
206
|
+
|
|
195
207
|
## npm publish
|
|
196
208
|
|
|
197
209
|
When ready to publish:
|
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -210,7 +210,11 @@ async function validatePatternFile(patternPath, options, context) {
|
|
|
210
210
|
if (blockErrors.length > 0) {
|
|
211
211
|
saveResult.errors.push(...blockErrors.map(e => ({
|
|
212
212
|
type: 'block_validation',
|
|
213
|
-
message: `${e.blockName} (${e.blockId}): ${e.error}
|
|
213
|
+
message: `${e.blockName} (${e.blockId}): ${e.error}${
|
|
214
|
+
e.validationIssues?.length
|
|
215
|
+
? '\n Issues: ' + e.validationIssues.join('\n ')
|
|
216
|
+
: ''
|
|
217
|
+
}`,
|
|
214
218
|
})));
|
|
215
219
|
}
|
|
216
220
|
|
|
@@ -266,6 +270,7 @@ async function writeLogFile(results) {
|
|
|
266
270
|
duration: r.duration,
|
|
267
271
|
errors: r.errors,
|
|
268
272
|
warnings: r.warnings,
|
|
273
|
+
...(r.passed ? {} : { savedContent: r.savedContent ?? null }),
|
|
269
274
|
})),
|
|
270
275
|
};
|
|
271
276
|
await fs.promises.writeFile(logPath, JSON.stringify(payload, null, 2));
|
package/src/validation.js
CHANGED
|
@@ -8,7 +8,18 @@ export async function checkBlockValidation(page) {
|
|
|
8
8
|
return await page.evaluate(() => {
|
|
9
9
|
const walk = blocks => blocks.flatMap(block => [
|
|
10
10
|
...(block.isValid === false
|
|
11
|
-
? [{
|
|
11
|
+
? [{
|
|
12
|
+
blockId: block.clientId,
|
|
13
|
+
blockName: block.name,
|
|
14
|
+
error: 'Block validation failed',
|
|
15
|
+
validationIssues: (block.validationIssues ?? []).map(issue => {
|
|
16
|
+
try {
|
|
17
|
+
return (issue.args ?? [])
|
|
18
|
+
.map(a => (typeof a === 'string' ? a : JSON.stringify(a)))
|
|
19
|
+
.join(' ');
|
|
20
|
+
} catch { return 'unknown issue'; }
|
|
21
|
+
}),
|
|
22
|
+
}]
|
|
12
23
|
: []),
|
|
13
24
|
...walk(block.innerBlocks ?? []),
|
|
14
25
|
]);
|