@geonosis/walk 3.1.0 → 3.3.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/CHANGELOG.md +25 -0
- package/README.md +41 -10
- package/dist/browser.d.ts +2 -18
- package/dist/config.d.ts +3 -2
- package/dist/config.js +65 -15
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -2
- package/dist/options.d.ts +2 -11
- package/dist/options.js +4 -1
- package/dist/probes/buy-box-above-fold.d.ts +1 -14
- package/dist/probes/buy-box-above-fold.js +3 -5
- package/dist/probes/define.d.ts +7 -0
- package/dist/probes/define.js +12 -0
- package/dist/probes/empty-section.d.ts +1 -16
- package/dist/probes/empty-section.js +3 -3
- package/dist/probes/error-page-status.d.ts +1 -20
- package/dist/probes/error-page-status.js +8 -31
- package/dist/probes/fabricated-claim.d.ts +1 -14
- package/dist/probes/fabricated-claim.js +6 -23
- package/dist/probes/fake-session.d.ts +1 -14
- package/dist/probes/fake-session.js +3 -4
- package/dist/probes/index.d.ts +1 -5
- package/dist/probes/light-on-light.d.ts +1 -15
- package/dist/probes/light-on-light.js +3 -3
- package/dist/probes/link-integrity.d.ts +2 -14
- package/dist/probes/link-integrity.js +19 -12
- package/dist/probes/money-format.d.ts +1 -14
- package/dist/probes/money-format.js +3 -3
- package/dist/probes/ops-leakage.d.ts +1 -13
- package/dist/probes/ops-leakage.js +6 -23
- package/dist/probes/orphan-url.d.ts +1 -13
- package/dist/probes/orphan-url.js +3 -3
- package/dist/probes/placeholder-asset.d.ts +1 -14
- package/dist/probes/placeholder-asset.js +3 -4
- package/dist/probes/stub-only-entity.d.ts +1 -14
- package/dist/probes/stub-only-entity.js +3 -3
- package/dist/probes/text-probe.d.ts +12 -0
- package/dist/probes/text-probe.js +37 -0
- package/dist/probes/thin-page.d.ts +1 -14
- package/dist/probes/thin-page.js +3 -3
- package/dist/types.d.ts +18 -55
- package/dist/types.js +11 -1
- package/dist/walk-cli.js +31 -8
- package/dist/walk.d.ts +5 -13
- package/dist/walk.js +81 -28
- package/package.json +19 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @geonosis/walk
|
|
2
2
|
|
|
3
|
+
## 3.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fb08b28: `walk.versionKey` and `--version-key <key>` send `Cloudflare-Workers-Version-Key` with every request to the origin of each walked page (#64). During a gradual deployment on Workers each request is otherwise routed to a version by chance, so a walk can read HTML from one version and ask the other for its content-hashed assets. The header goes on the page's own requests through a route scoped to that origin, and on the HEAD and GET requests `link-integrity` makes to it (`ProbeContext.headers`); another origin's requests are left alone, because a custom header sends them through a CORS preflight.
|
|
8
|
+
- fb08b28: A page that answers 400 or worse is walked instead of aborting the run (#61). `walk()` threw for any status of 400 or more before a probe ran, so the run exited 2 with no report, the pages already walked lost their findings, and `error-page-status`'s `honestFrom` could never take effect. Every page that answered is now walked, each probe is handed the status, and the report records it per page (`status`). The status a page must answer is declared in the config, `walk.urls: [{ "url": …, "status": 404 }]`, and a page that answers anything else is a finding: `link-integrity` for a broken link in the walk list (an undeclared 400 or worse, or a declared 200 that answered an error) and `error-page-status` for a soft 404 (a declared error that answered 200). Exit 2 stays for a page that answered nothing or could not be opened; that stops the walk, names the URL, and writes the pages walked so far to `<report>.partial.json` while the report the ratchet reads stays absent. `walk()` takes `expected`, throws `WalkStopped` (a `WalkError` carrying the partial report), and `PageReport` gains `status`.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- fb08b28: The published manifests no longer declare `engines.bun`, which yarn 1 warned about once per installed package (`The engine "bun" appears to be invalid`). A package that starts its bins on bun now names it in `devEngines.runtime`, the same list the kit's root declares; measured on yarn 1.22.22, npm 11.13.0, pnpm 11.8.0 and 12.10.1 and bun 1.4.2, none of them warns on that field in a dependency. A test over every published manifest holds that `engines` has only keys yarn 1 knows and that the list equals the root's, and a yarn 1 install of those manifests prints no engine line (#46).
|
|
13
|
+
- Updated dependencies [fb08b28]
|
|
14
|
+
- @geonosis/base@3.3.0
|
|
15
|
+
|
|
16
|
+
## 3.2.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- f5632b7: New `@geonosis/base`: the zero-dependency bottom of the method, holding what packages used to copy. `@geonosis/base` is `isRecord`, `isStringList`, `stringsOf`, the error text helpers and the markdown readers (`headingsOf`, `sectionUnder`, `fencedLines`, `titleOf`), safe in a browser or a Worker; `@geonosis/base/node` is `packageRootFrom`, `versionOf` and `isDirectory`; `@geonosis/base/bin-harness` is `binRunner(runtime)` for running a package's bin in a test, with `GIT_ISOLATED` for a bin that shells to git.
|
|
21
|
+
`cli`, `create-geonosis`, `ledger`, `mcp`, `observability`, `rails`, `release`, `review`, `themekit`, `verify`, `verify-arch` and `walk` import the guards from it instead of carrying their own; their behaviour is unchanged and each now installs `@geonosis/base`, which a consumer never declares.
|
|
22
|
+
The ratchet keeps its own copies: the build runs on its source before any package exists, so nothing it imports may be a package the build produces.
|
|
23
|
+
- 58eaf3a: `link-integrity` refuses an `ignore` pattern that is not a regular expression before it reads a link, naming the pattern, and reports why a target could not be reached rather than `answered 599`.
|
|
24
|
+
- deef511: The README's account of what the probes reach is recounted for the thirteen it ships: of the audit's 36 defects, six reproduce from a probe alone, sixteen partially and fourteen by none (it said four, fourteen and eighteen, for the first eight).
|
|
25
|
+
- Updated dependencies [f5632b7]
|
|
26
|
+
- @geonosis/base@3.2.0
|
|
27
|
+
|
|
3
28
|
## 3.1.0
|
|
4
29
|
|
|
5
30
|
No changes in this release.
|
package/README.md
CHANGED
|
@@ -20,12 +20,30 @@ npx geonosis-walk https://example.test/ https://example.test/products/x --report
|
|
|
20
20
|
```
|
|
21
21
|
0 the walk ran and found nothing
|
|
22
22
|
1 the walk ran and found something
|
|
23
|
-
2 the walk did not run — no browser, a
|
|
23
|
+
2 the walk did not run — no browser, a page that could not be opened, a probe with no list to look for
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
Two is why there are three. A tool that answered "no findings" for a browser it could not launch
|
|
27
27
|
would pass hardest exactly when it was broken.
|
|
28
28
|
|
|
29
|
+
**A page that answers is walked, whatever its status.** A 404 is a page a customer sees: every probe
|
|
30
|
+
runs on it with the status passed through, so `error-page-status`'s `honestFrom` takes effect (a
|
|
31
|
+
status at or above it is honest and the probe skips the page). What the status ought to be is
|
|
32
|
+
declared per URL, and a page that answers anything else is a finding, not a crash:
|
|
33
|
+
|
|
34
|
+
| the walk list says | the page answers | finding |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| nothing | 200 | none |
|
|
37
|
+
| nothing | 400 or worse | `link-integrity`, blocking: a broken link in the walk list |
|
|
38
|
+
| `{ "url": …, "status": 404 }` | 404 | none: the healthy answer of a deliberate not-found page |
|
|
39
|
+
| `{ "url": …, "status": 404 }` | 200 | `error-page-status`, blocking: a soft 404, which every health check reads as healthy |
|
|
40
|
+
| `{ "url": …, "status": 200 }` | 404 | `link-integrity`, blocking |
|
|
41
|
+
|
|
42
|
+
Exit 2 stays for a page that answered nothing or could not be opened. It stops the walk, and the
|
|
43
|
+
pages walked before it are not thrown away: they are written beside the report as
|
|
44
|
+
`<report>.partial.json` (`stoppedAt` names the URL), and the report itself, the one a ratchet
|
|
45
|
+
counter reads, is left absent.
|
|
46
|
+
|
|
29
47
|
## The thirteen probes
|
|
30
48
|
|
|
31
49
|
| id | What it reads | Needs |
|
|
@@ -62,7 +80,12 @@ Everything lives in the `walk` block of `geonosis.json`; the command line wins w
|
|
|
62
80
|
```json
|
|
63
81
|
{
|
|
64
82
|
"walk": {
|
|
65
|
-
"urls": [
|
|
83
|
+
"urls": [
|
|
84
|
+
"http://localhost:3000/",
|
|
85
|
+
"http://localhost:3000/products/kraft-mailer-box",
|
|
86
|
+
{ "url": "http://localhost:3000/does-not-exist/", "status": 404 }
|
|
87
|
+
],
|
|
88
|
+
"versionKey": "release-check",
|
|
66
89
|
"viewport": { "width": 1440, "height": 900 },
|
|
67
90
|
"report": ".geonosis/walk-report.json",
|
|
68
91
|
"probes": ["light-on-light", "placeholder-asset", "link-integrity", "fabricated-claim"],
|
|
@@ -76,9 +99,16 @@ Everything lives in the `walk` block of `geonosis.json`; the command line wins w
|
|
|
76
99
|
```
|
|
77
100
|
|
|
78
101
|
```
|
|
79
|
-
geonosis-walk [url…] [--report <path>] [--config <path>] [--viewport WIDTHxHEIGHT] [--probe <id>]…
|
|
102
|
+
geonosis-walk [url…] [--report <path>] [--config <path>] [--viewport WIDTHxHEIGHT] [--probe <id>]… [--version-key <key>]
|
|
80
103
|
```
|
|
81
104
|
|
|
105
|
+
`versionKey` (or `--version-key`) sends `Cloudflare-Workers-Version-Key: <key>` with every request
|
|
106
|
+
to the origin of each walked page, including the HEAD requests `link-integrity` makes, and to no
|
|
107
|
+
other origin. During a gradual deployment on Workers, Cloudflare routes each request to a version by
|
|
108
|
+
chance unless the key pins the client, so a walk without one can read HTML from one version and its
|
|
109
|
+
assets from the other
|
|
110
|
+
([Version affinity](https://developers.cloudflare.com/workers/versions-and-deployments/gradual-deployments/version-affinity/)).
|
|
111
|
+
|
|
82
112
|
With no `probes` the walk runs the three that need no list. A mobile pass is the same command with
|
|
83
113
|
`--viewport 390x844`.
|
|
84
114
|
|
|
@@ -90,7 +120,7 @@ With no `probes` the walk runs the three that need no list. A mobile pass is the
|
|
|
90
120
|
"viewport": { "width": 390, "height": 844 },
|
|
91
121
|
"probes": ["buy-box-above-fold"],
|
|
92
122
|
"counts": { "buy-box-above-fold": 1 },
|
|
93
|
-
"pages": [{ "url": "…", "findings": [
|
|
123
|
+
"pages": [{ "url": "…", "status": 200, "findings": [
|
|
94
124
|
{ "class": "buy-box-above-fold", "severity": "major", "url": "…",
|
|
95
125
|
"selector": "[data-testid=\"buy-box\"]",
|
|
96
126
|
"evidence": "the buy box starts at 900px, below the fold at 844px" }
|
|
@@ -128,10 +158,11 @@ the status agrees with the body, and asking the server again asks a different qu
|
|
|
128
158
|
|
|
129
159
|
## What this is not
|
|
130
160
|
|
|
131
|
-
A green report is not a clean surface.
|
|
132
|
-
|
|
133
|
-
disagree, a cart that re-prices what the product page
|
|
134
|
-
four levels of taxonomy for fourteen products — are
|
|
135
|
-
Those stay the walker's judgement. The
|
|
136
|
-
the list is meant to grow. The reasoning,
|
|
161
|
+
A green report is not a clean surface. Twelve of the thirteen probes came from hand audits of one
|
|
162
|
+
storefront, the largest holding 36 defects; six are reproduced by a probe alone, sixteen partially,
|
|
163
|
+
and fourteen — five product tables that disagree, a cart that re-prices what the product page
|
|
164
|
+
quoted, copy promising a control nobody built, four levels of taxonomy for fourteen products — are
|
|
165
|
+
invisible to any browser probe there could be. Those stay the walker's judgement. The thirteenth
|
|
166
|
+
came from a production incident instead, which is how the list is meant to grow. The reasoning,
|
|
167
|
+
defect by defect, is in
|
|
137
168
|
[`docs/walk-review-inventory-2026-08-30.md`](../../docs/walk-review-inventory-2026-08-30.md).
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { Page } from 'playwright';
|
|
2
|
-
/**
|
|
3
|
-
* The browser's own globals, declared here rather than by adding `"lib": ["DOM"]`.
|
|
4
|
-
*
|
|
5
|
-
* The repo typechecks eleven packages against one `tsconfig.base.json`; turning the DOM on for all
|
|
6
|
-
* of them so that this one file can say `document` would put `fetch`, `Response` and `Request` into
|
|
7
|
-
* ten Node packages that have their own. So the surface these probes actually read is written out,
|
|
8
|
-
* module-locally — it leaks into nothing, and it is a list of exactly what the walk touches.
|
|
9
|
-
*/
|
|
2
|
+
/** Declared module-locally: enabling `lib: DOM` would put `fetch`, `Response` and `Request` into every Node package sharing `tsconfig.base.json`. */
|
|
10
3
|
type DomRect = {
|
|
11
4
|
height: number;
|
|
12
5
|
left: number;
|
|
@@ -49,11 +42,6 @@ export type GeometryHit = {
|
|
|
49
42
|
rect: DomRect | null;
|
|
50
43
|
selector: string;
|
|
51
44
|
};
|
|
52
|
-
/**
|
|
53
|
-
* How much a container actually says, counted after layout: the words a reader is shown, how many
|
|
54
|
-
* of them are its own headings, and how many pieces of media stand in for the rest. A section with
|
|
55
|
-
* a heading and nothing under it renders perfectly and tells nobody anything.
|
|
56
|
-
*/
|
|
57
45
|
export type ProseHit = {
|
|
58
46
|
headingWords: number;
|
|
59
47
|
media: number;
|
|
@@ -113,11 +101,7 @@ export type JobResult = {
|
|
|
113
101
|
prose: ProseHit[];
|
|
114
102
|
text: TextHit[];
|
|
115
103
|
};
|
|
116
|
-
/**
|
|
117
|
-
* The one cast in the package. `page.evaluate` runs `inPage` in another VM, so nothing about the
|
|
118
|
-
* value that comes back is checkable from here — the discriminant is the contract, and it is
|
|
119
|
-
* covered by the probe tests that read each shape through a real browser.
|
|
120
|
-
*/
|
|
104
|
+
/** The one cast: the value comes back from another VM, so the discriminant is the contract, covered by the probe tests. */
|
|
121
105
|
export declare const collect: <K extends Job['kind']>(page: Page, job: Extract<Job, {
|
|
122
106
|
kind: K;
|
|
123
107
|
}>) => Promise<JobResult[K]>;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { Viewport } from './types.js';
|
|
2
2
|
export type WalkConfig = {
|
|
3
|
+
expected: Record<string, number>;
|
|
3
4
|
options: Record<string, Record<string, unknown>>;
|
|
4
5
|
probes: string[];
|
|
5
6
|
report: string;
|
|
6
7
|
urls: string[];
|
|
8
|
+
versionKey?: string;
|
|
7
9
|
viewport: Viewport;
|
|
8
10
|
};
|
|
9
11
|
export declare const WALK_REPORT = ".geonosis/walk-report.json";
|
|
10
12
|
export declare const WALK_DEFAULT: WalkConfig;
|
|
11
13
|
export declare const configShape: () => string;
|
|
12
|
-
/** `WxH`, the shape a viewport is written in everywhere else — 1440x900, 390x844. */
|
|
13
14
|
export declare const parseViewport: (value: string) => Viewport;
|
|
14
|
-
|
|
15
|
+
export declare const partialReportPath: (report: string) => string;
|
|
15
16
|
export declare const loadWalkConfig: (file: string) => WalkConfig;
|
|
16
17
|
export declare const configPath: (cwd: string, given?: string) => string;
|
package/dist/config.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
// src/config.ts
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
|
+
import { errorMessage, isRecord, isStringList } from "@geonosis/base";
|
|
4
5
|
import { DEFAULT_PROBES } from "./probes/index.js";
|
|
5
6
|
import { WalkError } from "./types.js";
|
|
6
7
|
var VIEWPORT = { height: 900, width: 1440 };
|
|
7
8
|
var WALK_REPORT = ".geonosis/walk-report.json";
|
|
8
9
|
var WALK_DEFAULT = {
|
|
10
|
+
expected: {},
|
|
9
11
|
options: {},
|
|
10
12
|
probes: DEFAULT_PROBES.map((one) => one.id),
|
|
11
13
|
report: WALK_REPORT,
|
|
12
14
|
urls: [],
|
|
13
15
|
viewport: VIEWPORT
|
|
14
16
|
};
|
|
15
|
-
var KNOWN = new Set(["options", "probes", "report", "urls", "viewport"]);
|
|
16
17
|
var ABOUT = {
|
|
17
18
|
options: "object? keyed by probe id; each probe validates its own",
|
|
18
19
|
probes: "string[]? the probe ids to run",
|
|
19
20
|
report: "string? where the JSON report is written",
|
|
20
|
-
urls: "string[]? the pages to walk",
|
|
21
|
+
urls: "(string | { url, status? })[]? the pages to walk, and the status a page must answer",
|
|
22
|
+
versionKey: "string? sent as Cloudflare-Workers-Version-Key on every request to a walked origin",
|
|
21
23
|
viewport: 'object? { "width": <number>, "height": <number> }'
|
|
22
24
|
};
|
|
25
|
+
var KNOWN = new Set(Object.keys(ABOUT));
|
|
23
26
|
var configShape = () => [
|
|
24
27
|
"geonosis-walk reads geonosis.json",
|
|
25
28
|
"",
|
|
26
29
|
'geonosis.json → "walk" every key optional, every default a contract',
|
|
27
|
-
...
|
|
30
|
+
...Object.entries(ABOUT).map(([key, about]) => ` ${key.padEnd(11)}${about}`),
|
|
28
31
|
"",
|
|
29
32
|
"A key outside this list is REFUSED by name: a misspelling accepted in silence is a probe nobody",
|
|
30
33
|
"is running against a page nobody is walking."
|
|
31
34
|
].join(`
|
|
32
35
|
`);
|
|
33
|
-
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
36
|
var readViewport = (value) => {
|
|
35
37
|
if (value === undefined)
|
|
36
38
|
return VIEWPORT;
|
|
@@ -46,14 +48,62 @@ var parseViewport = (value) => {
|
|
|
46
48
|
}
|
|
47
49
|
return { height: Number(found[2]), width: Number(found[1]) };
|
|
48
50
|
};
|
|
51
|
+
var readOptions = (value) => {
|
|
52
|
+
if (value === undefined)
|
|
53
|
+
return {};
|
|
54
|
+
if (!isRecord(value))
|
|
55
|
+
throw new WalkError("walk.options must be an object keyed by probe id");
|
|
56
|
+
const options = {};
|
|
57
|
+
for (const [id, one] of Object.entries(value)) {
|
|
58
|
+
if (!isRecord(one))
|
|
59
|
+
throw new WalkError(`walk.options.${id} must be an object`);
|
|
60
|
+
options[id] = one;
|
|
61
|
+
}
|
|
62
|
+
return options;
|
|
63
|
+
};
|
|
49
64
|
var readStrings = (value, name, fallback) => {
|
|
50
65
|
if (value === undefined)
|
|
51
66
|
return fallback;
|
|
52
|
-
if (!
|
|
67
|
+
if (!isStringList(value)) {
|
|
53
68
|
throw new WalkError(`walk.${name} must be a list of strings`);
|
|
54
69
|
}
|
|
55
70
|
return value;
|
|
56
71
|
};
|
|
72
|
+
var URL_ENTRY = 'expected a URL, or { "url": <string>, "status"?: <100-599> }';
|
|
73
|
+
var readUrls = (value) => {
|
|
74
|
+
if (value === undefined)
|
|
75
|
+
return { expected: {}, urls: [] };
|
|
76
|
+
if (!Array.isArray(value))
|
|
77
|
+
throw new WalkError(`walk.urls must be a list — ${URL_ENTRY}`);
|
|
78
|
+
const expected = {};
|
|
79
|
+
const urls = [];
|
|
80
|
+
for (const [index, entry] of value.entries()) {
|
|
81
|
+
const at = `walk.urls[${index}]`;
|
|
82
|
+
if (typeof entry === "string") {
|
|
83
|
+
urls.push(entry);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (!isRecord(entry))
|
|
87
|
+
throw new WalkError(`${at} must be a string or an object — ${URL_ENTRY}`);
|
|
88
|
+
const unknown = Object.keys(entry).find((key) => key !== "status" && key !== "url");
|
|
89
|
+
if (unknown !== undefined)
|
|
90
|
+
throw new WalkError(`${at}.${unknown} is not a key it takes — ${URL_ENTRY}`);
|
|
91
|
+
const url = entry.url;
|
|
92
|
+
if (typeof url !== "string" || url === "") {
|
|
93
|
+
throw new WalkError(`${at}.url must be the page to walk — ${URL_ENTRY}`);
|
|
94
|
+
}
|
|
95
|
+
const status = entry.status;
|
|
96
|
+
if (status !== undefined) {
|
|
97
|
+
if (typeof status !== "number" || !Number.isInteger(status) || status < 100 || status > 599) {
|
|
98
|
+
throw new WalkError(`${at}.status must be an HTTP status, 100 to 599 — ${URL_ENTRY}`);
|
|
99
|
+
}
|
|
100
|
+
expected[url] = status;
|
|
101
|
+
}
|
|
102
|
+
urls.push(url);
|
|
103
|
+
}
|
|
104
|
+
return { expected, urls };
|
|
105
|
+
};
|
|
106
|
+
var partialReportPath = (report) => report.endsWith(".json") ? `${report.slice(0, -".json".length)}.partial.json` : `${report}.partial`;
|
|
57
107
|
var loadWalkConfig = (file) => {
|
|
58
108
|
if (!existsSync(file))
|
|
59
109
|
return WALK_DEFAULT;
|
|
@@ -61,7 +111,7 @@ var loadWalkConfig = (file) => {
|
|
|
61
111
|
try {
|
|
62
112
|
parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
63
113
|
} catch (error) {
|
|
64
|
-
throw new WalkError(`${file} is not valid JSON: ${error
|
|
114
|
+
throw new WalkError(`${file} is not valid JSON: ${errorMessage(error)}`);
|
|
65
115
|
}
|
|
66
116
|
if (!isRecord(parsed))
|
|
67
117
|
throw new WalkError(`${file} must hold an object`);
|
|
@@ -74,18 +124,17 @@ var loadWalkConfig = (file) => {
|
|
|
74
124
|
if (!KNOWN.has(key))
|
|
75
125
|
throw new WalkError(`walk.${key} is not a key of the walk block`);
|
|
76
126
|
}
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
throw new WalkError("walk.
|
|
80
|
-
for (const [id, one] of Object.entries(options)) {
|
|
81
|
-
if (!isRecord(one))
|
|
82
|
-
throw new WalkError(`walk.options.${id} must be an object`);
|
|
127
|
+
const { expected, urls } = readUrls(block.urls);
|
|
128
|
+
if (block.versionKey !== undefined && (typeof block.versionKey !== "string" || block.versionKey === "")) {
|
|
129
|
+
throw new WalkError("walk.versionKey must be the value to send as Cloudflare-Workers-Version-Key");
|
|
83
130
|
}
|
|
84
131
|
return {
|
|
85
|
-
|
|
132
|
+
expected,
|
|
133
|
+
options: readOptions(block.options),
|
|
86
134
|
probes: readStrings(block.probes, "probes", WALK_DEFAULT.probes),
|
|
87
135
|
report: typeof block.report === "string" ? block.report : WALK_REPORT,
|
|
88
|
-
urls
|
|
136
|
+
urls,
|
|
137
|
+
...block.versionKey === undefined ? {} : { versionKey: block.versionKey },
|
|
89
138
|
viewport: readViewport(block.viewport)
|
|
90
139
|
};
|
|
91
140
|
};
|
|
@@ -96,5 +145,6 @@ export {
|
|
|
96
145
|
configPath,
|
|
97
146
|
configShape,
|
|
98
147
|
loadWalkConfig,
|
|
99
|
-
parseViewport
|
|
148
|
+
parseViewport,
|
|
149
|
+
partialReportPath
|
|
100
150
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { WalkConfig } from './config.js';
|
|
2
|
-
export { configPath, loadWalkConfig, parseViewport, WALK_DEFAULT, WALK_REPORT } from './config.js';
|
|
2
|
+
export { configPath, loadWalkConfig, parseViewport, partialReportPath, WALK_DEFAULT, WALK_REPORT } from './config.js';
|
|
3
3
|
export { DEFAULT_PROBES, PROBES, probeById } from './probes/index.js';
|
|
4
4
|
export type { DefectClass, Finding, PageReport, Probe, ProbeContext, Severity, Viewport, WalkReport } from './types.js';
|
|
5
|
-
export { WalkError } from './types.js';
|
|
5
|
+
export { WalkError, WalkStopped } from './types.js';
|
|
6
6
|
export type { WalkInput } from './walk.js';
|
|
7
7
|
export { findingsIn, walk } from './walk.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
configPath,
|
|
4
|
+
loadWalkConfig,
|
|
5
|
+
parseViewport,
|
|
6
|
+
partialReportPath,
|
|
7
|
+
WALK_DEFAULT,
|
|
8
|
+
WALK_REPORT
|
|
9
|
+
} from "./config.js";
|
|
3
10
|
import { DEFAULT_PROBES, PROBES, probeById } from "./probes/index.js";
|
|
4
|
-
import { WalkError } from "./types.js";
|
|
11
|
+
import { WalkError, WalkStopped } from "./types.js";
|
|
5
12
|
import { findingsIn, walk } from "./walk.js";
|
|
6
13
|
export {
|
|
7
14
|
DEFAULT_PROBES,
|
|
@@ -9,10 +16,12 @@ export {
|
|
|
9
16
|
WALK_DEFAULT,
|
|
10
17
|
WALK_REPORT,
|
|
11
18
|
WalkError,
|
|
19
|
+
WalkStopped,
|
|
12
20
|
configPath,
|
|
13
21
|
findingsIn,
|
|
14
22
|
loadWalkConfig,
|
|
15
23
|
parseViewport,
|
|
24
|
+
partialReportPath,
|
|
16
25
|
probeById,
|
|
17
26
|
walk
|
|
18
27
|
};
|
package/dist/options.d.ts
CHANGED
|
@@ -2,18 +2,9 @@ export declare const stringOption: (probe: string, options: Record<string, unkno
|
|
|
2
2
|
export declare const stringsOption: (options: Record<string, unknown>, name: string, fallback: string[]) => string[];
|
|
3
3
|
export declare const numberOption: (options: Record<string, unknown>, name: string, fallback: number) => number;
|
|
4
4
|
export declare const flagOption: (options: Record<string, unknown>, name: string, fallback: boolean) => boolean;
|
|
5
|
-
/** The refusal half of D-031, as one line at the top of a probe that cannot work without a list. */
|
|
6
5
|
export declare const requireStrings: (probe: string, options: Record<string, unknown>, name: string) => string[];
|
|
7
|
-
/** The same refusal for a number a probe cannot invent: a floor, a threshold, a count. */
|
|
8
6
|
export declare const requireNumber: (probe: string, options: Record<string, unknown>, name: string) => number;
|
|
9
|
-
/**
|
|
10
|
-
* The `flags` option, validated, with `g` left out on purpose: every use of these patterns is a
|
|
11
|
-
* scan for all matches, and `g` belongs to the call that scans — a shared `g` regex carries a
|
|
12
|
-
* `lastIndex` between calls, which is how a scan silently skips half a page.
|
|
13
|
-
*/
|
|
7
|
+
/** `g` is left out: a shared `g` regex carries `lastIndex` between calls and silently skips half a page. */
|
|
14
8
|
export declare const patternFlags: (probe: string, options: Record<string, unknown>) => string;
|
|
15
|
-
/**
|
|
16
|
-
* Compiled at the top of the run, never at the point of use, so a typo in one entry is a refusal
|
|
17
|
-
* naming the pattern rather than a crash inside a page evaluation three URLs later.
|
|
18
|
-
*/
|
|
9
|
+
/** Compiled at the top of the run so a typo is a refusal naming the pattern, not a crash inside a page evaluation. */
|
|
19
10
|
export declare const assertPatterns: (probe: string, patterns: string[], flags: string) => void;
|
package/dist/options.js
CHANGED
|
@@ -18,7 +18,10 @@ var numberOption = (options, name, fallback) => {
|
|
|
18
18
|
const value = options[name];
|
|
19
19
|
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
20
20
|
};
|
|
21
|
-
var flagOption = (options, name, fallback) =>
|
|
21
|
+
var flagOption = (options, name, fallback) => {
|
|
22
|
+
const value = options[name];
|
|
23
|
+
return typeof value === "boolean" ? value : fallback;
|
|
24
|
+
};
|
|
22
25
|
var requireStrings = (probe, options, name) => {
|
|
23
26
|
const value = stringsOption(options, name, []);
|
|
24
27
|
if (value.length === 0) {
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* The thing a buyer came to do, below the thing they did not.
|
|
4
|
-
*
|
|
5
|
-
* A Medusa storefront's phone PDP ordered gallery → full-screen 3D preview → (scroll) → name →
|
|
6
|
-
* price → … → Add to cart: the buy box was two screens down behind a decoration. This is the one
|
|
7
|
-
* class of the eight that is pure geometry — `getBoundingClientRect()` at a stated viewport, which
|
|
8
|
-
* is why a viewport is part of the walk's input and not a probe option.
|
|
9
|
-
*
|
|
10
|
-
* A page with no buy box says nothing by default: a home page is not a defect, and a probe that
|
|
11
|
-
* fired on every other URL of a walk would be turned off. `required: true` inverts that for a walk
|
|
12
|
-
* whose URLs are all product pages.
|
|
13
|
-
*/
|
|
14
|
-
export declare const buyBoxAboveFold: Probe;
|
|
1
|
+
export declare const buyBoxAboveFold: import('../index.js').Probe;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/probes/buy-box-above-fold.ts
|
|
2
2
|
import { collect } from "../browser.js";
|
|
3
3
|
import { flagOption, numberOption, stringOption } from "../options.js";
|
|
4
|
-
|
|
4
|
+
import { defineProbe } from "./define.js";
|
|
5
|
+
var buyBoxAboveFold = defineProbe({
|
|
5
6
|
class: "buy-box-above-fold",
|
|
6
7
|
id: "buy-box-above-fold",
|
|
7
8
|
needs: (options) => {
|
|
@@ -18,7 +19,6 @@ var buyBoxAboveFold = {
|
|
|
18
19
|
if (buyBox === null) {
|
|
19
20
|
return flagOption(options, "required", false) ? [
|
|
20
21
|
{
|
|
21
|
-
class: "buy-box-above-fold",
|
|
22
22
|
evidence: `no element matches "${selector}" on a page the walk requires one on`,
|
|
23
23
|
severity: "major",
|
|
24
24
|
url
|
|
@@ -30,7 +30,6 @@ var buyBoxAboveFold = {
|
|
|
30
30
|
const found = [];
|
|
31
31
|
if (other !== null && buyBox.top > other.top) {
|
|
32
32
|
found.push({
|
|
33
|
-
class: "buy-box-above-fold",
|
|
34
33
|
evidence: `the buy box starts at ${Math.round(buyBox.top)}px, below "${above}" at ${Math.round(other.top)}px`,
|
|
35
34
|
selector,
|
|
36
35
|
severity: "major",
|
|
@@ -39,7 +38,6 @@ var buyBoxAboveFold = {
|
|
|
39
38
|
}
|
|
40
39
|
if (buyBox.top >= fold) {
|
|
41
40
|
found.push({
|
|
42
|
-
class: "buy-box-above-fold",
|
|
43
41
|
evidence: `the buy box starts at ${Math.round(buyBox.top)}px, below the fold at ${Math.round(fold)}px`,
|
|
44
42
|
selector,
|
|
45
43
|
severity: "major",
|
|
@@ -48,7 +46,7 @@ var buyBoxAboveFold = {
|
|
|
48
46
|
}
|
|
49
47
|
return found;
|
|
50
48
|
}
|
|
51
|
-
};
|
|
49
|
+
});
|
|
52
50
|
export {
|
|
53
51
|
buyBoxAboveFold
|
|
54
52
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Finding, FinishContext, Probe } from '../types.js';
|
|
2
|
+
export type Reported = Omit<Finding, 'class'>;
|
|
3
|
+
export type ProbeSpec = Omit<Probe, 'finish' | 'run'> & {
|
|
4
|
+
finish?: (context: FinishContext) => Reported[];
|
|
5
|
+
run: (...given: Parameters<Probe['run']>) => Promise<Reported[]>;
|
|
6
|
+
};
|
|
7
|
+
export declare const defineProbe: ({ finish, run, ...rest }: ProbeSpec) => Probe;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/probes/define.ts
|
|
2
|
+
var defineProbe = ({ finish, run, ...rest }) => {
|
|
3
|
+
const stamp = (found) => found.map((one) => ({ class: rest.class, ...one }));
|
|
4
|
+
return {
|
|
5
|
+
...rest,
|
|
6
|
+
...finish === undefined ? {} : { finish: (context) => stamp(finish(context)) },
|
|
7
|
+
run: async (...given) => stamp(await run(...given))
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
defineProbe
|
|
12
|
+
};
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A section that promises something in its heading and delivers nothing under it.
|
|
4
|
-
*
|
|
5
|
-
* The heading is the promise: "Care and repair", "How it works", "Shipping". A section carrying one
|
|
6
|
-
* and no body is a heading a reader scrolls to and then leaves — and it renders exactly like a
|
|
7
|
-
* section that is merely short, so nothing that looks at pixels or at status codes sees it.
|
|
8
|
-
*
|
|
9
|
-
* Media counts as a body. An illustrated section with a caption in the image is a section that says
|
|
10
|
-
* something, and a probe that fired on it would be switched off.
|
|
11
|
-
*
|
|
12
|
-
* `selector` is REQUIRED (D-031): which containers are sections is a fact about a repo's markup —
|
|
13
|
-
* `section`, `[data-block]`, a grid child — and defaulting to `section` would assume semantic HTML
|
|
14
|
-
* and then report a clean page for every repo that does not write it.
|
|
15
|
-
*/
|
|
16
|
-
export declare const emptySection: Probe;
|
|
1
|
+
export declare const emptySection: import('../index.js').Probe;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/probes/empty-section.ts
|
|
2
2
|
import { collect } from "../browser.js";
|
|
3
3
|
import { stringOption } from "../options.js";
|
|
4
|
-
|
|
4
|
+
import { defineProbe } from "./define.js";
|
|
5
|
+
var emptySection = defineProbe({
|
|
5
6
|
class: "content-integrity",
|
|
6
7
|
id: "empty-section",
|
|
7
8
|
needs: (options) => {
|
|
@@ -16,14 +17,13 @@ var emptySection = {
|
|
|
16
17
|
selector: stringOption("empty-section", options, "selector")
|
|
17
18
|
});
|
|
18
19
|
return hits.filter((hit) => hit.headingWords > 0 && hit.words <= hit.headingWords && hit.media === 0).map((hit) => ({
|
|
19
|
-
class: "content-integrity",
|
|
20
20
|
evidence: `the section renders ${hit.headingWords} heading word(s) and nothing else — no body text, no media`,
|
|
21
21
|
selector: hit.selector,
|
|
22
22
|
severity: "major",
|
|
23
23
|
url
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
|
-
};
|
|
26
|
+
});
|
|
27
27
|
export {
|
|
28
28
|
emptySection
|
|
29
29
|
};
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A page that renders an error and answers 200.
|
|
4
|
-
*
|
|
5
|
-
* From a production incident: a framework error boundary was served with a 200, so every
|
|
6
|
-
* curl-style health check, every uptime monitor and every load balancer read the surface as
|
|
7
|
-
* healthy while nobody could use it. The status is the only thing those readers look at, and it
|
|
8
|
-
* was the one thing that was wrong.
|
|
9
|
-
*
|
|
10
|
-
* The status comes from the page's OWN response, which is why it is on the context rather than
|
|
11
|
-
* re-requested here: a second request asks a different question of a server that may not answer
|
|
12
|
-
* twice the same way. A page that answered 400 or worse is a server that told the truth, and this
|
|
13
|
-
* probe says nothing about it — `walk` itself refuses that URL, which is the other half of the
|
|
14
|
-
* same rule.
|
|
15
|
-
*
|
|
16
|
-
* What an error surface LOOKS like is a framework's and a repo's own vocabulary — a digest line, a
|
|
17
|
-
* boundary's copy, a status page's wording, in a language the kit does not know — so `patterns` is
|
|
18
|
-
* required and the probe refuses without it (D-031).
|
|
19
|
-
*/
|
|
20
|
-
export declare const errorPageStatus: Probe;
|
|
1
|
+
export declare const errorPageStatus: import('../index.js').Probe;
|
|
@@ -1,37 +1,14 @@
|
|
|
1
1
|
// src/probes/error-page-status.ts
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
numberOption,
|
|
6
|
-
patternFlags,
|
|
7
|
-
requireStrings,
|
|
8
|
-
stringOption
|
|
9
|
-
} from "../options.js";
|
|
10
|
-
var errorPageStatus = {
|
|
2
|
+
import { numberOption } from "../options.js";
|
|
3
|
+
import { defineTextProbe } from "./text-probe.js";
|
|
4
|
+
var errorPageStatus = defineTextProbe({
|
|
11
5
|
class: "error-page-status",
|
|
6
|
+
evidence: (hit, status) => `"${hit.text}" is on a page that answered ${status} — every health check reads that as healthy`,
|
|
12
7
|
id: "error-page-status",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
run: async (page, { options, status, url }) => {
|
|
18
|
-
if (status >= numberOption(options, "honestFrom", 400))
|
|
19
|
-
return [];
|
|
20
|
-
const hits = await collect(page, {
|
|
21
|
-
flags: patternFlags("error-page-status", options),
|
|
22
|
-
kind: "text",
|
|
23
|
-
patterns: requireStrings("error-page-status", options, "patterns"),
|
|
24
|
-
scope: stringOption("error-page-status", options, "scope", "")
|
|
25
|
-
});
|
|
26
|
-
return hits.map((hit) => ({
|
|
27
|
-
class: "error-page-status",
|
|
28
|
-
evidence: `"${hit.text}" is on a page that answered ${status} — every health check reads that as healthy`,
|
|
29
|
-
selector: hit.selector,
|
|
30
|
-
severity: "blocking",
|
|
31
|
-
url
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
};
|
|
8
|
+
option: "patterns",
|
|
9
|
+
severity: "blocking",
|
|
10
|
+
skip: (options, status) => status >= numberOption(options, "honestFrom", 400)
|
|
11
|
+
});
|
|
35
12
|
export {
|
|
36
13
|
errorPageStatus
|
|
37
14
|
};
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Claims the repo has said it cannot stand behind, in the text a reader can actually read.
|
|
4
|
-
*
|
|
5
|
-
* A Medusa storefront's home page carried "4.9/5 average rating", "2,400+ brands ship with us" and
|
|
6
|
-
* "12M+ units printed to date" on a business that had not shipped a unit. Which sentences those are
|
|
7
|
-
* is a fact about a company, never about a kit, so `claims` is required and the probe refuses
|
|
8
|
-
* without it (D-031): a claim scanner that ran with an empty list would report a clean page for
|
|
9
|
-
* every repo that had not configured it.
|
|
10
|
-
*
|
|
11
|
-
* `innerText`, not the markup: a claim in a comment or in a `hidden` element is a claim nobody was
|
|
12
|
-
* shown, and reporting it sends the fixer to a string that is already dead.
|
|
13
|
-
*/
|
|
14
|
-
export declare const fabricatedClaim: Probe;
|
|
1
|
+
export declare const fabricatedClaim: import('../index.js').Probe;
|