mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 02:51:34 +00:00
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
//go:build tools
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func main() {
|
|
domainDir := "internal/domain"
|
|
|
|
dirs, err := ioutil.ReadDir(domainDir)
|
|
if err != nil {
|
|
fmt.Println("Error reading domain directory:", err)
|
|
return
|
|
}
|
|
|
|
for _, dir := range dirs {
|
|
if dir.IsDir() {
|
|
repoFilePath := filepath.Join(domainDir, dir.Name(), "repo.go")
|
|
if _, err := os.Stat(repoFilePath); err == nil {
|
|
content, err := ioutil.ReadFile(repoFilePath)
|
|
if err != nil {
|
|
fmt.Printf("Error reading file %s: %v\n", repoFilePath, err)
|
|
continue
|
|
}
|
|
|
|
newContent := strings.Replace(string(content), "domain.Base", "domain.BaseRepository", -1)
|
|
newContent = strings.Replace(newContent, "domain."+strings.Title(dir.Name()), "domain."+strings.Title(dir.Name()), -1)
|
|
|
|
// Fix for names with underscore
|
|
newContent = strings.Replace(newContent, "domain.Copyright_claim", "domain.CopyrightClaim", -1)
|
|
newContent = strings.Replace(newContent, "domain.Email_verification", "domain.EmailVerification", -1)
|
|
newContent = strings.Replace(newContent, "domain.Password_reset", "domain.PasswordReset", -1)
|
|
newContent = strings.Replace(newContent, "domain.User_profile", "domain.UserProfile", -1)
|
|
newContent = strings.Replace(newContent, "domain.User_session", "domain.UserSession", -1)
|
|
|
|
|
|
if err := ioutil.WriteFile(repoFilePath, []byte(newContent), 0644); err != nil {
|
|
fmt.Printf("Error writing file %s: %v\n", repoFilePath, err)
|
|
} else {
|
|
fmt.Printf("Fixed repo %s\n", repoFilePath)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|