aria-ease 2.0.2 ā 2.1.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/README.md +2 -3
- package/bin/audit-cli.cjs +663 -0
- package/bin/audit-cli.cjs.map +1 -0
- package/bin/audit-cli.d.cts +1 -0
- package/bin/audit-cli.d.ts +1 -0
- package/bin/audit-cli.js +566 -0
- package/bin/audit-cli.js.map +1 -0
- package/bin/audit-cli.ts +80 -0
- package/dist/Types.d-p85gN5m_.d.cts +22 -0
- package/dist/Types.d-p85gN5m_.d.ts +22 -0
- package/dist/chunk-4366LRNM.js +38 -0
- package/dist/chunk-4366LRNM.js.map +1 -0
- package/dist/chunk-5HQ6LLC5.js +21 -0
- package/dist/chunk-5HQ6LLC5.js.map +1 -0
- package/dist/chunk-FBQ5LF2T.js +21 -0
- package/dist/chunk-FBQ5LF2T.js.map +1 -0
- package/dist/chunk-KVTLMA4J.js +58 -0
- package/dist/chunk-KVTLMA4J.js.map +1 -0
- package/dist/chunk-MEA5U2G4.js +24 -0
- package/dist/chunk-MEA5U2G4.js.map +1 -0
- package/dist/chunk-RK3JUAFZ.js +18 -0
- package/dist/chunk-RK3JUAFZ.js.map +1 -0
- package/dist/chunk-RT5IROW4.js +99 -0
- package/dist/chunk-RT5IROW4.js.map +1 -0
- package/dist/index.cjs +6 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -115
- package/dist/index.d.ts +7 -115
- package/dist/index.js +7 -313
- package/dist/index.js.map +1 -1
- package/dist/src/accordion/index.cjs +25 -0
- package/dist/src/accordion/index.cjs.map +1 -0
- package/dist/src/accordion/index.d.cts +13 -0
- package/dist/src/accordion/index.d.ts +13 -0
- package/dist/src/accordion/index.js +2 -0
- package/dist/src/accordion/index.js.map +1 -0
- package/dist/src/block/index.cjs +121 -0
- package/dist/src/block/index.cjs.map +1 -0
- package/dist/src/block/index.d.cts +8 -0
- package/dist/src/block/index.d.ts +8 -0
- package/dist/src/block/index.js +3 -0
- package/dist/src/block/index.js.map +1 -0
- package/dist/src/checkbox/index.cjs +19 -0
- package/dist/src/checkbox/index.cjs.map +1 -0
- package/dist/src/checkbox/index.d.cts +13 -0
- package/dist/src/checkbox/index.d.ts +13 -0
- package/dist/src/checkbox/index.js +2 -0
- package/dist/src/checkbox/index.js.map +1 -0
- package/dist/src/menu/index.cjs +155 -0
- package/dist/src/menu/index.cjs.map +1 -0
- package/dist/src/menu/index.d.cts +17 -0
- package/dist/src/menu/index.d.ts +17 -0
- package/dist/src/menu/index.js +3 -0
- package/dist/src/menu/index.js.map +1 -0
- package/dist/src/radio/index.cjs +22 -0
- package/dist/src/radio/index.cjs.map +1 -0
- package/dist/src/radio/index.d.cts +13 -0
- package/dist/src/radio/index.d.ts +13 -0
- package/dist/src/radio/index.js +2 -0
- package/dist/src/radio/index.js.map +1 -0
- package/dist/src/toggle/index.cjs +22 -0
- package/dist/src/toggle/index.cjs.map +1 -0
- package/dist/src/toggle/index.d.cts +13 -0
- package/dist/src/toggle/index.d.ts +13 -0
- package/dist/src/toggle/index.js +2 -0
- package/dist/src/toggle/index.js.map +1 -0
- package/dist/src/utils/audit/audit.cjs +208 -0
- package/dist/src/utils/audit/audit.cjs.map +1 -0
- package/dist/src/utils/audit/audit.d.cts +5 -0
- package/dist/src/utils/audit/audit.d.ts +5 -0
- package/dist/src/utils/audit/audit.js +201 -0
- package/dist/src/utils/audit/audit.js.map +1 -0
- package/package.json +46 -4
- package/dist/index.d.mts +0 -140
- package/dist/index.mjs +0 -110
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/bin/audit-cli.js
ADDED
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_without_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
|
+
}
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
|
+
try {
|
|
12
|
+
var info = gen[key](arg);
|
|
13
|
+
var value = info.value;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (info.done) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
} else {
|
|
21
|
+
Promise.resolve(value).then(_next, _throw);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function _async_to_generator(fn) {
|
|
25
|
+
return function() {
|
|
26
|
+
var self = this, args = arguments;
|
|
27
|
+
return new Promise(function(resolve, reject) {
|
|
28
|
+
var gen = fn.apply(self, args);
|
|
29
|
+
function _next(value) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
31
|
+
}
|
|
32
|
+
function _throw(err) {
|
|
33
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
34
|
+
}
|
|
35
|
+
_next(undefined);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _iterable_to_array(iter) {
|
|
40
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
41
|
+
}
|
|
42
|
+
function _non_iterable_spread() {
|
|
43
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
44
|
+
}
|
|
45
|
+
function _to_consumable_array(arr) {
|
|
46
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
47
|
+
}
|
|
48
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
49
|
+
if (!o) return;
|
|
50
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
51
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
52
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
53
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
54
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
55
|
+
}
|
|
56
|
+
function _ts_generator(thisArg, body) {
|
|
57
|
+
var f, y, t, _ = {
|
|
58
|
+
label: 0,
|
|
59
|
+
sent: function() {
|
|
60
|
+
if (t[0] & 1) throw t[1];
|
|
61
|
+
return t[1];
|
|
62
|
+
},
|
|
63
|
+
trys: [],
|
|
64
|
+
ops: []
|
|
65
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
66
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
67
|
+
return this;
|
|
68
|
+
}), g;
|
|
69
|
+
function verb(n) {
|
|
70
|
+
return function(v) {
|
|
71
|
+
return step([
|
|
72
|
+
n,
|
|
73
|
+
v
|
|
74
|
+
]);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function step(op) {
|
|
78
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
79
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
80
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
81
|
+
if (y = 0, t) op = [
|
|
82
|
+
op[0] & 2,
|
|
83
|
+
t.value
|
|
84
|
+
];
|
|
85
|
+
switch(op[0]){
|
|
86
|
+
case 0:
|
|
87
|
+
case 1:
|
|
88
|
+
t = op;
|
|
89
|
+
break;
|
|
90
|
+
case 4:
|
|
91
|
+
_.label++;
|
|
92
|
+
return {
|
|
93
|
+
value: op[1],
|
|
94
|
+
done: false
|
|
95
|
+
};
|
|
96
|
+
case 5:
|
|
97
|
+
_.label++;
|
|
98
|
+
y = op[1];
|
|
99
|
+
op = [
|
|
100
|
+
0
|
|
101
|
+
];
|
|
102
|
+
continue;
|
|
103
|
+
case 7:
|
|
104
|
+
op = _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
default:
|
|
108
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
109
|
+
_ = 0;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
113
|
+
_.label = op[1];
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
117
|
+
_.label = t[1];
|
|
118
|
+
t = op;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
if (t && _.label < t[2]) {
|
|
122
|
+
_.label = t[2];
|
|
123
|
+
_.ops.push(op);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
if (t[2]) _.ops.pop();
|
|
127
|
+
_.trys.pop();
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
op = body.call(thisArg, _);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
op = [
|
|
133
|
+
6,
|
|
134
|
+
e
|
|
135
|
+
];
|
|
136
|
+
y = 0;
|
|
137
|
+
} finally{
|
|
138
|
+
f = t = 0;
|
|
139
|
+
}
|
|
140
|
+
if (op[0] & 5) throw op[1];
|
|
141
|
+
return {
|
|
142
|
+
value: op[0] ? op[1] : void 0,
|
|
143
|
+
done: true
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// bin/audit-cli.ts
|
|
148
|
+
import { Command } from "commander";
|
|
149
|
+
import chalk from "chalk";
|
|
150
|
+
import path from "path";
|
|
151
|
+
import fs from "fs-extra";
|
|
152
|
+
// dist/src/utils/audit/audit.js
|
|
153
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
154
|
+
import { chromium } from "playwright";
|
|
155
|
+
function asyncGeneratorStep1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
156
|
+
try {
|
|
157
|
+
var info = gen[key](arg);
|
|
158
|
+
var value = info.value;
|
|
159
|
+
} catch (error) {
|
|
160
|
+
reject(error);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (info.done) {
|
|
164
|
+
resolve(value);
|
|
165
|
+
} else {
|
|
166
|
+
Promise.resolve(value).then(_next, _throw);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function _async_to_generator1(fn) {
|
|
170
|
+
return function() {
|
|
171
|
+
var self = this, args = arguments;
|
|
172
|
+
return new Promise(function(resolve, reject) {
|
|
173
|
+
var gen = fn.apply(self, args);
|
|
174
|
+
function _next(value) {
|
|
175
|
+
asyncGeneratorStep1(gen, resolve, reject, _next, _throw, "next", value);
|
|
176
|
+
}
|
|
177
|
+
function _throw(err) {
|
|
178
|
+
asyncGeneratorStep1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
179
|
+
}
|
|
180
|
+
_next(void 0);
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function _ts_generator1(thisArg, body) {
|
|
185
|
+
var f, y, t, _ = {
|
|
186
|
+
label: 0,
|
|
187
|
+
sent: function sent() {
|
|
188
|
+
if (t[0] & 1) throw t[1];
|
|
189
|
+
return t[1];
|
|
190
|
+
},
|
|
191
|
+
trys: [],
|
|
192
|
+
ops: []
|
|
193
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
194
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
195
|
+
return this;
|
|
196
|
+
}), g;
|
|
197
|
+
function verb(n) {
|
|
198
|
+
return function(v) {
|
|
199
|
+
return step([
|
|
200
|
+
n,
|
|
201
|
+
v
|
|
202
|
+
]);
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function step(op) {
|
|
206
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
207
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
208
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
209
|
+
if (y = 0, t) op = [
|
|
210
|
+
op[0] & 2,
|
|
211
|
+
t.value
|
|
212
|
+
];
|
|
213
|
+
switch(op[0]){
|
|
214
|
+
case 0:
|
|
215
|
+
case 1:
|
|
216
|
+
t = op;
|
|
217
|
+
break;
|
|
218
|
+
case 4:
|
|
219
|
+
_.label++;
|
|
220
|
+
return {
|
|
221
|
+
value: op[1],
|
|
222
|
+
done: false
|
|
223
|
+
};
|
|
224
|
+
case 5:
|
|
225
|
+
_.label++;
|
|
226
|
+
y = op[1];
|
|
227
|
+
op = [
|
|
228
|
+
0
|
|
229
|
+
];
|
|
230
|
+
continue;
|
|
231
|
+
case 7:
|
|
232
|
+
op = _.ops.pop();
|
|
233
|
+
_.trys.pop();
|
|
234
|
+
continue;
|
|
235
|
+
default:
|
|
236
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
237
|
+
_ = 0;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
241
|
+
_.label = op[1];
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
245
|
+
_.label = t[1];
|
|
246
|
+
t = op;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
if (t && _.label < t[2]) {
|
|
250
|
+
_.label = t[2];
|
|
251
|
+
_.ops.push(op);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
if (t[2]) _.ops.pop();
|
|
255
|
+
_.trys.pop();
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
op = body.call(thisArg, _);
|
|
259
|
+
} catch (e) {
|
|
260
|
+
op = [
|
|
261
|
+
6,
|
|
262
|
+
e
|
|
263
|
+
];
|
|
264
|
+
y = 0;
|
|
265
|
+
} finally{
|
|
266
|
+
f = t = 0;
|
|
267
|
+
}
|
|
268
|
+
if (op[0] & 5) throw op[1];
|
|
269
|
+
return {
|
|
270
|
+
value: op[0] ? op[1] : void 0,
|
|
271
|
+
done: true
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function runAudit(url) {
|
|
276
|
+
return _async_to_generator1(function() {
|
|
277
|
+
var browser, context, page, axe, axeResults, error;
|
|
278
|
+
return _ts_generator1(this, function(_state) {
|
|
279
|
+
switch(_state.label){
|
|
280
|
+
case 0:
|
|
281
|
+
return [
|
|
282
|
+
4,
|
|
283
|
+
chromium.launch({
|
|
284
|
+
headless: true
|
|
285
|
+
})
|
|
286
|
+
];
|
|
287
|
+
case 1:
|
|
288
|
+
browser = _state.sent();
|
|
289
|
+
return [
|
|
290
|
+
4,
|
|
291
|
+
browser.newContext()
|
|
292
|
+
];
|
|
293
|
+
case 2:
|
|
294
|
+
context = _state.sent();
|
|
295
|
+
return [
|
|
296
|
+
4,
|
|
297
|
+
context.newPage()
|
|
298
|
+
];
|
|
299
|
+
case 3:
|
|
300
|
+
page = _state.sent();
|
|
301
|
+
return [
|
|
302
|
+
4,
|
|
303
|
+
page.goto(url, {
|
|
304
|
+
waitUntil: "networkidle"
|
|
305
|
+
})
|
|
306
|
+
];
|
|
307
|
+
case 4:
|
|
308
|
+
_state.sent();
|
|
309
|
+
_state.label = 5;
|
|
310
|
+
case 5:
|
|
311
|
+
_state.trys.push([
|
|
312
|
+
5,
|
|
313
|
+
7,
|
|
314
|
+
,
|
|
315
|
+
8
|
|
316
|
+
]);
|
|
317
|
+
axe = new AxeBuilder({
|
|
318
|
+
page: page
|
|
319
|
+
});
|
|
320
|
+
return [
|
|
321
|
+
4,
|
|
322
|
+
axe.analyze()
|
|
323
|
+
];
|
|
324
|
+
case 6:
|
|
325
|
+
axeResults = _state.sent();
|
|
326
|
+
return [
|
|
327
|
+
2,
|
|
328
|
+
axeResults
|
|
329
|
+
];
|
|
330
|
+
case 7:
|
|
331
|
+
error = _state.sent();
|
|
332
|
+
console.log(error);
|
|
333
|
+
return [
|
|
334
|
+
3,
|
|
335
|
+
8
|
|
336
|
+
];
|
|
337
|
+
case 8:
|
|
338
|
+
return [
|
|
339
|
+
4,
|
|
340
|
+
browser.close()
|
|
341
|
+
];
|
|
342
|
+
case 9:
|
|
343
|
+
_state.sent();
|
|
344
|
+
return [
|
|
345
|
+
2
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
})();
|
|
350
|
+
}
|
|
351
|
+
// src/utils/audit/formatters.ts
|
|
352
|
+
function formatResults(allResults, format) {
|
|
353
|
+
switch(format){
|
|
354
|
+
case "json":
|
|
355
|
+
return JSON.stringify(allResults.flatMap(function(param) {
|
|
356
|
+
var url = param.url, result = param.result;
|
|
357
|
+
return result ? result.violations.flatMap(function(v) {
|
|
358
|
+
return v.nodes.map(function(n) {
|
|
359
|
+
return {
|
|
360
|
+
URL: url,
|
|
361
|
+
Rule: v.id,
|
|
362
|
+
Impact: v.impact,
|
|
363
|
+
Description: v.description,
|
|
364
|
+
Target: n.target,
|
|
365
|
+
FailureSummary: n.failureSummary
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
}) : [];
|
|
369
|
+
}), null, 2);
|
|
370
|
+
case "csv":
|
|
371
|
+
return toCSV(allResults);
|
|
372
|
+
default:
|
|
373
|
+
return "";
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function toCSV(allResults) {
|
|
377
|
+
var rows = [
|
|
378
|
+
"URL,Rule,Impact,Description,Target,FailureSummary"
|
|
379
|
+
];
|
|
380
|
+
allResults.forEach(function(param) {
|
|
381
|
+
var url = param.url, result = param.result;
|
|
382
|
+
if (result) {
|
|
383
|
+
result.violations.forEach(function(v) {
|
|
384
|
+
v.nodes.forEach(function(n) {
|
|
385
|
+
rows.push('"'.concat(url, '","').concat(v.id, '","').concat(v.impact, '","').concat(v.description, '","').concat(n.target, '","').concat(n.failureSummary, '"'));
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
return rows.join("\n");
|
|
391
|
+
}
|
|
392
|
+
// bin/audit-cli.ts
|
|
393
|
+
var program = new Command();
|
|
394
|
+
program.name("aria-ease").description("Run accessibility audits").version("2.0.4");
|
|
395
|
+
program.command("audit").description("Run accessibility audit").option("-u, --url <url>", "Single URL to audit").option("-f, --format <format>", "Output format for the audit report: json | csv", "csv").option("-o, --out <path>", "Directory to save the audit report", "./accessibility-reports").action(function(opts) {
|
|
396
|
+
return _async_to_generator(function() {
|
|
397
|
+
var _urls, configPath, config, _tmp, urls, allResults, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, url, result, err, err1, hasResults, formatted, timestamp, fileName, filePath;
|
|
398
|
+
return _ts_generator(this, function(_state) {
|
|
399
|
+
switch(_state.label){
|
|
400
|
+
case 0:
|
|
401
|
+
console.log(chalk.cyanBright("\uD83D\uDE80 Starting accessibility audit...\n"));
|
|
402
|
+
configPath = path.resolve(process.cwd(), "ariaease.config.js");
|
|
403
|
+
config = {};
|
|
404
|
+
return [
|
|
405
|
+
4,
|
|
406
|
+
fs.pathExists(configPath)
|
|
407
|
+
];
|
|
408
|
+
case 1:
|
|
409
|
+
if (!_state.sent()) return [
|
|
410
|
+
3,
|
|
411
|
+
5
|
|
412
|
+
];
|
|
413
|
+
return [
|
|
414
|
+
4,
|
|
415
|
+
import(configPath)
|
|
416
|
+
];
|
|
417
|
+
case 2:
|
|
418
|
+
_tmp = _state.sent().default;
|
|
419
|
+
if (_tmp) return [
|
|
420
|
+
3,
|
|
421
|
+
4
|
|
422
|
+
];
|
|
423
|
+
return [
|
|
424
|
+
4,
|
|
425
|
+
import(configPath)
|
|
426
|
+
];
|
|
427
|
+
case 3:
|
|
428
|
+
_tmp = _state.sent();
|
|
429
|
+
_state.label = 4;
|
|
430
|
+
case 4:
|
|
431
|
+
config = _tmp;
|
|
432
|
+
console.log(chalk.green("\u2705 Loaded config from ariaease.config.js\n"));
|
|
433
|
+
return [
|
|
434
|
+
3,
|
|
435
|
+
6
|
|
436
|
+
];
|
|
437
|
+
case 5:
|
|
438
|
+
console.log(chalk.yellow("\u2139\uFE0F No ariaease.config.js found at project root, using default configurations."));
|
|
439
|
+
_state.label = 6;
|
|
440
|
+
case 6:
|
|
441
|
+
urls = [];
|
|
442
|
+
if (opts.url) urls.push(opts.url);
|
|
443
|
+
if (config.urls && Array.isArray(config.urls)) (_urls = urls).push.apply(_urls, _to_consumable_array(config.urls));
|
|
444
|
+
if (urls.length === 0) {
|
|
445
|
+
console.log(chalk.red('\u274C No URLs provided. Use --url option or add "urls" in ariaease.config.js'));
|
|
446
|
+
process.exit(1);
|
|
447
|
+
}
|
|
448
|
+
allResults = [];
|
|
449
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
450
|
+
_state.label = 7;
|
|
451
|
+
case 7:
|
|
452
|
+
_state.trys.push([
|
|
453
|
+
7,
|
|
454
|
+
14,
|
|
455
|
+
15,
|
|
456
|
+
16
|
|
457
|
+
]);
|
|
458
|
+
_iterator = urls[Symbol.iterator]();
|
|
459
|
+
_state.label = 8;
|
|
460
|
+
case 8:
|
|
461
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
462
|
+
3,
|
|
463
|
+
13
|
|
464
|
+
];
|
|
465
|
+
url = _step.value;
|
|
466
|
+
console.log(chalk.yellow("\uD83D\uDD0E Auditing: ".concat(url)));
|
|
467
|
+
_state.label = 9;
|
|
468
|
+
case 9:
|
|
469
|
+
_state.trys.push([
|
|
470
|
+
9,
|
|
471
|
+
11,
|
|
472
|
+
,
|
|
473
|
+
12
|
|
474
|
+
]);
|
|
475
|
+
return [
|
|
476
|
+
4,
|
|
477
|
+
runAudit(url)
|
|
478
|
+
];
|
|
479
|
+
case 10:
|
|
480
|
+
result = _state.sent();
|
|
481
|
+
allResults.push({
|
|
482
|
+
url: url,
|
|
483
|
+
result: result
|
|
484
|
+
});
|
|
485
|
+
console.log(chalk.green("ā
Completed audit for ".concat(url, "\n")));
|
|
486
|
+
return [
|
|
487
|
+
3,
|
|
488
|
+
12
|
|
489
|
+
];
|
|
490
|
+
case 11:
|
|
491
|
+
err = _state.sent();
|
|
492
|
+
console.log(chalk.red("ā Failed auditing ".concat(url, ": ").concat(err.message)));
|
|
493
|
+
return [
|
|
494
|
+
3,
|
|
495
|
+
12
|
|
496
|
+
];
|
|
497
|
+
case 12:
|
|
498
|
+
_iteratorNormalCompletion = true;
|
|
499
|
+
return [
|
|
500
|
+
3,
|
|
501
|
+
8
|
|
502
|
+
];
|
|
503
|
+
case 13:
|
|
504
|
+
return [
|
|
505
|
+
3,
|
|
506
|
+
16
|
|
507
|
+
];
|
|
508
|
+
case 14:
|
|
509
|
+
err1 = _state.sent();
|
|
510
|
+
_didIteratorError = true;
|
|
511
|
+
_iteratorError = err1;
|
|
512
|
+
return [
|
|
513
|
+
3,
|
|
514
|
+
16
|
|
515
|
+
];
|
|
516
|
+
case 15:
|
|
517
|
+
try {
|
|
518
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
519
|
+
_iterator.return();
|
|
520
|
+
}
|
|
521
|
+
} finally{
|
|
522
|
+
if (_didIteratorError) {
|
|
523
|
+
throw _iteratorError;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return [
|
|
527
|
+
7
|
|
528
|
+
];
|
|
529
|
+
case 16:
|
|
530
|
+
hasResults = allResults.some(function(r) {
|
|
531
|
+
return r.result && r.result.violations && r.result.violations.length > 0;
|
|
532
|
+
});
|
|
533
|
+
if (!hasResults) {
|
|
534
|
+
console.log(chalk.red("\u274C No audit report generated"));
|
|
535
|
+
process.exit(1);
|
|
536
|
+
}
|
|
537
|
+
formatted = formatResults(allResults, opts.format);
|
|
538
|
+
return [
|
|
539
|
+
4,
|
|
540
|
+
fs.ensureDir(opts.out)
|
|
541
|
+
];
|
|
542
|
+
case 17:
|
|
543
|
+
_state.sent();
|
|
544
|
+
timestamp = /* @__PURE__ */ new Date().toISOString().replace(/[:.]/g, "-");
|
|
545
|
+
fileName = "ariaease-report-".concat(timestamp, ".").concat(opts.format);
|
|
546
|
+
filePath = path.join(opts.out, fileName);
|
|
547
|
+
return [
|
|
548
|
+
4,
|
|
549
|
+
fs.writeFile(filePath, formatted, "utf-8")
|
|
550
|
+
];
|
|
551
|
+
case 18:
|
|
552
|
+
_state.sent();
|
|
553
|
+
console.log(chalk.magentaBright("\uD83D\uDCC1 Report saved to ".concat(filePath)));
|
|
554
|
+
console.log(chalk.green("\n\uD83C\uDF89 All audits completed."));
|
|
555
|
+
return [
|
|
556
|
+
2
|
|
557
|
+
];
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
})();
|
|
561
|
+
});
|
|
562
|
+
program.command("help").description("Display help information").action(function() {
|
|
563
|
+
program.outputHelp();
|
|
564
|
+
});
|
|
565
|
+
program.parse(process.argv);
|
|
566
|
+
//# sourceMappingURL=audit-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/macx/aria-ease/package/bin/audit-cli.js","../dist/src/utils/audit/audit.js"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\n\n// dist/src/utils/audit/audit.js\nimport AxeBuilder from \"@axe-core/playwright\";\nimport { chromium } from \"playwright\";\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nfunction _async_to_generator(fn) {\n return function() {\n var self = this, args2 = arguments;\n return new Promise(function(resolve, reject) {\n var gen = fn.apply(self, args2);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(void 0);\n });\n };\n}\nfunction _ts_generator(thisArg, body) {\n var f, y, t, _ = {\n label: 0,\n sent: function() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n }, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([\n n,\n v\n ]);\n };\n }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [\n op[0] & 2,\n t.value\n ];\n switch (op[0]) {\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n case 5:\n _.label++;\n y = op[1];\n op = [\n 0\n ];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2]) _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [\n 6,\n e\n ];\n y = 0;\n } finally {\n f = t = 0;\n }\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\nfunction runAudit() {\n return _async_to_generator(function() {\n var browser, context, page, axe, axeResults, snapshot, error;\n return _ts_generator(this, function(_state) {\n switch (_state.label) {\n case 0:\n return [\n 4,\n chromium.launch({\n headless: true\n })\n ];\n case 1:\n browser = _state.sent();\n return [\n 4,\n browser.newContext()\n ];\n case 2:\n context = _state.sent();\n return [\n 4,\n context.newPage()\n ];\n case 3:\n page = _state.sent();\n return [\n 4,\n page.goto(\"http://localhost:5173/\")\n ];\n case 4:\n _state.sent();\n _state.label = 5;\n case 5:\n _state.trys.push([\n 5,\n 8,\n ,\n 9\n ]);\n axe = new AxeBuilder({\n page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 6:\n axeResults = _state.sent();\n console.log(\"--- AXE-CORE RESULTS ---\");\n console.log(axeResults);\n return [\n 4,\n page.accessibility.snapshot()\n ];\n case 7:\n snapshot = _state.sent();\n console.log(\"\\n--- PLAYWRIGHT SNAPSHOT ---\");\n console.log(snapshot);\n return [\n 3,\n 9\n ];\n case 8:\n error = _state.sent();\n console.log(error);\n return [\n 3,\n 9\n ];\n case 9:\n return [\n 4,\n browser.close()\n ];\n case 10:\n _state.sent();\n return [\n 2\n ];\n }\n });\n })();\n}\n\n// bin/audit-cli.ts\nvar args = process.argv.slice(2);\nif (args[0] === \"audit\") {\n (async () => {\n await runAudit();\n })();\n} else {\n console.log(\"Usage: npx aria-ease audit\");\n}\n","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\nfunction _async_to_generator(fn) {\n return function() {\n var self = this, args = arguments;\n return new Promise(function(resolve, reject) {\n var gen = fn.apply(self, args);\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n _next(undefined);\n });\n };\n}\nfunction _ts_generator(thisArg, body) {\n var f, y, t, _ = {\n label: 0,\n sent: function() {\n if (t[0] & 1) throw t[1];\n return t[1];\n },\n trys: [],\n ops: []\n }, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() {\n return this;\n }), g;\n function verb(n) {\n return function(v) {\n return step([\n n,\n v\n ]);\n };\n }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while(g && (g = 0, op[0] && (_ = 0)), _)try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [\n op[0] & 2,\n t.value\n ];\n switch(op[0]){\n case 0:\n case 1:\n t = op;\n break;\n case 4:\n _.label++;\n return {\n value: op[1],\n done: false\n };\n case 5:\n _.label++;\n y = op[1];\n op = [\n 0\n ];\n continue;\n case 7:\n op = _.ops.pop();\n _.trys.pop();\n continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {\n _ = 0;\n continue;\n }\n if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {\n _.label = op[1];\n break;\n }\n if (op[0] === 6 && _.label < t[1]) {\n _.label = t[1];\n t = op;\n break;\n }\n if (t && _.label < t[2]) {\n _.label = t[2];\n _.ops.push(op);\n break;\n }\n if (t[2]) _.ops.pop();\n _.trys.pop();\n continue;\n }\n op = body.call(thisArg, _);\n } catch (e) {\n op = [\n 6,\n e\n ];\n y = 0;\n } finally{\n f = t = 0;\n }\n if (op[0] & 5) throw op[1];\n return {\n value: op[0] ? op[1] : void 0,\n done: true\n };\n }\n}\nimport AxeBuilder from '@axe-core/playwright';\nimport { chromium } from 'playwright';\n// src/utils/audit/audit.ts\nfunction runAudit(url) {\n return _async_to_generator(function() {\n var browser, context, page, axe, axeResults, error;\n return _ts_generator(this, function(_state) {\n switch(_state.label){\n case 0:\n return [\n 4,\n chromium.launch({\n headless: true\n })\n ];\n case 1:\n browser = _state.sent();\n return [\n 4,\n browser.newContext()\n ];\n case 2:\n context = _state.sent();\n return [\n 4,\n context.newPage()\n ];\n case 3:\n page = _state.sent();\n return [\n 4,\n page.goto(url, {\n waitUntil: \"networkidle\"\n })\n ];\n case 4:\n _state.sent();\n _state.label = 5;\n case 5:\n _state.trys.push([\n 5,\n 7,\n ,\n 8\n ]);\n axe = new AxeBuilder({\n page: page\n });\n return [\n 4,\n axe.analyze()\n ];\n case 6:\n axeResults = _state.sent();\n return [\n 2,\n axeResults\n ];\n case 7:\n error = _state.sent();\n console.log(error);\n return [\n 3,\n 8\n ];\n case 8:\n return [\n 4,\n browser.close()\n ];\n case 9:\n _state.sent();\n return [\n 2\n ];\n }\n });\n })();\n}\nexport { runAudit }; //# sourceMappingURL=audit.js.map\n//# sourceMappingURL=audit.js.map"]}
|
package/bin/audit-cli.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import fs from "fs-extra";
|
|
7
|
+
import { AriaEaseConfig, AxeResults } from "Types";
|
|
8
|
+
import { runAudit } from "aria-ease/audit";
|
|
9
|
+
import { formatResults } from "src/utils/audit/formatters";
|
|
10
|
+
|
|
11
|
+
const program = new Command();
|
|
12
|
+
|
|
13
|
+
program.name('aria-ease').description('Run accessibility audits').version('2.0.4');
|
|
14
|
+
|
|
15
|
+
program.command('audit')
|
|
16
|
+
.description('Run accessibility audit')
|
|
17
|
+
.option('-u, --url <url>', 'Single URL to audit')
|
|
18
|
+
.option('-f, --format <format>', 'Output format for the audit report: json | csv', 'csv')
|
|
19
|
+
.option('-o, --out <path>', 'Directory to save the audit report', './accessibility-reports')
|
|
20
|
+
.action(async (opts) => {
|
|
21
|
+
console.log(chalk.cyanBright('š Starting accessibility audit...\n'));
|
|
22
|
+
|
|
23
|
+
const configPath = path.resolve(process.cwd(), 'ariaease.config.js');
|
|
24
|
+
let config: AriaEaseConfig = {};
|
|
25
|
+
if (await fs.pathExists(configPath)) {
|
|
26
|
+
config = (await import(configPath)).default || (await import(configPath));
|
|
27
|
+
console.log(chalk.green('ā
Loaded config from ariaease.config.js\n'));
|
|
28
|
+
} else {
|
|
29
|
+
console.log(chalk.yellow('ā¹ļø No ariaease.config.js found at project root, using default configurations.'));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const urls: string[] = [];
|
|
33
|
+
if(opts.url) urls.push(opts.url);
|
|
34
|
+
if(config.urls && Array.isArray(config.urls)) urls.push(...config.urls);
|
|
35
|
+
|
|
36
|
+
if(urls.length === 0) {
|
|
37
|
+
console.log(chalk.red('ā No URLs provided. Use --url option or add "urls" in ariaease.config.js'));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const allResults: { url: string, result?: AxeResults }[] = [];
|
|
42
|
+
for (const url of urls) {
|
|
43
|
+
console.log(chalk.yellow(`š Auditing: ${url}`));
|
|
44
|
+
try {
|
|
45
|
+
const result = await runAudit(url);
|
|
46
|
+
allResults.push({ url: url, result });
|
|
47
|
+
console.log(chalk.green(`ā
Completed audit for ${url}\n`));
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
} catch (err: any) {
|
|
51
|
+
console.log(chalk.red(`ā Failed auditing ${url}: ${err.message}`));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const hasResults = allResults.some(r => r.result && r.result.violations && r.result.violations.length > 0);
|
|
56
|
+
if (!hasResults) {
|
|
57
|
+
console.log(chalk.red('ā No audit report generated'));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const formatted = formatResults(allResults, opts.format);
|
|
62
|
+
|
|
63
|
+
await fs.ensureDir(opts.out);
|
|
64
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
65
|
+
const fileName = `ariaease-report-${timestamp}.${opts.format}`;
|
|
66
|
+
const filePath = path.join(opts.out, fileName);
|
|
67
|
+
|
|
68
|
+
await fs.writeFile(filePath, formatted, 'utf-8');
|
|
69
|
+
console.log(chalk.magentaBright(`š Report saved to ${filePath}`));
|
|
70
|
+
|
|
71
|
+
console.log(chalk.green('\nš All audits completed.'));
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
program.command('help')
|
|
75
|
+
.description('Display help information')
|
|
76
|
+
.action(() => {
|
|
77
|
+
program.outputHelp();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
program.parse(process.argv);
|