-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpike.go
48 lines (39 loc) · 1.09 KB
/
pike.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"github.com/sashabaranov/pike/pike"
"io/ioutil"
"os"
"path/filepath"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: pike project.yaml")
return
}
projFile := os.Args[1]
content, err := ioutil.ReadFile(projFile)
if err != nil {
fmt.Printf("Error reading project file: %v\n", err)
return
}
proj, err := pike.ProjectFromYAMLString(string(content))
if err != nil {
fmt.Printf("Error unmarshalling yaml: %v\n", err)
return
}
proj.CheckDirectoryNotPresent()
proj.CreateDirectories()
projectDir := proj.AbsolutePath()
protobufFile := fmt.Sprintf("proto/%s.proto", proj.Name)
proj.GenerateProto(filepath.Join(projectDir, protobufFile))
proj.GenerateSQLMigrations(filepath.Join(projectDir, "sql/migrations"))
proj.GenerateGoFiles(filepath.Join(projectDir, proj.Name))
proj.GenerateConfigFiles(filepath.Join(projectDir, "configs"))
proj.GenerateLauncher(filepath.Join(projectDir, "cmd/backend"))
proj.GenerateBinScripts(filepath.Join(projectDir, "bin"))
proj.CompileProtobuf()
proj.RunGoModInit()
proj.RunGoModTidy()
proj.PrintOutro()
}