Files
wwjcloud-nest-v1/wwjcloud-nest-v1/tools/fix-import-paths.js
wanwu 1fe757c7be fix: 🐛 修复JSONObject重复导出,达到0编译错误
- 删除 common.types.ts 中重复的 JSONObject 定义
- 保留 util.types.ts 中的 JSONObject 类型定义
- 编译结果: 17,816 错误 → 0 错误 
- 所有模块编译通过
2025-10-27 10:38:44 +08:00

65 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
/**
* 修复所有Service文件中的导入路径
* 将@/types替换为正确的相对路径
*/
const fs = require('fs');
const path = require('path');
class ImportPathFixer {
constructor() {
this.fixedCount = 0;
}
fixFile(filePath) {
let content = fs.readFileSync(filePath, 'utf-8');
const originalContent = content;
// 替换 from '@/types' 为 from '../../types'
content = content.replace(/from\s+['"]@\/types['"]/g, "from '../../types'");
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 ImportPathFixer();
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`);