From c300772e2e57281bc4d2254c378b85a70fdcfd86 Mon Sep 17 00:00:00 2001 From: Davit Napitupulu Date: Wed, 27 Aug 2025 08:55:12 +0700 Subject: [PATCH] fix: fix customize.ps1 --- customize.ps1 | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/customize.ps1 b/customize.ps1 index 98fee11..6e9fc10 100644 --- a/customize.ps1 +++ b/customize.ps1 @@ -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) { @@ -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 @@ -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 @@ -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 }