@rgaa-audit/cli 0.0.0-stage → 0.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RGAA Audit Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # @rgaa-audit/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Pré-audit d'accessibilité **RGAA 4.1.2** en ligne de commande, avec Playwright.
4
+
5
+ > Outil de pré-audit : il repère des non-conformités fréquentes pour prioriser les corrections. Il ne délivre pas de conformité légale, qui se confirme par un audit humain.
6
+
7
+ Développé par l'association Le Singe Du Numérique. Code source, extension Chrome et documentation complète : [github.com/Stan69000/rgaa-audit](https://github.com/Stan69000/rgaa-audit).
8
+
9
+ ## Installation
10
+
11
+ Node.js 20 ou plus.
12
+
13
+ ```bash
14
+ npm install -g @rgaa-audit/cli
15
+ npx playwright install chromium
16
+ ```
17
+
18
+ ## Utilisation
19
+
20
+ Audit d'une page, avec un rapport JSON et un rapport HTML vulgarisé :
21
+
22
+ ```bash
23
+ rgaa-audit https://mon-site.fr -o json -s ./rapport.json \
24
+ --vulgarized-save ./rapport-vulgarise.html
25
+ ```
26
+
27
+ Audit de plusieurs pages :
28
+
29
+ ```bash
30
+ rgaa-audit https://mon-site.fr --depth 8 -o json -s ./rapport.json
31
+ ```
32
+
33
+ Suivi des régressions en CI : le code de sortie vaut 1 uniquement s'il apparaît de nouvelles non-conformités par rapport à l'audit de référence.
34
+
35
+ ```bash
36
+ rgaa-audit https://mon-site.fr -d 8 -o json -s ./rapport.json \
37
+ --baseline ./rapport-precedent.json --fail-on-new
38
+ ```
39
+
40
+ Pré-remplissage de la grille d'audit ODS officielle :
41
+
42
+ ```bash
43
+ rgaa-fill-grid --report ./p01.json --report ./p02.json \
44
+ --template ./rgaa4.1.2.modele-de-grille-d-audit.ods \
45
+ --output ./rgaa-grille-prefill.ods
46
+ ```
47
+
48
+ Toutes les options : `rgaa-audit --help`.
49
+
50
+ ## Lire les résultats
51
+
52
+ | Statut | Signification |
53
+ |---|---|
54
+ | `NC` | Non-conformité probable, détectée de façon fiable. |
55
+ | `NT` | À vérifier : indice heuristique ou contrôle manuel requis. |
56
+ | `C` | Conforme sur l'échantillon testé. |
57
+ | `NA` | Non applicable. |
58
+
59
+ Le score ne compte que les critères tranchés automatiquement : `C / (C + NC)`. Ce n'est pas un taux de conformité RGAA.
60
+
61
+ ## Licence
62
+
63
+ MIT
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RGAA Audit CLI — Point d'entrée
4
+ * Usage: node bin/rgaa-audit.js <url> [options]
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ const { parseArgs } = require('node:util');
10
+ const { runAudit } = require('../src/audit');
11
+ const { version } = require('../package.json');
12
+
13
+ const { values, positionals } = parseArgs({
14
+ args: process.argv.slice(2),
15
+ options: {
16
+ output: { type: 'string', short: 'o', default: 'json' }, // json | html | csv | vulgarized
17
+ save: { type: 'string', short: 's', default: '' }, // chemin fichier
18
+ 'output-dir': { type: 'string', default: '' }, // dossier de sortie
19
+ 'vulgarized-save': { type: 'string', default: '' }, // rapport vulgarisé html
20
+ 'ods-template': { type: 'string', default: '' }, // modèle ODS RGAA
21
+ 'ods-save': { type: 'string', default: '' }, // sortie ODS pré-remplie
22
+ 'ods-replicate-all-sheets': { type: 'boolean', default: false },
23
+ simulate: { type: 'boolean', short: 'S', default: true }, // simulation clavier
24
+ 'no-simulate': { type: 'boolean', default: false },
25
+ 'no-captures': { type: 'boolean', default: false }, // pas de captures des NC
26
+ 'color-scheme': { type: 'string', default: 'auto' }, // auto | light | both
27
+ dismiss: { type: 'string', default: 'auto' }, // auto | off | sélecteur CSS
28
+ 'theme-click': { type: 'string', default: '' }, // bouton du thème alternatif
29
+ 'theme-script': { type: 'string', default: '' }, // JS qui active le thème alternatif
30
+ 'validate-html': { type: 'boolean', default: false }, // validation du code généré (8.2)
31
+ baseline: { type: 'string', default: '' }, // rapport JSON de référence
32
+ 'fail-on-new': { type: 'boolean', default: false }, // code de sortie 1 si nouvelles NC
33
+ depth: { type: 'string', short: 'd', default: '1' }, // nb pages à crawler
34
+ headless: { type: 'boolean', short: 'H', default: true }, // headless ou visible
35
+ verbose: { type: 'boolean', short: 'v', default: false }, // logs debug
36
+ debug: { type: 'boolean', default: false }, // alias verbose
37
+ 'safe-crawl': { type: 'boolean', default: false }, // crawl défensif
38
+ 'strict-security': { type: 'boolean', default: false }, // alias safe-crawl
39
+ help: { type: 'boolean', short: 'h', default: false },
40
+ },
41
+ allowPositionals: true,
42
+ });
43
+
44
+ if (values.help || !positionals.length) {
45
+ console.log(`
46
+ ♿ RGAA Audit CLI — v${version}
47
+
48
+ Usage:
49
+ rgaa-audit <url> [options]
50
+
51
+ Options:
52
+ -o, --output Format de sortie : json (défaut) | html | csv | vulgarized
53
+ -s, --save Chemin du fichier de sortie
54
+ --output-dir Dossier racine de sortie pour les rapports (optionnel)
55
+ --vulgarized-save Génère un rapport vulgarisé HTML (non-technique)
56
+ --ods-template Modèle ODS RGAA (pour export grille)
57
+ --ods-save Chemin du fichier ODS de sortie pré-rempli
58
+ --ods-replicate-all-sheets Réplique le 1er rapport sur P01..P20
59
+ -S, --simulate Simuler les actions humaines (défaut: true)
60
+ --no-simulate Désactive la simulation (audit DOM seul, plus rapide)
61
+ --no-captures Pas de captures annotées des non-conformités
62
+ --color-scheme auto (défaut) : mesure aussi les contrastes en thème sombre
63
+ si la page réagit à prefers-color-scheme ; light : thème clair
64
+ seul ; both : force la double mesure
65
+ --dismiss Bandeau cookies : auto (défaut, clique « Refuser »), off,
66
+ ou sélecteur CSS du bouton à cliquer
67
+ --theme-click Sélecteur du bouton de thème : mesure aussi les contrastes
68
+ dans le thème alternatif du site
69
+ --theme-script Script JS qui active le thème alternatif
70
+ (ex. "document.documentElement.dataset.theme='light'")
71
+ --validate-html Valide le code source généré (8.2) avec html-validate,
72
+ en local (Node.js 22.22+)
73
+ --baseline Rapport JSON de référence : liste les non-conformités
74
+ nouvelles et résolues depuis cet audit
75
+ --fail-on-new Avec --baseline : code de sortie 1 s’il y a de nouvelles
76
+ non-conformités (utile en CI)
77
+ -d, --depth Nombre de pages à auditer (défaut: 1)
78
+ -H, --headless Mode headless (défaut: true)
79
+ -v, --verbose Active les logs debug de crawl/navigateur
80
+ --debug Alias de --verbose
81
+ --safe-crawl Crawl défensif (validation/filtrage renforcés)
82
+ --strict-security Alias de --safe-crawl
83
+ -h, --help Afficher cette aide
84
+
85
+ Exemples:
86
+ node bin/rgaa-audit.js https://mon-site.fr
87
+ node bin/rgaa-audit.js https://mon-site.fr -o html -s rapport.html
88
+ node bin/rgaa-audit.js https://mon-site.fr -o json -s rapport.json --vulgarized-save rapport-vulgarise.html
89
+ node bin/rgaa-audit.js https://mon-site.fr -d 8 --ods-template ./grille.ods --ods-save ./grille-remplie.ods --vulgarized-save ./rapport-vulgarise.html
90
+ `);
91
+ process.exit(0);
92
+ }
93
+
94
+ // Compatibilité : « -S false » était documenté mais parseArgs le lit comme un argument positionnel.
95
+ const simulateDisabled = values['no-simulate'] || positionals.slice(1).includes('false');
96
+ if (!['auto', 'light', 'both'].includes(values['color-scheme'])) {
97
+ console.error(`\n❌ --color-scheme doit valoir auto, light ou both (reçu : ${values['color-scheme']})`);
98
+ process.exit(1);
99
+ }
100
+
101
+ const url = positionals[0];
102
+ const opts = {
103
+ output: values.output,
104
+ save: values.save,
105
+ outputDir: values['output-dir'],
106
+ vulgarizedSave: values['vulgarized-save'],
107
+ odsTemplate: values['ods-template'],
108
+ odsSave: values['ods-save'],
109
+ odsReplicateAllSheets: values['ods-replicate-all-sheets'],
110
+ simulate: values.simulate && !simulateDisabled,
111
+ colorScheme: values['color-scheme'],
112
+ dismiss: values.dismiss || 'auto',
113
+ themeClick: values['theme-click'],
114
+ themeScript: values['theme-script'],
115
+ validateHtml: values['validate-html'],
116
+ baseline: values.baseline,
117
+ captures: !values['no-captures'],
118
+ depth: parseInt(values.depth),
119
+ headless: values.headless,
120
+ verbose: values.verbose,
121
+ debug: values.debug,
122
+ safeCrawl: values['safe-crawl'],
123
+ strictSecurity: values['strict-security'],
124
+ };
125
+
126
+ (async () => {
127
+ try {
128
+ if (values['fail-on-new'] && !values.baseline) {
129
+ console.error('\n❌ --fail-on-new nécessite --baseline <rapport.json>');
130
+ process.exit(1);
131
+ }
132
+ const report = await runAudit(url, opts);
133
+ if (values['fail-on-new'] && report.baseline && report.baseline.newCount > 0) {
134
+ console.error(`\n❌ ${report.baseline.newCount} nouvelle(s) non-conformité(s) par rapport à la référence.`);
135
+ process.exitCode = 1;
136
+ }
137
+ } catch (e) {
138
+ console.error('\n❌ Erreur fatale :', e.message);
139
+ process.exit(1);
140
+ }
141
+ })();
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+ const { parseArgs } = require('node:util');
7
+ const { fillRgaaGridFromReports } = require('../src/reporters/ods-grid');
8
+
9
+ const { values } = parseArgs({
10
+ args: process.argv.slice(2),
11
+ options: {
12
+ report: { type: 'string', short: 'r', multiple: true },
13
+ template: { type: 'string', short: 't' },
14
+ output: { type: 'string', short: 'o' },
15
+ 'replicate-to-all-sheets': { type: 'boolean', default: false },
16
+ help: { type: 'boolean', short: 'h', default: false },
17
+ },
18
+ });
19
+
20
+ if (values.help || !values.report?.length || !values.template || !values.output) {
21
+ console.log(`
22
+ Usage:
23
+ rgaa-fill-grid --report <audit1.json> [--report <audit2.json> ...] --template <modele.ods> --output <sortie.ods> [--replicate-to-all-sheets]
24
+
25
+ Options:
26
+ -r, --report JSON produit par rgaa-audit (répéter l'option pour P01..Pn)
27
+ -t, --template Grille ODS RGAA (modèle officiel)
28
+ -o, --output ODS de sortie pré-rempli
29
+ --replicate-to-all-sheets Applique le premier rapport à P01..P20
30
+ -h, --help Aide
31
+ `);
32
+ process.exit(0);
33
+ }
34
+
35
+ try {
36
+ const templatePath = path.resolve(values.template);
37
+ const outputPath = path.resolve(values.output);
38
+ const reportPaths = values.report.map(p => path.resolve(p));
39
+ const reports = [];
40
+
41
+ for (const reportPath of reportPaths) {
42
+ const parsed = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
43
+ if (Array.isArray(parsed)) {
44
+ reports.push(...parsed);
45
+ continue;
46
+ }
47
+ if (parsed && Array.isArray(parsed.results)) {
48
+ reports.push(parsed);
49
+ continue;
50
+ }
51
+ if (Array.isArray(parsed.reports)) {
52
+ reports.push(...parsed.reports);
53
+ continue;
54
+ }
55
+ if (Array.isArray(parsed.pages) && parsed.pages.every((p) => p && Array.isArray(p.results))) {
56
+ reports.push(...parsed.pages);
57
+ continue;
58
+ }
59
+ reports.push(parsed);
60
+ }
61
+
62
+ const result = fillRgaaGridFromReports({
63
+ reports,
64
+ templatePath,
65
+ outputPath,
66
+ replicateToAllSheets: values['replicate-to-all-sheets'],
67
+ });
68
+
69
+ console.log(`Grille générée: ${result.outputPath}`);
70
+ console.log(`Onglets remplis: ${result.filledSheets}`);
71
+ console.log(`Critères consolidés depuis le rapport: ${result.filledCriteria}`);
72
+ } catch (err) {
73
+ console.error(`Erreur: ${err.message}`);
74
+ process.exit(1);
75
+ }
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@rgaa-audit/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.0",
4
+ "description": "Pré-audit RGAA 4.1.2 — CLI Playwright avec simulation d’actions humaines",
5
+ "main": "src/audit.js",
6
+ "bin": {
7
+ "rgaa-audit": "bin/rgaa-audit.js",
8
+ "rgaa-fill-grid": "bin/rgaa-fill-grid.js"
9
+ },
10
+ "scripts": {
11
+ "test": "node --test tests/*.test.js ../extension/tests/*.test.js",
12
+ "test:verbose": "node --test --test-reporter=spec tests/*.test.js ../extension/tests/*.test.js",
13
+ "audit:smoke": "node bin/rgaa-audit.js https://example.com -o json -s /tmp/smoke.json --no-simulate",
14
+ "lint": "node ../engine/build.js --check && node --check bin/rgaa-audit.js && node --check bin/rgaa-fill-grid.js && node --check src/audit.js && node --check src/simulator.js && node --check src/browser.js && node --check src/shared.js && node --check src/rules/index.js && node --check src/reporters/index.js && node --check src/reporters/ods-grid.js && node --check ../extension/shared/rgaa-rules.js && node --check ../extension/shared/rgaa-criteria.js && node --check ../extension/background.js && node --check ../extension/panel/panel.js && node --check src/page-prep.js && node --check src/html-validation.js && node --check src/aggregate.js && node --check src/captures.js && node --check ../extension/shared/rgaa-guide-page.js && node --check ../extension/shared/rgaa-guide-fiches.js && node --check ../extension/guide/guide-core.js && node --check ../extension/guide/guide.js",
15
+ "prepack": "node scripts/vendor-shared.js",
16
+ "docs:coverage": "node scripts/generate-docs.js",
17
+ "package:extension": "cd ../extension && V=$(node -p \"require('./manifest.json').version\") && rm -f ../rgaa-audit-extension-$V.zip && zip -qr ../rgaa-audit-extension-$V.zip . -x 'tests/*' '*.md' '.DS_Store' && echo rgaa-audit-extension-$V.zip",
18
+ "build:engine": "node ../engine/build.js",
19
+ "store:screenshots": "node scripts/store-screenshots.js"
20
+ },
21
+ "dependencies": {
22
+ "html-validate": "11.21.1",
23
+ "playwright": "^1.65.1"
24
+ },
25
+ "engines": {
26
+ "node": ">=20"
27
+ },
28
+ "keywords": [
29
+ "rgaa",
30
+ "accessibility",
31
+ "a11y",
32
+ "wcag",
33
+ "audit",
34
+ "playwright"
35
+ ],
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/Stan69000/rgaa-audit.git"
40
+ },
41
+ "files": [
42
+ "bin/",
43
+ "src/",
44
+ "vendor/",
45
+ "README.md"
46
+ ],
47
+ "homepage": "https://github.com/Stan69000/rgaa-audit#readme",
48
+ "bugs": {
49
+ "url": "https://github.com/Stan69000/rgaa-audit/issues"
50
+ }
51
+ }
@@ -0,0 +1,77 @@
1
+ // src/aggregate.js
2
+ // Regroupements transverses d'un rapport multi-pages : défauts de gabarit (même constat
3
+ // sur plusieurs pages) et comparaison avec un audit de référence (--baseline).
4
+ 'use strict';
5
+
6
+ /** Message sans compteurs ni mesures, pour reconnaître un même constat d'une page à l'autre. */
7
+ function normalizeMessage(message) {
8
+ return String(message || '')
9
+ .replace(/\s*\(\d+ occurrences?\)/g, '')
10
+ .replace(/\b\d+(?:[.,]\d+)?\b/g, '#')
11
+ .replace(/\s+/g, ' ')
12
+ .trim();
13
+ }
14
+
15
+ function fingerprint(result) {
16
+ return `${result.id}|${result.rule || result.source || ''}|${normalizeMessage(result.message)}`;
17
+ }
18
+
19
+ function pagePath(url) {
20
+ try {
21
+ const u = new URL(url);
22
+ return `${u.pathname}${u.search}` || '/';
23
+ } catch {
24
+ return String(url || '');
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Non-conformités présentes à l'identique sur plusieurs pages : elles viennent presque
30
+ * toujours d'un gabarit commun (en-tête, pied de page, composant) et se corrigent une fois.
31
+ */
32
+ function findTemplateIssues(results, minPages = 2) {
33
+ const byKey = new Map();
34
+ for (const r of results || []) {
35
+ if (r.status !== 'NC' || !r.pageUrl) continue;
36
+ const key = fingerprint(r);
37
+ if (!byKey.has(key)) byKey.set(key, { id: r.id, rule: r.rule || r.source, message: normalizeMessage(r.message).replace(/#/g, '…'), sample: r.message, pages: new Set(), occurrences: 0 });
38
+ const entry = byKey.get(key);
39
+ entry.pages.add(r.pageUrl);
40
+ entry.occurrences += Number(r.count) || 1;
41
+ }
42
+ return [...byKey.values()]
43
+ .filter((e) => e.pages.size >= minPages)
44
+ .map((e) => ({ id: e.id, rule: e.rule, message: e.sample, pages: [...e.pages], pageCount: e.pages.size, occurrences: e.occurrences }))
45
+ .sort((a, b) => b.pageCount - a.pageCount || b.occurrences - a.occurrences);
46
+ }
47
+
48
+ function ncKeys(results) {
49
+ const keys = new Map();
50
+ for (const r of results || []) {
51
+ if (r.status !== 'NC') continue;
52
+ const key = `${pagePath(r.pageUrl || '')}|${fingerprint(r)}`;
53
+ if (!keys.has(key)) keys.set(key, r);
54
+ }
55
+ return keys;
56
+ }
57
+
58
+ /** Nouvelles non-conformités et non-conformités résolues par rapport à un rapport de référence. */
59
+ function compareWithBaseline(current, baseline) {
60
+ const now = ncKeys(current.results);
61
+ const before = ncKeys(baseline.results);
62
+ const describe = (r) => ({ id: r.id, rule: r.rule || r.source || null, page: pagePath(r.pageUrl || ''), message: r.message });
63
+ const added = [...now.entries()].filter(([k]) => !before.has(k)).map(([, r]) => describe(r));
64
+ const resolved = [...before.entries()].filter(([k]) => !now.has(k)).map(([, r]) => describe(r));
65
+ const engineChanged = Boolean(baseline.engineVersion !== current.engineVersion);
66
+ return {
67
+ baselineTimestamp: baseline.timestamp || null,
68
+ baselineEngineVersion: baseline.engineVersion || null,
69
+ engineChanged,
70
+ newCount: added.length,
71
+ resolvedCount: resolved.length,
72
+ added,
73
+ resolved,
74
+ };
75
+ }
76
+
77
+ module.exports = { normalizeMessage, fingerprint, findTemplateIssues, compareWithBaseline, pagePath };