@holmdigital/engine 2.2.0 → 2.3.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.
- package/README.md +12 -3
- package/dist/{chunk-FAZPXKHR.mjs → chunk-2TQMD2NR.mjs} +61 -9
- package/dist/cli/index.js +98 -15
- package/dist/cli/index.mjs +38 -7
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +61 -9
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Most accessibility tools give you technical errors (e.g., "Color contrast must b
|
|
|
14
14
|
It handles the heavy lifting of:
|
|
15
15
|
1. **Mapping** technical failures to specific legal clauses.
|
|
16
16
|
2. **Validating** HTML structure to ensure test accuracy.
|
|
17
|
-
3. **Reporting** in multiple languages (EN, SV, NO, FI, DA, NL, DE, FR, ES) for non-technical stakeholders.
|
|
17
|
+
3. **Reporting** in multiple languages (EN, SV, NO, FI, DA, NL, DE, FR, ES, IT, PT, PL) for non-technical stakeholders.
|
|
18
18
|
4. **CI/CD Pipeline Integration** with automatic enforcement.
|
|
19
19
|
|
|
20
20
|
For a comprehensive guide on CLI flags, CI/CD integration, and configuration files, see the **[Engine Library Catalog](../../docs/reference/engine.md)**.
|
|
@@ -23,7 +23,7 @@ For a comprehensive guide on CLI flags, CI/CD integration, and configuration fil
|
|
|
23
23
|
|
|
24
24
|
- **Regulatory Mapping**: Maps technical failures to EU laws (EN 301 549, EAA).
|
|
25
25
|
- **HTML Structure Validation**: Built-in `html-validate` checks to prevent false positives/negatives.
|
|
26
|
-
- **Internationalization (i18n)**: Comprehensive support for
|
|
26
|
+
- **Internationalization (i18n)**: Comprehensive support for 12 languages: English (`en`), Swedish (`sv`), Norwegian (`no`), Finnish (`fi`), Danish (`da`), German (`de`), French (`fr`), Spanish (`es`), Dutch (`nl`), Italian (`it`), Portuguese (`pt`), and Polish (`pl`).
|
|
27
27
|
- **Template-Driven Accessibility Statements**: Generates modern, glassmorphism-styled statements using externalized JSON templates for each language, allowing for professional legal phrasing and deep customization.
|
|
28
28
|
- **Multi-Company Metadata**: Easily customize statements via CLI flags or `.a11yrc` for scalable client generation.
|
|
29
29
|
- **Enriched JUnit XML**: Professional CI/CD reports including scan duration, page title, engine metadata, and **detailed failing node** snippets (Target + HTML).
|
|
@@ -49,7 +49,7 @@ npx hd-a11y-scan <url> [options]
|
|
|
49
49
|
**Options:**
|
|
50
50
|
| Option | Description |
|
|
51
51
|
|--------|-------------|
|
|
52
|
-
| `--lang <code>` | Language code (`en`, `sv`, `
|
|
52
|
+
| `--lang <code>` | Language code (`en`, `sv`, `no`, `fi`, `da`, `de`, `fr`, `es`, `nl`, `it`, `pt`, `pl`) |
|
|
53
53
|
| `--threshold <level>` | Severity threshold for compliance (`critical`, `high`, `medium`, `low`). Default: `high` |
|
|
54
54
|
| `--ci` | Run in CI mode (exit code 1 on failure) |
|
|
55
55
|
| `--json` | Output results as JSON |
|
|
@@ -60,11 +60,14 @@ npx hd-a11y-scan <url> [options]
|
|
|
60
60
|
| `--phone <number>` | Contact phone for the statement metadata |
|
|
61
61
|
| `--response-time <val>` | Response time for the statement metadata |
|
|
62
62
|
| `--publish-date <date>` | Publish date for the website (YYYY-MM-DD) |
|
|
63
|
+
| `--country <code>` | Country code for enforcement body (`SE`, `NO`, `DE`, `IT`, `PT`, `PL`, etc.) |
|
|
64
|
+
| `--sector <type>` | Sector type: `public` (WAD) or `private` (EAA). Default: `public` |
|
|
63
65
|
| `--viewport <size>` | Set viewport size (`mobile`, `tablet`, `desktop`, or custom `1024x768`) |
|
|
64
66
|
| `--generate-tests` | Generate Pseudo-Automation tests |
|
|
65
67
|
| `--invalid-https-cert` | Allow scanning sites with invalid/self-signed HTTPS certificates ⚠️ |
|
|
66
68
|
| `--api-key <key>` | API Key for HolmDigital Cloud |
|
|
67
69
|
| `--cloud-url <url>` | Custom Cloud API Endpoint (default: cloud.holmdigital.se) |
|
|
70
|
+
| `--light` | Fast score-only mode — skips HTML validation and detailed legal mapping |
|
|
68
71
|
|
|
69
72
|
### 🏆 Accessibility Badge
|
|
70
73
|
If your site achieves a **100% score**, the CLI will generate a [Shields.io](https://shields.io/) badge that you can add to your project's README:
|
|
@@ -82,6 +85,12 @@ npx hd-a11y-scan https://example.com --ci --threshold critical
|
|
|
82
85
|
|
|
83
86
|
# Full JSON output with metadata
|
|
84
87
|
npx hd-a11y-scan https://example.com --json
|
|
88
|
+
|
|
89
|
+
# Quick score check (ideal for APIs and dashboards)
|
|
90
|
+
npx hd-a11y-scan https://example.com --light
|
|
91
|
+
|
|
92
|
+
# Light scan with JSON output (perfect for scan-server integration)
|
|
93
|
+
npx hd-a11y-scan https://example.com --light --json
|
|
85
94
|
```
|
|
86
95
|
|
|
87
96
|
## JSON Output
|
|
@@ -138,7 +138,7 @@ var HtmlValidator = class {
|
|
|
138
138
|
// src/core/regulatory-scanner.ts
|
|
139
139
|
import { readFileSync } from "fs";
|
|
140
140
|
function getEngineVersion() {
|
|
141
|
-
return "2.
|
|
141
|
+
return "2.3.1";
|
|
142
142
|
}
|
|
143
143
|
function getStandardsVersion() {
|
|
144
144
|
try {
|
|
@@ -210,13 +210,16 @@ var RegulatoryScanner = class {
|
|
|
210
210
|
}
|
|
211
211
|
pageTitle = await page.title();
|
|
212
212
|
pageLanguage = await page.evaluate(() => document.documentElement.lang || void 0);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
let htmlValidation;
|
|
214
|
+
if (!this.options.light) {
|
|
215
|
+
const pageContent = await page.content();
|
|
216
|
+
htmlValidation = await this.htmlValidator.validate(pageContent);
|
|
217
|
+
if (!htmlValidation.valid) {
|
|
218
|
+
this.log(`HTML Validation: Found ${htmlValidation.errors.length} structural issues.`);
|
|
219
|
+
}
|
|
220
|
+
const vDomBuilder = new VirtualDOMBuilder(page);
|
|
221
|
+
await vDomBuilder.build({ includeComputedStyle: ["color", "background-color"] });
|
|
217
222
|
}
|
|
218
|
-
const vDomBuilder = new VirtualDOMBuilder(page);
|
|
219
|
-
await vDomBuilder.build({ includeComputedStyle: ["color", "background-color"] });
|
|
220
223
|
await this.injectAxe(page);
|
|
221
224
|
this.log("Axe injected. Running analysis...");
|
|
222
225
|
const axeResults = await page.evaluate(async () => {
|
|
@@ -237,10 +240,12 @@ var RegulatoryScanner = class {
|
|
|
237
240
|
});
|
|
238
241
|
this.log(`Raw Axe Violations: ${axeResults.violations?.length || 0}`);
|
|
239
242
|
passedCount = axeResults.passes?.length || 0;
|
|
240
|
-
const regulatoryReports = await this.enrichResults(axeResults);
|
|
243
|
+
const regulatoryReports = this.options.light ? this.enrichResultsLight(axeResults) : await this.enrichResults(axeResults);
|
|
241
244
|
const scanDuration = Date.now() - startTime;
|
|
242
245
|
const result = this.generateResultPackage(regulatoryReports, passedCount, scanDuration, pageTitle, pageLanguage);
|
|
243
|
-
|
|
246
|
+
if (htmlValidation) {
|
|
247
|
+
result.htmlValidation = htmlValidation;
|
|
248
|
+
}
|
|
244
249
|
return result;
|
|
245
250
|
} finally {
|
|
246
251
|
await this.close();
|
|
@@ -268,6 +273,53 @@ var RegulatoryScanner = class {
|
|
|
268
273
|
const axeSource = axeCore.source;
|
|
269
274
|
await page.evaluate(axeSource);
|
|
270
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Light enrichment — maps axe severity directly without standards lookup.
|
|
278
|
+
* Much faster: no async imports, no rule database queries.
|
|
279
|
+
*/
|
|
280
|
+
enrichResultsLight(axeResults) {
|
|
281
|
+
const impactToRisk = {
|
|
282
|
+
critical: "critical",
|
|
283
|
+
serious: "high",
|
|
284
|
+
moderate: "medium",
|
|
285
|
+
minor: "low"
|
|
286
|
+
};
|
|
287
|
+
return axeResults.violations.map((violation) => {
|
|
288
|
+
const impact = violation.impact || "moderate";
|
|
289
|
+
const risk = impactToRisk[impact] || "medium";
|
|
290
|
+
return {
|
|
291
|
+
ruleId: violation.id,
|
|
292
|
+
wcagCriteria: violation.tags.find((t) => t.startsWith("wcag")) || "Unknown",
|
|
293
|
+
en301549Criteria: "",
|
|
294
|
+
dosLagenReference: "",
|
|
295
|
+
diggRisk: risk,
|
|
296
|
+
eaaImpact: risk,
|
|
297
|
+
remediation: {
|
|
298
|
+
description: violation.help,
|
|
299
|
+
technicalGuidance: violation.description,
|
|
300
|
+
component: void 0
|
|
301
|
+
},
|
|
302
|
+
holmdigitalInsight: {
|
|
303
|
+
diggRisk: risk,
|
|
304
|
+
eaaImpact: risk,
|
|
305
|
+
reasoning: violation.help,
|
|
306
|
+
swedishInterpretation: "",
|
|
307
|
+
priorityRationale: ""
|
|
308
|
+
},
|
|
309
|
+
testability: {
|
|
310
|
+
automated: true,
|
|
311
|
+
requiresManualCheck: false,
|
|
312
|
+
pseudoAutomation: false,
|
|
313
|
+
complexity: "simple"
|
|
314
|
+
},
|
|
315
|
+
failingNodes: violation.nodes.slice(0, 3).map((node) => ({
|
|
316
|
+
html: node.html,
|
|
317
|
+
target: node.target.join(" "),
|
|
318
|
+
failureSummary: node.failureSummary
|
|
319
|
+
}))
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
}
|
|
271
323
|
async enrichResults(axeResults) {
|
|
272
324
|
const reports = [];
|
|
273
325
|
const { searchRulesByTags, generateRegulatoryReport, getConvergenceRule } = await import("@holmdigital/standards");
|
package/dist/cli/index.js
CHANGED
|
@@ -782,7 +782,7 @@ var HtmlValidator = class {
|
|
|
782
782
|
// src/core/regulatory-scanner.ts
|
|
783
783
|
var import_node_fs = require("fs");
|
|
784
784
|
function getEngineVersion() {
|
|
785
|
-
return "2.
|
|
785
|
+
return "2.3.1";
|
|
786
786
|
}
|
|
787
787
|
function getStandardsVersion() {
|
|
788
788
|
try {
|
|
@@ -854,13 +854,16 @@ var RegulatoryScanner = class {
|
|
|
854
854
|
}
|
|
855
855
|
pageTitle = await page.title();
|
|
856
856
|
pageLanguage = await page.evaluate(() => document.documentElement.lang || void 0);
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
857
|
+
let htmlValidation;
|
|
858
|
+
if (!this.options.light) {
|
|
859
|
+
const pageContent = await page.content();
|
|
860
|
+
htmlValidation = await this.htmlValidator.validate(pageContent);
|
|
861
|
+
if (!htmlValidation.valid) {
|
|
862
|
+
this.log(`HTML Validation: Found ${htmlValidation.errors.length} structural issues.`);
|
|
863
|
+
}
|
|
864
|
+
const vDomBuilder = new VirtualDOMBuilder(page);
|
|
865
|
+
await vDomBuilder.build({ includeComputedStyle: ["color", "background-color"] });
|
|
861
866
|
}
|
|
862
|
-
const vDomBuilder = new VirtualDOMBuilder(page);
|
|
863
|
-
await vDomBuilder.build({ includeComputedStyle: ["color", "background-color"] });
|
|
864
867
|
await this.injectAxe(page);
|
|
865
868
|
this.log("Axe injected. Running analysis...");
|
|
866
869
|
const axeResults = await page.evaluate(async () => {
|
|
@@ -881,10 +884,12 @@ var RegulatoryScanner = class {
|
|
|
881
884
|
});
|
|
882
885
|
this.log(`Raw Axe Violations: ${axeResults.violations?.length || 0}`);
|
|
883
886
|
passedCount = axeResults.passes?.length || 0;
|
|
884
|
-
const regulatoryReports = await this.enrichResults(axeResults);
|
|
887
|
+
const regulatoryReports = this.options.light ? this.enrichResultsLight(axeResults) : await this.enrichResults(axeResults);
|
|
885
888
|
const scanDuration = Date.now() - startTime;
|
|
886
889
|
const result = this.generateResultPackage(regulatoryReports, passedCount, scanDuration, pageTitle, pageLanguage);
|
|
887
|
-
|
|
890
|
+
if (htmlValidation) {
|
|
891
|
+
result.htmlValidation = htmlValidation;
|
|
892
|
+
}
|
|
888
893
|
return result;
|
|
889
894
|
} finally {
|
|
890
895
|
await this.close();
|
|
@@ -912,6 +917,53 @@ var RegulatoryScanner = class {
|
|
|
912
917
|
const axeSource = import_axe_core.default.source;
|
|
913
918
|
await page.evaluate(axeSource);
|
|
914
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* Light enrichment — maps axe severity directly without standards lookup.
|
|
922
|
+
* Much faster: no async imports, no rule database queries.
|
|
923
|
+
*/
|
|
924
|
+
enrichResultsLight(axeResults) {
|
|
925
|
+
const impactToRisk = {
|
|
926
|
+
critical: "critical",
|
|
927
|
+
serious: "high",
|
|
928
|
+
moderate: "medium",
|
|
929
|
+
minor: "low"
|
|
930
|
+
};
|
|
931
|
+
return axeResults.violations.map((violation) => {
|
|
932
|
+
const impact = violation.impact || "moderate";
|
|
933
|
+
const risk = impactToRisk[impact] || "medium";
|
|
934
|
+
return {
|
|
935
|
+
ruleId: violation.id,
|
|
936
|
+
wcagCriteria: violation.tags.find((t2) => t2.startsWith("wcag")) || "Unknown",
|
|
937
|
+
en301549Criteria: "",
|
|
938
|
+
dosLagenReference: "",
|
|
939
|
+
diggRisk: risk,
|
|
940
|
+
eaaImpact: risk,
|
|
941
|
+
remediation: {
|
|
942
|
+
description: violation.help,
|
|
943
|
+
technicalGuidance: violation.description,
|
|
944
|
+
component: void 0
|
|
945
|
+
},
|
|
946
|
+
holmdigitalInsight: {
|
|
947
|
+
diggRisk: risk,
|
|
948
|
+
eaaImpact: risk,
|
|
949
|
+
reasoning: violation.help,
|
|
950
|
+
swedishInterpretation: "",
|
|
951
|
+
priorityRationale: ""
|
|
952
|
+
},
|
|
953
|
+
testability: {
|
|
954
|
+
automated: true,
|
|
955
|
+
requiresManualCheck: false,
|
|
956
|
+
pseudoAutomation: false,
|
|
957
|
+
complexity: "simple"
|
|
958
|
+
},
|
|
959
|
+
failingNodes: violation.nodes.slice(0, 3).map((node) => ({
|
|
960
|
+
html: node.html,
|
|
961
|
+
target: node.target.join(" "),
|
|
962
|
+
failureSummary: node.failureSummary
|
|
963
|
+
}))
|
|
964
|
+
};
|
|
965
|
+
});
|
|
966
|
+
}
|
|
915
967
|
async enrichResults(axeResults) {
|
|
916
968
|
const reports = [];
|
|
917
969
|
const { searchRulesByTags, generateRegulatoryReport, getConvergenceRule } = await import("@holmdigital/standards");
|
|
@@ -1881,7 +1933,7 @@ function isValidUrl(urlString) {
|
|
|
1881
1933
|
}
|
|
1882
1934
|
var program = new import_commander.Command();
|
|
1883
1935
|
program.name("hd-a11y-scan").description("HolmDigital Regulatory Scanner").version(getEngineVersion());
|
|
1884
|
-
program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").action(async (url, cliOptions) => {
|
|
1936
|
+
program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").option("--light", "Light scan: fast score-only mode (skips HTML validation and detailed legal mapping)").action(async (url, cliOptions) => {
|
|
1885
1937
|
const explorer = (0, import_cosmiconfig.cosmiconfig)("a11y");
|
|
1886
1938
|
const configResult = await explorer.search();
|
|
1887
1939
|
const fileConfig = configResult ? configResult.config : {};
|
|
@@ -1907,7 +1959,8 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
1907
1959
|
responseTime: cliOptions.responseTime || fileConfig.responseTime,
|
|
1908
1960
|
country: cliOptions.country || fileConfig.country,
|
|
1909
1961
|
sector: cliOptions.sector || fileConfig.sector || "public",
|
|
1910
|
-
publishDate: cliOptions.publishDate || fileConfig.publishDate
|
|
1962
|
+
publishDate: cliOptions.publishDate || fileConfig.publishDate,
|
|
1963
|
+
light: cliOptions.light ?? fileConfig.light ?? false
|
|
1911
1964
|
};
|
|
1912
1965
|
setLanguage(options.lang);
|
|
1913
1966
|
if (!isValidUrl(url)) {
|
|
@@ -1936,10 +1989,10 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
1936
1989
|
url,
|
|
1937
1990
|
failOnCritical: options.ci,
|
|
1938
1991
|
viewport,
|
|
1939
|
-
silent: options.json,
|
|
1940
|
-
// Suppress debug output for JSON mode
|
|
1992
|
+
silent: options.json || options.light,
|
|
1941
1993
|
severityThreshold: options.threshold,
|
|
1942
|
-
invalidHttpsCert: options.invalidHttpsCert
|
|
1994
|
+
invalidHttpsCert: options.invalidHttpsCert,
|
|
1995
|
+
light: options.light
|
|
1943
1996
|
});
|
|
1944
1997
|
if (spinner) spinner.text = t("cli.analyzing");
|
|
1945
1998
|
const result = await scanner.scan();
|
|
@@ -1969,8 +2022,38 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
1969
2022
|
}
|
|
1970
2023
|
if (spinner) spinner.succeed(t("cli.statement_saved", { path: options.statement }));
|
|
1971
2024
|
}
|
|
1972
|
-
if (options.json) {
|
|
2025
|
+
if (options.json && options.light) {
|
|
2026
|
+
const lightResult = {
|
|
2027
|
+
url: result.url,
|
|
2028
|
+
score: result.score,
|
|
2029
|
+
complianceStatus: result.complianceStatus,
|
|
2030
|
+
stats: result.stats,
|
|
2031
|
+
scanDuration: result.metadata.scanDuration,
|
|
2032
|
+
topIssues: result.reports.slice(0, 5).map((r) => ({
|
|
2033
|
+
id: r.ruleId,
|
|
2034
|
+
impact: r.holmdigitalInsight.diggRisk,
|
|
2035
|
+
description: r.remediation.description
|
|
2036
|
+
}))
|
|
2037
|
+
};
|
|
2038
|
+
console.log(JSON.stringify(lightResult, null, 2));
|
|
2039
|
+
} else if (options.json) {
|
|
1973
2040
|
console.log(JSON.stringify(result, null, 2));
|
|
2041
|
+
} else if (options.light) {
|
|
2042
|
+
const scoreColor = result.score >= 90 ? import_chalk.default.green : result.score >= 70 ? import_chalk.default.yellow : import_chalk.default.red;
|
|
2043
|
+
const statusColor = result.complianceStatus === "PASS" ? import_chalk.default.green : import_chalk.default.red;
|
|
2044
|
+
console.log("");
|
|
2045
|
+
console.log(import_chalk.default.bold(`Score: ${scoreColor(`${result.score}/100`)} Status: ${statusColor(result.complianceStatus)}`));
|
|
2046
|
+
console.log(import_chalk.default.gray(`Critical: ${result.stats.critical} | High: ${result.stats.high} | Medium: ${result.stats.medium} | Low: ${result.stats.low}`));
|
|
2047
|
+
if (result.reports.length > 0) {
|
|
2048
|
+
console.log("");
|
|
2049
|
+
console.log(import_chalk.default.bold("Top Issues:"));
|
|
2050
|
+
result.reports.slice(0, 5).forEach((r) => {
|
|
2051
|
+
const color = r.holmdigitalInsight.diggRisk === "critical" ? import_chalk.default.red : r.holmdigitalInsight.diggRisk === "high" ? import_chalk.default.yellow : import_chalk.default.gray;
|
|
2052
|
+
console.log(color(` [${r.holmdigitalInsight.diggRisk.toUpperCase()}] ${r.ruleId} \u2014 ${r.remediation.description}`));
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
console.log(import_chalk.default.gray(`
|
|
2056
|
+
Scan: ${result.metadata.scanDuration}ms | ${result.metadata.engineVersion}`));
|
|
1974
2057
|
} else {
|
|
1975
2058
|
console.log("\n");
|
|
1976
2059
|
const scoreColor = result.score >= 90 ? import_chalk.default.green : result.score >= 70 ? import_chalk.default.yellow : import_chalk.default.red;
|
package/dist/cli/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
generateStatement,
|
|
8
8
|
generateStatementContent,
|
|
9
9
|
getEngineVersion
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-2TQMD2NR.mjs";
|
|
11
11
|
import {
|
|
12
12
|
getCurrentLang,
|
|
13
13
|
setLanguage,
|
|
@@ -442,7 +442,7 @@ function isValidUrl(urlString) {
|
|
|
442
442
|
}
|
|
443
443
|
var program = new Command();
|
|
444
444
|
program.name("hd-a11y-scan").description("HolmDigital Regulatory Scanner").version(getEngineVersion());
|
|
445
|
-
program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").action(async (url, cliOptions) => {
|
|
445
|
+
program.argument("<url>", "URL to scan").option("--lang <code>", "Language code (en, sv)").option("--ci", "Run in CI/CD mode (exit code 1 on critical failures)").option("--generate-tests", "Generate Pseudo-Automation tests").option("--json", "Output as JSON").option("--junit <path>", "Generate JUnit XML report").option("--pdf <path>", "Generate PDF report to path").option("--statement <path>", "Generate accessibility statement HTML to path").option("--format <type>", "Output format for statement (html, md)", "html").option("--viewport <size>", 'Set viewport (e.g. "mobile", "desktop", "1024x768")').option("--threshold <level>", "Severity threshold (critical, high, medium, low)").option("--api-key <key>", "API key for HolmDigital Cloud").option("--cloud-url <url>", "Cloud API URL").option("--invalid-https-cert", "Allow scanning on pages with invalid https certificate").option("--email <email>", "Contact email for accessibility statement").option("--phone <number>", "Contact phone number for accessibility statement").option("--org <name>", "Organization name for accessibility statement").option("--response-time <time>", "Expected response time for accessibility statement").option("--country <code>", "Country code for accessibility statement enforcement body").option("--sector <type>", "Sector type: public (WAD) or private (EAA)", "public").option("--publish-date <date>", "Publish date for the website (YYYY-MM-DD)").option("--light", "Light scan: fast score-only mode (skips HTML validation and detailed legal mapping)").action(async (url, cliOptions) => {
|
|
446
446
|
const explorer = cosmiconfig("a11y");
|
|
447
447
|
const configResult = await explorer.search();
|
|
448
448
|
const fileConfig = configResult ? configResult.config : {};
|
|
@@ -468,7 +468,8 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
468
468
|
responseTime: cliOptions.responseTime || fileConfig.responseTime,
|
|
469
469
|
country: cliOptions.country || fileConfig.country,
|
|
470
470
|
sector: cliOptions.sector || fileConfig.sector || "public",
|
|
471
|
-
publishDate: cliOptions.publishDate || fileConfig.publishDate
|
|
471
|
+
publishDate: cliOptions.publishDate || fileConfig.publishDate,
|
|
472
|
+
light: cliOptions.light ?? fileConfig.light ?? false
|
|
472
473
|
};
|
|
473
474
|
setLanguage(options.lang);
|
|
474
475
|
if (!isValidUrl(url)) {
|
|
@@ -497,10 +498,10 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
497
498
|
url,
|
|
498
499
|
failOnCritical: options.ci,
|
|
499
500
|
viewport,
|
|
500
|
-
silent: options.json,
|
|
501
|
-
// Suppress debug output for JSON mode
|
|
501
|
+
silent: options.json || options.light,
|
|
502
502
|
severityThreshold: options.threshold,
|
|
503
|
-
invalidHttpsCert: options.invalidHttpsCert
|
|
503
|
+
invalidHttpsCert: options.invalidHttpsCert,
|
|
504
|
+
light: options.light
|
|
504
505
|
});
|
|
505
506
|
if (spinner) spinner.text = t("cli.analyzing");
|
|
506
507
|
const result = await scanner.scan();
|
|
@@ -530,8 +531,38 @@ program.argument("<url>", "URL to scan").option("--lang <code>", "Language code
|
|
|
530
531
|
}
|
|
531
532
|
if (spinner) spinner.succeed(t("cli.statement_saved", { path: options.statement }));
|
|
532
533
|
}
|
|
533
|
-
if (options.json) {
|
|
534
|
+
if (options.json && options.light) {
|
|
535
|
+
const lightResult = {
|
|
536
|
+
url: result.url,
|
|
537
|
+
score: result.score,
|
|
538
|
+
complianceStatus: result.complianceStatus,
|
|
539
|
+
stats: result.stats,
|
|
540
|
+
scanDuration: result.metadata.scanDuration,
|
|
541
|
+
topIssues: result.reports.slice(0, 5).map((r) => ({
|
|
542
|
+
id: r.ruleId,
|
|
543
|
+
impact: r.holmdigitalInsight.diggRisk,
|
|
544
|
+
description: r.remediation.description
|
|
545
|
+
}))
|
|
546
|
+
};
|
|
547
|
+
console.log(JSON.stringify(lightResult, null, 2));
|
|
548
|
+
} else if (options.json) {
|
|
534
549
|
console.log(JSON.stringify(result, null, 2));
|
|
550
|
+
} else if (options.light) {
|
|
551
|
+
const scoreColor = result.score >= 90 ? chalk.green : result.score >= 70 ? chalk.yellow : chalk.red;
|
|
552
|
+
const statusColor = result.complianceStatus === "PASS" ? chalk.green : chalk.red;
|
|
553
|
+
console.log("");
|
|
554
|
+
console.log(chalk.bold(`Score: ${scoreColor(`${result.score}/100`)} Status: ${statusColor(result.complianceStatus)}`));
|
|
555
|
+
console.log(chalk.gray(`Critical: ${result.stats.critical} | High: ${result.stats.high} | Medium: ${result.stats.medium} | Low: ${result.stats.low}`));
|
|
556
|
+
if (result.reports.length > 0) {
|
|
557
|
+
console.log("");
|
|
558
|
+
console.log(chalk.bold("Top Issues:"));
|
|
559
|
+
result.reports.slice(0, 5).forEach((r) => {
|
|
560
|
+
const color = r.holmdigitalInsight.diggRisk === "critical" ? chalk.red : r.holmdigitalInsight.diggRisk === "high" ? chalk.yellow : chalk.gray;
|
|
561
|
+
console.log(color(` [${r.holmdigitalInsight.diggRisk.toUpperCase()}] ${r.ruleId} \u2014 ${r.remediation.description}`));
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
console.log(chalk.gray(`
|
|
565
|
+
Scan: ${result.metadata.scanDuration}ms | ${result.metadata.engineVersion}`));
|
|
535
566
|
} else {
|
|
536
567
|
console.log("\n");
|
|
537
568
|
const scoreColor = result.score >= 90 ? chalk.green : result.score >= 70 ? chalk.yellow : chalk.red;
|
package/dist/index.d.mts
CHANGED
|
@@ -25,6 +25,7 @@ interface ScannerOptions {
|
|
|
25
25
|
silent?: boolean;
|
|
26
26
|
severityThreshold?: 'critical' | 'high' | 'medium' | 'low';
|
|
27
27
|
invalidHttpsCert?: boolean;
|
|
28
|
+
light?: boolean;
|
|
28
29
|
}
|
|
29
30
|
interface ScanMetadata {
|
|
30
31
|
engineVersion: string;
|
|
@@ -66,6 +67,7 @@ declare class RegulatoryScanner {
|
|
|
66
67
|
private initBrowser;
|
|
67
68
|
private getPage;
|
|
68
69
|
private injectAxe;
|
|
70
|
+
private enrichResultsLight;
|
|
69
71
|
private enrichResults;
|
|
70
72
|
private generateResultPackage;
|
|
71
73
|
close(): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ interface ScannerOptions {
|
|
|
25
25
|
silent?: boolean;
|
|
26
26
|
severityThreshold?: 'critical' | 'high' | 'medium' | 'low';
|
|
27
27
|
invalidHttpsCert?: boolean;
|
|
28
|
+
light?: boolean;
|
|
28
29
|
}
|
|
29
30
|
interface ScanMetadata {
|
|
30
31
|
engineVersion: string;
|
|
@@ -66,6 +67,7 @@ declare class RegulatoryScanner {
|
|
|
66
67
|
private initBrowser;
|
|
67
68
|
private getPage;
|
|
68
69
|
private injectAxe;
|
|
70
|
+
private enrichResultsLight;
|
|
69
71
|
private enrichResults;
|
|
70
72
|
private generateResultPackage;
|
|
71
73
|
close(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -676,7 +676,7 @@ var HtmlValidator = class {
|
|
|
676
676
|
// src/core/regulatory-scanner.ts
|
|
677
677
|
var import_node_fs = require("fs");
|
|
678
678
|
function getEngineVersion() {
|
|
679
|
-
return "2.
|
|
679
|
+
return "2.3.1";
|
|
680
680
|
}
|
|
681
681
|
function getStandardsVersion() {
|
|
682
682
|
try {
|
|
@@ -748,13 +748,16 @@ var RegulatoryScanner = class {
|
|
|
748
748
|
}
|
|
749
749
|
pageTitle = await page.title();
|
|
750
750
|
pageLanguage = await page.evaluate(() => document.documentElement.lang || void 0);
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
751
|
+
let htmlValidation;
|
|
752
|
+
if (!this.options.light) {
|
|
753
|
+
const pageContent = await page.content();
|
|
754
|
+
htmlValidation = await this.htmlValidator.validate(pageContent);
|
|
755
|
+
if (!htmlValidation.valid) {
|
|
756
|
+
this.log(`HTML Validation: Found ${htmlValidation.errors.length} structural issues.`);
|
|
757
|
+
}
|
|
758
|
+
const vDomBuilder = new VirtualDOMBuilder(page);
|
|
759
|
+
await vDomBuilder.build({ includeComputedStyle: ["color", "background-color"] });
|
|
755
760
|
}
|
|
756
|
-
const vDomBuilder = new VirtualDOMBuilder(page);
|
|
757
|
-
await vDomBuilder.build({ includeComputedStyle: ["color", "background-color"] });
|
|
758
761
|
await this.injectAxe(page);
|
|
759
762
|
this.log("Axe injected. Running analysis...");
|
|
760
763
|
const axeResults = await page.evaluate(async () => {
|
|
@@ -775,10 +778,12 @@ var RegulatoryScanner = class {
|
|
|
775
778
|
});
|
|
776
779
|
this.log(`Raw Axe Violations: ${axeResults.violations?.length || 0}`);
|
|
777
780
|
passedCount = axeResults.passes?.length || 0;
|
|
778
|
-
const regulatoryReports = await this.enrichResults(axeResults);
|
|
781
|
+
const regulatoryReports = this.options.light ? this.enrichResultsLight(axeResults) : await this.enrichResults(axeResults);
|
|
779
782
|
const scanDuration = Date.now() - startTime;
|
|
780
783
|
const result = this.generateResultPackage(regulatoryReports, passedCount, scanDuration, pageTitle, pageLanguage);
|
|
781
|
-
|
|
784
|
+
if (htmlValidation) {
|
|
785
|
+
result.htmlValidation = htmlValidation;
|
|
786
|
+
}
|
|
782
787
|
return result;
|
|
783
788
|
} finally {
|
|
784
789
|
await this.close();
|
|
@@ -806,6 +811,53 @@ var RegulatoryScanner = class {
|
|
|
806
811
|
const axeSource = import_axe_core.default.source;
|
|
807
812
|
await page.evaluate(axeSource);
|
|
808
813
|
}
|
|
814
|
+
/**
|
|
815
|
+
* Light enrichment — maps axe severity directly without standards lookup.
|
|
816
|
+
* Much faster: no async imports, no rule database queries.
|
|
817
|
+
*/
|
|
818
|
+
enrichResultsLight(axeResults) {
|
|
819
|
+
const impactToRisk = {
|
|
820
|
+
critical: "critical",
|
|
821
|
+
serious: "high",
|
|
822
|
+
moderate: "medium",
|
|
823
|
+
minor: "low"
|
|
824
|
+
};
|
|
825
|
+
return axeResults.violations.map((violation) => {
|
|
826
|
+
const impact = violation.impact || "moderate";
|
|
827
|
+
const risk = impactToRisk[impact] || "medium";
|
|
828
|
+
return {
|
|
829
|
+
ruleId: violation.id,
|
|
830
|
+
wcagCriteria: violation.tags.find((t2) => t2.startsWith("wcag")) || "Unknown",
|
|
831
|
+
en301549Criteria: "",
|
|
832
|
+
dosLagenReference: "",
|
|
833
|
+
diggRisk: risk,
|
|
834
|
+
eaaImpact: risk,
|
|
835
|
+
remediation: {
|
|
836
|
+
description: violation.help,
|
|
837
|
+
technicalGuidance: violation.description,
|
|
838
|
+
component: void 0
|
|
839
|
+
},
|
|
840
|
+
holmdigitalInsight: {
|
|
841
|
+
diggRisk: risk,
|
|
842
|
+
eaaImpact: risk,
|
|
843
|
+
reasoning: violation.help,
|
|
844
|
+
swedishInterpretation: "",
|
|
845
|
+
priorityRationale: ""
|
|
846
|
+
},
|
|
847
|
+
testability: {
|
|
848
|
+
automated: true,
|
|
849
|
+
requiresManualCheck: false,
|
|
850
|
+
pseudoAutomation: false,
|
|
851
|
+
complexity: "simple"
|
|
852
|
+
},
|
|
853
|
+
failingNodes: violation.nodes.slice(0, 3).map((node) => ({
|
|
854
|
+
html: node.html,
|
|
855
|
+
target: node.target.join(" "),
|
|
856
|
+
failureSummary: node.failureSummary
|
|
857
|
+
}))
|
|
858
|
+
};
|
|
859
|
+
});
|
|
860
|
+
}
|
|
809
861
|
async enrichResults(axeResults) {
|
|
810
862
|
const reports = [];
|
|
811
863
|
const { searchRulesByTags, generateRegulatoryReport, getConvergenceRule } = await import("@holmdigital/standards");
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holmdigital/engine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -69,15 +69,15 @@
|
|
|
69
69
|
"html-validate": "10.4.0",
|
|
70
70
|
"ora": "^8.1.1",
|
|
71
71
|
"puppeteer": "23.10.4",
|
|
72
|
-
"react": "^18.3.1",
|
|
73
|
-
"react-dom": "^18.3.1",
|
|
72
|
+
"react": "^18.3.1 || ^19.0.0",
|
|
73
|
+
"react-dom": "^18.3.1 || ^19.0.0",
|
|
74
74
|
"ws": "^8.18.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/cosmiconfig": "^5.0.3",
|
|
78
78
|
"@types/node": "^22.10.2",
|
|
79
|
-
"@types/react": "^18.3.1",
|
|
80
|
-
"@types/react-dom": "^18.3.1",
|
|
79
|
+
"@types/react": "^18.3.1 || ^19.0.0",
|
|
80
|
+
"@types/react-dom": "^18.3.1 || ^19.0.0",
|
|
81
81
|
"@types/ws": "^8.5.13",
|
|
82
82
|
"tsup": "^8.3.5",
|
|
83
83
|
"typescript": "^5.7.2",
|