kontenhumas-be/update_service_methods.ps1

45 lines
1.2 KiB
PowerShell

# PowerShell script to update service method signatures
# Usage: .\update_service_methods.ps1 <file_path>
param(
[Parameter(Mandatory=$true)]
[string]$FilePath
)
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
exit 1
}
Write-Host "Updating service methods in: $FilePath"
# Create backup
$BackupPath = "$FilePath.backup"
Copy-Item $FilePath $BackupPath
Write-Host "Backup created at: $BackupPath"
# Read file content
$Content = Get-Content $FilePath -Raw
# Update method signatures - replace clientId *uuid.UUID with authToken string
$Patterns = @(
@{
Pattern = 'func \(_i \*(\w+)Service\) (\w+)\(clientId \*uuid\.UUID, '
Replacement = 'func (_i *$1Service) $2(authToken string, '
},
@{
Pattern = 'func \(_i \*(\w+)Service\) (\w+)\(clientId \*uuid\.UUID\) '
Replacement = 'func (_i *$1Service) $2(authToken string) '
}
)
foreach ($Pattern in $Patterns) {
$Content = $Content -replace $Pattern.Pattern, $Pattern.Replacement
}
# Write updated content
Set-Content $FilePath $Content -NoNewline
Write-Host "Service method signatures updated."
Write-Host "Please review the changes and add clientId extraction logic manually."