56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package lib
|
|
|
|
import (
|
|
"log"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"git.ymnuktech.ru/ymnuk/yt-gen-app/lib/templ"
|
|
)
|
|
|
|
func execCommands() {
|
|
if AppConfig.OutdirBackend != "" {
|
|
cmd := exec.Command("go", "mod", "init", Project.Name)
|
|
cmd.Dir = filepath.Join(AppConfig.OutdirBackend)
|
|
cmd.Output()
|
|
if cmd.Err != nil {
|
|
log.Fatal(cmd.Err)
|
|
}
|
|
|
|
if buff, err := templ.Content.ReadFile("tmpl/backend/go-list-module.txt"); err != nil {
|
|
log.Fatal(err)
|
|
} else {
|
|
strs := strings.Split(string(buff), "\n")
|
|
if Project.DB.SQLite {
|
|
strs = append(strs, "gorm.io/driver/sqlite")
|
|
}
|
|
if len(strs) > 0 {
|
|
for _, str := range strs {
|
|
cmd := exec.Command("go", "get", str)
|
|
cmd.Dir = filepath.Join(AppConfig.OutdirBackend)
|
|
cmd.Output()
|
|
if cmd.Err != nil {
|
|
log.Fatal(cmd.Err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cmd = exec.Command("go", "install", "github.com/swaggo/swag/cmd/swag@latest")
|
|
cmd.Dir = filepath.Join(AppConfig.OutdirBackend)
|
|
cmd.Output()
|
|
if cmd.Err != nil {
|
|
log.Fatal(cmd.Err)
|
|
}
|
|
|
|
cmd = exec.Command("swag", "init")
|
|
cmd.Dir = filepath.Join(AppConfig.OutdirBackend)
|
|
cmd.Output()
|
|
if cmd.Err != nil {
|
|
log.Fatal(cmd.Err)
|
|
}
|
|
}
|
|
|
|
}
|