erp-platform/configs/rename-solutions.ps1
2025-11-11 22:41:32 +03:00

79 lines
3.7 KiB
PowerShell
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# =====================================================
# Tüm projede Kurs -> Erp dönüştürme scripti
# (Klasör, dosya, namespace, sln, csproj, json vs.)
# =====================================================
$basePath = "D:\Sozsoft\kurs-platform\api"
$oldPrefixes = @("Kurs.Platform", "Kurs.")
$newPrefixes = @("Erp.Platform", "Erp.")
Write-Host "=====================================================" -ForegroundColor Cyan
Write-Host "KURS → ERP TAM DÖNÜŞÜM BAŞLATILDI" -ForegroundColor Cyan
Write-Host "Kök dizin: $basePath"
Write-Host "=====================================================" -ForegroundColor Cyan
Write-Host ""
foreach ($i in 0..($oldPrefixes.Count - 1)) {
$old = $oldPrefixes[$i]
$new = $newPrefixes[$i]
Write-Host "🔹 Değişim: $old$new" -ForegroundColor Yellow
# 1⃣ Namespace, using ve genel metin dosyalarındaki içerik değişimi
Write-Host "➡ Metin tabanlı dosyalarda içerik güncelleniyor..." -ForegroundColor Yellow
$textExtensions = @("*.cs","*.csproj","*.sln","*.json","*.props","*.xml","*.config","*.dockerfile","*.md","*.ps1","*.yml","*.yaml")
Get-ChildItem -Path $basePath -Recurse -Include $textExtensions -ErrorAction SilentlyContinue | ForEach-Object {
try {
$content = Get-Content $_.FullName -Raw
$updated = $content.Replace($old, $new)
if ($content -ne $updated) {
$updated | Set-Content -Path $_.FullName -Force -Encoding UTF8
Write-Host "✔ İçerik güncellendi: $($_.FullName)" -ForegroundColor Green
}
}
catch {
Write-Host "⚠ Dosya atlandı (kilitli): $($_.FullName)" -ForegroundColor Yellow
}
}
# 2⃣ Dosya adlarını güncelle
Write-Host "➡ Dosya adları güncelleniyor..." -ForegroundColor Yellow
Get-ChildItem -Path $basePath -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "$($old)*" } | ForEach-Object {
$newName = $_.Name.Replace($old, $new)
try {
Rename-Item -Path $_.FullName -NewName $newName -ErrorAction Stop
Write-Host "✔ Dosya adı değişti: $($_.Name) -> $newName" -ForegroundColor Cyan
}
catch {
Write-Host "⚠ Dosya atlandı: $($_.Name)" -ForegroundColor Yellow
}
}
# 3⃣ Klasör adlarını değiştir (gerçek rename)
Write-Host "➡ Klasör adları değiştiriliyor..." -ForegroundColor Yellow
Get-ChildItem -Path $basePath -Directory -Recurse -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | ForEach-Object {
$folderName = Split-Path $_.FullName -Leaf
if ($folderName -like "$($old)*") {
$newName = $folderName.Replace($old, $new)
$parent = Split-Path $_.FullName -Parent
$targetPath = Join-Path $parent $newName
try {
if (-not (Test-Path $targetPath)) {
Move-Item -Path $_.FullName -Destination $targetPath -Force
Write-Host "✔ Klasör yeniden adlandırıldı: $folderName -> $newName" -ForegroundColor Magenta
}
else {
Write-Host "⚠ Atlandı (hedef zaten var): $targetPath" -ForegroundColor Yellow
}
}
catch {
Write-Host "⚠ Klasör atlandı: $folderName" -ForegroundColor Red
}
}
}
}
Write-Host ""
Write-Host "=====================================================" -ForegroundColor Cyan
Write-Host "✅ TÜM DÖNÜŞÜM TAMAMLANDI — KURS → ERP" -ForegroundColor Green
Write-Host "=====================================================" -ForegroundColor Cyan