80 lines
3.8 KiB
PowerShell
80 lines
3.8 KiB
PowerShell
# Enhanced script to remove client_id usage from remaining files
|
|
Write-Host "Starting enhanced client_id removal process..." -ForegroundColor Green
|
|
|
|
# List of files that still have client_id usage
|
|
$problemFiles = @(
|
|
"app/module/custom_static_pages/repository/custom_static_pages.repository.go",
|
|
"app/module/article_files/repository/article_files.repository.go",
|
|
"app/module/article_comments/repository/article_comments.repository.go",
|
|
"app/module/article_categories/repository/article_categories.repository.go",
|
|
"app/module/articles/repository/articles.repository.go",
|
|
"app/module/advertisement/repository/advertisement.repository.go",
|
|
"app/module/activity_logs/repository/activity_logs.repository.go",
|
|
"app/module/users/service/users.service.go",
|
|
"app/module/subscription/repository/subscription.repository.go",
|
|
"app/module/subscription/controller/subscription.controller.go",
|
|
"app/module/subscription/service/subscription.service.go",
|
|
"app/module/magazines/controller/magazines.controller.go",
|
|
"app/module/magazines/repository/magazines.repository.go",
|
|
"app/module/magazines/service/magazines.service.go",
|
|
"app/module/users/controller/users.controller.go",
|
|
"app/module/feedbacks/service/feedbacks.service.go",
|
|
"app/module/feedbacks/repository/feedbacks.repository.go",
|
|
"app/module/feedbacks/controller/feedbacks.controller.go"
|
|
)
|
|
|
|
foreach ($filePath in $problemFiles) {
|
|
if (Test-Path $filePath) {
|
|
Write-Host "Processing: $filePath" -ForegroundColor Yellow
|
|
|
|
$content = Get-Content $filePath -Raw
|
|
|
|
# More aggressive replacements
|
|
$content = $content -replace 'clientId \*uuid\.UUID,?\s*', ''
|
|
$content = $content -replace 'clientId \*uuid\.UUID\s*,?\s*', ''
|
|
$content = $content -replace 'clientId \*uuid\.UUID\s*', ''
|
|
|
|
# Remove clientId assignments
|
|
$content = $content -replace 'clientId := middleware\.GetClientID\(c\)\s*\n\s*', ''
|
|
$content = $content -replace 'clientId := middleware\.GetClientID\(c\)', ''
|
|
|
|
# Remove clientId from function calls - be more specific
|
|
$content = $content -replace '\(clientId,', '('
|
|
$content = $content -replace ', clientId\)', ')'
|
|
$content = $content -replace '\(clientId\)', '()'
|
|
|
|
# Remove client_id filters
|
|
$content = $content -replace 'if clientId != nil \{\s*\n\s*query = query\.Where\("client_id = \?", clientId\)\s*\n\s*\}', ''
|
|
$content = $content -replace 'if clientId != nil \{\s*\n\s*query\.Where\("client_id = \?", clientId\)\s*\n\s*\}', ''
|
|
|
|
# Remove clientId logging
|
|
$content = $content -replace '_i\.Log\.Info\(\)\.Interface\("clientId", clientId\)\.Msg\(""\)\s*\n\s*', ''
|
|
|
|
# Remove clientId comments
|
|
$content = $content -replace '// Add ClientId filter\s*\n', ''
|
|
$content = $content -replace '// Get ClientId from context\s*\n', ''
|
|
|
|
# Clean up function signatures
|
|
$content = $content -replace ',\s*,', ','
|
|
$content = $content -replace '\(\s*,', '('
|
|
$content = $content -replace ',\s*\)', ')'
|
|
$content = $content -replace '\(\s*\)', '()'
|
|
|
|
# Remove unused imports
|
|
if ($content -notmatch 'uuid\.') {
|
|
$content = $content -replace '"github\.com/google/uuid"\s*\n', ''
|
|
$content = $content -replace 'github\.com/google/uuid\s*\n', ''
|
|
}
|
|
|
|
if ($content -notmatch 'middleware\.') {
|
|
$content = $content -replace '"narasi-ahli-be/app/middleware"\s*\n', ''
|
|
$content = $content -replace 'narasi-ahli-be/app/middleware\s*\n', ''
|
|
}
|
|
|
|
# Write back to file
|
|
Set-Content -Path $filePath -Value $content -NoNewline
|
|
}
|
|
}
|
|
|
|
Write-Host "Enhanced client ID removal process completed!" -ForegroundColor Green
|