lighthouse 13.5.0 → 13.6.0-dev.20261028
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/.agents/skills/update-ard-port/SKILL.md +171 -0
- package/.agents/skills/update-trace-engine/SKILL.md +154 -0
- package/cli/bin.d.ts +2 -2
- package/cli/bin.js +5 -4
- package/cli/cli-flags.d.ts +16 -1
- package/cli/cli-flags.js +53 -2
- package/cli/printer.js +5 -8
- package/cli/run.d.ts +5 -5
- package/cli/run.js +97 -47
- package/cli/sentry-prompt.js +3 -4
- package/cli/test/smokehouse/__snapshots__/report-assert-test.js.snap +1 -1
- package/cli/test/smokehouse/config/exclusions.js +3 -1
- package/cli/test/smokehouse/frontends/smokehouse-bin.js +5 -3
- package/cli/test/smokehouse/report-assert-test.js +65 -0
- package/cli/test/smokehouse/report-assert.js +24 -39
- package/cli/test/smokehouse/smokehouse-test.d.ts +2 -0
- package/cli/test/smokehouse/smokehouse-test.js +120 -0
- package/cli/test/smokehouse/smokehouse.js +37 -15
- package/cli/test/smokehouse/version-check-test.js +5 -0
- package/cli/test/smokehouse/version-check.d.ts +1 -1
- package/cli/test/smokehouse/version-check.js +1 -1
- package/commitlint.config.js +1 -1
- package/core/audits/accessibility/accesskeys.js +1 -1
- package/core/audits/accessibility/aria-allowed-attr.js +1 -1
- package/core/audits/accessibility/aria-allowed-role.js +1 -1
- package/core/audits/accessibility/aria-command-name.js +1 -1
- package/core/audits/accessibility/aria-conditional-attr.js +1 -1
- package/core/audits/accessibility/aria-deprecated-role.js +1 -1
- package/core/audits/accessibility/aria-dialog-name.js +1 -1
- package/core/audits/accessibility/aria-hidden-body.js +1 -1
- package/core/audits/accessibility/aria-hidden-focus.js +1 -1
- package/core/audits/accessibility/aria-input-field-name.js +1 -1
- package/core/audits/accessibility/aria-meter-name.js +1 -1
- package/core/audits/accessibility/aria-progressbar-name.js +1 -1
- package/core/audits/accessibility/aria-prohibited-attr.js +1 -1
- package/core/audits/accessibility/aria-required-attr.js +1 -1
- package/core/audits/accessibility/aria-required-children.js +1 -1
- package/core/audits/accessibility/aria-required-parent.js +1 -1
- package/core/audits/accessibility/aria-roles.js +1 -1
- package/core/audits/accessibility/aria-text.js +1 -1
- package/core/audits/accessibility/aria-toggle-field-name.js +1 -1
- package/core/audits/accessibility/aria-tooltip-name.js +1 -1
- package/core/audits/accessibility/aria-treeitem-name.js +1 -1
- package/core/audits/accessibility/aria-valid-attr-value.js +1 -1
- package/core/audits/accessibility/aria-valid-attr.js +1 -1
- package/core/audits/accessibility/autocomplete-valid.js +1 -1
- package/core/audits/accessibility/button-name.js +1 -1
- package/core/audits/accessibility/bypass.js +1 -1
- package/core/audits/accessibility/color-contrast.js +1 -1
- package/core/audits/accessibility/definition-list.js +1 -1
- package/core/audits/accessibility/dlitem.js +1 -1
- package/core/audits/accessibility/document-title.js +1 -1
- package/core/audits/accessibility/duplicate-id-aria.js +1 -1
- package/core/audits/accessibility/empty-heading.js +1 -1
- package/core/audits/accessibility/form-field-multiple-labels.js +1 -1
- package/core/audits/accessibility/frame-title.js +1 -1
- package/core/audits/accessibility/heading-order.js +1 -1
- package/core/audits/accessibility/html-has-lang.js +1 -1
- package/core/audits/accessibility/html-lang-valid.js +1 -1
- package/core/audits/accessibility/html-xml-lang-mismatch.js +1 -1
- package/core/audits/accessibility/identical-links-same-purpose.js +1 -1
- package/core/audits/accessibility/image-alt.js +1 -1
- package/core/audits/accessibility/image-redundant-alt.js +1 -1
- package/core/audits/accessibility/input-button-name.js +1 -1
- package/core/audits/accessibility/input-image-alt.js +1 -1
- package/core/audits/accessibility/label-content-name-mismatch.js +1 -1
- package/core/audits/accessibility/label.js +1 -1
- package/core/audits/accessibility/landmark-one-main.js +1 -1
- package/core/audits/accessibility/link-in-text-block.js +1 -1
- package/core/audits/accessibility/link-name.js +1 -1
- package/core/audits/accessibility/list.js +1 -1
- package/core/audits/accessibility/listitem.js +1 -1
- package/core/audits/accessibility/meta-refresh.js +1 -1
- package/core/audits/accessibility/meta-viewport.js +1 -1
- package/core/audits/accessibility/object-alt.js +1 -1
- package/core/audits/accessibility/presentation-role-conflict.js +1 -1
- package/core/audits/accessibility/select-name.js +1 -1
- package/core/audits/accessibility/skip-link.js +1 -1
- package/core/audits/accessibility/svg-img-alt.js +1 -1
- package/core/audits/accessibility/tabindex.js +1 -1
- package/core/audits/accessibility/table-duplicate-name.js +1 -1
- package/core/audits/accessibility/table-fake-caption.js +1 -1
- package/core/audits/accessibility/target-size.js +1 -1
- package/core/audits/accessibility/td-has-header.js +1 -1
- package/core/audits/accessibility/td-headers-attr.js +1 -1
- package/core/audits/accessibility/th-has-data-cells.js +1 -1
- package/core/audits/accessibility/valid-lang.js +1 -1
- package/core/audits/accessibility/video-caption.js +1 -1
- package/core/audits/agentic/ard-schema.d.ts +13 -0
- package/core/audits/agentic/ard-schema.js +81 -33
- package/core/audits/agentic/llms-txt.js +5 -2
- package/core/audits/baseline.d.ts +29 -7
- package/core/audits/baseline.js +19 -6
- package/core/audits/byte-efficiency/byte-efficiency-audit.js +2 -2
- package/core/audits/insights/insight-audit.d.ts +9 -0
- package/core/audits/insights/insight-audit.js +35 -28
- package/core/audits/long-tasks.js +2 -1
- package/core/audits/predictive-perf.js +2 -2
- package/core/audits/screenshot-thumbnails.d.ts +0 -13
- package/core/audits/screenshot-thumbnails.js +0 -45
- package/core/audits/script-treemap-data.js +26 -6
- package/core/audits/seo/robots-txt.js +3 -8
- package/core/audits/unsized-images.d.ts +0 -7
- package/core/audits/unsized-images.js +7 -26
- package/core/computed/lcp-image-record.d.ts +2 -23
- package/core/computed/lcp-image-record.js +3 -67
- package/core/computed/lcp-network-record.d.ts +24 -0
- package/core/computed/lcp-network-record.js +74 -0
- package/core/computed/metrics/lantern-metric.js +1 -1
- package/core/computed/metrics/lcp-breakdown.js +6 -6
- package/core/computed/metrics/time-to-first-byte.js +5 -3
- package/core/computed/navigation-insights.js +3 -2
- package/core/computed/page-dependency-graph.js +55 -5
- package/core/computed/speedline.js +20 -5
- package/core/computed/trace-engine-result.js +25 -5
- package/core/computed/unused-css.js +15 -2
- package/core/config/config-helpers.d.ts +5 -0
- package/core/config/config-helpers.js +17 -28
- package/core/config/config-plugin.d.ts +7 -0
- package/core/config/config-plugin.js +49 -0
- package/core/config/config.js +10 -2
- package/core/config/constants.d.ts +2 -28
- package/core/config/filters.js +1 -0
- package/core/config/lr-desktop-config.js +13 -0
- package/core/config/lr-mobile-config.js +13 -0
- package/core/gather/base-artifacts.js +7 -1
- package/core/gather/driver/storage.js +3 -2
- package/core/gather/gatherers/agentic/ard.d.ts +59 -4
- package/core/gather/gatherers/agentic/ard.js +218 -56
- package/core/gather/gatherers/full-page-screenshot.js +2 -2
- package/core/gather/gatherers/image-elements.d.ts +7 -0
- package/core/gather/gatherers/image-elements.js +75 -24
- package/core/gather/gatherers/inspector-issues.js +2 -0
- package/core/gather/gatherers/js-usage.js +2 -0
- package/core/gather/gatherers/scripts.d.ts +16 -3
- package/core/gather/gatherers/scripts.js +157 -14
- package/core/gather/gatherers/stylesheets.js +2 -0
- package/core/gather/gatherers/trace-elements.js +2 -1
- package/core/gather/gatherers/trace.d.ts +6 -0
- package/core/gather/gatherers/trace.js +56 -16
- package/core/index.d.ts +2 -0
- package/core/index.js +2 -0
- package/core/lib/arbitrary-equality-map.d.ts +14 -3
- package/core/lib/arbitrary-equality-map.js +113 -6
- package/core/lib/baseline/web-features-data.json +32 -11
- package/core/lib/baseline/web-features-metadata.json +1 -1
- package/core/lib/bf-cache-strings.js +237 -254
- package/core/lib/cdt/Common.d.ts +1 -1
- package/core/lib/cdt/Common.js +2 -2
- package/core/lib/cdt/Platform.d.ts +7 -7
- package/core/lib/cdt/Platform.js +11 -8
- package/core/lib/cdt/SDK.d.ts +5 -1
- package/core/lib/cdt/SDK.js +4 -2
- package/core/lib/cdt/generated/ParsedURL.d.ts +0 -1
- package/core/lib/cdt/generated/ParsedURL.js +3 -9
- package/core/lib/cdt/generated/SourceMap.d.ts +24 -25
- package/core/lib/cdt/generated/SourceMap.js +7 -15
- package/core/lib/deprecations-strings.d.ts +93 -88
- package/core/lib/deprecations-strings.js +20 -14
- package/core/lib/i18n/i18n.d.ts +2 -1
- package/core/lib/i18n/i18n.js +25 -13
- package/core/lib/legacy-javascript/legacy-javascript.d.ts +3 -2
- package/core/lib/legacy-javascript/legacy-javascript.js +235 -111
- package/core/lib/legacy-javascript/polyfill-graph-data.json +94 -89
- package/core/lib/legacy-javascript/polyfill-module-data.json +48 -7
- package/core/lib/minification-estimator.js +10 -10
- package/core/lib/network-request.d.ts +2 -0
- package/core/lib/network-request.js +21 -0
- package/core/lib/page-functions.js +2 -5
- package/core/lib/sentry.d.ts +1 -0
- package/core/lib/sentry.js +3 -0
- package/core/lib/trace-engine.d.ts +1 -0
- package/core/lib/trace-engine.js +2 -0
- package/core/runner.js +9 -3
- package/dist/report/bundle.esm.js +10 -10
- package/dist/report/flow.js +13 -13
- package/dist/report/standalone.js +5 -5
- package/flow-report/src/common.tsx +5 -2
- package/flow-report/src/i18n/i18n.d.ts +2 -0
- package/flow-report/src/summary/summary.tsx +9 -1
- package/flow-report/src/util.d.ts +1 -1
- package/package.json +62 -98
- package/readme.md +13 -18
- package/report/generator/file-namer.d.ts +1 -1
- package/report/generator/file-namer.js +5 -4
- package/report/generator/flow-report-assets.js +1 -3
- package/report/generator/report-assets.js +1 -2
- package/report/renderer/category-renderer.js +2 -2
- package/report/renderer/details-renderer.js +3 -2
- package/report/renderer/dom.d.ts +8 -2
- package/report/renderer/dom.js +29 -1
- package/report/renderer/element-screenshot-renderer.js +3 -0
- package/report/renderer/performance-category-renderer.js +3 -1
- package/report/renderer/report-renderer.js +4 -0
- package/report/renderer/report-utils.d.ts +1 -0
- package/report/renderer/report-utils.js +2 -0
- package/report/renderer/text-encoding.js +2 -2
- package/report/types/augment-dom.d.ts +4 -0
- package/shared/esm-utils.d.ts +0 -8
- package/shared/esm-utils.js +0 -18
- package/shared/localization/format.js +5 -3
- package/shared/localization/locales/ar-XB.json +157 -142
- package/shared/localization/locales/ar.json +157 -142
- package/shared/localization/locales/bg.json +154 -139
- package/shared/localization/locales/ca.json +157 -142
- package/shared/localization/locales/cs.json +148 -133
- package/shared/localization/locales/da.json +153 -138
- package/shared/localization/locales/de.json +152 -137
- package/shared/localization/locales/el.json +153 -138
- package/shared/localization/locales/en-GB.json +160 -145
- package/shared/localization/locales/en-US.json +239 -218
- package/shared/localization/locales/en-XL.json +239 -218
- package/shared/localization/locales/es-419.json +150 -135
- package/shared/localization/locales/es.json +149 -134
- package/shared/localization/locales/fi.json +151 -136
- package/shared/localization/locales/fil.json +154 -139
- package/shared/localization/locales/fr.json +150 -135
- package/shared/localization/locales/he.json +160 -145
- package/shared/localization/locales/hi.json +156 -141
- package/shared/localization/locales/hr.json +154 -139
- package/shared/localization/locales/hu.json +111 -96
- package/shared/localization/locales/id.json +153 -138
- package/shared/localization/locales/it.json +153 -138
- package/shared/localization/locales/ja.json +150 -135
- package/shared/localization/locales/ko.json +42 -27
- package/shared/localization/locales/lt.json +152 -137
- package/shared/localization/locales/lv.json +93 -78
- package/shared/localization/locales/nl.json +149 -134
- package/shared/localization/locales/no.json +152 -137
- package/shared/localization/locales/pl.json +153 -138
- package/shared/localization/locales/pt-PT.json +152 -137
- package/shared/localization/locales/pt.json +157 -142
- package/shared/localization/locales/ro.json +149 -134
- package/shared/localization/locales/ru.json +76 -61
- package/shared/localization/locales/sk.json +153 -138
- package/shared/localization/locales/sl.json +149 -134
- package/shared/localization/locales/sr-Latn.json +151 -136
- package/shared/localization/locales/sr.json +151 -136
- package/shared/localization/locales/sv.json +152 -137
- package/shared/localization/locales/ta.json +156 -141
- package/shared/localization/locales/te.json +157 -142
- package/shared/localization/locales/th.json +111 -96
- package/shared/localization/locales/tr.json +153 -138
- package/shared/localization/locales/uk.json +149 -134
- package/shared/localization/locales/vi.json +162 -147
- package/shared/localization/locales/zh-HK.json +150 -135
- package/shared/localization/locales/zh-TW.json +154 -139
- package/shared/localization/locales/zh.json +152 -137
- package/shared/localization/swap-locale.js +10 -5
- package/shared/root.js +1 -3
- package/third-party/ard/README.md +19 -10
- package/third-party/ard/ard-test.js +189 -266
- package/third-party/ard/ard.d.ts +18 -1
- package/third-party/ard/ard.js +282 -45
- package/third-party/ard/schema-validator.d.ts +14 -5
- package/third-party/ard/schema-validator.js +921 -1177
- package/third-party/ard/spec/schemas/ard-entry.schema.json +176 -0
- package/tsconfig.json +0 -2
- package/types/artifacts.d.ts +43 -7
- package/types/config.d.ts +6 -1
- package/types/externs.d.ts +4 -0
- package/types/internal/test.d.ts +1 -0
- package/build-tracker.config.js +0 -16
- package/core/lib/cdt/package.json +0 -4
- package/eslint-local-rules.d.cts +0 -9
- package/eslint.config.mjs +0 -242
- package/third-party/ard/spec/schemas/ai-catalog.schema.json +0 -292
- package/third-party/esbuild-plugins-polyfills/LICENSE +0 -3
- package/third-party/esbuild-plugins-polyfills/README.md +0 -7
- package/third-party/esbuild-plugins-polyfills/esbuild-polyfills.d.ts +0 -9
- package/third-party/esbuild-plugins-polyfills/esbuild-polyfills.js +0 -129
- package/types/internal/lookup-closest-locale.d.ts +0 -13
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: update-ard-port
|
|
3
|
+
description: Sync Lighthouse's Agentic Resource Discovery (ARD) port with upstream ards-project/ard-spec. Invoke when `node core/scripts/update-ard-spec.js --check` reports the ARD spec is out of sync, when the weekly cron CI job fails on it, or when asked to update the ARD conformance script, schema, or discovery rules.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Update the ARD port
|
|
7
|
+
|
|
8
|
+
Lighthouse vendors a JavaScript port of the upstream ARD conformance tester. When
|
|
9
|
+
upstream changes, the port must be brought back to **1:1 parity** while preserving the
|
|
10
|
+
Lighthouse-specific adaptations listed in `third-party/ard/README.md`.
|
|
11
|
+
|
|
12
|
+
## What lives where
|
|
13
|
+
|
|
14
|
+
| Upstream (ards-project/ard-spec) | Lighthouse | Notes |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `conformance/bin/conformance-test` → `validate_manifest` and helpers | `third-party/ard/ard.js` | `ConformanceTester` (`validate_manifest`, `run_json_schema_validation`, `add_error/warning/info`), `parse_media_type`, `classify_media_type`, `format_schema_error`. Keep upstream `snake_case` names and **word-for-word message text**. |
|
|
17
|
+
| `spec/schemas/ard-entry.schema.json` | `third-party/ard/spec/schemas/ard-entry.schema.json` | Must stay byte-identical to upstream. |
|
|
18
|
+
| (generated) | `third-party/ard/schema-validator.js` | Precompiled Ajv standalone validator, built by `build/build-ard-schema.js` (`yarn build-ard-schema`). Never hand-edit. |
|
|
19
|
+
| `spec/ard.md` §5.1 Discovery Mechanisms (+ `resolve_publisher` in the script) | `core/gather/gatherers/agentic/ard.js` | Candidate order: robots.txt `agentmap` → `<link rel="ard">` → `Link` header → `/.well-known/ard.json` → legacy `ai-catalog` equivalents. Source names in `Artifacts.ArdDiscoverySource` (`types/artifacts.d.ts`). |
|
|
20
|
+
| severity / scoring (Lighthouse-only) | `core/audits/agentic/ard-schema.js` | errors → score 0; warnings/legacy/broken-link → 0.9; clean → 1. `infos` are not surfaced. |
|
|
21
|
+
| pinned SHA + reviewed hashes + deviation list | `third-party/ard/README.md` | `**Pinned Commit SHA**` and the `**Reviewed Upstream Files**` SHA-256 lines are parsed/written by the update script. Never edit the hashes by hand — they are the proof that the port was reviewed against that exact upstream content. |
|
|
22
|
+
|
|
23
|
+
Tests:
|
|
24
|
+
- `third-party/ard/ard-test.js` — port unit tests
|
|
25
|
+
- `core/test/gather/gatherers/agentic/ard-test.js` — gatherer
|
|
26
|
+
- `core/test/audits/agentic/ard-schema-test.js` — audit
|
|
27
|
+
- `cli/test/smokehouse/test-definitions/ard.js`, `ard-invalid.js` + fixtures in `cli/test/fixtures/agentic/`
|
|
28
|
+
- `core/test/results/artifacts/artifacts.json` — sample `AgentResourceDiscovery` artifact
|
|
29
|
+
|
|
30
|
+
## Procedure
|
|
31
|
+
|
|
32
|
+
### 1. See what changed
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
node core/scripts/update-ard-spec.js --check
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
"In sync" means upstream HEAD matches the vendored schema byte-for-byte **and** the
|
|
39
|
+
SHA-256 of `conformance/bin/conformance-test` and `spec/ard.md` match the hashes recorded
|
|
40
|
+
in the README. The output lists which of the three differ, plus old/new SHA and a compare
|
|
41
|
+
link. Pull the upstream files at **both** SHAs for side-by-side review (the compare API
|
|
42
|
+
patch is often truncated):
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
https://raw.githubusercontent.com/ards-project/ard-spec/<sha>/conformance/bin/conformance-test
|
|
46
|
+
https://raw.githubusercontent.com/ards-project/ard-spec/<sha>/spec/schemas/ard-entry.schema.json
|
|
47
|
+
https://raw.githubusercontent.com/ards-project/ard-spec/<sha>/spec/ard.md
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Save them in the conversation scratch dir and diff old vs new. Also check
|
|
51
|
+
`conformance/` for new test fixtures/expected outputs and `docs/adr/` for ADRs explaining
|
|
52
|
+
renamed or removed fields (e.g. `collections`, media type renames).
|
|
53
|
+
|
|
54
|
+
### 2. Sync the schema
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
yarn update:ard-spec
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This writes `third-party/ard/spec/schemas/ard-entry.schema.json` verbatim from upstream
|
|
61
|
+
and prints the `conformance-test` diff. If a hand-ported file changed it **exits 1 and
|
|
62
|
+
does not bump the pinned SHA** — that is expected; the SHA is bumped in step 8 after
|
|
63
|
+
porting. Do not pass `--ack-port` yet.
|
|
64
|
+
|
|
65
|
+
### 3. Port conformance-test changes into `third-party/ard/ard.js`
|
|
66
|
+
|
|
67
|
+
For every hunk in the upstream `conformance-test` diff decide whether it touches:
|
|
68
|
+
- **Validation rules** (new/removed checks, changed thresholds such as the
|
|
69
|
+
`representativeQueries` 2–5 range, new deprecated media types, URN regex) → port 1:1.
|
|
70
|
+
- **Severity** (error ↔ warning ↔ info) → mirror it; this changes audit scoring.
|
|
71
|
+
- **Message text** → copy exactly; the audit shows these strings to users and tests
|
|
72
|
+
assert on them.
|
|
73
|
+
- **CLI/ANSI output, argparse, `main()`, `resolve_publisher`** → not ported (see README
|
|
74
|
+
deviations); skip unless the discovery logic itself changed (then see step 4).
|
|
75
|
+
- **`format_schema_error`** → only adapt if upstream changes how schema errors are
|
|
76
|
+
phrased. Ajv's messages differ from Python `jsonschema`; keep the
|
|
77
|
+
`'x' is a required property` mapping.
|
|
78
|
+
|
|
79
|
+
Rules to preserve:
|
|
80
|
+
- Treat non-object roots/entries as empty instead of throwing.
|
|
81
|
+
- Push `{element, message}` objects; never return formatted strings.
|
|
82
|
+
- Log through `lighthouse-logger`, not `console`.
|
|
83
|
+
- Only `ARD_VERSION`, `ConformanceTester` and `classify_media_type` are exported; add exports only if
|
|
84
|
+
tests need them.
|
|
85
|
+
|
|
86
|
+
If `classify_media_type` / `parse_media_type` changed, run a parity check against the
|
|
87
|
+
real Python script on a list of tricky inputs (params, quoted strings, casing,
|
|
88
|
+
deprecated/unknown `application/*` types) and fix any mismatch.
|
|
89
|
+
|
|
90
|
+
### 4. If `spec/ard.md` changed
|
|
91
|
+
|
|
92
|
+
Read §5.1 (and any section the script's `resolve_publisher` references). If the
|
|
93
|
+
mechanisms, well-known path, `rel` names, header names, or precedence changed:
|
|
94
|
+
- Update the candidate list/order in `core/gather/gatherers/agentic/ard.js`
|
|
95
|
+
(`resolveManifest`) and the `getArdLinksInDOM` rel names.
|
|
96
|
+
- Update `Artifacts.ArdDiscoverySource` and `discoverySignals` in `types/artifacts.d.ts`.
|
|
97
|
+
- Update `LEGACY_SOURCES` / UIStrings in `core/audits/agentic/ard-schema.js` if what counts
|
|
98
|
+
as legacy changed.
|
|
99
|
+
|
|
100
|
+
### 5. Rebuild the validator (only if the schema changed)
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
yarn build-ard-schema
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Review the `schema-validator.js` diff: it should only reflect schema changes. The build
|
|
107
|
+
throws if any `require(` survives or a `$id` is missing — fix `build/build-ard-schema.js`
|
|
108
|
+
rather than the output.
|
|
109
|
+
|
|
110
|
+
### 6. Update tests and fixtures
|
|
111
|
+
|
|
112
|
+
- `third-party/ard/ard-test.js`: add a case for every new/changed rule and message.
|
|
113
|
+
- Gatherer/audit tests if discovery or scoring changed.
|
|
114
|
+
- Smoke: `cli/test/fixtures/agentic/ard.json` / `ai-catalog-invalid.json` and the
|
|
115
|
+
expectations in `cli/test/smokehouse/test-definitions/ard-invalid.js`. Smokehouse
|
|
116
|
+
asserts the **exact count and order** of `details.items`.
|
|
117
|
+
- `core/test/results/artifacts/artifacts.json` if the artifact shape changed.
|
|
118
|
+
|
|
119
|
+
### 7. Update docs
|
|
120
|
+
|
|
121
|
+
- README "Modifications for Lighthouse" if a new deviation was introduced, and the
|
|
122
|
+
"Updating Conformance Script" steps if the process changed.
|
|
123
|
+
- `ARD_VERSION` in `ard.js` is updated automatically by `yarn update:ard-spec --ack-port`;
|
|
124
|
+
update `@fileoverview` comments in `ard.js`, the gatherer and the audit if the major/minor
|
|
125
|
+
spec version changed.
|
|
126
|
+
- Audit `UIStrings` if user-facing wording or the spec link changed.
|
|
127
|
+
|
|
128
|
+
### 8. Verify, then acknowledge
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
yarn mocha third-party/ard/ard-test.js core/test/gather/gatherers/agentic/ard-test.js core/test/audits/agentic/ard-schema-test.js
|
|
132
|
+
yarn smoke ard ardInvalid
|
|
133
|
+
yarn type-check
|
|
134
|
+
yarn lint --fix
|
|
135
|
+
yarn update:sample-json
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`yarn update:sample-json` also runs `i18n:collect-strings`; audit tests resolve
|
|
139
|
+
UIStrings through `shared/localization/locales/en-US.json`, so new strings fail tests
|
|
140
|
+
until this runs. Do not run `yarn unit`.
|
|
141
|
+
|
|
142
|
+
Only once everything above is green:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
yarn update:ard-spec --ack-port # records reviewed hashes + bumps pinned SHA
|
|
146
|
+
node core/scripts/update-ard-spec.js --check # must now report in sync
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`--ack-port` is the single statement that "the port matches this upstream content". Never
|
|
150
|
+
run it to silence the check without having ported the diff.
|
|
151
|
+
|
|
152
|
+
### 9. Report
|
|
153
|
+
|
|
154
|
+
Summarize for the user: upstream SHA range, each rule/message/severity change and its
|
|
155
|
+
effect on audit scoring, any discovery changes, and any deviation added to the README.
|
|
156
|
+
Do not commit or open a PR unless asked.
|
|
157
|
+
|
|
158
|
+
## Gotchas
|
|
159
|
+
|
|
160
|
+
- The check compares *content*, not commit IDs. A green check after a deps upgrade means
|
|
161
|
+
nothing changed upstream, not that someone looked. `upgrade-deps.sh` only runs
|
|
162
|
+
`--check`; it cannot acknowledge changes.
|
|
163
|
+
- `run_command` rejects `grep`; use `grep_search`, `awk`, or `sed`.
|
|
164
|
+
- Upstream v0.91 has no `specVersion` check, logs unknown root members only, warns on
|
|
165
|
+
`collections` (removed by ADR-0003), does not check HTTPS, and does not validate
|
|
166
|
+
`capabilities`. Do not add Lighthouse-only checks to the port — put them in the audit
|
|
167
|
+
if ever wanted.
|
|
168
|
+
- The `[label]` prefix upstream prepends to entry messages is carried in `element`, not
|
|
169
|
+
in `message`.
|
|
170
|
+
- The gatherer, not the port, decides which manifest URL is validated; the port only
|
|
171
|
+
receives `raw_content` and `source_label`.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: update-trace-engine
|
|
3
|
+
description: Build, validate, publish, and roll @paulirish/trace_engine from devtools-frontend into Lighthouse. Invoke when asked to update or roll the trace_engine package.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Update `@paulirish/trace_engine`
|
|
7
|
+
|
|
8
|
+
Lighthouse consumes Chrome DevTools' trace processor (`front_end/models/trace`) via the standalone `@paulirish/trace_engine` npm package, built from the `trace-engine-lib` branch of `paulirish/devtools-frontend`.
|
|
9
|
+
|
|
10
|
+
## What lives where
|
|
11
|
+
|
|
12
|
+
| Location | Purpose | Notes |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `devtools-frontend` checkout (branch `trace-engine-lib`) | Source & packaging scripts | Tracks `origin/main` (`https://chromium.googlesource.com/devtools/devtools-frontend`) + packaging scripts in `scripts/trace/`. Common local path: `~/devtools/devtools-frontend` (ask user if not found). |
|
|
15
|
+
| `scripts/trace/prep-trace-engine-package.sh` (in `devtools-frontend`) | Builds `out/TraceEngine` and prepares standalone package | Converts `export const enum` → `export enum` in `front_end/models/trace/**/*.ts`, builds with `gn` + `autoninja`, applies shims from `scripts/trace/replacements/`, extracts insight locale strings, and invokes `copy-build-trace-engine-for-publish.sh`. |
|
|
16
|
+
| `scripts/trace/copy-build-trace-engine-for-publish.sh` (in `devtools-frontend`) | Copies dist to `$HOME/code/trace_engine` and tests | Copies `out/TraceEngine/dist` to `$HOME/code/trace_engine`, runs `npm install` and `npm test` (Mocha tests in `test/test-trace-engine.mjs` + `tsc --build ./tsconfig.json`). |
|
|
17
|
+
| `$HOME/code/trace_engine` | Standalone npm package staging directory | Where `npm version` and `npm publish` are run. |
|
|
18
|
+
| `core/lib/trace-engine.js` (in Lighthouse) | Lighthouse entry point for `@paulirish/trace_engine` | Re-exports `TraceProcessor`, `TraceHandlers`, `Insights`, `Helpers`, and `Types`. |
|
|
19
|
+
|
|
20
|
+
## Procedure
|
|
21
|
+
|
|
22
|
+
### 1. Merge `origin/main` into `trace-engine-lib` in `devtools-frontend`
|
|
23
|
+
|
|
24
|
+
1. Find the previous `devtools-frontend` `main` commit SHA from the most recent `deps: upgrade trace_engine` commit or PR in Lighthouse (or via `git log -n 1 --merges --pretty=format:"%P"` on `trace-engine-lib`).
|
|
25
|
+
2. In the `devtools-frontend` checkout:
|
|
26
|
+
```sh
|
|
27
|
+
git checkout trace-engine-lib
|
|
28
|
+
git fetch origin main
|
|
29
|
+
git merge origin/main --no-edit
|
|
30
|
+
```
|
|
31
|
+
3. Record the commit range `<old_sha>...<new_sha>` and inspect upstream changes:
|
|
32
|
+
```sh
|
|
33
|
+
git log --oneline <old_sha>..<new_sha> -- front_end/models/trace front_end/models/cpu_profile
|
|
34
|
+
```
|
|
35
|
+
4. If there are merge conflicts in `front_end/models/trace/**/*.ts` due to `export const enum` vs `export enum`, resolve in favor of `origin/main` — `prep-trace-engine-package.sh` automatically converts `export const enum` to `export enum`.
|
|
36
|
+
|
|
37
|
+
### 2. Build and test the standalone package
|
|
38
|
+
|
|
39
|
+
Ensure `depot_tools` (`gn`, `autoninja`) and Node/npm are on `PATH`, then run:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
scripts/trace/prep-trace-engine-package.sh
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This builds `out/TraceEngine`, populates `$HOME/code/trace_engine`, and runs `npm test` (`mocha` + `tsc --build ./tsconfig.json`).
|
|
46
|
+
|
|
47
|
+
#### Fixing build or test failures in `trace-engine-lib`
|
|
48
|
+
|
|
49
|
+
- **TypeScript (`tsc --build ./tsconfig.json`) errors in `$HOME/code/trace_engine`**:
|
|
50
|
+
- `prep-trace-engine-package.sh` replaces several DevTools modules using `scripts/trace/replacements/` so Lighthouse can bundle `trace_engine` into an IIFE (`esbuild`) and defer localization (`LH.IcuMessage`):
|
|
51
|
+
- `HostRuntime.js`: synchronous stub replacing top-level `await` in `core/platform/HostRuntime.js`.
|
|
52
|
+
- `UIString.d.ts` & `i18n.{js,d.ts}`: types `LocalizedString` as a deferred `{i18nId, values}` object instead of a branded `string`. If a file in `core/platform/` (such as `UserVisibleError.d.ts`) fails type-checking because it expects `LocalizedString` to be assignable to `string` and isn't needed by `models/trace`, stub its `.d.ts` in `prep-trace-engine-package.sh` (`echo 'export {};' > "$dist/core/platform/<File>.d.ts"`).
|
|
53
|
+
- `common.{js,d.ts}`, `sdk.d.ts`, `crux-manager.d.ts`: minimal stubs for `core/common`, `core/sdk`, and `models/crux-manager`. Update these if `models/trace` references new symbols from those modules.
|
|
54
|
+
- **Mocha (`test/test-trace-engine.mjs`) failures**:
|
|
55
|
+
- If an assertion in `scripts/trace/test/test-trace-engine.mjs` fails due to an intentional upstream calculation change in `front_end/models/trace`, update `scripts/trace/test/test-trace-engine.mjs` and re-run `scripts/trace/copy-build-trace-engine-for-publish.sh`.
|
|
56
|
+
- Commit any updated files on `trace-engine-lib` and push to Paul's fork (`git push paulirish trace-engine-lib`) when requested.
|
|
57
|
+
|
|
58
|
+
### 3. Bump the package version
|
|
59
|
+
|
|
60
|
+
Determine the next patch version (`0.0.X` → `0.0.(X+1)`) from `package.json` in Lighthouse or `npm view @paulirish/trace_engine version --registry https://registry.npmjs.org/`:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
cd $HOME/code/trace_engine
|
|
64
|
+
npm version v0.0.XXX --no-git-tag-version
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 4. Validate locally in Lighthouse before publishing
|
|
68
|
+
|
|
69
|
+
Copy the built package into Lighthouse's `node_modules/@paulirish/trace_engine` to validate before publishing to npm:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
rm -rf node_modules/@paulirish/trace_engine/{models,core,generated,third_party,locales,test}
|
|
73
|
+
cp -rp $HOME/code/trace_engine/{models,core,generated,third_party,locales,package.json,tsconfig.json} node_modules/@paulirish/trace_engine/
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run the Lighthouse validation checks:
|
|
77
|
+
|
|
78
|
+
1. **Type-checking**:
|
|
79
|
+
```sh
|
|
80
|
+
yarn type-check
|
|
81
|
+
```
|
|
82
|
+
Fix any Lighthouse code or JSDoc types broken by upstream `TraceEngine` API/type changes (commonly in `core/audits/insights/`, `core/computed/`, `core/gather/gatherers/trace-elements.js`, or `core/lib/trace-engine.js`).
|
|
83
|
+
|
|
84
|
+
2. **Bundles**:
|
|
85
|
+
```sh
|
|
86
|
+
yarn build-devtools && yarn build-lr && yarn build-devtools-mcp
|
|
87
|
+
```
|
|
88
|
+
Confirms `esbuild` can bundle `trace_engine` into IIFE (`dt-bundle.js`, Lightrider) and ESM without top-level `await` or missing module errors.
|
|
89
|
+
|
|
90
|
+
3. **Unit tests**:
|
|
91
|
+
```sh
|
|
92
|
+
yarn mocha core/test/audits/insights/*-test.js core/test/audits/metrics-test.js core/test/audits/predictive-perf-test.js core/test/audits/byte-efficiency/byte-efficiency-audit-test.js core/test/computed/metrics/*-test.js core/test/computed/trace-engine-result-test.js core/test/computed/navigation-insights-test.js core/test/computed/entity-classification-test.js core/test/computed/tbt-impact-tasks-test.js
|
|
93
|
+
INTERNAL_LANTERN_USE_TRACE=1 yarn mocha core/test/computed/metrics/*-test.js core/test/audits/metrics-test.js core/test/audits/predictive-perf-test.js
|
|
94
|
+
```
|
|
95
|
+
Update test expectations and snapshots (`yarn mocha --update <test-file>`) where upstream changes intentionally affect metrics, insights, or Lantern trace simulations.
|
|
96
|
+
|
|
97
|
+
4. **Sample JSON, locale strings, flow fixtures, and Lantern baselines**:
|
|
98
|
+
```sh
|
|
99
|
+
yarn update:sample-json
|
|
100
|
+
bash core/scripts/assert-baseline-flow-result-unchanged.sh
|
|
101
|
+
yarn test-lantern
|
|
102
|
+
```
|
|
103
|
+
- If `assert-baseline-flow-result-unchanged.sh` fails due to expected changes, update flow fixtures with `yarn update:flow-fixtures`.
|
|
104
|
+
- If `yarn test-lantern` reports expected metric changes on the Lantern dataset (or if `models/trace/lantern` changed upstream), update the Lantern baseline files (`core/test/fixtures/lantern-baseline-computed-values.json` and `core/test/fixtures/lantern-baseline-accuracy.json`):
|
|
105
|
+
```sh
|
|
106
|
+
FORCE=1 ./core/scripts/lantern/update-baseline-lantern-values.js
|
|
107
|
+
./core/scripts/lantern/assert-baseline-lantern-values-unchanged.js
|
|
108
|
+
```
|
|
109
|
+
- Review `git diff core/test/results/sample_v2.json` and `git diff shared/localization/locales/en-US.json` to make sure every change is accounted for by an upstream commit.
|
|
110
|
+
|
|
111
|
+
5. **Linter**:
|
|
112
|
+
```sh
|
|
113
|
+
yarn lint --fix
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 5. Pause for npm publish
|
|
117
|
+
|
|
118
|
+
Once local validation passes, pause and ask the user to publish `$HOME/code/trace_engine` to npm (requires interactive npm authentication):
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
cd $HOME/code/trace_engine
|
|
122
|
+
npm publish --access public --registry https://registry.npmjs.org/
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 6. Roll `package.json`, `yarn.lock`, and open the PR
|
|
126
|
+
|
|
127
|
+
After the user confirms `@paulirish/trace_engine@0.0.XXX` is published on npm:
|
|
128
|
+
|
|
129
|
+
1. Update `"@paulirish/trace_engine": "0.0.XXX"` in `package.json` and run `yarn` to update `yarn.lock`.
|
|
130
|
+
2. Commit all changes (`deps: upgrade trace_engine to 0.0.XXX`).
|
|
131
|
+
3. Run `yarn diff:sample-json` after committing (note: `assert-strings-collected.sh` runs `git diff --exit-code shared/localization/locales/`, so uncommitted locale changes will cause it to fail).
|
|
132
|
+
4. Push the branch and open a PR against `GoogleChrome/lighthouse` with title `deps: upgrade trace_engine to 0.0.XXX` and description formatted like [PR #17307](https://github.com/GoogleChrome/lighthouse/pull/17307) (including the collapsible `<details><summary>` block with the full `git log <old_sha>...<new_sha> -- front_end/models/trace` output):
|
|
133
|
+
|
|
134
|
+
````markdown
|
|
135
|
+
Roll `@paulirish/trace_engine` from `0.0.OLD` to `0.0.NEW` (`<old_sha>...<new_sha>`).
|
|
136
|
+
|
|
137
|
+
https://chromium.googlesource.com/devtools/devtools-frontend.git/+log/<old_sha>..<new_sha>
|
|
138
|
+
|
|
139
|
+
### Highlights for Lighthouse
|
|
140
|
+
|
|
141
|
+
- **<Category>**:
|
|
142
|
+
- **<Highlight>** ([CL <cl_number>](https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/<cl_number>)): <summary of upstream change and impact on Lighthouse>
|
|
143
|
+
|
|
144
|
+
`git log <old_sha>...<new_sha> -- front_end/models/trace`:
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary>Changelog (just front_end/models/trace, mostly relevant to our usage in LH)</summary>
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
<full output of: git log <old_sha>...<new_sha> -- front_end/models/trace>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
</details>
|
|
154
|
+
````
|
package/cli/bin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @return {Promise<LH.RunnerResult|void>}
|
|
2
|
+
* @return {Promise<LH.RunnerResult|LH.RunnerResult[]|void>}
|
|
3
3
|
*/
|
|
4
|
-
export function begin(): Promise<LH.RunnerResult | void>;
|
|
4
|
+
export function begin(): Promise<LH.RunnerResult | LH.RunnerResult[] | void>;
|
|
5
5
|
//# sourceMappingURL=bin.d.ts.map
|
package/cli/bin.js
CHANGED
|
@@ -41,7 +41,7 @@ function isDev() {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* @return {Promise<LH.RunnerResult|void>}
|
|
44
|
+
* @return {Promise<LH.RunnerResult|LH.RunnerResult[]|void>}
|
|
45
45
|
*/
|
|
46
46
|
async function begin() {
|
|
47
47
|
const cliFlags = getFlags();
|
|
@@ -61,7 +61,7 @@ async function begin() {
|
|
|
61
61
|
commands.listTraceCategories();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
const
|
|
64
|
+
const urlsUnderTest = cliFlags._.length > 1 ? cliFlags._ : cliFlags._[0];
|
|
65
65
|
|
|
66
66
|
/** @type {LH.Config|undefined} */
|
|
67
67
|
let config;
|
|
@@ -89,6 +89,7 @@ async function begin() {
|
|
|
89
89
|
log.setLevel(cliFlags.logLevel);
|
|
90
90
|
|
|
91
91
|
if (
|
|
92
|
+
cliFlags._.length <= 1 &&
|
|
92
93
|
cliFlags.output.length === 1 &&
|
|
93
94
|
cliFlags.output[0] === Printer.OutputMode.json &&
|
|
94
95
|
!cliFlags.outputPath
|
|
@@ -120,7 +121,7 @@ async function begin() {
|
|
|
120
121
|
}
|
|
121
122
|
if (cliFlags.enableErrorReporting) {
|
|
122
123
|
await Sentry.init({
|
|
123
|
-
url:
|
|
124
|
+
url: cliFlags._.join(', '),
|
|
124
125
|
flags: cliFlags,
|
|
125
126
|
config,
|
|
126
127
|
environmentData: {
|
|
@@ -131,7 +132,7 @@ async function begin() {
|
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
return runLighthouse(
|
|
135
|
+
return runLighthouse(urlsUnderTest, cliFlags, config);
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
export {
|
package/cli/cli-flags.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function getYargsParser(manualArgv?: string | undefined): import("yargs")
|
|
|
24
24
|
default: boolean;
|
|
25
25
|
describe: string;
|
|
26
26
|
};
|
|
27
|
-
}>, "port" | "screenEmulation" | "emulatedUserAgent" | "hostname" | "preset" | "save-assets" | "list-all-audits" | "list-locales" | "list-trace-categories" | "debug-navigation" | "additional-trace-categories" | "config-path" | "chrome-flags" | "form-factor" | "max-wait-for-load" | "enable-error-reporting" | "gather-mode" | "audit-mode" | "only-audits" | "only-categories" | "skip-audits" | "disable-full-page-screenshot" | "ignore-status-code"> & import("yargs").InferredOptionTypes<{
|
|
27
|
+
}>, "port" | "screenEmulation" | "emulatedUserAgent" | "hostname" | "preset" | "save-assets" | "list-all-audits" | "list-locales" | "list-trace-categories" | "debug-navigation" | "additional-trace-categories" | "config-path" | "chrome-flags" | "form-factor" | "max-wait-for-load" | "enable-error-reporting" | "gather-mode" | "audit-mode" | "only-audits" | "only-categories" | "skip-audits" | "disable-full-page-screenshot" | "ignore-status-code" | "url-file" | "fail-fast"> & import("yargs").InferredOptionTypes<{
|
|
28
28
|
'save-assets': {
|
|
29
29
|
type: "boolean";
|
|
30
30
|
default: boolean;
|
|
@@ -133,6 +133,15 @@ export function getYargsParser(manualArgv?: string | undefined): import("yargs")
|
|
|
133
133
|
type: "boolean";
|
|
134
134
|
describe: string;
|
|
135
135
|
};
|
|
136
|
+
'url-file': {
|
|
137
|
+
type: "string";
|
|
138
|
+
coerce: typeof coerceUrlFile;
|
|
139
|
+
describe: string;
|
|
140
|
+
};
|
|
141
|
+
'fail-fast': {
|
|
142
|
+
type: "boolean";
|
|
143
|
+
describe: string;
|
|
144
|
+
};
|
|
136
145
|
}>, "output" | "view" | "output-path"> & import("yargs").InferredOptionTypes<{
|
|
137
146
|
output: {
|
|
138
147
|
type: "array";
|
|
@@ -221,6 +230,12 @@ declare function coerceOptionalStringBoolean(value: unknown): boolean | string |
|
|
|
221
230
|
* @return {Array<string>=}
|
|
222
231
|
*/
|
|
223
232
|
declare function splitCommaSeparatedValues(strings?: Array<string> | undefined): Array<string> | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* Reads newline-delimited URLs from a file, ignoring empty lines and `#` comments.
|
|
235
|
+
* @param {unknown=} value
|
|
236
|
+
* @return {Array<string>=}
|
|
237
|
+
*/
|
|
238
|
+
declare function coerceUrlFile(value?: unknown | undefined): Array<string> | undefined;
|
|
224
239
|
/**
|
|
225
240
|
* Coerce output CLI input to `LH.SharedFlagsSettings['output']` or throw if not possible.
|
|
226
241
|
* @param {Array<unknown>} values
|
package/cli/cli-flags.js
CHANGED
|
@@ -20,7 +20,6 @@ import {isObjectOfUnknownValues} from '../shared/type-verifiers.js';
|
|
|
20
20
|
*/
|
|
21
21
|
function getYargsParser(manualArgv) {
|
|
22
22
|
const y = manualArgv ?
|
|
23
|
-
// @ts-expect-error - undocumented, but yargs() supports parsing a single `string`.
|
|
24
23
|
yargs(manualArgv) :
|
|
25
24
|
yargs(yargsHelpers.hideBin(process.argv));
|
|
26
25
|
|
|
@@ -204,12 +203,22 @@ function getYargsParser(manualArgv) {
|
|
|
204
203
|
type: 'boolean',
|
|
205
204
|
describe: 'Disables failing on all error status codes, and instead issues a warning.',
|
|
206
205
|
},
|
|
206
|
+
'url-file': {
|
|
207
|
+
type: 'string',
|
|
208
|
+
coerce: coerceUrlFile,
|
|
209
|
+
describe: 'The path to a file containing newline-delimited URLs to audit.',
|
|
210
|
+
},
|
|
211
|
+
'fail-fast': {
|
|
212
|
+
type: 'boolean',
|
|
213
|
+
describe: 'Stop auditing remaining URLs immediately if a run fails.',
|
|
214
|
+
},
|
|
207
215
|
})
|
|
208
216
|
.group([
|
|
209
217
|
'save-assets', 'list-all-audits', 'list-locales', 'list-trace-categories', 'additional-trace-categories',
|
|
210
218
|
'config-path', 'preset', 'chrome-flags', 'port', 'hostname', 'form-factor', 'screenEmulation', 'emulatedUserAgent',
|
|
211
219
|
'max-wait-for-load', 'enable-error-reporting', 'gather-mode', 'audit-mode',
|
|
212
220
|
'only-audits', 'only-categories', 'skip-audits', 'disable-full-page-screenshot', 'ignore-status-code',
|
|
221
|
+
'url-file', 'fail-fast',
|
|
213
222
|
], 'Configuration:')
|
|
214
223
|
|
|
215
224
|
// Output
|
|
@@ -223,7 +232,8 @@ function getYargsParser(manualArgv) {
|
|
|
223
232
|
'output-path': {
|
|
224
233
|
type: 'string',
|
|
225
234
|
coerce: coerceOutputPath,
|
|
226
|
-
describe: `The file path to output the results. Use 'stdout' to write to stdout.
|
|
235
|
+
describe: `The file or directory path to output the results. Use 'stdout' to write to stdout.
|
|
236
|
+
Directories in the path must already exist. If a directory is specified, the file name will be based on the test URL and date.
|
|
227
237
|
If using JSON output, default is stdout.
|
|
228
238
|
If using HTML or CSV output, default is a file in the working directory with a name based on the test URL and date.
|
|
229
239
|
If using multiple outputs, --output-path is appended with the standard extension for each output type. "reports/my-run" -> "reports/my-run.report.html", "reports/my-run.report.json", etc.
|
|
@@ -306,6 +316,24 @@ Example: --output-path=./lighthouse-results.html`,
|
|
|
306
316
|
.choices('preset', /** @type {const} */ (['perf', 'experimental', 'desktop']))
|
|
307
317
|
|
|
308
318
|
.check(argv => {
|
|
319
|
+
if (Array.isArray(argv.urlFile)) {
|
|
320
|
+
argv._.push(...argv.urlFile);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (argv._.length > 1) {
|
|
324
|
+
if (argv.gatherMode || argv.auditMode) {
|
|
325
|
+
throw new Error('Cannot use -G/--gather-mode or -A/--audit-mode when auditing multiple URLs');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (
|
|
329
|
+
typeof argv.outputPath === 'string' &&
|
|
330
|
+
argv.outputPath &&
|
|
331
|
+
(!fs.existsSync(argv.outputPath) || !fs.statSync(argv.outputPath).isDirectory())
|
|
332
|
+
) {
|
|
333
|
+
throw new Error('--output-path must be an existing directory when auditing multiple URLs');
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
309
337
|
// Lighthouse doesn't need a URL if...
|
|
310
338
|
// - We're just listing the available options.
|
|
311
339
|
// - We're just printing the config.
|
|
@@ -419,6 +447,29 @@ function coerceOutputPath(value) {
|
|
|
419
447
|
return value;
|
|
420
448
|
}
|
|
421
449
|
|
|
450
|
+
/**
|
|
451
|
+
* Reads newline-delimited URLs from a file, ignoring empty lines and `#` comments.
|
|
452
|
+
* @param {unknown=} value
|
|
453
|
+
* @return {Array<string>=}
|
|
454
|
+
*/
|
|
455
|
+
function coerceUrlFile(value) {
|
|
456
|
+
if (value === undefined) return;
|
|
457
|
+
|
|
458
|
+
if (
|
|
459
|
+
typeof value !== 'string' ||
|
|
460
|
+
!value ||
|
|
461
|
+
!fs.existsSync(value) ||
|
|
462
|
+
fs.statSync(value).isDirectory()
|
|
463
|
+
) {
|
|
464
|
+
throw new Error(`--url-file (${value}) cannot be read`);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return fs.readFileSync(value, 'utf-8')
|
|
468
|
+
.split(/\r?\n/)
|
|
469
|
+
.map(line => line.trim())
|
|
470
|
+
.filter(line => line.length > 0 && !line.startsWith('#'));
|
|
471
|
+
}
|
|
472
|
+
|
|
422
473
|
/**
|
|
423
474
|
* Verifies value is a string, then coerces type to LH.Locale for convenience. However, don't
|
|
424
475
|
* allowlist specific locales. Why? So we can support the user who requests 'es-MX' (unsupported)
|
package/cli/printer.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import path from 'path';
|
|
9
|
+
import {setTimeout} from 'timers/promises';
|
|
9
10
|
|
|
10
11
|
import log from 'lighthouse-logger';
|
|
11
12
|
|
|
@@ -40,14 +41,10 @@ function checkOutputPath(path) {
|
|
|
40
41
|
* @param {string} output
|
|
41
42
|
* @return {Promise<void>}
|
|
42
43
|
*/
|
|
43
|
-
function writeToStdout(output) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
process.stdout.write(`${output}\n`);
|
|
48
|
-
resolve();
|
|
49
|
-
}, 50);
|
|
50
|
-
});
|
|
44
|
+
async function writeToStdout(output) {
|
|
45
|
+
// small delay to avoid race with debug() logs
|
|
46
|
+
await setTimeout(50);
|
|
47
|
+
process.stdout.write(`${output}\n`);
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
/**
|
package/cli/run.d.ts
CHANGED
|
@@ -11,14 +11,14 @@ export function parseChromeFlags(flags?: string | Array<string>): Array<string>;
|
|
|
11
11
|
/**
|
|
12
12
|
* @param {LH.RunnerResult} runnerResult
|
|
13
13
|
* @param {LH.CliFlags} flags
|
|
14
|
-
* @return {Promise<
|
|
14
|
+
* @return {Promise<string|undefined>}
|
|
15
15
|
*/
|
|
16
|
-
export function saveResults(runnerResult: LH.RunnerResult, flags: LH.CliFlags): Promise<
|
|
16
|
+
export function saveResults(runnerResult: LH.RunnerResult, flags: LH.CliFlags): Promise<string | undefined>;
|
|
17
17
|
/**
|
|
18
|
-
* @param {string}
|
|
18
|
+
* @param {string|string[]|undefined} urlOrUrls
|
|
19
19
|
* @param {LH.CliFlags} flags
|
|
20
20
|
* @param {LH.Config|undefined} config
|
|
21
|
-
* @return {Promise<LH.RunnerResult|undefined>}
|
|
21
|
+
* @return {Promise<LH.RunnerResult|LH.RunnerResult[]|undefined>}
|
|
22
22
|
*/
|
|
23
|
-
export function runLighthouse(
|
|
23
|
+
export function runLighthouse(urlOrUrls: string | string[] | undefined, flags: LH.CliFlags, config: LH.Config | undefined): Promise<LH.RunnerResult | LH.RunnerResult[] | undefined>;
|
|
24
24
|
//# sourceMappingURL=run.d.ts.map
|