gbu-accessibility-package 1.2.0 → 1.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.
Files changed (3) hide show
  1. package/README.md +50 -6
  2. package/cli.js +67 -2
  3. package/package.json +11 -6
package/README.md CHANGED
@@ -60,15 +60,18 @@ Options:
60
60
  -l, --language <lang> Language for lang attribute (default: ja)
61
61
  --no-backup Don't create backup files
62
62
  --dry-run Preview changes without applying
63
- --cleanup-only Only cleanup duplicate role attributes
64
63
  --comprehensive, --all Run all fixes including cleanup (recommended)
64
+ --cleanup-only Only cleanup duplicate role attributes
65
+ --alt-only Only fix alt attributes for images
66
+ --lang-only Only fix HTML lang attributes
67
+ --role-only Only fix role attributes
65
68
  -h, --help Show help message
66
69
  ```
67
70
 
68
71
  ### Examples
69
72
 
70
73
  ```bash
71
- # Basic fixes for current directory
74
+ # Basic fixes for current directory (all standard fixes)
72
75
  gbu-a11y
73
76
 
74
77
  # Preview all changes
@@ -77,8 +80,15 @@ gbu-a11y --dry-run --comprehensive
77
80
  # Fix with English language
78
81
  gbu-a11y -l en ./public
79
82
 
80
- # Only cleanup duplicates
81
- gbu-a11y --cleanup-only
83
+ # Individual fix types
84
+ gbu-a11y --alt-only # Only fix alt attributes
85
+ gbu-a11y --lang-only # Only fix lang attributes
86
+ gbu-a11y --role-only # Only fix role attributes
87
+ gbu-a11y --cleanup-only # Only cleanup duplicates
88
+
89
+ # Combine with other options
90
+ gbu-a11y --alt-only --dry-run ./src # Preview alt fixes only
91
+ gbu-a11y --role-only -l en ./public # Fix roles with English lang
82
92
 
83
93
  # Fix without creating backups
84
94
  gbu-a11y --no-backup ./dist
@@ -108,7 +118,38 @@ async function fixAccessibility() {
108
118
  fixAccessibility();
109
119
  ```
110
120
 
111
- ## šŸŽÆ What Gets Fixed
121
+ ## šŸŽÆ Fix Modes
122
+
123
+ ### Individual Fix Options
124
+ You can now fix specific accessibility issues individually:
125
+
126
+ - `--alt-only` - Only fix alt attributes for images
127
+ - `--lang-only` - Only fix HTML lang attributes
128
+ - `--role-only` - Only fix role attributes
129
+ - `--cleanup-only` - Only cleanup duplicate role attributes
130
+
131
+ ### Combined Modes
132
+ - **Standard mode** (default) - Fixes alt, lang, and role attributes
133
+ - `--comprehensive` - All fixes including duplicate cleanup
134
+
135
+ ```bash
136
+ # Fix only missing alt attributes
137
+ gbu-a11y --alt-only
138
+
139
+ # Fix only HTML lang attributes
140
+ gbu-a11y --lang-only
141
+
142
+ # Fix only role attributes
143
+ gbu-a11y --role-only
144
+
145
+ # Clean up duplicate roles only
146
+ gbu-a11y --cleanup-only
147
+
148
+ # All fixes (recommended)
149
+ gbu-a11y --comprehensive
150
+ ```
151
+
152
+ ## šŸ”§ What Gets Fixed
112
153
 
113
154
  ### 1. Alt Attributes
114
155
  - **Missing alt attributes** → Adds contextual alt text
@@ -245,7 +286,10 @@ The package uses intelligent context analysis to generate meaningful alt text:
245
286
  "a11y:fix": "gbu-a11y",
246
287
  "a11y:check": "gbu-a11y --dry-run",
247
288
  "a11y:comprehensive": "gbu-a11y --comprehensive",
248
- "a11y:cleanup": "gbu-a11y --cleanup-only"
289
+ "a11y:cleanup": "gbu-a11y --cleanup-only",
290
+ "a11y:alt": "gbu-a11y --alt-only",
291
+ "a11y:lang": "gbu-a11y --lang-only",
292
+ "a11y:role": "gbu-a11y --role-only"
249
293
  }
250
294
  }
251
295
  ```
package/cli.js CHANGED
@@ -18,7 +18,10 @@ const options = {
18
18
  dryRun: false,
19
19
  help: false,
20
20
  cleanupOnly: false,
21
- comprehensive: false
21
+ comprehensive: false,
22
+ altOnly: false,
23
+ langOnly: false,
24
+ roleOnly: false
22
25
  };
23
26
 
24
27
  // Parse arguments
@@ -51,6 +54,15 @@ for (let i = 0; i < args.length; i++) {
51
54
  case '--all':
52
55
  options.comprehensive = true;
53
56
  break;
57
+ case '--alt-only':
58
+ options.altOnly = true;
59
+ break;
60
+ case '--lang-only':
61
+ options.langOnly = true;
62
+ break;
63
+ case '--role-only':
64
+ options.roleOnly = true;
65
+ break;
54
66
  default:
55
67
  if (!arg.startsWith('-')) {
56
68
  options.directory = arg;
@@ -70,13 +82,19 @@ Options:
70
82
  -l, --language <lang> Language for lang attribute (default: ja)
71
83
  --no-backup Don't create backup files
72
84
  --dry-run Preview changes without applying
73
- --cleanup-only Only cleanup duplicate role attributes
74
85
  --comprehensive, --all Run all fixes including cleanup (recommended)
86
+ --cleanup-only Only cleanup duplicate role attributes
87
+ --alt-only Only fix alt attributes for images
88
+ --lang-only Only fix HTML lang attributes
89
+ --role-only Only fix role attributes
75
90
  -h, --help Show this help message
76
91
 
77
92
  Examples:
78
93
  node cli.js # Fix current directory (standard fixes)
79
94
  node cli.js --comprehensive # Run all fixes including cleanup
95
+ node cli.js --alt-only # Only fix alt attributes
96
+ node cli.js --lang-only # Only fix lang attributes
97
+ node cli.js --role-only # Only fix role attributes
80
98
  node cli.js --cleanup-only # Only cleanup duplicate roles
81
99
  node cli.js ./src # Fix src directory
82
100
  node cli.js -l en --dry-run ./dist # Preview fixes for dist directory in English
@@ -131,6 +149,53 @@ async function main() {
131
149
  console.log(chalk.green('\nšŸŽ‰ Cleanup completed successfully!'));
132
150
  }
133
151
  return;
152
+
153
+ } else if (options.altOnly) {
154
+ // Only fix alt attributes
155
+ console.log(chalk.blue('šŸ–¼ļø Running alt attribute fixes only...'));
156
+ const altResults = await fixer.fixEmptyAltAttributes(options.directory);
157
+ const altFixed = altResults.filter(r => r.status === 'fixed').length;
158
+ const totalAltIssues = altResults.reduce((sum, r) => sum + (r.issues || 0), 0);
159
+
160
+ console.log(chalk.green(`\nāœ… Fixed alt attributes in ${altFixed} files (${totalAltIssues} issues)`));
161
+
162
+ if (options.dryRun) {
163
+ console.log(chalk.cyan('\nšŸ’” This was a dry run. Use without --dry-run to apply changes.'));
164
+ } else {
165
+ console.log(chalk.green('\nšŸŽ‰ Alt attribute fixes completed successfully!'));
166
+ }
167
+ return;
168
+
169
+ } else if (options.langOnly) {
170
+ // Only fix lang attributes
171
+ console.log(chalk.blue('šŸ“ Running HTML lang attribute fixes only...'));
172
+ const langResults = await fixer.fixHtmlLang(options.directory);
173
+ const langFixed = langResults.filter(r => r.status === 'fixed').length;
174
+
175
+ console.log(chalk.green(`\nāœ… Fixed lang attributes in ${langFixed} files`));
176
+
177
+ if (options.dryRun) {
178
+ console.log(chalk.cyan('\nšŸ’” This was a dry run. Use without --dry-run to apply changes.'));
179
+ } else {
180
+ console.log(chalk.green('\nšŸŽ‰ Lang attribute fixes completed successfully!'));
181
+ }
182
+ return;
183
+
184
+ } else if (options.roleOnly) {
185
+ // Only fix role attributes
186
+ console.log(chalk.blue('šŸŽ­ Running role attribute fixes only...'));
187
+ const roleResults = await fixer.fixRoleAttributes(options.directory);
188
+ const roleFixed = roleResults.filter(r => r.status === 'fixed').length;
189
+ const totalRoleIssues = roleResults.reduce((sum, r) => sum + (r.issues || 0), 0);
190
+
191
+ console.log(chalk.green(`\nāœ… Fixed role attributes in ${roleFixed} files (${totalRoleIssues} issues)`));
192
+
193
+ if (options.dryRun) {
194
+ console.log(chalk.cyan('\nšŸ’” This was a dry run. Use without --dry-run to apply changes.'));
195
+ } else {
196
+ console.log(chalk.green('\nšŸŽ‰ Role attribute fixes completed successfully!'));
197
+ }
198
+ return;
134
199
  }
135
200
 
136
201
  // Standard mode - run individual fixes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gbu-accessibility-package",
3
- "version": "1.2.0",
4
- "description": "Automated accessibility fixes for HTML files - Alt attributes, Lang attributes, Role attributes. Smart context-aware alt text generation and comprehensive role attribute management.",
3
+ "version": "1.4.0",
4
+ "description": "Automated accessibility fixes for HTML files - Alt attributes, Lang attributes, Role attributes. Smart context-aware alt text generation with individual fix options and comprehensive role attribute management.",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "gbu-a11y": "./cli.js",
@@ -11,6 +11,11 @@
11
11
  "start": "node cli.js",
12
12
  "fix": "node cli.js",
13
13
  "preview": "node cli.js --dry-run",
14
+ "comprehensive": "node cli.js --comprehensive",
15
+ "alt-only": "node cli.js --alt-only",
16
+ "lang-only": "node cli.js --lang-only",
17
+ "role-only": "node cli.js --role-only",
18
+ "cleanup-only": "node cli.js --cleanup-only",
14
19
  "test": "node test-package.js",
15
20
  "demo": "node cli.js --dry-run demo",
16
21
  "prepublishOnly": "npm run test"
@@ -34,11 +39,11 @@
34
39
  "license": "MIT",
35
40
  "repository": {
36
41
  "type": "git",
37
- "url": "https://github.com/your-org/gbu-accessibility-package.git"
42
+ "url": "https://github.com/dangpv94/gbu-accessibility-tool.git"
38
43
  },
39
- "homepage": "https://github.com/your-org/gbu-accessibility-package#readme",
44
+ "homepage": "https://github.com/dangpv94/gbu-accessibility-tool#readme",
40
45
  "bugs": {
41
- "url": "https://github.com/your-org/gbu-accessibility-package/issues"
46
+ "url": "https://github.com/dangpv94/gbu-accessibility-tool/issues"
42
47
  },
43
48
  "files": [
44
49
  "lib/",
@@ -59,4 +64,4 @@
59
64
  "publishConfig": {
60
65
  "access": "public"
61
66
  }
62
- }
67
+ }