42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const files = [
|
|
"lib/storage/service.ts",
|
|
"app/(chat)/api/files/upload/route.ts",
|
|
"app/(auth)/login/page.tsx",
|
|
"app/api/auth/dingtalk/callback/route.ts",
|
|
"lib/ai/providers/gemini-image.ts",
|
|
"lib/ai/providers/volcano-vision.ts",
|
|
"lib/ai/providers/qianwen-video.ts",
|
|
"services/canvas/index.ts",
|
|
"components/image-annotator.tsx",
|
|
"app/api/canvas/auto-title/route.ts",
|
|
"app/api/canvas/text-detect/route.ts",
|
|
"app/api/canvas/detail-plan/route.ts",
|
|
"app/api/scene-fusion/route.ts",
|
|
];
|
|
|
|
const consolePattern = /\bconsole\.(log|warn|error|info|debug)\b/g;
|
|
const violations = [];
|
|
|
|
for (const file of files) {
|
|
const source = readFileSync(file, "utf8");
|
|
const lines = source.split(/\r?\n/);
|
|
lines.forEach((line, index) => {
|
|
if (consolePattern.test(line)) {
|
|
violations.push(`${file}:${index + 1}: ${line.trim()}`);
|
|
}
|
|
consolePattern.lastIndex = 0;
|
|
});
|
|
}
|
|
|
|
if (violations.length > 0) {
|
|
console.error("Scoped log hygiene failed. Use createLogger/createClientLogger instead of console.* in governed files.");
|
|
console.error(violations.join("\n"));
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`Scoped log hygiene passed for ${files.length} files.`);
|