#!/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!');
|