Repository navigation
Expand file tree
/
Copy pathrefactor_usecases.ps1
More file actions
149 lines (123 loc) · 5.24 KB
/
Copy pathrefactor_usecases.ps1
File metadata and controls
149 lines (123 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
$ErrorActionPreference = "Stop"
$basePath = "c:\Users\TehoonAhn\Documents\Depth_kotlin\4th-MainProject-SeatNow-Android\app\src\main\java\com\gmg\seatnow"
$usecasePath = "$basePath\domain\usecase"
$map = @{
"FormatDateUseCase" = "common.logic";
"FormatTimerUseCase" = "common.logic";
"CalculateSpaceInfoUseCase" = "common.logic";
"ValidateEmailUseCase" = "common.validation";
"ValidatePasswordUseCase" = "common.validation";
"CheckTestAccountUseCase" = "common.validation";
"ReissueTokenUseCase" = "common.auth";
"RequestEmailAuthCodeUseCase" = "common.auth";
"RequestPhoneAuthCodeUseCase" = "common.auth";
"VerifyEmailAuthCodeUseCase" = "common.auth";
"VerifyPhoneAuthCodeUseCase" = "common.auth";
"ChangeOwnerPasswordUseCase" = "owner.auth";
"GetOwnerAccountUseCase" = "owner.auth";
"OwnerLoginUseCase" = "owner.auth";
"OwnerLogoutUseCase" = "owner.auth";
"OwnerWithdrawUseCase" = "owner.auth";
"SignUpOwnerUseCase" = "owner.auth";
"VerifyBusinessNumberUseCase" = "owner.auth";
"VerifyOwnerPasswordUseCase" = "owner.auth";
"GetStoreProfileUseCase" = "owner.store";
"UpdateStorePhoneUseCase" = "owner.store";
"DeleteMenuUseCase" = "owner.store";
"FormatMenuCategoryUseCase" = "owner.store";
"GetStoreImagesUseCase" = "owner.store";
"GetStoreOperationInfoUseCase" = "owner.store";
"LimitStorePhotosUseCase" = "owner.store";
"UploadMenuImageUseCase" = "owner.store";
"UploadStoreImagesUseCase" = "owner.store";
"SaveStoreDetailUseCase" = "owner.store";
"UpdateStoreOperationUseCase" = "owner.store";
"UpdateMenuCategoriesUseCase" = "owner.store";
"UpdateMenuOrdersUseCase" = "owner.store";
"UpdateStoreImagesUseCase" = "owner.store";
"UpdateStoreOperationInfoUseCase" = "owner.store";
"CheckScheduleCollisionUseCase" = "owner.store";
"UpdateMenuUseCase" = "owner.store";
"CalculateSeatCountUseCase" = "owner.seat";
"GetSeatConfigurationUseCase" = "owner.seat";
"GetSeatStatusUseCase" = "owner.seat";
"CalculateSeatDisplayUseCase" = "owner.seat";
"UpdateStoreLayoutUseCase" = "owner.seat";
"UpdateTableStatusUseCase" = "owner.seat";
"UpdateSeatUsageUseCase" = "owner.seat";
"UpdateTableCountUseCase" = "owner.seat";
"AutoLoginUseCase" = "user.auth";
"CheckGuestTermsUseCase" = "user.auth";
"CheckIsGuestUseCase" = "user.auth";
"CheckKakaoTermsUseCase" = "user.auth";
"GetSplashDestinationUseCase" = "user.auth";
"GetUserNicknameUseCase" = "user.auth";
"LoginWithKakaoUseCase" = "user.auth";
"SaveGuestTermsUseCase" = "user.auth";
"SaveKakaoTermsUseCase" = "user.auth";
"SaveKakaoUserInfoUseCase" = "user.auth";
"WithdrawUserUseCase" = "user.auth";
"CheckDeveloperModeUseCase" = "user.auth";
"SetDeveloperModeUseCase" = "user.auth";
"GetKeepStoresUseCase" = "user.mypage";
"ToggleKeepStoreUseCase" = "user.mypage";
"GetNearbyUniversityUseCase" = "user.home";
"SearchStoresUseCase" = "user.home";
"ExtractNeighborhoodUseCase" = "user.home";
"ValidateHeadCountUseCase" = "user.home";
"AdjustHeadCountUseCase" = "user.home";
"GetStoresByHeadCountUseCase" = "user.home";
"GetStoresUseCase" = "user.home";
"GetStoreDetailUseCase" = "user.detail";
"GetStoreMenusUseCase" = "user.detail";
"FormatStoreDetailUseCase" = "user.detail";
}
$files = Get-ChildItem -Path $usecasePath -Recurse -Filter "*.kt" | Where-Object { !($_.PSIsContainer) }
$replacements = @()
foreach ($f in $files) {
$name = $f.BaseName
$oldSub = $f.Directory.Name
if ($map.ContainsKey($name)) {
$newSub = $map[$name]
} else {
$newSub = $oldSub # keep it if not mapped
}
$oldImport = "com.gmg.seatnow.domain.usecase.$oldSub.$name"
$newImport = "com.gmg.seatnow.domain.usecase.$newSub.$name"
$newDir = Join-Path $usecasePath $newSub.Replace(".", "\")
if (!(Test-Path $newDir)) {
New-Item -ItemType Directory -Force -Path $newDir | Out-Null
}
$newPath = Join-Path $newDir $f.Name
# Check if we need to do anything
if ($f.FullName -eq $newPath) {
continue
}
# Move file
Move-Item -Path $f.FullName -Destination $newPath
# Add to replacements
$replacements += [PSCustomObject]@{ Old = $oldImport; New = $newImport }
# Update package declaration in the file itself (regex exact match)
$content = Get-Content $newPath -Raw
$oldPkg = "package com.gmg.seatnow.domain.usecase.$oldSub"
$newPkg = "package com.gmg.seatnow.domain.usecase.$newSub"
$content = $content.Replace($oldPkg, $newPkg)
[IO.File]::WriteAllText($newPath, $content)
}
# 2. Update imports globally
$allFiles = Get-ChildItem -Path $basePath -Recurse -Filter "*.kt" | Where-Object { !($_.PSIsContainer) }
foreach ($f in $allFiles) {
if ($f.FullName -like "*\build\*") { continue }
$content = Get-Content $f.FullName -Raw
$modified = $false
foreach ($rep in $replacements) {
if ($content.Contains($rep.Old)) {
$content = $content.Replace($rep.Old, $rep.New)
$modified = $true
}
}
if ($modified) {
[IO.File]::WriteAllText($f.FullName, $content)
}
}
Write-Output "Refactoring completed successfully!"