Skip to content

Commit 720f67b

Browse files
fix: fix customize.ps1 (#2)
1 parent d4458a5 commit 720f67b

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

customize.ps1

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ param(
77
[string]$GitHubOrg
88
)
99

10-
Write-Host "🚀 Kotlin Multimodule Template Customization" -ForegroundColor Green
11-
Write-Host "==============================================`n" -ForegroundColor Green
10+
Write-Host "Kotlin Multimodule Template Customization" -ForegroundColor Green
11+
Write-Host "===========================================" -ForegroundColor Green
12+
Write-Host ""
1213

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

2425
# Validate inputs
2526
if (-not $ProjectName -or -not $OrganizationDomain -or -not $GitHubOrg) {
26-
Write-Host "Error: All fields are required" -ForegroundColor Red
27+
Write-Host "Error: All fields are required" -ForegroundColor Red
2728
exit 1
2829
}
2930

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

36-
Write-Host "`n📋 Configuration Summary:" -ForegroundColor Yellow
38+
Write-Host ""
39+
Write-Host "Configuration Summary:" -ForegroundColor Yellow
3740
Write-Host " Project Name: $ProjectName"
3841
Write-Host " Kebab Case: $ProjectNameKebab"
3942
Write-Host " Camel Case: $ProjectNameCamel"
4043
Write-Host " Package Name: $PackageName"
41-
Write-Host " GitHub Org: $GitHubOrg`n"
44+
Write-Host " GitHub Org: $GitHubOrg"
45+
Write-Host ""
4246

4347
$Confirm = Read-Host "Continue with these settings? (y/N)"
4448
if ($Confirm -ne "y" -and $Confirm -ne "Y") {
45-
Write-Host "Customization cancelled" -ForegroundColor Red
49+
Write-Host "Customization cancelled" -ForegroundColor Red
4650
exit 0
4751
}
4852

49-
Write-Host "`n🔄 Starting customization..." -ForegroundColor Green
53+
Write-Host ""
54+
Write-Host "Starting customization..." -ForegroundColor Green
5055

5156
try {
5257
# Update settings.gradle
53-
Write-Host "📝 Updating settings.gradle..."
58+
Write-Host "Updating settings.gradle..."
5459
(Get-Content "settings.gradle") -replace "kotlin-multimodule-template", $ProjectNameKebab | Set-Content "settings.gradle"
5560

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

6166
# Create new package structure
62-
Write-Host "📁 Creating new package structure..."
67+
Write-Host "Creating new package structure..."
6368
$OldPackagePath = "io/programmernewbie/template"
6469

6570
# Service module
@@ -83,7 +88,7 @@ try {
8388
}
8489

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

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

108-
Write-Host "`n✅ Customization completed successfully!" -ForegroundColor Green
109-
Write-Host "`n🔧 Next steps:" -ForegroundColor Yellow
113+
Write-Host ""
114+
Write-Host "Customization completed successfully!" -ForegroundColor Green
115+
Write-Host ""
116+
Write-Host "Next steps:" -ForegroundColor Yellow
110117
Write-Host "1. Build the project: ./gradlew build"
111118
Write-Host "2. Run the application: ./gradlew :springboot-application:bootRun"
112119
Write-Host "3. Test the endpoints: curl http://localhost:8080/api/example/health"
113120
Write-Host "4. Start building your application!"
114-
Write-Host "`n📚 See TEMPLATE_SETUP.md for detailed customization guide"
121+
Write-Host ""
122+
Write-Host "See TEMPLATE_SETUP.md for detailed customization guide"
115123

116124
} catch {
117-
Write-Host "❌ Error during customization: $($_.Exception.Message)" -ForegroundColor Red
125+
$errorMessage = $_.Exception.Message
126+
Write-Host "Error during customization: $errorMessage" -ForegroundColor Red
118127
exit 1
119128
}

0 commit comments

Comments
 (0)