const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

const SERVICES_DIR = __dirname;

// 需要修复的目录（大写 -> 小写）
const dirsToFix = [
  'AI',
  'Analytics', 
  'Core',
  'Logistics',
  'Product',
  'Business',
  'Infra'
];

console.log('Fixing directory case issues...\n');

dirsToFix.forEach(dirName => {
  const dirPath = path.join(SERVICES_DIR, dirName);
  const lowerDirName = dirName.toLowerCase();
  const lowerDirPath = path.join(SERVICES_DIR, lowerDirName);
  
  if (fs.existsSync(dirPath)) {
    try {
      // 使用PowerShell的Move-Item命令来强制重命名
      const command = `powershell.exe -Command "Move-Item -Path '${dirPath}' -Destination '${lowerDirPath}' -Force"`;
      execSync(command, { stdio: 'inherit' });
      console.log(`Renamed: ${dirName} -> ${lowerDirName}`);
    } catch (error) {
      console.error(`Failed to rename ${dirName}: ${error.message}`);
    }
  } else {
    console.log(`Directory does not exist: ${dirName}`);
  }
});

console.log('\nDone!');
