2404135205
CI / test (push) Has been cancelled
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
66 lines
2.2 KiB
JavaScript
66 lines
2.2 KiB
JavaScript
import { readFileSync, readdirSync } from 'fs';
|
|
import { join, dirname } from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(__dirname, '..');
|
|
const jsDir = join(root, 'js');
|
|
|
|
const files = readdirSync(jsDir).filter(f => f.endsWith('.js'));
|
|
|
|
let errors = 0;
|
|
for (const file of files) {
|
|
const path = join(jsDir, file);
|
|
const source = readFileSync(path, 'utf-8');
|
|
// Basic sanity: file is non-empty and has balanced braces
|
|
if (source.length < 10) {
|
|
console.log(` FAIL ${file}: too small`);
|
|
errors++;
|
|
continue;
|
|
}
|
|
const openBraces = (source.match(/{/g) || []).length;
|
|
const closeBraces = (source.match(/}/g) || []).length;
|
|
if (openBraces !== closeBraces) {
|
|
console.log(` FAIL ${file}: unbalanced braces (${openBraces} open, ${closeBraces} close)`);
|
|
errors++;
|
|
continue;
|
|
}
|
|
const openParens = (source.match(/\(/g) || []).length;
|
|
const closeParens = (source.match(/\)/g) || []).length;
|
|
if (openParens !== closeParens) {
|
|
console.log(` FAIL ${file}: unbalanced parentheses`);
|
|
errors++;
|
|
continue;
|
|
}
|
|
console.log(` PASS ${file}`);
|
|
}
|
|
|
|
const html = readFileSync(join(root, 'index.html'), 'utf-8');
|
|
if (html.includes('<canvas') && html.includes('<script')) {
|
|
console.log(' PASS index.html');
|
|
} else {
|
|
console.log(' FAIL index.html missing required elements');
|
|
errors++;
|
|
}
|
|
|
|
const css = readFileSync(join(root, 'css', 'style.css'), 'utf-8');
|
|
if (css.includes('#game-canvas') && css.includes('#loading-screen')) {
|
|
console.log(' PASS css/style.css');
|
|
} else {
|
|
console.log(' FAIL css/style.css missing required selectors');
|
|
errors++;
|
|
}
|
|
|
|
const required = ['main', 'flight-model', 'terrain', 'airport', 'aircraft', 'hud', 'ui', 'retro', 'sound'];
|
|
for (const mod of required) {
|
|
const source = readFileSync(join(jsDir, `${mod}.js`), 'utf-8');
|
|
if (source.includes('export class') || source.includes('export default')) {
|
|
console.log(` PASS js/${mod}.js exports correctly`);
|
|
} else {
|
|
console.log(` WARN js/${mod}.js missing export`);
|
|
}
|
|
}
|
|
|
|
console.log(`\n${errors === 0 ? 'All checks passed!' : `${errors} error(s) found.`}`);
|
|
if (errors > 0) process.exit(1);
|