aria-ease 2.2.3 → 2.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.
- package/README.md +407 -27
- package/bin/cli.cjs +475 -0
- package/bin/cli.cjs.map +1 -0
- package/bin/cli.d.ts.map +1 -0
- package/bin/cli.js +452 -0
- package/bin/cli.js.map +1 -0
- package/bin/{audit-cli.ts → cli.ts} +25 -20
- package/bin/configLoader.d.ts +19 -0
- package/bin/configLoader.d.ts.map +1 -0
- package/bin/configLoader.js +155 -0
- package/bin/configLoader.ts +170 -0
- package/bin/contractTestRunnerPlaywright-2LQHVMXT.js +426 -0
- package/bin/contractTestRunnerPlaywright-2LQHVMXT.js.map +1 -0
- package/dist/chunk-4F6O5RKZ.js +207 -0
- package/dist/chunk-4F6O5RKZ.js.map +1 -0
- package/dist/contractTestRunnerPlaywright-FM6MK6DY.js +255 -0
- package/dist/contractTestRunnerPlaywright-FM6MK6DY.js.map +1 -0
- package/dist/index.cjs +13644 -233
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -7
- package/dist/index.d.ts +102 -7
- package/dist/index.js +13191 -7
- package/dist/index.js.map +1 -1
- package/dist/{Types.d-p85gN5m_.d.cts → src/Types.d-BbztRe-S.d.cts} +0 -5
- package/dist/{Types.d-p85gN5m_.d.ts → src/Types.d-BbztRe-S.d.ts} +0 -5
- package/dist/src/accordion/index.cjs +25 -19
- package/dist/src/accordion/index.cjs.map +1 -1
- package/dist/src/accordion/index.d.cts +1 -1
- package/dist/src/accordion/index.d.ts +1 -1
- package/dist/src/accordion/index.js +28 -1
- package/dist/src/accordion/index.js.map +1 -1
- package/dist/src/block/index.cjs +99 -99
- package/dist/src/block/index.cjs.map +1 -1
- package/dist/src/block/index.d.cts +4 -2
- package/dist/src/block/index.d.ts +4 -2
- package/dist/src/block/index.js +42 -2
- package/dist/src/block/index.js.map +1 -1
- package/dist/src/checkbox/index.cjs +30 -13
- package/dist/src/checkbox/index.cjs.map +1 -1
- package/dist/src/checkbox/index.d.cts +1 -1
- package/dist/src/checkbox/index.d.ts +1 -1
- package/dist/src/checkbox/index.js +33 -1
- package/dist/src/checkbox/index.js.map +1 -1
- package/dist/src/chunk-MNMWQWXH.js +117 -0
- package/dist/src/chunk-MNMWQWXH.js.map +1 -0
- package/dist/src/menu/index.cjs +208 -130
- package/dist/src/menu/index.cjs.map +1 -1
- package/dist/src/menu/index.d.cts +9 -3
- package/dist/src/menu/index.d.ts +9 -3
- package/dist/src/menu/index.js +118 -2
- package/dist/src/menu/index.js.map +1 -1
- package/dist/src/radio/index.cjs +29 -16
- package/dist/src/radio/index.cjs.map +1 -1
- package/dist/src/radio/index.d.cts +1 -1
- package/dist/src/radio/index.d.ts +1 -1
- package/dist/src/radio/index.js +32 -1
- package/dist/src/radio/index.js.map +1 -1
- package/dist/src/toggle/index.cjs +26 -16
- package/dist/src/toggle/index.cjs.map +1 -1
- package/dist/src/toggle/index.d.cts +1 -1
- package/dist/src/toggle/index.d.ts +1 -1
- package/dist/src/toggle/index.js +29 -1
- package/dist/src/toggle/index.js.map +1 -1
- package/dist/src/utils/test/chunk-UAS6V5MH.js +203 -0
- package/dist/src/utils/test/chunk-UAS6V5MH.js.map +1 -0
- package/dist/src/utils/test/contractTestRunnerPlaywright-IBC4FHWK.js +251 -0
- package/dist/src/utils/test/contractTestRunnerPlaywright-IBC4FHWK.js.map +1 -0
- package/dist/src/utils/test/contracts/MenuContract.json +343 -0
- package/dist/src/utils/test/index.cjs +13092 -0
- package/dist/src/utils/test/index.cjs.map +1 -0
- package/dist/src/utils/test/index.d.cts +16 -0
- package/dist/src/utils/test/index.d.ts +16 -0
- package/dist/src/utils/test/index.js +12608 -0
- package/dist/src/utils/test/index.js.map +1 -0
- package/package.json +33 -12
- package/bin/audit-cli.cjs +0 -876
- package/bin/audit-cli.cjs.map +0 -1
- package/bin/audit-cli.js +0 -779
- package/bin/audit-cli.js.map +0 -1
- package/dist/chunk-4366LRNM.js +0 -38
- package/dist/chunk-4366LRNM.js.map +0 -1
- package/dist/chunk-5HQ6LLC5.js +0 -21
- package/dist/chunk-5HQ6LLC5.js.map +0 -1
- package/dist/chunk-FBQ5LF2T.js +0 -21
- package/dist/chunk-FBQ5LF2T.js.map +0 -1
- package/dist/chunk-KVTLMA4J.js +0 -58
- package/dist/chunk-KVTLMA4J.js.map +0 -1
- package/dist/chunk-MEA5U2G4.js +0 -24
- package/dist/chunk-MEA5U2G4.js.map +0 -1
- package/dist/chunk-RK3JUAFZ.js +0 -18
- package/dist/chunk-RK3JUAFZ.js.map +0 -1
- package/dist/chunk-RT5IROW4.js +0 -99
- package/dist/chunk-RT5IROW4.js.map +0 -1
- package/dist/src/utils/audit/audit.cjs +0 -239
- package/dist/src/utils/audit/audit.cjs.map +0 -1
- package/dist/src/utils/audit/audit.d.cts +0 -5
- package/dist/src/utils/audit/audit.d.ts +0 -5
- package/dist/src/utils/audit/audit.js +0 -232
- package/dist/src/utils/audit/audit.js.map +0 -1
- /package/bin/{audit-cli.d.cts → cli.d.cts} +0 -0
- /package/bin/{audit-cli.d.ts → cli.d.ts} +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
/**
|
|
4
|
+
* Validates the structure of an AriaEase config object
|
|
5
|
+
* @param config - The config object to validate
|
|
6
|
+
* @returns Validation result with errors if any
|
|
7
|
+
*/
|
|
8
|
+
function validateConfig(config) {
|
|
9
|
+
const errors = [];
|
|
10
|
+
if (!config || typeof config !== 'object') {
|
|
11
|
+
errors.push('Config must be an object');
|
|
12
|
+
return { valid: false, errors };
|
|
13
|
+
}
|
|
14
|
+
const cfg = config;
|
|
15
|
+
// Validate audit config if present
|
|
16
|
+
if (cfg.audit !== undefined) {
|
|
17
|
+
if (typeof cfg.audit !== 'object' || cfg.audit === null) {
|
|
18
|
+
errors.push('audit must be an object');
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// Validate urls
|
|
22
|
+
if (cfg.audit.urls !== undefined) {
|
|
23
|
+
if (!Array.isArray(cfg.audit.urls)) {
|
|
24
|
+
errors.push('audit.urls must be an array');
|
|
25
|
+
}
|
|
26
|
+
else if (cfg.audit.urls.some(url => typeof url !== 'string')) {
|
|
27
|
+
errors.push('audit.urls must contain only strings');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Validate output format
|
|
31
|
+
if (cfg.audit.output !== undefined) {
|
|
32
|
+
if (typeof cfg.audit.output !== 'object') {
|
|
33
|
+
errors.push('audit.output must be an object');
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const output = cfg.audit.output;
|
|
37
|
+
if (output.format !== undefined) {
|
|
38
|
+
if (!['json', 'csv', 'html', 'all'].includes(output.format)) {
|
|
39
|
+
errors.push('audit.output.format must be one of: json, csv, html, all');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (output.out !== undefined && typeof output.out !== 'string') {
|
|
43
|
+
errors.push('audit.output.out must be a string');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Validate test config if present
|
|
50
|
+
if (cfg.test !== undefined) {
|
|
51
|
+
if (typeof cfg.test !== 'object' || cfg.test === null) {
|
|
52
|
+
errors.push('test must be an object');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if (cfg.test.components !== undefined) {
|
|
56
|
+
if (!Array.isArray(cfg.test.components)) {
|
|
57
|
+
errors.push('test.components must be an array');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
cfg.test.components.forEach((comp, idx) => {
|
|
61
|
+
if (typeof comp !== 'object' || comp === null) {
|
|
62
|
+
errors.push(`test.components[${idx}] must be an object`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (typeof comp.name !== 'string') {
|
|
66
|
+
errors.push(`test.components[${idx}].name must be a string`);
|
|
67
|
+
}
|
|
68
|
+
if (typeof comp.path !== 'string') {
|
|
69
|
+
errors.push(`test.components[${idx}].path must be a string`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { valid: errors.length === 0, errors };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Attempts to load and parse a config file
|
|
81
|
+
* @param filePath - Absolute path to the config file
|
|
82
|
+
* @returns The parsed config or null if loading fails
|
|
83
|
+
*/
|
|
84
|
+
async function loadConfigFile(filePath) {
|
|
85
|
+
try {
|
|
86
|
+
const ext = path.extname(filePath);
|
|
87
|
+
if (ext === '.json') {
|
|
88
|
+
// Load JSON file
|
|
89
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
90
|
+
return JSON.parse(content);
|
|
91
|
+
}
|
|
92
|
+
else if (['.js', '.mjs', '.cjs', '.ts'].includes(ext)) {
|
|
93
|
+
// Dynamic import for JS/TS modules
|
|
94
|
+
const imported = await import(filePath);
|
|
95
|
+
// Handle both default export and named exports
|
|
96
|
+
return imported.default || imported;
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Return null on any error - caller will handle
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Searches for and loads an AriaEase config file
|
|
107
|
+
* Checks for config files in this order:
|
|
108
|
+
* - ariaease.config.js
|
|
109
|
+
* - ariaease.config.mjs
|
|
110
|
+
* - ariaease.config.cjs
|
|
111
|
+
* - ariaease.config.json
|
|
112
|
+
* - ariaease.config.ts
|
|
113
|
+
*
|
|
114
|
+
* @param cwd - Current working directory to search in
|
|
115
|
+
* @returns Object containing the config and any errors
|
|
116
|
+
*/
|
|
117
|
+
export async function loadConfig(cwd = process.cwd()) {
|
|
118
|
+
const configNames = [
|
|
119
|
+
'ariaease.config.js',
|
|
120
|
+
'ariaease.config.mjs',
|
|
121
|
+
'ariaease.config.cjs',
|
|
122
|
+
'ariaease.config.json',
|
|
123
|
+
'ariaease.config.ts'
|
|
124
|
+
];
|
|
125
|
+
let loadedConfig = null;
|
|
126
|
+
let foundPath = null;
|
|
127
|
+
const errors = [];
|
|
128
|
+
// Try to find and load config
|
|
129
|
+
for (const name of configNames) {
|
|
130
|
+
const configPath = path.resolve(cwd, name);
|
|
131
|
+
if (await fs.pathExists(configPath)) {
|
|
132
|
+
foundPath = configPath;
|
|
133
|
+
loadedConfig = await loadConfigFile(configPath);
|
|
134
|
+
if (loadedConfig === null) {
|
|
135
|
+
errors.push(`Found config at ${name} but failed to load it. Check for syntax errors.`);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// Validate the loaded config
|
|
139
|
+
const validation = validateConfig(loadedConfig);
|
|
140
|
+
if (!validation.valid) {
|
|
141
|
+
errors.push(`Config validation failed in ${name}:`);
|
|
142
|
+
errors.push(...validation.errors.map(err => ` - ${err}`));
|
|
143
|
+
loadedConfig = null;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// Successfully loaded and validated
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
config: loadedConfig || {},
|
|
152
|
+
configPath: loadedConfig ? foundPath : null,
|
|
153
|
+
errors
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { AriaEaseConfig } from "Types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Validates the structure of an AriaEase config object
|
|
7
|
+
* @param config - The config object to validate
|
|
8
|
+
* @returns Validation result with errors if any
|
|
9
|
+
*/
|
|
10
|
+
function validateConfig(config: unknown): { valid: boolean; errors: string[] } {
|
|
11
|
+
const errors: string[] = [];
|
|
12
|
+
|
|
13
|
+
if (!config || typeof config !== 'object') {
|
|
14
|
+
errors.push('Config must be an object');
|
|
15
|
+
return { valid: false, errors };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const cfg = config as Partial<AriaEaseConfig>;
|
|
19
|
+
|
|
20
|
+
// Validate audit config if present
|
|
21
|
+
if (cfg.audit !== undefined) {
|
|
22
|
+
if (typeof cfg.audit !== 'object' || cfg.audit === null) {
|
|
23
|
+
errors.push('audit must be an object');
|
|
24
|
+
} else {
|
|
25
|
+
// Validate urls
|
|
26
|
+
if (cfg.audit.urls !== undefined) {
|
|
27
|
+
if (!Array.isArray(cfg.audit.urls)) {
|
|
28
|
+
errors.push('audit.urls must be an array');
|
|
29
|
+
} else if (cfg.audit.urls.some(url => typeof url !== 'string')) {
|
|
30
|
+
errors.push('audit.urls must contain only strings');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Validate output format
|
|
35
|
+
if (cfg.audit.output !== undefined) {
|
|
36
|
+
if (typeof cfg.audit.output !== 'object') {
|
|
37
|
+
errors.push('audit.output must be an object');
|
|
38
|
+
} else {
|
|
39
|
+
const output = cfg.audit.output as { format?: string; out?: string };
|
|
40
|
+
if (output.format !== undefined) {
|
|
41
|
+
if (!['json', 'csv', 'html', 'all'].includes(output.format)) {
|
|
42
|
+
errors.push('audit.output.format must be one of: json, csv, html, all');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (output.out !== undefined && typeof output.out !== 'string') {
|
|
46
|
+
errors.push('audit.output.out must be a string');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Validate test config if present
|
|
54
|
+
if (cfg.test !== undefined) {
|
|
55
|
+
if (typeof cfg.test !== 'object' || cfg.test === null) {
|
|
56
|
+
errors.push('test must be an object');
|
|
57
|
+
} else {
|
|
58
|
+
if (cfg.test.components !== undefined) {
|
|
59
|
+
if (!Array.isArray(cfg.test.components)) {
|
|
60
|
+
errors.push('test.components must be an array');
|
|
61
|
+
} else {
|
|
62
|
+
cfg.test.components.forEach((comp, idx) => {
|
|
63
|
+
if (typeof comp !== 'object' || comp === null) {
|
|
64
|
+
errors.push(`test.components[${idx}] must be an object`);
|
|
65
|
+
} else {
|
|
66
|
+
if (typeof comp.name !== 'string') {
|
|
67
|
+
errors.push(`test.components[${idx}].name must be a string`);
|
|
68
|
+
}
|
|
69
|
+
if (typeof comp.path !== 'string') {
|
|
70
|
+
errors.push(`test.components[${idx}].path must be a string`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return { valid: errors.length === 0, errors };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Attempts to load and parse a config file
|
|
84
|
+
* @param filePath - Absolute path to the config file
|
|
85
|
+
* @returns The parsed config or null if loading fails
|
|
86
|
+
*/
|
|
87
|
+
async function loadConfigFile(filePath: string): Promise<AriaEaseConfig | null> {
|
|
88
|
+
try {
|
|
89
|
+
const ext = path.extname(filePath);
|
|
90
|
+
|
|
91
|
+
if (ext === '.json') {
|
|
92
|
+
// Load JSON file
|
|
93
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
94
|
+
return JSON.parse(content);
|
|
95
|
+
} else if (['.js', '.mjs', '.cjs', '.ts'].includes(ext)) {
|
|
96
|
+
// Dynamic import for JS/TS modules
|
|
97
|
+
const imported = await import(filePath);
|
|
98
|
+
// Handle both default export and named exports
|
|
99
|
+
return imported.default || imported;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return null;
|
|
103
|
+
} catch {
|
|
104
|
+
// Return null on any error - caller will handle
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Searches for and loads an AriaEase config file
|
|
111
|
+
* Checks for config files in this order:
|
|
112
|
+
* - ariaease.config.js
|
|
113
|
+
* - ariaease.config.mjs
|
|
114
|
+
* - ariaease.config.cjs
|
|
115
|
+
* - ariaease.config.json
|
|
116
|
+
* - ariaease.config.ts
|
|
117
|
+
*
|
|
118
|
+
* @param cwd - Current working directory to search in
|
|
119
|
+
* @returns Object containing the config and any errors
|
|
120
|
+
*/
|
|
121
|
+
export async function loadConfig(cwd: string = process.cwd()): Promise<{
|
|
122
|
+
config: AriaEaseConfig;
|
|
123
|
+
configPath: string | null;
|
|
124
|
+
errors: string[];
|
|
125
|
+
}> {
|
|
126
|
+
const configNames = [
|
|
127
|
+
'ariaease.config.js',
|
|
128
|
+
'ariaease.config.mjs',
|
|
129
|
+
'ariaease.config.cjs',
|
|
130
|
+
'ariaease.config.json',
|
|
131
|
+
'ariaease.config.ts'
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
let loadedConfig: AriaEaseConfig | null = null;
|
|
135
|
+
let foundPath: string | null = null;
|
|
136
|
+
const errors: string[] = [];
|
|
137
|
+
|
|
138
|
+
// Try to find and load config
|
|
139
|
+
for (const name of configNames) {
|
|
140
|
+
const configPath = path.resolve(cwd, name);
|
|
141
|
+
|
|
142
|
+
if (await fs.pathExists(configPath)) {
|
|
143
|
+
foundPath = configPath;
|
|
144
|
+
loadedConfig = await loadConfigFile(configPath);
|
|
145
|
+
|
|
146
|
+
if (loadedConfig === null) {
|
|
147
|
+
errors.push(`Found config at ${name} but failed to load it. Check for syntax errors.`);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Validate the loaded config
|
|
152
|
+
const validation = validateConfig(loadedConfig);
|
|
153
|
+
if (!validation.valid) {
|
|
154
|
+
errors.push(`Config validation failed in ${name}:`);
|
|
155
|
+
errors.push(...validation.errors.map(err => ` - ${err}`));
|
|
156
|
+
loadedConfig = null;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Successfully loaded and validated
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
config: loadedConfig || {},
|
|
167
|
+
configPath: loadedConfig ? foundPath : null,
|
|
168
|
+
errors
|
|
169
|
+
};
|
|
170
|
+
}
|