mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 19:20:34 +07:00
feat & fix: detailed logging & correct path processing
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
"nto_cli/entities"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
@@ -39,8 +40,9 @@ func GenerateScheme(structName string, fields []entities.Field, mkPath string) {
|
||||
Dependencies: processDependencies(fields),
|
||||
}
|
||||
|
||||
fileName := strings.ToUpper(structName[:1]) + strings.ToLower(structName[1:]) + "Scheme.vue"
|
||||
schemeFile, err := os.Create(mkPath + "/" + fileName)
|
||||
schemeFilename := strings.ToUpper(structName[:1]) + strings.ToLower(structName[1:]) + "Scheme.vue"
|
||||
schemeFilePath := filepath.Join(mkPath, schemeFilename)
|
||||
schemeFile, err := os.Create(schemeFilePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create file: %s", err)
|
||||
}
|
||||
@@ -60,6 +62,7 @@ func GenerateScheme(structName string, fields []entities.Field, mkPath string) {
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to execute template: %s", err)
|
||||
}
|
||||
log.Printf("Scheme for `%s` model is written: %s", structName, schemeFilePath)
|
||||
}
|
||||
|
||||
func processDependencies(fields []entities.Field) []Dependency {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
@@ -19,7 +20,8 @@ type ServiceTemplateContext struct {
|
||||
}
|
||||
|
||||
func GenerateService(structName, mkPath string) {
|
||||
serviceFile, err := os.Create(mkPath + "/" + strings.ToLower(structName) + ".service.ts")
|
||||
servicePath := filepath.Join(mkPath, strings.ToLower(structName)+".service.ts")
|
||||
serviceFile, err := os.Create(servicePath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create service file: %s", err)
|
||||
}
|
||||
@@ -47,4 +49,5 @@ func GenerateService(structName, mkPath string) {
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to execute template: %s", err)
|
||||
}
|
||||
log.Printf("Service for `%s` model is written: %s", structName, servicePath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user