gbu-accessibility-package 3.12.0 → 3.13.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/bin/fix.js CHANGED
@@ -1,140 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- /**
4
- * CLI tool for accessibility fixes
5
- */
6
-
7
- const { program } = require('commander');
8
- const { AccessibilityFixer } = require('../index');
9
- const chalk = require('chalk');
10
-
11
- program
12
- .name('a11y-fix')
13
- .description('Accessibility fixing CLI tool')
14
- .version('1.0.0');
15
-
16
- program
17
- .command('lang')
18
- .description('Fix HTML lang attributes')
19
- .option('-d, --directory <dir>', 'Directory to scan', '.')
20
- .option('-l, --language <lang>', 'Language code', 'ja')
21
- .option('--no-backup', 'Skip creating backup files')
22
- .option('--dry-run', 'Show what would be changed without making changes')
23
- .action(async (options) => {
24
- try {
25
- const fixer = new AccessibilityFixer({
26
- language: options.language,
27
- backupFiles: options.backup,
28
- dryRun: options.dryRun
29
- });
30
-
31
- const results = await fixer.fixHtmlLang(options.directory);
32
-
33
- const fixed = results.filter(r => r.status === 'fixed').length;
34
- const errors = results.filter(r => r.status === 'error').length;
35
-
36
- console.log(chalk.green(`\n✅ Lang attribute fixes completed!`));
37
- console.log(` Files fixed: ${fixed}`);
38
- console.log(` Errors: ${errors}`);
39
-
40
- } catch (error) {
41
- console.error(chalk.red(`❌ Error: ${error.message}`));
42
- process.exit(1);
43
- }
44
- });
45
-
46
- program
47
- .command('alt')
48
- .description('Fix empty alt attributes')
49
- .option('-d, --directory <dir>', 'Directory to scan', '.')
50
- .option('--no-backup', 'Skip creating backup files')
51
- .option('--dry-run', 'Show what would be changed without making changes')
52
- .action(async (options) => {
53
- try {
54
- const fixer = new AccessibilityFixer({
55
- backupFiles: options.backup,
56
- dryRun: options.dryRun
57
- });
58
-
59
- const results = await fixer.fixEmptyAltAttributes(options.directory);
60
-
61
- const fixed = results.filter(r => r.status === 'fixed').length;
62
- const errors = results.filter(r => r.status === 'error').length;
63
-
64
- console.log(chalk.green(`\n✅ Alt attribute fixes completed!`));
65
- console.log(` Files fixed: ${fixed}`);
66
- console.log(` Errors: ${errors}`);
67
-
68
- } catch (error) {
69
- console.error(chalk.red(`❌ Error: ${error.message}`));
70
- process.exit(1);
71
- }
72
- });
73
-
74
- program
75
- .command('role')
76
- .description('Fix role attributes')
77
- .option('-d, --directory <dir>', 'Directory to scan', '.')
78
- .option('--no-backup', 'Skip creating backup files')
79
- .option('--dry-run', 'Show what would be changed without making changes')
80
- .action(async (options) => {
81
- try {
82
- const fixer = new AccessibilityFixer({
83
- backupFiles: options.backup,
84
- dryRun: options.dryRun
85
- });
86
-
87
- const results = await fixer.fixRoleAttributes(options.directory);
88
-
89
- const fixed = results.filter(r => r.status === 'fixed').length;
90
- const errors = results.filter(r => r.status === 'error').length;
91
-
92
- console.log(chalk.green(`\n✅ Role attribute fixes completed!`));
93
- console.log(` Files fixed: ${fixed}`);
94
- console.log(` Errors: ${errors}`);
95
-
96
- } catch (error) {
97
- console.error(chalk.red(`❌ Error: ${error.message}`));
98
- process.exit(1);
99
- }
100
- });
101
-
102
- program
103
- .command('all')
104
- .description('Run all automated fixes')
105
- .option('-d, --directory <dir>', 'Directory to scan', '.')
106
- .option('-l, --language <lang>', 'Language code', 'ja')
107
- .option('--no-backup', 'Skip creating backup files')
108
- .option('--dry-run', 'Show what would be changed without making changes')
109
- .action(async (options) => {
110
- try {
111
- const fixer = new AccessibilityFixer({
112
- language: options.language,
113
- backupFiles: options.backup,
114
- dryRun: options.dryRun
115
- });
116
-
117
- console.log(chalk.blue('🔧 Running all accessibility fixes...\n'));
118
-
119
- await fixer.fixHtmlLang(options.directory);
120
- await fixer.fixEmptyAltAttributes(options.directory);
121
- await fixer.fixRoleAttributes(options.directory);
122
-
123
- const suggestions = await fixer.addMainLandmarks(options.directory);
124
-
125
- if (suggestions.length > 0) {
126
- console.log(chalk.yellow('\n📋 Manual fixes needed:'));
127
- suggestions.forEach(suggestion => {
128
- console.log(` ${suggestion.file}: ${suggestion.recommendation}`);
129
- });
130
- }
131
-
132
- console.log(chalk.green('\n✅ All automated fixes completed!'));
133
-
134
- } catch (error) {
135
- console.error(chalk.red(`❌ Error: ${error.message}`));
136
- process.exit(1);
137
- }
138
- });
139
-
140
- program.parse();
3
+ require('../cli.js');