gaoluyang
2026-06-29 27cd042df9aca0383a49f3514bc21958dd890912
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env node
import { unlinkSync, readdirSync, statSync } from 'node:fs';
import { join } from 'node:path';
 
const projectRoot = 'D:/beforeProject/yudao-ui-admin-vben/web-antd-standalone';
 
function removePackageJsonFiles(dir) {
  const entries = readdirSync(dir);
  for (const entry of entries) {
    const fullPath = join(dir, entry);
    if (statSync(fullPath).isDirectory()) {
      if (!['node_modules', 'dist', '.git'].includes(entry)) {
        removePackageJsonFiles(fullPath);
      }
    } else if (entry === 'package.json') {
      // 不删除根目录的 package.json
      if (fullPath !== join(projectRoot, 'package.json')) {
        try {
          unlinkSync(fullPath);
          console.log(`Removed: ${fullPath}`);
        } catch (e) {
          console.error(`Failed to remove ${fullPath}: ${e.message}`);
        }
      }
    }
  }
}
 
removePackageJsonFiles(join(projectRoot, 'src/packages'));
removePackageJsonFiles(join(projectRoot, 'src/internal'));
 
console.log('Done!');