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.
Files changed (84) hide show
  1. package/ACCESSIBILITY.md +205 -0
  2. package/LICENSE +21 -0
  3. package/README.md +940 -0
  4. package/dist/cli.d.ts +7 -0
  5. package/dist/cli.js +528 -0
  6. package/dist/commands/audit-palette.d.ts +18 -0
  7. package/dist/commands/audit-palette.js +613 -0
  8. package/dist/commands/auto-pr.d.ts +19 -0
  9. package/dist/commands/auto-pr.js +434 -0
  10. package/dist/commands/badge.d.ts +11 -0
  11. package/dist/commands/badge.js +143 -0
  12. package/dist/commands/completion.d.ts +4 -0
  13. package/dist/commands/completion.js +185 -0
  14. package/dist/commands/crawl.d.ts +12 -0
  15. package/dist/commands/crawl.js +249 -0
  16. package/dist/commands/doctor.d.ts +5 -0
  17. package/dist/commands/doctor.js +233 -0
  18. package/dist/commands/explain.d.ts +12 -0
  19. package/dist/commands/explain.js +233 -0
  20. package/dist/commands/fix.d.ts +13 -0
  21. package/dist/commands/fix.js +668 -0
  22. package/dist/commands/health.d.ts +11 -0
  23. package/dist/commands/health.js +367 -0
  24. package/dist/commands/history.d.ts +10 -0
  25. package/dist/commands/history.js +191 -0
  26. package/dist/commands/init.d.ts +9 -0
  27. package/dist/commands/init.js +164 -0
  28. package/dist/commands/learn.d.ts +8 -0
  29. package/dist/commands/learn.js +592 -0
  30. package/dist/commands/pr-check.d.ts +12 -0
  31. package/dist/commands/pr-check.js +270 -0
  32. package/dist/commands/report.d.ts +11 -0
  33. package/dist/commands/report.js +375 -0
  34. package/dist/commands/scan-storybook.d.ts +18 -0
  35. package/dist/commands/scan-storybook.js +402 -0
  36. package/dist/commands/scan.d.ts +25 -0
  37. package/dist/commands/scan.js +673 -0
  38. package/dist/commands/stats.d.ts +5 -0
  39. package/dist/commands/stats.js +137 -0
  40. package/dist/commands/tree.d.ts +12 -0
  41. package/dist/commands/tree.js +635 -0
  42. package/dist/commands/triage.d.ts +13 -0
  43. package/dist/commands/triage.js +327 -0
  44. package/dist/commands/watch.d.ts +17 -0
  45. package/dist/commands/watch.js +302 -0
  46. package/dist/types/index.d.ts +60 -0
  47. package/dist/types/index.js +4 -0
  48. package/dist/utils/baseline.d.ts +62 -0
  49. package/dist/utils/baseline.js +169 -0
  50. package/dist/utils/browser.d.ts +78 -0
  51. package/dist/utils/browser.js +239 -0
  52. package/dist/utils/cache.d.ts +76 -0
  53. package/dist/utils/cache.js +178 -0
  54. package/dist/utils/config.d.ts +102 -0
  55. package/dist/utils/config.js +237 -0
  56. package/dist/utils/converters.d.ts +77 -0
  57. package/dist/utils/converters.js +200 -0
  58. package/dist/utils/copilot.d.ts +36 -0
  59. package/dist/utils/copilot.js +139 -0
  60. package/dist/utils/detect.d.ts +22 -0
  61. package/dist/utils/detect.js +197 -0
  62. package/dist/utils/enhanced-errors.d.ts +46 -0
  63. package/dist/utils/enhanced-errors.js +295 -0
  64. package/dist/utils/errors.d.ts +31 -0
  65. package/dist/utils/errors.js +149 -0
  66. package/dist/utils/fix-patterns.d.ts +56 -0
  67. package/dist/utils/fix-patterns.js +529 -0
  68. package/dist/utils/history-tracking.d.ts +94 -0
  69. package/dist/utils/history-tracking.js +230 -0
  70. package/dist/utils/history.d.ts +42 -0
  71. package/dist/utils/history.js +255 -0
  72. package/dist/utils/impact-scores.d.ts +44 -0
  73. package/dist/utils/impact-scores.js +257 -0
  74. package/dist/utils/retry.d.ts +24 -0
  75. package/dist/utils/retry.js +76 -0
  76. package/dist/utils/scanner.d.ts +74 -0
  77. package/dist/utils/scanner.js +606 -0
  78. package/dist/utils/scanner.test.d.ts +4 -0
  79. package/dist/utils/scanner.test.js +162 -0
  80. package/dist/utils/ui.d.ts +44 -0
  81. package/dist/utils/ui.js +276 -0
  82. package/mcp-server/dist/index.d.ts +8 -0
  83. package/mcp-server/dist/index.js +1923 -0
  84. 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;