Fix models name and docs.go
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Ymnuk 2023-08-10 15:37:50 +03:00
parent d02f4c7040
commit 2536a92ecb
7 changed files with 59 additions and 9 deletions

2
.vscode/launch.json vendored
View File

@ -49,7 +49,7 @@
"--outdir-backend",
"../zmap/backend",
"--outdir-frontend",
"dist/frontend"
"../zmap/frontend"
]
}
]

25
lib/backend-fixapi.go Normal file
View File

@ -0,0 +1,25 @@
package lib
import (
"fmt"
"log"
"os"
"regexp"
)
func backendFixApi() {
buff, err := os.ReadFile(fmt.Sprintf("%s/docs/docs.go", AppConfig.OutdirBackend))
if err != nil {
log.Fatal(err)
}
re1 := regexp.MustCompile(`\n[\s\t]{1,100}LeftDelim`)
re2 := regexp.MustCompile(`\n[\s\t]{1,100}RightDelim`)
str := re1.ReplaceAllString(string(buff), "\n // LeftDelim")
str = re2.ReplaceAllString(str, "\n // RightDelim")
if err = os.WriteFile(fmt.Sprintf("%s/docs/docs.go", AppConfig.OutdirBackend), []byte(str), 0755); err != nil {
log.Fatal(err)
}
}

View File

@ -32,6 +32,7 @@ func Backend() {
generateBackendTmpl()
execCommands()
backendFixApi()
}
// Генерирование структуры БД

View File

@ -5,9 +5,10 @@ import (
"log"
"os"
"regexp"
"strings"
)
func fixApi() {
func angularFixApi() {
buff, err := os.ReadFile(fmt.Sprintf("%s/src/app/module/api/encoder.ts", AppConfig.OutdirFrontend))
if err != nil {
log.Fatal(err)
@ -23,12 +24,33 @@ func fixApi() {
}
re3 := regexp.MustCompile(`\s{1,10}protected basePath = '.+';`)
buff, err = os.ReadFile(fmt.Sprintf("%s/src/app/module/api/api/users.service.ts", AppConfig.OutdirFrontend))
/*buff, err = os.ReadFile(fmt.Sprintf("%s/src/app/module/api/api/users.service.ts", AppConfig.OutdirFrontend))
if err != nil {
log.Fatal(err)
}
str = re3.ReplaceAllString(string(buff), "\n protected basePath = '/api';")
if err = os.WriteFile(fmt.Sprintf("%s/src/app/module/api/api/users.service.ts", AppConfig.OutdirFrontend), []byte(str), 0755); err != nil {
log.Fatal(err)
}*/
if files, err := os.ReadDir(fmt.Sprintf("%s/src/app/module/api/api", AppConfig.OutdirFrontend)); err != nil {
log.Fatal(err)
} else {
for _, file := range files {
if file.IsDir() {
continue
}
if strings.Contains(file.Name(), ".service.ts") {
buff, err = os.ReadFile(fmt.Sprintf("%s/src/app/module/api/api/%s", AppConfig.OutdirFrontend, file.Name()))
if err != nil {
log.Fatal(err)
}
str = re3.ReplaceAllString(string(buff), fmt.Sprintf("\n\n protected basePath = '%s';", Project.BasePath))
if err = os.WriteFile(fmt.Sprintf("%s/src/app/module/api/api/%s", AppConfig.OutdirFrontend, file.Name()), []byte(str), 0755); err != nil {
log.Fatal(err)
}
}
}
}
}

View File

@ -129,10 +129,6 @@ func generateFrontendAngularTmpl() {
FileIn: "tmpl/frontend/angular/src/app/app.component.ts.tmpl",
FileOut: filepath.Join(AppConfig.OutdirFrontend, "src", "app", "app.component.ts"),
},
{
FileIn: "tmpl/frontend/angular/src/app/app.module.ts.tmpl",
FileOut: filepath.Join(AppConfig.OutdirFrontend, "src", "app", "app.module.ts"),
},
{
FileIn: "tmpl/frontend/angular/src/assets/gitkeep.tmpl",
FileOut: filepath.Join(AppConfig.OutdirFrontend, "src", "assets", ".gitkeep"),
@ -203,6 +199,11 @@ func generateFrontendAngularTmpl() {
FileOut: filepath.Join(AppConfig.OutdirFrontend, "swagger-codegen-cli-2.4.32.jar"),
},
}
/*{
FileIn: "tmpl/frontend/angular/src/app/app.module.ts.tmpl",
FileOut: filepath.Join(AppConfig.OutdirFrontend, "src", "app", "app.module.ts"),
},*/
templ.PrepareTmplIsNotExists("tmpl/frontend/angular/src/app/app.module.ts.tmpl", Project, filepath.Join(AppConfig.OutdirFrontend, "src", "app", "app.module.ts"))
if len(staticTmpls) > 0 {
for _, staticTmpl := range staticTmpls {

View File

@ -11,7 +11,7 @@ func Frontend() {
case "angular":
generateFrontendAngularTmpl()
execCommandsFrontendAngular()
fixApi()
angularFixApi()
default:
log.Fatalf("Unknow param lang in frontend \"%s\"", Project.Frontend.Lang)
}

View File

@ -111,7 +111,8 @@ func FieldDBName(field *structs.Field) (res string) {
if res == "" {
log.Fatal("Shoudl be set name for field")
}
res = strings.ToLower(res)
//res = strings.ToLower(res)
res = FieldNameLowerPrepare(res)
return
}