| 12345678910111213141516171819202122232425262728293031323334353637 |
- const fs = require('fs');
- const path = require('path');
- function walkDir(dir, callback) {
- fs.readdirSync(dir).forEach(f => {
- let dirPath = path.join(dir, f);
- let isDirectory = fs.statSync(dirPath).isDirectory();
- if (isDirectory) {
- if (f !== 'node_modules' && f !== '.git' && f !== 'dist' && f !== '.next' && f !== 'build' && f !== 'coverage') {
- walkDir(dirPath, callback);
- }
- } else {
- if (dirPath.endsWith('.ts') || dirPath.endsWith('.tsx') || dirPath.endsWith('.js')) {
- callback(path.join(dir, f));
- }
- }
- });
- }
- const filesWithLogs = [];
- const logRegex = /(console|logger|Logger)\.(log|error|warn|info|debug|verbose)\(([^)]*[\u4e00-\u9fa5]+[^)]*)\)/g;
- walkDir('d:/workspace/AuraK/server', (filePath) => {
- const content = fs.readFileSync(filePath, 'utf8');
- if (logRegex.test(content)) {
- filesWithLogs.push(filePath);
- }
- });
- walkDir('d:/workspace/AuraK/web', (filePath) => {
- const content = fs.readFileSync(filePath, 'utf8');
- if (logRegex.test(content)) {
- filesWithLogs.push(filePath);
- }
- });
- console.log('Found ' + filesWithLogs.length + ' files');
- fs.writeFileSync('d:/workspace/AuraK/files_to_translate.json', JSON.stringify(filesWithLogs, null, 2));
|