source: Add rules for AI Coding

This commit is contained in:
2026-03-09 16:51:44 +07:00
parent 4b7236493f
commit 3003a0ff0b
27 changed files with 2103 additions and 70 deletions

View File

@@ -0,0 +1,67 @@
# PowerShell script to rename the project from MyNewProjectName to a new name
# Usage: .\rename-project.ps1 -NewName "NewProjectName"
param(
[Parameter(Mandatory=$true)]
[string]$NewName
)
$OldName = "MyNewProjectName"
Write-Host "🔄 Renaming project from '$OldName' to '$NewName'..." -ForegroundColor Cyan
# Clean build artifacts first
Write-Host "🧹 Cleaning build artifacts..." -ForegroundColor Yellow
Get-ChildItem -Path . -Include bin,obj -Recurse -Directory | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
# Replace content in files
Write-Host "📝 Replacing content in files..." -ForegroundColor Yellow
$extensions = @("*.cs", "*.csproj", "*.sln", "*.json", "*.xml", "*.md", "*.props", "*.targets", "*.http")
$excludePaths = @("*\bin\*", "*\obj\*", "*\.git\*")
foreach ($ext in $extensions) {
Get-ChildItem -Path . -Filter $ext -Recurse -File |
Where-Object {
$path = $_.FullName
-not ($excludePaths | Where-Object { $path -like $_ })
} |
ForEach-Object {
$content = Get-Content $_.FullName -Raw -ErrorAction SilentlyContinue
if ($content -and $content -match $OldName) {
Write-Host " Updating: $($_.FullName)" -ForegroundColor Gray
$newContent = $content -replace $OldName, $NewName
Set-Content -Path $_.FullName -Value $newContent -NoNewline
}
}
}
# Rename files
Write-Host "📁 Renaming files..." -ForegroundColor Yellow
Get-ChildItem -Path . -Recurse -File |
Where-Object { $_.Name -match $OldName } |
ForEach-Object {
$newFileName = $_.Name -replace $OldName, $NewName
$newPath = Join-Path $_.Directory.FullName $newFileName
Write-Host " Renaming: $($_.Name) -> $newFileName" -ForegroundColor Gray
Rename-Item -Path $_.FullName -NewName $newFileName
}
# Rename directories (from deepest to shallowest)
Write-Host "📁 Renaming directories..." -ForegroundColor Yellow
Get-ChildItem -Path . -Recurse -Directory |
Where-Object { $_.Name -match $OldName } |
Sort-Object { $_.FullName.Length } -Descending |
ForEach-Object {
$newDirName = $_.Name -replace $OldName, $NewName
Write-Host " Renaming: $($_.Name) -> $newDirName" -ForegroundColor Gray
Rename-Item -Path $_.FullName -NewName $newDirName
}
Write-Host ""
Write-Host " Project renamed successfully from '$OldName' to '$NewName'!" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Cyan
Write-Host " 1. Review the changes"
Write-Host " 2. Update your connection string in appsettings.json"
Write-Host " 3. Run 'dotnet restore'"
Write-Host " 4. Run 'dotnet build'"

View File

@@ -0,0 +1,81 @@
#!/bin/bash
# Script to rename the project from MyNewProjectName to a new name
# Usage: ./rename-project.sh NewProjectName
set -e
if [ -z "$1" ]; then
echo "Usage: ./rename-project.sh NewProjectName"
echo "Example: ./rename-project.sh MyAwesomeApp"
exit 1
fi
OLD_NAME="MyNewProjectName"
NEW_NAME="$1"
echo "🔄 Renaming project from '$OLD_NAME' to '$NEW_NAME'..."
# Function to rename files and directories
rename_files() {
# Rename directories (from deepest to shallowest)
find . -depth -type d -name "*${OLD_NAME}*" 2>/dev/null | while read dir; do
new_dir=$(echo "$dir" | sed "s/${OLD_NAME}/${NEW_NAME}/g")
if [ "$dir" != "$new_dir" ]; then
echo " Renaming directory: $dir -> $new_dir"
mv "$dir" "$new_dir"
fi
done
# Rename files
find . -type f -name "*${OLD_NAME}*" 2>/dev/null | while read file; do
new_file=$(echo "$file" | sed "s/${OLD_NAME}/${NEW_NAME}/g")
if [ "$file" != "$new_file" ]; then
echo " Renaming file: $file -> $new_file"
mv "$file" "$new_file"
fi
done
}
# Function to replace content in files
replace_content() {
echo "📝 Replacing content in files..."
# Find all text files and replace content
find . -type f \( \
-name "*.cs" -o \
-name "*.csproj" -o \
-name "*.sln" -o \
-name "*.json" -o \
-name "*.xml" -o \
-name "*.md" -o \
-name "*.props" -o \
-name "*.targets" -o \
-name "*.http" \
\) ! -path "*/bin/*" ! -path "*/obj/*" ! -path "*/.git/*" 2>/dev/null | while read file; do
if grep -q "${OLD_NAME}" "$file" 2>/dev/null; then
echo " Updating: $file"
sed -i "s/${OLD_NAME}/${NEW_NAME}/g" "$file"
fi
done
}
# Clean build artifacts first
echo "🧹 Cleaning build artifacts..."
find . -type d \( -name "bin" -o -name "obj" \) -exec rm -rf {} + 2>/dev/null || true
# Replace content first (before renaming directories)
replace_content
# Then rename files and directories
echo "📁 Renaming files and directories..."
rename_files
echo ""
echo " Project renamed successfully from '$OLD_NAME' to '$NEW_NAME'!"
echo ""
echo "Next steps:"
echo " 1. Review the changes"
echo " 2. Update your connection string in appsettings.json"
echo " 3. Run 'dotnet restore'"
echo " 4. Run 'dotnet build'"

3
rename-project/rename.md Normal file
View File

@@ -0,0 +1,3 @@
Window: .\rename-project.ps1 -NewName "TenDuAnThucTeCuaBan"
Linux: ./rename-project.sh "TenDuAnThucTeCuaBan"