ally-a11y 1.0.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/ACCESSIBILITY.md +205 -0
- package/LICENSE +21 -0
- package/README.md +940 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +528 -0
- package/dist/commands/audit-palette.d.ts +18 -0
- package/dist/commands/audit-palette.js +613 -0
- package/dist/commands/auto-pr.d.ts +19 -0
- package/dist/commands/auto-pr.js +434 -0
- package/dist/commands/badge.d.ts +11 -0
- package/dist/commands/badge.js +143 -0
- package/dist/commands/completion.d.ts +4 -0
- package/dist/commands/completion.js +185 -0
- package/dist/commands/crawl.d.ts +12 -0
- package/dist/commands/crawl.js +249 -0
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.js +233 -0
- package/dist/commands/explain.d.ts +12 -0
- package/dist/commands/explain.js +233 -0
- package/dist/commands/fix.d.ts +13 -0
- package/dist/commands/fix.js +668 -0
- package/dist/commands/health.d.ts +11 -0
- package/dist/commands/health.js +367 -0
- package/dist/commands/history.d.ts +10 -0
- package/dist/commands/history.js +191 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.js +164 -0
- package/dist/commands/learn.d.ts +8 -0
- package/dist/commands/learn.js +592 -0
- package/dist/commands/pr-check.d.ts +12 -0
- package/dist/commands/pr-check.js +270 -0
- package/dist/commands/report.d.ts +11 -0
- package/dist/commands/report.js +375 -0
- package/dist/commands/scan-storybook.d.ts +18 -0
- package/dist/commands/scan-storybook.js +402 -0
- package/dist/commands/scan.d.ts +25 -0
- package/dist/commands/scan.js +673 -0
- package/dist/commands/stats.d.ts +5 -0
- package/dist/commands/stats.js +137 -0
- package/dist/commands/tree.d.ts +12 -0
- package/dist/commands/tree.js +635 -0
- package/dist/commands/triage.d.ts +13 -0
- package/dist/commands/triage.js +327 -0
- package/dist/commands/watch.d.ts +17 -0
- package/dist/commands/watch.js +302 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/baseline.d.ts +62 -0
- package/dist/utils/baseline.js +169 -0
- package/dist/utils/browser.d.ts +78 -0
- package/dist/utils/browser.js +239 -0
- package/dist/utils/cache.d.ts +76 -0
- package/dist/utils/cache.js +178 -0
- package/dist/utils/config.d.ts +102 -0
- package/dist/utils/config.js +237 -0
- package/dist/utils/converters.d.ts +77 -0
- package/dist/utils/converters.js +200 -0
- package/dist/utils/copilot.d.ts +36 -0
- package/dist/utils/copilot.js +139 -0
- package/dist/utils/detect.d.ts +22 -0
- package/dist/utils/detect.js +197 -0
- package/dist/utils/enhanced-errors.d.ts +46 -0
- package/dist/utils/enhanced-errors.js +295 -0
- package/dist/utils/errors.d.ts +31 -0
- package/dist/utils/errors.js +149 -0
- package/dist/utils/fix-patterns.d.ts +56 -0
- package/dist/utils/fix-patterns.js +529 -0
- package/dist/utils/history-tracking.d.ts +94 -0
- package/dist/utils/history-tracking.js +230 -0
- package/dist/utils/history.d.ts +42 -0
- package/dist/utils/history.js +255 -0
- package/dist/utils/impact-scores.d.ts +44 -0
- package/dist/utils/impact-scores.js +257 -0
- package/dist/utils/retry.d.ts +24 -0
- package/dist/utils/retry.js +76 -0
- package/dist/utils/scanner.d.ts +74 -0
- package/dist/utils/scanner.js +606 -0
- package/dist/utils/scanner.test.d.ts +4 -0
- package/dist/utils/scanner.test.js +162 -0
- package/dist/utils/ui.d.ts +44 -0
- package/dist/utils/ui.js +276 -0
- package/mcp-server/dist/index.d.ts +8 -0
- package/mcp-server/dist/index.js +1923 -0
- package/package.json +88 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ally stats command - Shows accessibility progress over time
|
|
3
|
+
*/
|
|
4
|
+
import { readFile } from 'fs/promises';
|
|
5
|
+
import { existsSync } from 'fs';
|
|
6
|
+
import { resolve, join } from 'path';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import boxen from 'boxen';
|
|
9
|
+
import { printBanner, printError, animateScoreUp, } from '../utils/ui.js';
|
|
10
|
+
import { calculateTrend, formatTrend, renderAsciiChart, } from '../utils/history.js';
|
|
11
|
+
/**
|
|
12
|
+
* Convert legacy history entry to new format
|
|
13
|
+
*/
|
|
14
|
+
function normalizeHistoryEntry(entry) {
|
|
15
|
+
return {
|
|
16
|
+
date: entry.date,
|
|
17
|
+
score: entry.score,
|
|
18
|
+
errors: entry.errors ?? entry.violations ?? 0,
|
|
19
|
+
warnings: entry.warnings ?? 0,
|
|
20
|
+
filesScanned: entry.filesScanned ?? entry.files ?? 0,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export async function statsCommand() {
|
|
24
|
+
printBanner();
|
|
25
|
+
const projectPath = resolve('.');
|
|
26
|
+
const allyDir = resolve('.ally');
|
|
27
|
+
if (!existsSync(allyDir)) {
|
|
28
|
+
printError('No ally data found. Run `ally scan` first.');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Load current scan
|
|
32
|
+
const scanPath = join(allyDir, 'scan.json');
|
|
33
|
+
if (!existsSync(scanPath)) {
|
|
34
|
+
printError('No scan results found. Run `ally scan` first.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const scanContent = await readFile(scanPath, 'utf-8');
|
|
38
|
+
const report = JSON.parse(scanContent);
|
|
39
|
+
// Load history (use the utility, but also handle legacy format)
|
|
40
|
+
const historyPath = join(allyDir, 'history.json');
|
|
41
|
+
let history = [];
|
|
42
|
+
if (existsSync(historyPath)) {
|
|
43
|
+
try {
|
|
44
|
+
const historyContent = await readFile(historyPath, 'utf-8');
|
|
45
|
+
const rawHistory = JSON.parse(historyContent);
|
|
46
|
+
history = rawHistory.map(normalizeHistoryEntry);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
history = [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Display current score with animation
|
|
53
|
+
console.log(chalk.bold.cyan('\nš Accessibility Dashboard\n'));
|
|
54
|
+
const previousScore = history.length > 0 ? history[history.length - 1].score : 0;
|
|
55
|
+
await animateScoreUp(previousScore, report.summary.score);
|
|
56
|
+
// Show trend information
|
|
57
|
+
if (history.length > 0) {
|
|
58
|
+
const trend = calculateTrend(history, report.summary.score);
|
|
59
|
+
const trendText = formatTrend(trend);
|
|
60
|
+
if (trendText) {
|
|
61
|
+
console.log();
|
|
62
|
+
console.log(chalk.bold('Trend:'));
|
|
63
|
+
console.log(trendText);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Show ASCII chart of score history
|
|
67
|
+
if (history.length > 1) {
|
|
68
|
+
console.log();
|
|
69
|
+
console.log(renderAsciiChart(history, report.summary.score));
|
|
70
|
+
}
|
|
71
|
+
// Show recent history entries
|
|
72
|
+
if (history.length > 0) {
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(chalk.bold('š Recent History'));
|
|
75
|
+
console.log(chalk.dim('ā'.repeat(50)));
|
|
76
|
+
// Show last 5 entries
|
|
77
|
+
const recentHistory = history.slice(-5);
|
|
78
|
+
for (const entry of recentHistory) {
|
|
79
|
+
const date = new Date(entry.date).toLocaleDateString();
|
|
80
|
+
const scoreColor = entry.score >= 75 ? chalk.green : entry.score >= 50 ? chalk.yellow : chalk.red;
|
|
81
|
+
const bar = getSmallBar(entry.score);
|
|
82
|
+
const issues = entry.errors + entry.warnings;
|
|
83
|
+
console.log(` ${chalk.dim(date)} ${bar} ${scoreColor(entry.score.toString().padStart(3))} (${issues} issues)`);
|
|
84
|
+
}
|
|
85
|
+
// Current
|
|
86
|
+
const currentBar = getSmallBar(report.summary.score);
|
|
87
|
+
const currentColor = report.summary.score >= 75 ? chalk.green : report.summary.score >= 50 ? chalk.yellow : chalk.red;
|
|
88
|
+
console.log(` ${chalk.bold('Today')} ${currentBar} ${currentColor.bold(report.summary.score.toString().padStart(3))} (${report.summary.totalViolations} issues)`);
|
|
89
|
+
// Calculate improvement from first entry
|
|
90
|
+
const firstScore = history[0].score;
|
|
91
|
+
const improvement = report.summary.score - firstScore;
|
|
92
|
+
if (improvement > 0) {
|
|
93
|
+
console.log();
|
|
94
|
+
console.log(chalk.green.bold(` š +${improvement} points since you started!`));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Quick stats
|
|
98
|
+
console.log();
|
|
99
|
+
console.log(chalk.bold('š Current Status'));
|
|
100
|
+
console.log(chalk.dim('ā'.repeat(50)));
|
|
101
|
+
const stats = [
|
|
102
|
+
['Files scanned', report.totalFiles.toString()],
|
|
103
|
+
['Total violations', report.summary.totalViolations.toString()],
|
|
104
|
+
['Critical issues', (report.summary.bySeverity.critical || 0).toString()],
|
|
105
|
+
['Serious issues', (report.summary.bySeverity.serious || 0).toString()],
|
|
106
|
+
];
|
|
107
|
+
for (const [label, value] of stats) {
|
|
108
|
+
console.log(` ${chalk.dim(label + ':')} ${value}`);
|
|
109
|
+
}
|
|
110
|
+
// Motivational message
|
|
111
|
+
console.log();
|
|
112
|
+
if (report.summary.score === 100) {
|
|
113
|
+
console.log(boxen(chalk.green.bold('š Perfect Score! Your site is fully accessible.'), {
|
|
114
|
+
padding: { top: 0, bottom: 0, left: 1, right: 1 },
|
|
115
|
+
borderColor: 'green',
|
|
116
|
+
borderStyle: 'round',
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
else if (report.summary.score >= 90) {
|
|
120
|
+
console.log(chalk.green('Almost there! Just a few more fixes to reach 100%.'));
|
|
121
|
+
}
|
|
122
|
+
else if (report.summary.score >= 75) {
|
|
123
|
+
console.log(chalk.yellow('Good progress! Focus on critical and serious issues next.'));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.log(chalk.cyan('Run `ally fix` to start improving your score.'));
|
|
127
|
+
}
|
|
128
|
+
console.log();
|
|
129
|
+
}
|
|
130
|
+
function getSmallBar(score) {
|
|
131
|
+
const width = 15;
|
|
132
|
+
const filled = Math.round((score / 100) * width);
|
|
133
|
+
const empty = width - filled;
|
|
134
|
+
const color = score >= 75 ? chalk.green : score >= 50 ? chalk.yellow : chalk.red;
|
|
135
|
+
return color('ā'.repeat(filled)) + chalk.gray('ā'.repeat(empty));
|
|
136
|
+
}
|
|
137
|
+
export default statsCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ally tree command - Visualize accessibility tree for a URL
|
|
3
|
+
*/
|
|
4
|
+
interface TreeCommandOptions {
|
|
5
|
+
depth?: number;
|
|
6
|
+
role?: string;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
speak?: boolean;
|
|
9
|
+
noAudio?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function treeCommand(url: string, options?: TreeCommandOptions): Promise<void>;
|
|
12
|
+
export default treeCommand;
|