@finggujadhav/compiler 0.9.4 → 0.9.5
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/cli.js +62 -2
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* FingguFlux CLI
|
|
4
|
-
* v0.9.
|
|
4
|
+
* v0.9.5 Accessibility Hardening
|
|
5
5
|
*/
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
@@ -31,9 +31,12 @@ async function main() {
|
|
|
31
31
|
case 'doctor':
|
|
32
32
|
await runDoctor();
|
|
33
33
|
break;
|
|
34
|
+
case 'a11y':
|
|
35
|
+
await runA11y();
|
|
36
|
+
break;
|
|
34
37
|
default:
|
|
35
38
|
console.error(`Unknown command: ${command}`);
|
|
36
|
-
console.log('Available commands: build, analyze, doctor');
|
|
39
|
+
console.log('Available commands: build, analyze, doctor, a11y');
|
|
37
40
|
process.exit(1);
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -159,6 +162,63 @@ async function runDoctor() {
|
|
|
159
162
|
else console.log(`\n❌ Project has issues. See details above.`);
|
|
160
163
|
}
|
|
161
164
|
|
|
165
|
+
async function runA11y() {
|
|
166
|
+
console.log(`\n♿ FingguFlux Accessibility Audit`);
|
|
167
|
+
const { validateTemplate, getContrastRatio } = await import('./a11y.js');
|
|
168
|
+
const files = getProjectFiles(path.resolve(inputDir));
|
|
169
|
+
|
|
170
|
+
let totalIssues = 0;
|
|
171
|
+
|
|
172
|
+
// 1. Template Validation
|
|
173
|
+
files.forEach(file => {
|
|
174
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
175
|
+
const fileIssues = validateTemplate(content);
|
|
176
|
+
if (fileIssues.length > 0) {
|
|
177
|
+
console.log(`\nFile: ${path.relative(process.cwd(), file)}`);
|
|
178
|
+
fileIssues.forEach(issue => {
|
|
179
|
+
const typeColor = issue.type === 'Error' ? '\x1b[31m' : '\x1b[33m';
|
|
180
|
+
console.log(` [${typeColor}${issue.type}\x1b[0m] ${issue.component}: ${issue.message}`);
|
|
181
|
+
totalIssues++;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// 2. Token Contrast Check
|
|
187
|
+
console.log(`\n🎨 Semantic Token Contrast Check:`);
|
|
188
|
+
const possibleCorePaths = [
|
|
189
|
+
path.resolve('./packages/core/tokens.css'),
|
|
190
|
+
path.resolve('./node_modules/@finggujadhav/core/tokens.css')
|
|
191
|
+
];
|
|
192
|
+
const corePath = possibleCorePaths.find(p => fs.existsSync(p));
|
|
193
|
+
|
|
194
|
+
if (corePath) {
|
|
195
|
+
const tokens = fs.readFileSync(corePath, 'utf8');
|
|
196
|
+
const pairings = [
|
|
197
|
+
['--ff-success-surface', '--ff-success-content', 'Success'],
|
|
198
|
+
['--ff-warning-surface', '--ff-warning-content', 'Warning'],
|
|
199
|
+
['--ff-danger-surface', '--ff-danger-content', 'Danger']
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
pairings.forEach(([bgVar, fgVar, label]) => {
|
|
203
|
+
const bgMatch = tokens.match(new RegExp(`${bgVar}: ([#\\w]+)`));
|
|
204
|
+
const fgMatch = tokens.match(new RegExp(`${fgVar}: ([#\\w]+)`));
|
|
205
|
+
if (bgMatch && fgMatch) {
|
|
206
|
+
const ratio = getContrastRatio(bgMatch[1], fgMatch[1]);
|
|
207
|
+
const pass = ratio >= 4.5;
|
|
208
|
+
const status = pass ? '\x1b[32mPASS\x1b[0m' : '\x1b[31mFAIL\x1b[0m';
|
|
209
|
+
console.log(` ${label.padEnd(10)}: ${status} (${ratio.toFixed(2)}:1)`);
|
|
210
|
+
if (!pass) totalIssues++;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (totalIssues === 0) {
|
|
216
|
+
console.log(`\n✨ No accessibility issues found!`);
|
|
217
|
+
} else {
|
|
218
|
+
console.log(`\n❌ Found ${totalIssues} accessibility issues.`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
162
222
|
main().catch(err => {
|
|
163
223
|
console.error('Command failed:', err);
|
|
164
224
|
process.exit(1);
|