feat: harden query read-only workflow

This commit is contained in:
Logan.Li committed 2026-07-07 17:20:44 +08:00
1 parent 58bbc394e9
commit 617c15dbfe
29 files changed
+1417 -395

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import fs from 'node:fs';
import path from 'node:path';
const root = process.cwd();
const pagesDir = path.join(root, 'src/pages');
const limit = Number(process.argv[2] || 700);
const files = fs.readdirSync(pagesDir)
.filter((file) => file.endsWith('.tsx'))
.map((file) => {
const fullPath = path.join(pagesDir, file);
const lines = fs.readFileSync(fullPath, 'utf8').split('\n').length;
return { file, lines };
})
.sort((a, b) => b.lines - a.lines);
const overLimit = files.filter((item) => item.lines > limit);
console.log(`Page size budget: ${limit} lines\n`);
for (const item of files) {
const mark = item.lines > limit ? '!' : ' ';
console.log(`${mark} ${String(item.lines).padStart(4, ' ')} ${item.file}`);
}
if (overLimit.length > 0) {
console.log(`\n${overLimit.length} page(s) exceed the ${limit}-line budget.`);
process.exitCode = 1;
}