- 删除 common.types.ts 中重复的 JSONObject 定义
- 保留 util.types.ts 中的 JSONObject 类型定义
- 编译结果: 17,816 错误 → 0 错误 ✅
- 所有模块编译通过
76 lines
2.6 KiB
JavaScript
76 lines
2.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* 修复比较运算符错误
|
|
* = == → ===
|
|
* = !比 → !==
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
class ComparisonOperatorFixer {
|
|
constructor() {
|
|
this.fixedCount = 0;
|
|
}
|
|
|
|
fixFile(filePath) {
|
|
let content = fs.readFileSync(filePath, 'utf-8');
|
|
const originalContent = content;
|
|
|
|
// 修复 = == → ===
|
|
content = content.replace(/\s+=\s+==\s+/g, ' === ');
|
|
|
|
// 修复 = != → !==
|
|
content = content.replace(/\s+=\s+!=\s+/g, ' !== ');
|
|
|
|
// 修复 !=== 三等号错误(可能之前的工具引入)
|
|
content = content.replace(/!===/g, '!==');
|
|
|
|
// 修复 ====四等号
|
|
content = content.replace(/====/g, '===');
|
|
|
|
if (content !== originalContent) {
|
|
fs.writeFileSync(filePath, content, 'utf-8');
|
|
this.fixedCount++;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
processDirectory(dir) {
|
|
const files = fs.readdirSync(dir);
|
|
|
|
for (const file of files) {
|
|
const fullPath = path.join(dir, file);
|
|
const stat = fs.statSync(fullPath);
|
|
|
|
if (stat.isDirectory()) {
|
|
this.processDirectory(fullPath);
|
|
} else if (file.endsWith('.service.ts')) {
|
|
if (this.fixFile(fullPath)) {
|
|
console.log(`✅ ${path.basename(fullPath)}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 主执行
|
|
console.log('╔══════════════════════════════════════════════════════════════╗');
|
|
console.log('║ 🔧 比较运算符修复工具 ║');
|
|
console.log('╚══════════════════════════════════════════════════════════════╝\n');
|
|
|
|
const fixer = new ComparisonOperatorFixer();
|
|
const servicesDir = '/Users/wanwu/Documents/wanwujie/wwjcloud-nsetjs/wwjcloud-nest-v1/wwjcloud/libs/wwjcloud-core/src/services';
|
|
|
|
console.log('🔄 开始修复...\n');
|
|
fixer.processDirectory(servicesDir);
|
|
|
|
console.log('\n╔══════════════════════════════════════════════════════════════╗');
|
|
console.log('║ 📊 修复统计 ║');
|
|
console.log('╚══════════════════════════════════════════════════════════════╝');
|
|
console.log(`✅ 已修复文件: ${fixer.fixedCount} 个\n`);
|
|
|