Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions customize.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ param(
[string]$GitHubOrg
)

Write-Host "🚀 Kotlin Multimodule Template Customization" -ForegroundColor Green
Write-Host "==============================================`n" -ForegroundColor Green
Write-Host "Kotlin Multimodule Template Customization" -ForegroundColor Green
Write-Host "===========================================" -ForegroundColor Green
Write-Host ""

# Get user input if not provided as parameters
if (-not $ProjectName) {
Expand All @@ -23,43 +24,47 @@ if (-not $GitHubOrg) {

# Validate inputs
if (-not $ProjectName -or -not $OrganizationDomain -or -not $GitHubOrg) {
Write-Host "Error: All fields are required" -ForegroundColor Red
Write-Host "Error: All fields are required" -ForegroundColor Red
exit 1
}

# Convert project name to appropriate formats
$ProjectNameKebab = $ProjectName.ToLower() -replace '[^a-z0-9]', '-' -replace '--+', '-' -replace '^-|-$', ''
$ProjectNameCamel = (Get-Culture).TextInfo.ToTitleCase($ProjectName -replace '[^a-zA-Z0-9]', ' ') -replace ' ', ''
$ProjectNameWords = $ProjectName -replace '[^a-zA-Z0-9]', ' '
$ProjectNameCamel = (Get-Culture).TextInfo.ToTitleCase($ProjectNameWords) -replace ' ', ''
$PackageName = "$OrganizationDomain.$ProjectNameKebab"
$PackagePath = $PackageName -replace '\.', '/'

Write-Host "`n📋 Configuration Summary:" -ForegroundColor Yellow
Write-Host ""
Write-Host "Configuration Summary:" -ForegroundColor Yellow
Write-Host " Project Name: $ProjectName"
Write-Host " Kebab Case: $ProjectNameKebab"
Write-Host " Camel Case: $ProjectNameCamel"
Write-Host " Package Name: $PackageName"
Write-Host " GitHub Org: $GitHubOrg`n"
Write-Host " GitHub Org: $GitHubOrg"
Write-Host ""

$Confirm = Read-Host "Continue with these settings? (y/N)"
if ($Confirm -ne "y" -and $Confirm -ne "Y") {
Write-Host "Customization cancelled" -ForegroundColor Red
Write-Host "Customization cancelled" -ForegroundColor Red
exit 0
}

Write-Host "`n🔄 Starting customization..." -ForegroundColor Green
Write-Host ""
Write-Host "Starting customization..." -ForegroundColor Green

try {
# Update settings.gradle
Write-Host "📝 Updating settings.gradle..."
Write-Host "Updating settings.gradle..."
(Get-Content "settings.gradle") -replace "kotlin-multimodule-template", $ProjectNameKebab | Set-Content "settings.gradle"

# Update root build.gradle
Write-Host "📝 Updating root build.gradle..."
Write-Host "Updating root build.gradle..."
(Get-Content "build.gradle") -replace "io\.programmernewbie\.template", $PackageName | Set-Content "build.gradle"
(Get-Content "build.gradle") -replace "programmer-newbie-code/kotlin-multimodule-template", "$GitHubOrg/$ProjectNameKebab" | Set-Content "build.gradle"

# Create new package structure
Write-Host "📁 Creating new package structure..."
Write-Host "Creating new package structure..."
$OldPackagePath = "io/programmernewbie/template"

# Service module
Expand All @@ -83,7 +88,7 @@ try {
}

# Update package declarations in Kotlin files
Write-Host "📝 Updating package declarations..."
Write-Host "Updating package declarations..."
Get-ChildItem -Path . -Filter "*.kt" -Recurse | ForEach-Object {
(Get-Content $_.FullName) -replace "package io\.programmernewbie\.template", "package $PackageName" | Set-Content $_.FullName
(Get-Content $_.FullName) -replace "import io\.programmernewbie\.template", "import $PackageName" | Set-Content $_.FullName
Expand All @@ -101,19 +106,23 @@ try {
}

# Remove old package directories
Write-Host "🧹 Cleaning up old package structure..."
Write-Host "Cleaning up old package structure..."
Remove-Item "service-module/src/main/kotlin/$OldPackagePath" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "springboot-application/src/main/kotlin/$OldPackagePath" -Recurse -Force -ErrorAction SilentlyContinue

Write-Host "`n✅ Customization completed successfully!" -ForegroundColor Green
Write-Host "`n🔧 Next steps:" -ForegroundColor Yellow
Write-Host ""
Write-Host "Customization completed successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host "1. Build the project: ./gradlew build"
Write-Host "2. Run the application: ./gradlew :springboot-application:bootRun"
Write-Host "3. Test the endpoints: curl http://localhost:8080/api/example/health"
Write-Host "4. Start building your application!"
Write-Host "`n📚 See TEMPLATE_SETUP.md for detailed customization guide"
Write-Host ""
Write-Host "See TEMPLATE_SETUP.md for detailed customization guide"

} catch {
Write-Host "❌ Error during customization: $($_.Exception.Message)" -ForegroundColor Red
$errorMessage = $_.Exception.Message
Write-Host "Error during customization: $errorMessage" -ForegroundColor Red
exit 1
}
Loading