wcag-a11y 0.4.1 → 0.4.2
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 +23 -9
- package/dist/cli.js +9 -4
- package/dist/config.js +3 -2
- package/dist/crawler.js +1 -1
- package/dist/fixer.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,8 +78,13 @@ npm install -g wcag-a11y
|
|
|
78
78
|
## Quick start
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
|
-
# 1. Configure your AI provider (Gemini is free, no credit card)
|
|
82
|
-
wcag-a11y init
|
|
81
|
+
# 1. Configure your AI provider and framework (Gemini is free, no credit card)
|
|
82
|
+
wcag-a11y init --framework next # Next.js
|
|
83
|
+
wcag-a11y init --framework react # React / Vite
|
|
84
|
+
wcag-a11y init --framework vue # Vue / Nuxt
|
|
85
|
+
wcag-a11y init --framework angular # Angular
|
|
86
|
+
wcag-a11y init --framework svelte # Svelte / SvelteKit
|
|
87
|
+
wcag-a11y init # plain HTML or auto-detect
|
|
83
88
|
|
|
84
89
|
# 2. Start your dev server, then scan
|
|
85
90
|
wcag-a11y scan -u http://localhost:3000
|
|
@@ -116,6 +121,7 @@ wcag-a11y scan -u http://localhost:3000 --terminal --fast-mode
|
|
|
116
121
|
| `--group <strategy>` | `rule` | `rule`: one prompt per rule type. `none`: one prompt per element |
|
|
117
122
|
| `--ci` | off | Exit with code `1` if any violations are found |
|
|
118
123
|
| `--provider <name>` | from config | Override AI provider for this run |
|
|
124
|
+
| `--framework <name>` | from config | Override framework for this run (e.g. `next`, `react`, `vue`, `angular`, `svelte`, `astro`) |
|
|
119
125
|
|
|
120
126
|
---
|
|
121
127
|
|
|
@@ -159,21 +165,28 @@ wcag-a11y fix --from-report --apply # patches files from that report, no s
|
|
|
159
165
|
| `--from-report [path]` | `a11y-report.md` | Load violations from an existing report instead of rescanning |
|
|
160
166
|
| `--apply` | off | Write fixes to disk (dry-run without this flag) |
|
|
161
167
|
| `--provider <name>` | from config | Override AI provider for this run |
|
|
168
|
+
| `--framework <name>` | from config | Override framework for this run (e.g. `next`, `react`, `vue`, `angular`, `svelte`, `astro`) |
|
|
162
169
|
|
|
163
170
|
---
|
|
164
171
|
|
|
165
172
|
### `wcag-a11y init`
|
|
166
173
|
|
|
167
|
-
Create `a11y.config.json` pre-configured for your chosen provider.
|
|
174
|
+
Create `a11y.config.json` pre-configured for your chosen provider and framework.
|
|
168
175
|
|
|
169
176
|
```bash
|
|
170
|
-
wcag-a11y init
|
|
171
|
-
wcag-a11y init --provider openai
|
|
172
|
-
wcag-a11y init --provider
|
|
173
|
-
|
|
174
|
-
# … and 8 more providers
|
|
177
|
+
wcag-a11y init # Gemini (free, default)
|
|
178
|
+
wcag-a11y init --provider openai --framework next # OpenAI + Next.js
|
|
179
|
+
wcag-a11y init --provider ollama --framework react # local Ollama + React
|
|
180
|
+
# … 12 providers total, any framework string accepted
|
|
175
181
|
```
|
|
176
182
|
|
|
183
|
+
| Flag | Description |
|
|
184
|
+
|---|---|
|
|
185
|
+
| `--provider <name>` | AI provider. Default: `gemini`. See [AI Providers](#ai-providers) for all options |
|
|
186
|
+
| `--framework <name>` | Your project framework — saved to config so every scan uses it automatically |
|
|
187
|
+
|
|
188
|
+
Framework is saved as `"framework"` in `a11y.config.json`. You can also edit the file directly at any time. Supported values for best results: `next`, `react`, `vue`, `nuxt`, `angular`, `svelte`, `gatsby`, `remix`, `astro` — or any free-form string.
|
|
189
|
+
|
|
177
190
|
---
|
|
178
191
|
|
|
179
192
|
### `wcag-a11y demo`
|
|
@@ -217,7 +230,8 @@ Run `wcag-a11y init` to generate `a11y.config.json`. Only fill in the fields for
|
|
|
217
230
|
```json
|
|
218
231
|
{
|
|
219
232
|
"provider": "gemini",
|
|
220
|
-
"apiKey": "YOUR_GEMINI_API_KEY"
|
|
233
|
+
"apiKey": "YOUR_GEMINI_API_KEY",
|
|
234
|
+
"framework": "next"
|
|
221
235
|
}
|
|
222
236
|
```
|
|
223
237
|
|
package/dist/cli.js
CHANGED
|
@@ -13,13 +13,14 @@ const program = new Command();
|
|
|
13
13
|
program
|
|
14
14
|
.name('wcag-a11y')
|
|
15
15
|
.description('WCAG 2.1/2.2 accessibility auditor with AI-powered fixes')
|
|
16
|
-
.version('0.4.
|
|
16
|
+
.version('0.4.2');
|
|
17
17
|
program
|
|
18
18
|
.command('init')
|
|
19
19
|
.description('Create a11y.config.json in the current directory')
|
|
20
20
|
.option('--provider <name>', 'AI provider to configure (gemini|openai|ollama|anthropic|mistral|groq|cohere|xai|deepseek|together|perplexity|azure-openai)', 'gemini')
|
|
21
|
+
.option('--framework <name>', 'Your project framework — saves to config so every run uses it automatically (e.g. next, react, vue, angular, svelte, astro)')
|
|
21
22
|
.action((opts) => {
|
|
22
|
-
initConfig(opts.provider);
|
|
23
|
+
initConfig(opts.provider, opts.framework);
|
|
23
24
|
});
|
|
24
25
|
program
|
|
25
26
|
.command('scan')
|
|
@@ -35,10 +36,11 @@ program
|
|
|
35
36
|
.option('--group <strategy>', 'Group violations by rule or show individually (rule|none)', 'rule')
|
|
36
37
|
.option('--ci', 'Exit with code 1 if any violations are found (for CI/CD pipelines)', false)
|
|
37
38
|
.option('--provider <name>', 'Override the AI provider from config (gemini|openai|ollama|anthropic|mistral|groq|cohere|xai|deepseek|together|perplexity|azure-openai)')
|
|
39
|
+
.option('--framework <name>', 'Override framework detection for this run (e.g. next, react, vue, angular, svelte, astro)')
|
|
38
40
|
.action(async (opts) => {
|
|
39
41
|
try {
|
|
40
42
|
console.log(`\nScanning ${opts.url}...`);
|
|
41
|
-
const result = await crawl({ url: opts.url, pages: opts.pages, crawl: opts.crawl });
|
|
43
|
+
const result = await crawl({ url: opts.url, pages: opts.pages, crawl: opts.crawl, framework: opts.framework });
|
|
42
44
|
if (opts.terminal && !opts.fastMode) {
|
|
43
45
|
printTerminalReport(result);
|
|
44
46
|
}
|
|
@@ -51,10 +53,11 @@ program
|
|
|
51
53
|
const provider = createAIProvider(config);
|
|
52
54
|
const allViolations = result.pages.flatMap((p) => p.violations);
|
|
53
55
|
const ruleGroups = groupViolations(allViolations, strategy);
|
|
56
|
+
const framework = result.framework ?? config.framework;
|
|
54
57
|
if (!opts.fastMode) {
|
|
55
58
|
console.log(`\nGenerating AI fixes for ${ruleGroups.length} rule groups (${allViolations.length} violations)...`);
|
|
56
59
|
}
|
|
57
|
-
const fixes = await provider.generateFixes(allViolations, strategy,
|
|
60
|
+
const fixes = await provider.generateFixes(allViolations, strategy, framework);
|
|
58
61
|
if (opts.terminal) {
|
|
59
62
|
printAIPrompts(fixes, { explain: opts.explain, fastMode: opts.fastMode });
|
|
60
63
|
}
|
|
@@ -83,6 +86,7 @@ program
|
|
|
83
86
|
.option('--from-report [path]', 'Use an existing report instead of scanning (default: a11y-report.md)')
|
|
84
87
|
.option('--apply', 'Write fixes to source files (default: dry-run, shows diff only)', false)
|
|
85
88
|
.option('--provider <name>', 'Override the AI provider from config (gemini|openai|ollama|anthropic|mistral|groq|cohere|xai|deepseek|together|perplexity|azure-openai)')
|
|
89
|
+
.option('--framework <name>', 'Override framework detection for this run (e.g. next, react, vue, angular, svelte, astro)')
|
|
86
90
|
.action(async (opts) => {
|
|
87
91
|
if (!opts.url && !opts.fromReport) {
|
|
88
92
|
console.error('\nError: provide --url <url> to scan, or --from-report [path] to load an existing report.');
|
|
@@ -104,6 +108,7 @@ program
|
|
|
104
108
|
apply: opts.apply,
|
|
105
109
|
provider,
|
|
106
110
|
srcDir: resolve(process.cwd(), 'src'),
|
|
111
|
+
framework: opts.framework ?? config.framework,
|
|
107
112
|
});
|
|
108
113
|
}
|
|
109
114
|
catch (err) {
|
package/dist/config.js
CHANGED
|
@@ -82,13 +82,14 @@ const STARTER_CONFIGS = {
|
|
|
82
82
|
`Created ${CONFIG_FILE} — fill in your Azure OpenAI endpoint, deployment, and API key from https://portal.azure.com`,
|
|
83
83
|
],
|
|
84
84
|
};
|
|
85
|
-
export function initConfig(provider = 'gemini') {
|
|
85
|
+
export function initConfig(provider = 'gemini', framework) {
|
|
86
86
|
const configPath = join(process.cwd(), CONFIG_FILE);
|
|
87
87
|
if (existsSync(configPath)) {
|
|
88
88
|
console.log(`${CONFIG_FILE} already exists.`);
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
const [starter, message] = STARTER_CONFIGS[provider];
|
|
92
|
-
|
|
92
|
+
const config = framework ? { ...starter, framework } : starter;
|
|
93
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
93
94
|
console.log(message);
|
|
94
95
|
}
|
package/dist/crawler.js
CHANGED
package/dist/fixer.js
CHANGED
|
@@ -18,11 +18,12 @@ export async function runFix(opts) {
|
|
|
18
18
|
console.log(chalk.green('\nNo violations found in report.'));
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
+
framework = opts.framework;
|
|
21
22
|
console.log(`Found ${allViolations.length} violation(s) in report. Locating source files...\n`);
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
25
|
console.log(`\nScanning ${opts.url}...`);
|
|
25
|
-
const result = await crawl({ url: opts.url, pages: opts.pages, crawl: opts.crawl });
|
|
26
|
+
const result = await crawl({ url: opts.url, pages: opts.pages, crawl: opts.crawl, framework: opts.framework });
|
|
26
27
|
framework = result.framework;
|
|
27
28
|
if (result.totalViolations === 0) {
|
|
28
29
|
console.log(chalk.green('\nNo violations found.'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wcag-a11y",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "WCAG 2.1/2.2 accessibility auditor with AI-powered fixes. Crawls your dev server with Playwright, runs 40+ checks, and uses AI (12 providers) to generate fix prompts or patch source files directly.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wcag",
|