@diegovelasquezweb/a11y-engine 0.6.6 → 0.7.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/package.json +1 -1
- package/src/enrichment/analyzer.mjs +11 -0
- package/src/index.mjs +20 -8
- package/src/pipeline/dom-scanner.mjs +1 -0
package/package.json
CHANGED
|
@@ -744,6 +744,14 @@ function computeTestingMethodology(payload) {
|
|
|
744
744
|
const routes = payload.routes || [];
|
|
745
745
|
const scanned = routes.filter((r) => !r.error).length;
|
|
746
746
|
const errored = routes.filter((r) => r.error).length;
|
|
747
|
+
const tags = payload.axeTags || [];
|
|
748
|
+
const conformanceLevel = tags.includes("wcag2aaa")
|
|
749
|
+
? "AAA"
|
|
750
|
+
: tags.includes("wcag2aa") || tags.includes("wcag21aa") || tags.includes("wcag22aa")
|
|
751
|
+
? "AA"
|
|
752
|
+
: tags.includes("wcag2a") || tags.includes("wcag21a") || tags.includes("wcag22a")
|
|
753
|
+
? "A"
|
|
754
|
+
: null;
|
|
747
755
|
return {
|
|
748
756
|
automated_tools: [
|
|
749
757
|
"axe-core (via @axe-core/playwright)",
|
|
@@ -752,6 +760,9 @@ function computeTestingMethodology(payload) {
|
|
|
752
760
|
"Playwright + Chromium",
|
|
753
761
|
],
|
|
754
762
|
compliance_target: "WCAG 2.2",
|
|
763
|
+
conformance_level: conformanceLevel,
|
|
764
|
+
best_practices: tags.includes("best-practice"),
|
|
765
|
+
axe_tags: tags.length > 0 ? tags : null,
|
|
755
766
|
pages_scanned: scanned,
|
|
756
767
|
pages_errored: errored,
|
|
757
768
|
framework_detected: payload.projectContext?.framework || "Not detected",
|
package/src/index.mjs
CHANGED
|
@@ -660,14 +660,17 @@ export async function runAudit(options) {
|
|
|
660
660
|
// Fetch remote package.json via GitHub API if repoUrl is provided
|
|
661
661
|
let remotePackageJson = null;
|
|
662
662
|
if (options.repoUrl && !options.projectDir) {
|
|
663
|
+
if (onProgress) onProgress("repo", "running");
|
|
663
664
|
try {
|
|
664
665
|
const { fetchPackageJson } = await import("./core/github-api.mjs");
|
|
665
666
|
remotePackageJson = await fetchPackageJson(options.repoUrl, options.githubToken);
|
|
666
667
|
if (remotePackageJson) {
|
|
667
|
-
|
|
668
|
+
if (onProgress) onProgress("repo", "done", { packageJson: true });
|
|
669
|
+
} else {
|
|
670
|
+
if (onProgress) onProgress("repo", "skipped", { reason: "Could not read package.json" });
|
|
668
671
|
}
|
|
669
672
|
} catch (err) {
|
|
670
|
-
|
|
673
|
+
if (onProgress) onProgress("repo", "skipped", { reason: err.message });
|
|
671
674
|
}
|
|
672
675
|
}
|
|
673
676
|
|
|
@@ -708,6 +711,7 @@ export async function runAudit(options) {
|
|
|
708
711
|
// Step 3: Source patterns (optional) — works with local projectDir or remote repoUrl
|
|
709
712
|
const hasSourceContext = (options.projectDir || options.repoUrl) && !options.skipPatterns;
|
|
710
713
|
if (hasSourceContext) {
|
|
714
|
+
if (onProgress) onProgress("patterns", "running");
|
|
711
715
|
try {
|
|
712
716
|
const { patterns } = loadAssetJson(ASSET_PATHS.remediation.codePatterns, "code-patterns.json");
|
|
713
717
|
|
|
@@ -741,21 +745,26 @@ export async function runAudit(options) {
|
|
|
741
745
|
}
|
|
742
746
|
}
|
|
743
747
|
|
|
748
|
+
const confirmed = allPatternFindings.filter((f) => f.status === "confirmed").length;
|
|
749
|
+
const potential = allPatternFindings.filter((f) => f.status === "potential").length;
|
|
750
|
+
|
|
744
751
|
if (allPatternFindings.length > 0) {
|
|
745
752
|
findingsPayload.patternFindings = {
|
|
746
753
|
generated_at: new Date().toISOString(),
|
|
747
754
|
project_dir: options.projectDir || options.repoUrl,
|
|
748
755
|
findings: allPatternFindings,
|
|
749
|
-
summary: {
|
|
750
|
-
total: allPatternFindings.length,
|
|
751
|
-
confirmed: allPatternFindings.filter((f) => f.status === "confirmed").length,
|
|
752
|
-
potential: allPatternFindings.filter((f) => f.status === "potential").length,
|
|
753
|
-
},
|
|
756
|
+
summary: { total: allPatternFindings.length, confirmed, potential },
|
|
754
757
|
};
|
|
755
758
|
}
|
|
759
|
+
|
|
760
|
+
if (onProgress) onProgress("patterns", "done", {
|
|
761
|
+
total: allPatternFindings.length,
|
|
762
|
+
confirmed,
|
|
763
|
+
potential,
|
|
764
|
+
});
|
|
756
765
|
} catch (err) {
|
|
757
|
-
// Non-fatal: source scanning is optional
|
|
758
766
|
const msg = err instanceof Error ? err.message : String(err);
|
|
767
|
+
if (onProgress) onProgress("patterns", "skipped", { reason: msg });
|
|
759
768
|
console.warn(`Source pattern scan failed (non-fatal): ${msg}`);
|
|
760
769
|
}
|
|
761
770
|
}
|
|
@@ -765,6 +774,9 @@ export async function runAudit(options) {
|
|
|
765
774
|
// Step 4: AI enrichment (optional) — requires ANTHROPIC_API_KEY
|
|
766
775
|
const aiOptions = options.ai || {};
|
|
767
776
|
const aiEnabled = aiOptions.enabled !== false && !!aiOptions.apiKey;
|
|
777
|
+
if (!aiEnabled && onProgress && options.ai !== undefined) {
|
|
778
|
+
onProgress("ai", "skipped", { reason: "No API key configured" });
|
|
779
|
+
}
|
|
768
780
|
if (aiEnabled) {
|
|
769
781
|
try {
|
|
770
782
|
if (onProgress) onProgress("ai", "running");
|