gbu-accessibility-package 3.1.0 → 3.1.3

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/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.1.0] - 2024-07-25
9
+
10
+ ### Changed
11
+ - **BREAKING**: Default behavior now **no backup files** for faster processing
12
+ - **Backup is now optional**: Use `--backup` flag when you need backup files
13
+ - **Performance improvement**: Faster processing by default without backup creation
14
+ - **CLI help updated**: Reflects new default behavior
15
+ - **Documentation updated**: README and README-vi updated with new backup behavior
16
+
17
+ ### Migration Guide
18
+ - **No action needed for most users** - you get faster processing by default
19
+ - **If you want backup files**: Add `--backup` flag to your commands
20
+ - **Old behavior**: `gbu-a11y` (created backups) → **New behavior**: `gbu-a11y --backup`
21
+ - **Scripts using --no-backup**: Can remove the flag (now default behavior)
22
+
8
23
  ## [3.0.0] - 2024-07-25
9
24
 
10
25
  ### Added
package/README-vi.md CHANGED
@@ -19,7 +19,7 @@
19
19
  - 📑 **Phân tích Headings** - Phân tích cấu trúc heading với đề xuất
20
20
  - 🧹 **Dọn dẹp trùng lặp** - Xóa role attributes trùng lặp
21
21
  - 📁 **Xử lý hàng loạt** - Xử lý toàn bộ thư mục đệ quy
22
- - 💾 **Backup tự động** - Sửa đổi an toàn với file backup
22
+ - 💾 **Backup tùy chọn** - Tạo file backup khi cần với flag --backup
23
23
  - 🔍 **Chế độ xem trước** - Xem trước thay đổi trước khi áp dụng
24
24
  - 📊 **Báo cáo chi tiết** - Tóm tắt sửa chữa toàn diện
25
25
 
@@ -61,8 +61,8 @@ gbu-a11y [options] [directory/file]
61
61
  Tùy chọn:
62
62
  -d, --directory <path> Thư mục đích (mặc định: thư mục hiện tại)
63
63
  -l, --language <lang> Ngôn ngữ cho thuộc tính lang (mặc định: ja)
64
- --backup Tạo file backup (mặc định: bật)
65
- --no-backup Không tạo file backup
64
+ --backup Tạo file backup
65
+ --no-backup Không tạo file backup (mặc định)
66
66
  --dry-run Xem trước thay đổi mà không áp dụng
67
67
  --comprehensive, --all Chạy sửa toàn diện (giống mặc định)
68
68
  --cleanup-only Chỉ dọn dẹp role attributes trùng lặp
@@ -103,28 +103,28 @@ gbu-a11y --alt-only --dry-run ./src # Xem trước sửa alt
103
103
  gbu-a11y --forms-only -l en ./public # Sửa form với tiếng Anh
104
104
 
105
105
  # Tùy chọn backup
106
- gbu-a11y --backup ./dist # Bật backup ràng (mặc định)
107
- gbu-a11y --no-backup ./dist # Tắt backup để xử lý nhanh hơn
106
+ gbu-a11y --backup ./dist # Bật backup để an toàn
107
+ gbu-a11y --no-backup ./dist # Tắt backup (mặc định - xử lý nhanh hơn)
108
108
  ```
109
109
 
110
110
  ## 🔧 Sử dụng lập trình
111
111
 
112
112
  ```javascript
113
- const AccessibilityFixer = require('gbu-accessibility-package');
113
+ const AccessibilityFixer = require("gbu-accessibility-package");
114
114
 
115
115
  const fixer = new AccessibilityFixer({
116
- language: 'vi',
116
+ language: "vi",
117
117
  backupFiles: true,
118
- dryRun: false
118
+ dryRun: false,
119
119
  });
120
120
 
121
121
  // Sửa tất cả vấn đề accessibility
122
122
  async function fixAccessibility() {
123
123
  try {
124
- const results = await fixer.fixAllAccessibilityIssues('./src');
125
- console.log('File đã sửa:', results);
124
+ const results = await fixer.fixAllAccessibilityIssues("./src");
125
+ console.log("File đã sửa:", results);
126
126
  } catch (error) {
127
- console.error('Lỗi:', error);
127
+ console.error("Lỗi:", error);
128
128
  }
129
129
  }
130
130
 
@@ -134,6 +134,7 @@ fixAccessibility();
134
134
  ## 🎯 Chế độ sửa
135
135
 
136
136
  ### Chế độ toàn diện (Mặc định)
137
+
137
138
  Chạy tất cả các bước sửa bao gồm dọn dẹp:
138
139
 
139
140
  1. **HTML lang attributes** - Thêm thuộc tính ngôn ngữ
@@ -147,6 +148,7 @@ Chạy tất cả các bước sửa bao gồm dọn dẹp:
147
148
  9. **Cleanup** - Dọn dẹp role attributes trùng lặp
148
149
 
149
150
  ### Chế độ riêng lẻ
151
+
150
152
  Mỗi chế độ riêng lẻ đều bao gồm bước dọn dẹp:
151
153
 
152
154
  - `--alt-only` - Chỉ sửa alt attributes + dọn dẹp
@@ -159,35 +161,40 @@ Mỗi chế độ riêng lẻ đều bao gồm bước dọn dẹp:
159
161
  ## 🔧 Những gì được sửa
160
162
 
161
163
  ### 1. Alt Attributes
164
+
162
165
  - **Alt attributes thiếu** → Thêm alt text theo ngữ cảnh
163
166
  - **Alt attributes rỗng** → Tạo mô tả có ý nghĩa
164
167
  - **Tạo theo ngữ cảnh** → Sử dụng text xung quanh, tiêu đề, chú thích
165
168
 
166
169
  ```html
167
170
  <!-- Trước -->
168
- <img src="logo.png">
169
- <img src="chart.jpg" alt="">
171
+ <img src="logo.png" />
172
+ <img src="chart.jpg" alt="" />
170
173
 
171
174
  <!-- Sau -->
172
- <img src="logo.png" alt="ロゴ" role="img" aria-label="ロゴ">
173
- <img src="chart.jpg" alt="グラフ" role="img" aria-label="グラフ">
175
+ <img src="logo.png" alt="ロゴ" role="img" aria-label="ロゴ" />
176
+ <img src="chart.jpg" alt="グラフ" role="img" aria-label="グラフ" />
174
177
  ```
175
178
 
176
179
  ### 2. HTML Lang Attributes
180
+
177
181
  - **Lang attributes thiếu** → Thêm ngôn ngữ được chỉ định
178
182
  - **Lang attributes rỗng** → Đặt mã ngôn ngữ phù hợp
179
183
 
180
184
  ```html
181
185
  <!-- Trước -->
182
186
  <html>
183
- <html lang="">
184
-
185
- <!-- Sau -->
186
- <html lang="ja">
187
- <html lang="ja">
187
+ <html lang="">
188
+ <!-- Sau -->
189
+ <html lang="ja">
190
+ <html lang="ja"></html>
191
+ </html>
192
+ </html>
193
+ </html>
188
194
  ```
189
195
 
190
196
  ### 3. Role Attributes & Aria Labels
197
+
191
198
  - **Images** → `role="img"` + `aria-label` (khớp với alt text)
192
199
  - **Picture elements** → Di chuyển `role="img"` từ `<picture>` vào `<img>` bên trong
193
200
  - **Links** → `role="link"`
@@ -197,55 +204,58 @@ Mỗi chế độ riêng lẻ đều bao gồm bước dọn dẹp:
197
204
 
198
205
  ```html
199
206
  <!-- Trước -->
200
- <img src="icon.png" alt="Icon">
207
+ <img src="icon.png" alt="Icon" />
201
208
  <picture role="img">
202
- <img src="photo.jpg" alt="Photo">
209
+ <img src="photo.jpg" alt="Photo" />
203
210
  </picture>
204
211
  <a href="/home">Home</a>
205
212
  <div class="btn-click">Click me</div>
206
213
 
207
214
  <!-- Sau -->
208
- <img src="icon.png" alt="Icon" role="img" aria-label="Icon">
215
+ <img src="icon.png" alt="Icon" role="img" aria-label="Icon" />
209
216
  <picture>
210
- <img src="photo.jpg" alt="Photo" role="img" aria-label="Photo">
217
+ <img src="photo.jpg" alt="Photo" role="img" aria-label="Photo" />
211
218
  </picture>
212
219
  <a href="/home" role="link">Home</a>
213
220
  <div class="btn-click" role="button">Click me</div>
214
221
  ```
215
222
 
216
223
  ### 4. Form Labels
224
+
217
225
  - **Input thiếu label** → Thêm `aria-label` phù hợp
218
226
  - **Hỗ trợ nhiều loại input** → text, email, password, tel, etc.
219
227
 
220
228
  ```html
221
229
  <!-- Trước -->
222
- <input type="text" placeholder="Name">
223
- <input type="email">
224
- <input type="password">
230
+ <input type="text" placeholder="Name" />
231
+ <input type="email" />
232
+ <input type="password" />
225
233
 
226
234
  <!-- Sau -->
227
- <input type="text" placeholder="Name" aria-label="テキスト入力">
228
- <input type="email" aria-label="メールアドレス">
229
- <input type="password" aria-label="パスワード">
235
+ <input type="text" placeholder="Name" aria-label="テキスト入力" />
236
+ <input type="email" aria-label="メールアドレス" />
237
+ <input type="password" aria-label="パスワード" />
230
238
  ```
231
239
 
232
240
  ### 5. Button Names
241
+
233
242
  - **Button rỗng** → Thêm text và aria-label
234
243
  - **Input button thiếu value** → Thêm value phù hợp
235
244
 
236
245
  ```html
237
246
  <!-- Trước -->
238
247
  <button></button>
239
- <input type="submit">
240
- <input type="button">
248
+ <input type="submit" />
249
+ <input type="button" />
241
250
 
242
251
  <!-- Sau -->
243
252
  <button aria-label="ボタン">ボタン</button>
244
- <input type="submit" value="送信">
245
- <input type="button" value="ボタン">
253
+ <input type="submit" value="送信" />
254
+ <input type="button" value="ボタン" />
246
255
  ```
247
256
 
248
257
  ### 6. Link Names
258
+
249
259
  - **Link rỗng** → Thêm aria-label
250
260
  - **Generic text** → Phát hiện "Click here", "Read more"
251
261
  - **Image links** → Xử lý link chỉ chứa hình ảnh
@@ -254,15 +264,17 @@ Mỗi chế độ riêng lẻ đều bao gồm bước dọn dẹp:
254
264
  <!-- Trước -->
255
265
  <a href="/home"></a>
256
266
  <a href="/more">Click here</a>
257
- <a href="/image"><img src="icon.png"></a>
267
+ <a href="/image"><img src="icon.png" /></a>
258
268
 
259
269
  <!-- Sau -->
260
270
  <a href="/home" aria-label="リンク">リンク</a>
261
- <a href="/more">Click here</a> <!-- Được phát hiện nhưng không tự động sửa -->
262
- <a href="/image" aria-label="画像リンク"><img src="icon.png"></a>
271
+ <a href="/more">Click here</a>
272
+ <!-- Được phát hiện nhưng không tự động sửa -->
273
+ <a href="/image" aria-label="画像リンク"><img src="icon.png" /></a>
263
274
  ```
264
275
 
265
276
  ### 7. Landmarks
277
+
266
278
  - **Main landmark thiếu** → Thêm `role="main"`
267
279
  - **Navigation landmark thiếu** → Thêm `role="navigation"`
268
280
 
@@ -285,26 +297,29 @@ Mỗi chế độ riêng lẻ đều bao gồm bước dọn dẹp:
285
297
  ```
286
298
 
287
299
  ### 8. Heading Analysis
300
+
288
301
  - **Multiple h1** → Phát hiện và đề xuất
289
302
  - **Heading level skip** → Phát hiện nhảy cấp (h1 → h3)
290
303
  - **Empty headings** → Phát hiện heading rỗng
291
304
  - **Chỉ phân tích, không tự động sửa** → An toàn cho cấu trúc nội dung
292
305
 
293
306
  ### 9. Aria Label Enhancement
307
+
294
308
  - **Tự động aria-label** → Thêm `aria-label` khớp với `alt` text cho images
295
309
  - **Bảo tồn hiện có** → Không ghi đè `aria-label` đã có
296
310
  - **Phát hiện thông minh** → Chỉ thêm khi `alt` text tồn tại và không rỗng
297
311
 
298
312
  ### 10. Dọn dẹp trùng lặp
313
+
299
314
  - **Xóa role attributes trùng lặp** → Giữ lại occurrence đầu tiên
300
315
  - **Xử lý mixed quotes** → role="button" role='button'
301
316
 
302
317
  ```html
303
318
  <!-- Trước -->
304
- <img src="test.jpg" role="img" role="img" alt="Test">
319
+ <img src="test.jpg" role="img" role="img" alt="Test" />
305
320
 
306
321
  <!-- Sau -->
307
- <img src="test.jpg" role="img" alt="Test">
322
+ <img src="test.jpg" role="img" alt="Test" />
308
323
  ```
309
324
 
310
325
  ## 🌟 Tạo Alt Text thông minh
@@ -312,8 +327,9 @@ Mỗi chế độ riêng lẻ đều bao gồm bước dọn dẹp:
312
327
  Package sử dụng phân tích ngữ cảnh thông minh để tạo alt text có ý nghĩa:
313
328
 
314
329
  ### Nguồn ngữ cảnh
330
+
315
331
  1. **Title attributes**
316
- 2. **Aria-label attributes**
332
+ 2. **Aria-label attributes**
317
333
  3. **Definition terms (dt elements)**
318
334
  4. **Parent link text**
319
335
  5. **Nearby headings**
@@ -321,6 +337,7 @@ Package sử dụng phân tích ngữ cảnh thông minh để tạo alt text c
321
337
  7. **Surrounding text content**
322
338
 
323
339
  ### Mẫu dự phòng
340
+
324
341
  - `logo.png` → "ロゴ" (Logo)
325
342
  - `icon.svg` → "アイコン" (Icon)
326
343
  - `banner.jpg` → "バナー" (Banner)
@@ -330,6 +347,7 @@ Package sử dụng phân tích ngữ cảnh thông minh để tạo alt text c
330
347
  ## 📊 Ví dụ đầu ra
331
348
 
332
349
  ### Chế độ toàn diện
350
+
333
351
  ```
334
352
  🚀 Starting Accessibility Fixer...
335
353
  🎯 Running comprehensive accessibility fixes...
@@ -340,7 +358,7 @@ Package sử dụng phân tích ngữ cảnh thông minh để tạo alt text c
340
358
  🖼️ Step 2: Alt attributes...
341
359
  ✅ Fixed alt attributes in 12 files (34 issues)
342
360
 
343
- 🎭 Step 3: Role attributes...
361
+ 🎭 Step 3: Role attributes...
344
362
  ✅ Fixed role attributes in 8 files (67 issues)
345
363
 
346
364
  📋 Step 4: Form labels...
@@ -369,6 +387,7 @@ Package sử dụng phân tích ngữ cảnh thông minh để tạo alt text c
369
387
  ```
370
388
 
371
389
  ### Chế độ riêng lẻ
390
+
372
391
  ```
373
392
  🚀 Starting Accessibility Fixer...
374
393
  📋 Running form label fixes + cleanup...
@@ -392,30 +411,119 @@ Package sử dụng phân tích ngữ cảnh thông minh để tạo alt text c
392
411
  ## 🔒 Tính năng an toàn
393
412
 
394
413
  ### Tùy chọn Backup
395
- - **Hành vi mặc định**: Tự động tạo file `.backup` để an toàn
396
- - **Tắt backup**: Sử dụng `--no-backup` để xử lý nhanh hơn
397
- - **Bật rõ ràng**: Sử dụng `--backup` để ràng về việc tạo backup
414
+
415
+ - **Hành vi mặc định**: Không tạo backup files để xử lý nhanh hơn
416
+ - **Bật backup**: Sử dụng `--backup` để an toàn khi cần
417
+ - **Tắt rõ ràng**: Sử dụng `--no-backup` để rõ ràng (giống mặc định)
398
418
 
399
419
  ```bash
400
- # Chế độ an toàn (mặc định) - tạo backup
420
+ # Chế độ nhanh (mặc định) - không backup
401
421
  gbu-a11y --comprehensive
402
422
 
403
- # Chế độ nhanh - không backup
404
- gbu-a11y --no-backup --comprehensive
405
-
406
- # Chế độ backup rõ ràng
423
+ # Chế độ an toàn - tạo backup
407
424
  gbu-a11y --backup --comprehensive
425
+
426
+ # Chế độ không backup rõ ràng (giống mặc định)
427
+ gbu-a11y --no-backup --comprehensive
408
428
  ```
409
429
 
410
430
  ### Các tính năng an toàn khác
431
+
411
432
  - **Chế độ xem trước** để xem trước an toàn với `--dry-run`
412
433
  - **Không phá hoại** - chỉ thêm attributes thiếu
413
434
  - **Ngăn chặn trùng lặp** - không thêm attributes đã có
414
435
  - **Xử lý lỗi** - tiếp tục xử lý khi có lỗi file riêng lẻ
415
436
 
437
+ ## 🔧 Quản lý Package
438
+
439
+ ### Gỡ cài đặt và Cài đặt lại
440
+
441
+ Nếu bạn gặp vấn đề hoặc muốn cập nhật lên phiên bản mới nhất:
442
+
443
+ ```bash
444
+ # Gỡ cài đặt package global
445
+ npm uninstall -g gbu-accessibility-package
446
+
447
+ # Xóa npm cache
448
+ npm cache clean --force
449
+
450
+ # Cài đặt lại phiên bản mới nhất
451
+ npm install -g gbu-accessibility-package@latest
452
+
453
+ # Kiểm tra cài đặt
454
+ gbu-a11y --version
455
+ gbu-a11y --help
456
+ ```
457
+
458
+ ### Quản lý dự án cục bộ
459
+
460
+ ```bash
461
+ # Xóa khỏi dự án cục bộ
462
+ npm uninstall gbu-accessibility-package
463
+
464
+ # Xóa package-lock và node_modules
465
+ rm -rf node_modules package-lock.json
466
+
467
+ # Cài đặt lại dependencies
468
+ npm install
469
+
470
+ # Thêm phiên bản mới nhất
471
+ npm install gbu-accessibility-package@latest
472
+ ```
473
+
474
+ ### Xóa file Backup
475
+
476
+ ```bash
477
+ # Xóa tất cả file backup trong thư mục hiện tại
478
+ find . -name "*.backup" -type f -delete
479
+
480
+ # Xóa file backup trong thư mục cụ thể
481
+ find ./src -name "*.backup" -type f -delete
482
+
483
+ # Sử dụng npm script (nếu đã cấu hình)
484
+ npm run cleanup-backups
485
+ ```
486
+
487
+ ### Khắc phục sự cố cài đặt
488
+
489
+ ```bash
490
+ # Kiểm tra cấu hình npm
491
+ npm config list
492
+
493
+ # Reset npm registry (nếu cần)
494
+ npm config set registry https://registry.npmjs.org/
495
+
496
+ # Kiểm tra global packages
497
+ npm list -g --depth=0
498
+
499
+ # Sửa quyền (macOS/Linux)
500
+ sudo chown -R $(whoami) ~/.npm
501
+ sudo chown -R $(whoami) /usr/local/lib/node_modules
502
+
503
+ # Thay thế: Sử dụng npx mà không cài global
504
+ npx gbu-accessibility-package --help
505
+ ```
506
+
507
+ ### Quản lý phiên bản
508
+
509
+ ```bash
510
+ # Kiểm tra phiên bản hiện tại
511
+ gbu-a11y --version
512
+
513
+ # Kiểm tra các phiên bản có sẵn
514
+ npm view gbu-accessibility-package versions --json
515
+
516
+ # Cài đặt phiên bản cụ thể
517
+ npm install -g gbu-accessibility-package@2.0.0
518
+
519
+ # Cập nhật lên mới nhất
520
+ npm update -g gbu-accessibility-package
521
+ ```
522
+
416
523
  ## 🛠️ Cấu hình
417
524
 
418
525
  ### Package.json Scripts
526
+
419
527
  ```json
420
528
  {
421
529
  "scripts": {
@@ -434,12 +542,13 @@ gbu-a11y --backup --comprehensive
434
542
  ```
435
543
 
436
544
  ### Tích hợp CI/CD
545
+
437
546
  ```yaml
438
547
  # Ví dụ GitHub Actions
439
548
  - name: Check Accessibility
440
549
  run: npx gbu-accessibility-package --dry-run
441
550
 
442
- - name: Fix Accessibility Issues
551
+ - name: Fix Accessibility Issues
443
552
  run: npx gbu-accessibility-package --comprehensive
444
553
  ```
445
554
 
@@ -455,6 +564,115 @@ gbu-a11y --backup --comprehensive
455
564
 
456
565
  Dự án này được cấp phép theo Giấy phép MIT - xem file [LICENSE](LICENSE) để biết chi tiết.
457
566
 
567
+ ## 🔧 Khắc phục sự cố
568
+
569
+ ### Các vấn đề thường gặp và giải pháp
570
+
571
+ #### Package không tìm thấy hoặc lệnh không hoạt động
572
+
573
+ ```bash
574
+ # Kiểm tra package đã cài global chưa
575
+ npm list -g gbu-accessibility-package
576
+
577
+ # Nếu không tìm thấy, cài đặt global
578
+ npm install -g gbu-accessibility-package
579
+
580
+ # Kiểm tra PATH có chứa npm global bin không
581
+ echo $PATH | grep npm
582
+
583
+ # Thêm npm global bin vào PATH (nếu cần)
584
+ export PATH=$PATH:$(npm config get prefix)/bin
585
+ ```
586
+
587
+ #### Lỗi quyền truy cập
588
+
589
+ ```bash
590
+ # macOS/Linux: Sửa quyền npm
591
+ sudo chown -R $(whoami) ~/.npm
592
+ sudo chown -R $(whoami) $(npm config get prefix)
593
+
594
+ # Thay thế: Sử dụng npx
595
+ npx gbu-accessibility-package --help
596
+
597
+ # Windows: Chạy với quyền Administrator hoặc dùng npx
598
+ ```
599
+
600
+ #### Package không hoạt động sau khi cập nhật
601
+
602
+ ```bash
603
+ # Cài đặt lại hoàn toàn
604
+ npm uninstall -g gbu-accessibility-package
605
+ npm cache clean --force
606
+ npm install -g gbu-accessibility-package@latest
607
+
608
+ # Kiểm tra cài đặt
609
+ gbu-a11y --version
610
+ which gbu-a11y
611
+ ```
612
+
613
+ #### File không được xử lý
614
+
615
+ ```bash
616
+ # Kiểm tra phần mở rộng file (chỉ hỗ trợ .html)
617
+ ls -la *.html
618
+
619
+ # Kiểm tra quyền file
620
+ ls -la your-file.html
621
+
622
+ # Chạy với output chi tiết
623
+ gbu-a11y --dry-run your-file.html
624
+ ```
625
+
626
+ #### File backup tích tụ quá nhiều
627
+
628
+ ```bash
629
+ # Xóa tất cả file backup
630
+ find . -name "*.backup" -type f -delete
631
+
632
+ # Ngăn tạo backup
633
+ gbu-a11y --no-backup
634
+
635
+ # Cấu hình script cleanup
636
+ echo 'alias cleanup-backups="find . -name \"*.backup\" -type f -delete"' >> ~/.bashrc
637
+ ```
638
+
639
+ #### Vấn đề hiệu suất
640
+
641
+ ```bash
642
+ # Sử dụng --no-backup để xử lý nhanh hơn
643
+ gbu-a11y --no-backup
644
+
645
+ # Xử lý thư mục cụ thể thay vì toàn bộ dự án
646
+ gbu-a11y ./src
647
+
648
+ # Sử dụng individual modes cho sửa chữa có mục tiêu
649
+ gbu-a11y --alt-only ./images
650
+ ```
651
+
652
+ #### Vấn đề phiên bản Node.js
653
+
654
+ ```bash
655
+ # Kiểm tra phiên bản Node.js (yêu cầu >=12.0.0)
656
+ node --version
657
+
658
+ # Cập nhật Node.js nếu cần
659
+ # Truy cập: https://nodejs.org/
660
+
661
+ # Sử dụng nvm để quản lý phiên bản Node.js
662
+ nvm install 18
663
+ nvm use 18
664
+ ```
665
+
666
+ ### Nhận trợ giúp
667
+
668
+ Nếu bạn vẫn gặp vấn đề:
669
+
670
+ 1. **Kiểm tra phiên bản**: `gbu-a11y --version`
671
+ 2. **Thử dry run trước**: `gbu-a11y --dry-run`
672
+ 3. **Kiểm tra quyền file**: `ls -la your-files.html`
673
+ 4. **Xóa cache và cài lại**: Xem phần quản lý package ở trên
674
+ 5. **Sử dụng npx thay thế**: `npx gbu-accessibility-package --help`
675
+
458
676
  ## 🆘 Hỗ trợ
459
677
 
460
678
  - 📧 **Issues**: [GitHub Issues](https://github.com/dangpv94/gbu-accessibility-tool/issues)
@@ -478,6 +696,7 @@ Dự án này được cấp phép theo Giấy phép MIT - xem file [LICENSE](LI
478
696
  Package này giải quyết các vấn đề accessibility phổ biến từ axe DevTools:
479
697
 
480
698
  ### ✅ Đã hỗ trợ
699
+
481
700
  - `image-alt` - Images must have alternate text
482
701
  - `html-has-lang` - HTML element must have lang attribute
483
702
  - `label` - Form elements must have labels (cơ bản)
@@ -489,6 +708,7 @@ Package này giải quyết các vấn đề accessibility phổ biến từ axe
489
708
  - Duplicate role attributes cleanup
490
709
 
491
710
  ### 🔄 Đang phát triển
711
+
492
712
  - `color-contrast` - Color contrast checking
493
713
  - `focus-order-semantics` - Focus order validation
494
714
  - `aria-*` attributes validation
@@ -497,4 +717,4 @@ Package này giải quyết các vấn đề accessibility phổ biến từ axe
497
717
 
498
718
  ---
499
719
 
500
- Được tạo với ❤️ bởi GBU Team
720
+ Được tạo với ❤️ bởi GBU Team
package/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  - 📑 **Heading Analysis** - Analyze heading structure with suggestions (no auto-fix)
20
20
  - 🧹 **Duplicate Cleanup** - Remove duplicate role attributes
21
21
  - 📁 **Batch Processing** - Process entire directories recursively
22
- - 💾 **Automatic Backups** - Safe modifications with backup files
22
+ - 💾 **Optional Backups** - Create backup files when needed with --backup flag
23
23
  - 🔍 **Dry Run Mode** - Preview changes before applying
24
24
  - 📊 **Detailed Reports** - Comprehensive fix summaries
25
25
 
@@ -61,8 +61,8 @@ gbu-a11y [options] [directory/file]
61
61
  Options:
62
62
  -d, --directory <path> Target directory (default: current directory)
63
63
  -l, --language <lang> Language for lang attribute (default: ja)
64
- --backup Create backup files (default: enabled)
65
- --no-backup Don't create backup files
64
+ --backup Create backup files
65
+ --no-backup Don't create backup files (default)
66
66
  --dry-run Preview changes without applying
67
67
  --comprehensive, --all Run comprehensive fixes (same as default)
68
68
  --cleanup-only Only cleanup duplicate role attributes
@@ -103,8 +103,8 @@ gbu-a11y --alt-only --dry-run ./src # Preview alt fixes + cleanup
103
103
  gbu-a11y --forms-only -l en ./public # Form fixes + cleanup with English lang
104
104
 
105
105
  # Backup options
106
- gbu-a11y --backup ./dist # Explicitly enable backups (default)
107
- gbu-a11y --no-backup ./dist # Disable backups for faster processing
106
+ gbu-a11y --backup ./dist # Enable backups for safety
107
+ gbu-a11y --no-backup ./dist # Disable backups (default - faster processing)
108
108
  ```
109
109
 
110
110
  ## 🔧 Programmatic Usage
@@ -367,19 +367,19 @@ The package uses intelligent context analysis to generate meaningful alt text:
367
367
  ## 🔒 Safety Features
368
368
 
369
369
  ### Backup Options
370
- - **Default behavior**: Creates `.backup` files automatically for safety
371
- - **Disable backups**: Use `--no-backup` for faster processing
372
- - **Explicit enable**: Use `--backup` to be explicit about backup creation
370
+ - **Default behavior**: No backup files for faster processing
371
+ - **Enable backups**: Use `--backup` for safety when needed
372
+ - **Explicit disable**: Use `--no-backup` to be explicit (same as default)
373
373
 
374
374
  ```bash
375
- # Safe mode (default) - creates backups
375
+ # Fast mode (default) - no backups
376
376
  gbu-a11y --comprehensive
377
377
 
378
- # Fast mode - no backups
379
- gbu-a11y --no-backup --comprehensive
380
-
381
- # Explicit backup mode
378
+ # Safe mode - creates backups
382
379
  gbu-a11y --backup --comprehensive
380
+
381
+ # Explicit no backup mode (same as default)
382
+ gbu-a11y --no-backup --comprehensive
383
383
  ```
384
384
 
385
385
  ### Other Safety Features
@@ -388,6 +388,92 @@ gbu-a11y --backup --comprehensive
388
388
  - **Duplicate prevention** - won't add existing attributes
389
389
  - **Error handling** - continues processing on individual file errors
390
390
 
391
+ ## 🔧 Package Management
392
+
393
+ ### Uninstall and Reinstall
394
+
395
+ If you encounter issues or want to update to the latest version:
396
+
397
+ ```bash
398
+ # Uninstall global package
399
+ npm uninstall -g gbu-accessibility-package
400
+
401
+ # Clear npm cache
402
+ npm cache clean --force
403
+
404
+ # Reinstall latest version
405
+ npm install -g gbu-accessibility-package@latest
406
+
407
+ # Verify installation
408
+ gbu-a11y --version
409
+ gbu-a11y --help
410
+ ```
411
+
412
+ ### Local Project Management
413
+
414
+ ```bash
415
+ # Remove from local project
416
+ npm uninstall gbu-accessibility-package
417
+
418
+ # Clear package-lock and node_modules
419
+ rm -rf node_modules package-lock.json
420
+
421
+ # Reinstall dependencies
422
+ npm install
423
+
424
+ # Add latest version
425
+ npm install gbu-accessibility-package@latest
426
+ ```
427
+
428
+ ### Clear Backup Files
429
+
430
+ ```bash
431
+ # Remove all backup files in current directory
432
+ find . -name "*.backup" -type f -delete
433
+
434
+ # Remove backup files in specific directory
435
+ find ./src -name "*.backup" -type f -delete
436
+
437
+ # Using npm script (if configured)
438
+ npm run cleanup-backups
439
+ ```
440
+
441
+ ### Troubleshooting Installation
442
+
443
+ ```bash
444
+ # Check npm configuration
445
+ npm config list
446
+
447
+ # Reset npm registry (if needed)
448
+ npm config set registry https://registry.npmjs.org/
449
+
450
+ # Check global packages
451
+ npm list -g --depth=0
452
+
453
+ # Fix permissions (macOS/Linux)
454
+ sudo chown -R $(whoami) ~/.npm
455
+ sudo chown -R $(whoami) /usr/local/lib/node_modules
456
+
457
+ # Alternative: Use npx without global install
458
+ npx gbu-accessibility-package --help
459
+ ```
460
+
461
+ ### Version Management
462
+
463
+ ```bash
464
+ # Check current version
465
+ gbu-a11y --version
466
+
467
+ # Check available versions
468
+ npm view gbu-accessibility-package versions --json
469
+
470
+ # Install specific version
471
+ npm install -g gbu-accessibility-package@2.0.0
472
+
473
+ # Update to latest
474
+ npm update -g gbu-accessibility-package
475
+ ```
476
+
391
477
  ## 🛠️ Configuration
392
478
 
393
479
  ### Package.json Scripts
@@ -452,6 +538,108 @@ This package addresses common issues found by axe DevTools:
452
538
 
453
539
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
454
540
 
541
+ ## 🔧 Troubleshooting
542
+
543
+ ### Common Issues and Solutions
544
+
545
+ #### Package Not Found or Command Not Working
546
+ ```bash
547
+ # Check if package is installed globally
548
+ npm list -g gbu-accessibility-package
549
+
550
+ # If not found, install globally
551
+ npm install -g gbu-accessibility-package
552
+
553
+ # Check PATH includes npm global bin
554
+ echo $PATH | grep npm
555
+
556
+ # Add npm global bin to PATH (if needed)
557
+ export PATH=$PATH:$(npm config get prefix)/bin
558
+ ```
559
+
560
+ #### Permission Errors
561
+ ```bash
562
+ # macOS/Linux: Fix npm permissions
563
+ sudo chown -R $(whoami) ~/.npm
564
+ sudo chown -R $(whoami) $(npm config get prefix)
565
+
566
+ # Alternative: Use npx
567
+ npx gbu-accessibility-package --help
568
+
569
+ # Windows: Run as Administrator or use npx
570
+ ```
571
+
572
+ #### Package Not Working After Update
573
+ ```bash
574
+ # Complete reinstall
575
+ npm uninstall -g gbu-accessibility-package
576
+ npm cache clean --force
577
+ npm install -g gbu-accessibility-package@latest
578
+
579
+ # Verify installation
580
+ gbu-a11y --version
581
+ which gbu-a11y
582
+ ```
583
+
584
+ #### Files Not Being Processed
585
+ ```bash
586
+ # Check file extensions (only .html files supported)
587
+ ls -la *.html
588
+
589
+ # Check file permissions
590
+ ls -la your-file.html
591
+
592
+ # Run with verbose output
593
+ gbu-a11y --dry-run your-file.html
594
+ ```
595
+
596
+ #### Backup Files Accumulating
597
+ ```bash
598
+ # Clean all backup files
599
+ find . -name "*.backup" -type f -delete
600
+
601
+ # Prevent backup creation
602
+ gbu-a11y --no-backup
603
+
604
+ # Configure cleanup script
605
+ echo 'alias cleanup-backups="find . -name \"*.backup\" -type f -delete"' >> ~/.bashrc
606
+ ```
607
+
608
+ #### Performance Issues
609
+ ```bash
610
+ # Use --no-backup for faster processing
611
+ gbu-a11y --no-backup
612
+
613
+ # Process specific directories instead of entire project
614
+ gbu-a11y ./src
615
+
616
+ # Use individual modes for targeted fixes
617
+ gbu-a11y --alt-only ./images
618
+ ```
619
+
620
+ #### Node.js Version Issues
621
+ ```bash
622
+ # Check Node.js version (requires >=12.0.0)
623
+ node --version
624
+
625
+ # Update Node.js if needed
626
+ # Visit: https://nodejs.org/
627
+
628
+ # Use nvm to manage Node.js versions
629
+ nvm install 18
630
+ nvm use 18
631
+ ```
632
+
633
+ ### Getting Help
634
+
635
+ If you're still experiencing issues:
636
+
637
+ 1. **Check the version**: `gbu-a11y --version`
638
+ 2. **Try dry run first**: `gbu-a11y --dry-run`
639
+ 3. **Check file permissions**: `ls -la your-files.html`
640
+ 4. **Clear cache and reinstall**: See package management section above
641
+ 5. **Use npx as alternative**: `npx gbu-accessibility-package --help`
642
+
455
643
  ## 🆘 Support
456
644
 
457
645
  - 📧 **Issues**: [GitHub Issues](https://github.com/dangpv94/gbu-accessibility-tool/issues)
package/cli.js CHANGED
@@ -14,7 +14,7 @@ const args = process.argv.slice(2);
14
14
  const options = {
15
15
  directory: '.',
16
16
  language: 'ja',
17
- backupFiles: true, // Default to true for safety
17
+ backupFiles: false, // Default to false for faster processing
18
18
  dryRun: false,
19
19
  help: false,
20
20
  cleanupOnly: false,
@@ -103,8 +103,8 @@ Usage: node cli.js [options] [directory]
103
103
  Options:
104
104
  -d, --directory <path> Target directory (default: current directory)
105
105
  -l, --language <lang> Language for lang attribute (default: ja)
106
- --backup Create backup files (default: enabled)
107
- --no-backup Don't create backup files
106
+ --backup Create backup files
107
+ --no-backup Don't create backup files (default)
108
108
  --dry-run Preview changes without applying
109
109
  --comprehensive, --all Run comprehensive fixes (same as default)
110
110
  --cleanup-only Only cleanup duplicate role attributes
@@ -119,7 +119,7 @@ Options:
119
119
  -h, --help Show this help message
120
120
 
121
121
  Examples:
122
- node cli.js # Comprehensive fixes (default mode)
122
+ node cli.js # Comprehensive fixes (no backup by default)
123
123
  node cli.js --comprehensive # Comprehensive fixes (same as default)
124
124
  node cli.js --alt-only # Fix alt attributes + cleanup
125
125
  node cli.js --forms-only # Fix form labels + cleanup
@@ -130,7 +130,7 @@ Examples:
130
130
  node cli.js --cleanup-only # Only cleanup duplicate roles
131
131
  node cli.js ./src # Fix src directory (comprehensive)
132
132
  node cli.js -l en --dry-run ./dist # Preview comprehensive fixes in English
133
- node cli.js --no-backup ./public # Comprehensive fixes without backups
133
+ node cli.js --backup ./public # Comprehensive fixes with backups
134
134
 
135
135
  Features:
136
136
  ✅ Alt attributes for images
@@ -153,7 +153,7 @@ function showCompletionMessage(options, mode = 'fixes') {
153
153
  console.log(chalk.gray(' 📁 Backup files created with .backup extension'));
154
154
  console.log(chalk.gray(' 💡 Use --no-backup to disable backups in future runs'));
155
155
  } else {
156
- console.log(chalk.yellow(' ⚠️ No backup files created (--no-backup was used)'));
156
+ console.log(chalk.blue(' No backup files created (default behavior for faster processing)'));
157
157
  console.log(chalk.gray(' 💡 Use --backup to enable backups for safety'));
158
158
  }
159
159
  }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>No Backup Test</title>
6
+ </head>
7
+ <body>
8
+ <h1>No Backup Test</h1>
9
+ <img src="test.jpg" alt="Test image" role="img" aria-label="Test image">
10
+ <a href="/home" role="link">Home</a>
11
+ </body>
12
+ </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>No Backup Test</title>
6
+ </head>
7
+ <body>
8
+ <h1>No Backup Test</h1>
9
+ <img src="test.jpg" alt="Test image">
10
+ <a href="/home">Home</a>
11
+ </body>
12
+ </html>
package/lib/fixer.js CHANGED
@@ -10,7 +10,7 @@ const chalk = require('chalk');
10
10
  class AccessibilityFixer {
11
11
  constructor(config = {}) {
12
12
  this.config = {
13
- backupFiles: config.backupFiles !== false,
13
+ backupFiles: config.backupFiles === true,
14
14
  language: config.language || 'ja',
15
15
  dryRun: config.dryRun || false,
16
16
  ...config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gbu-accessibility-package",
3
- "version": "3.1.0",
3
+ "version": "3.1.3",
4
4
  "description": "Comprehensive accessibility fixes for HTML files. Smart context-aware alt text generation, form labels, button names, link names, landmarks, heading analysis, and WCAG-compliant role attributes. Covers major axe DevTools issues with individual fix modes.",
5
5
  "main": "index.js",
6
6
  "bin": {