Files
wwjcloud-nest-v1/admin/scripts/clean.mjs
万物街 1cd5d3bdef feat: 完成 NestJS 后端核心底座开发 (M1-M6) 和 Ant Design Vue 前端迁移
主要更新:
1. 后端核心底座完成 (M1-M6):
   - 健康检查、指标监控、分布式锁
   - 事件总线、队列系统、事务管理
   - 安全守卫、多租户隔离、存储适配器
   - 审计日志、配置管理、多语言支持

2. 前端迁移到 Ant Design Vue:
   - 从 Element Plus 迁移到 Ant Design Vue
   - 完善 system 模块 (role/menu/dept)
   - 修复依赖和配置问题

3. 文档完善:
   - AI 开发工作流文档
   - 架构约束和开发规范
   - 项目进度跟踪

4. 其他改进:
   - 修复编译错误和类型问题
   - 完善测试用例
   - 优化项目结构
2025-08-27 11:24:22 +08:00

57 lines
1.7 KiB
JavaScript

import { promises as fs } from 'node:fs';
import { join, normalize } from 'node:path';
const rootDir = process.cwd();
/**
* 递归查找并删除目标目录
* @param {string} currentDir - 当前遍历的目录路径
* @param {string[]} targets - 要删除的目标列表
*/
async function cleanTargetsRecursively(currentDir, targets) {
const items = await fs.readdir(currentDir);
for (const item of items) {
try {
const itemPath = normalize(join(currentDir, item));
const stat = await fs.lstat(itemPath);
if (targets.includes(item)) {
// 匹配到目标目录或文件时直接删除
await fs.rm(itemPath, { force: true, recursive: true });
console.log(`Deleted: ${itemPath}`);
} else if (stat.isDirectory()) {
// 只对目录进行递归处理
await cleanTargetsRecursively(itemPath, targets);
}
} catch (error) {
console.error(
`Error handling item ${item} in ${currentDir}: ${error.message}`,
);
}
}
}
(async function startCleanup() {
// 要删除的目录及文件名称
const targets = ['node_modules', 'dist', '.turbo', 'dist.zip'];
const deleteLockFile = process.argv.includes('--del-lock');
const cleanupTargets = [...targets];
if (deleteLockFile) {
cleanupTargets.push('pnpm-lock.yaml');
}
console.log(
`Starting cleanup of targets: ${cleanupTargets.join(', ')} from root: ${rootDir}`,
);
try {
await cleanTargetsRecursively(rootDir, cleanupTargets);
console.log('Cleanup process completed successfully.');
} catch (error) {
console.error(`Unexpected error during cleanup: ${error.message}`);
process.exit(1);
}
})();