55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const files = [
|
|
"app/(chat)/api/chat/route.ts",
|
|
"app/(chat)/api/chat/_lib/agent-output.ts",
|
|
"app/(chat)/api/chat/_lib/agent-scene-workflow.ts",
|
|
"app/(chat)/api/chat/_lib/billing.ts",
|
|
"app/(chat)/api/chat/_lib/detail-replacement.ts",
|
|
"app/(chat)/api/chat/_lib/errors.ts",
|
|
"app/(chat)/api/chat/_lib/image-failover.ts",
|
|
"app/(chat)/api/chat/_lib/image-media.ts",
|
|
"app/(chat)/api/chat/_lib/message-preparation.ts",
|
|
"app/(chat)/api/chat/_lib/model-resolver.ts",
|
|
"app/(chat)/api/chat/_lib/persistence.ts",
|
|
"app/(chat)/api/chat/_lib/stream.ts",
|
|
"app/(chat)/api/chat/_lib/video-models.ts",
|
|
"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.`);
|