feat: added a single development cli command
parent
d33a4f25ff
commit
d185e81ab2
@ -0,0 +1,64 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"log"
|
||||
"os/exec"
|
||||
"phc/website/model"
|
||||
"phc/website/services/config"
|
||||
"phc/website/services/database"
|
||||
"phc/website/services/server"
|
||||
"phc/website/sl"
|
||||
)
|
||||
|
||||
func main() {
|
||||
l := sl.New()
|
||||
|
||||
cfg := sl.InjectValue(l, config.Slot, &config.Config{
|
||||
Mode: "development",
|
||||
Host: ":4000",
|
||||
})
|
||||
|
||||
sl.InjectValue[database.Database](l, database.Slot, &database.Memory{
|
||||
Users: []model.User{
|
||||
{
|
||||
Id: "claire",
|
||||
FullName: "Claire Doe",
|
||||
Nickname: "claire-doe",
|
||||
AuthSources: map[string]model.AuthSource{},
|
||||
},
|
||||
{
|
||||
Id: "john",
|
||||
FullName: "John Smith",
|
||||
Nickname: "john-smith",
|
||||
AuthSources: map[string]model.AuthSource{},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
srv, err := server.Configure(l)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
log.Fatal(srv.Router.Listen(cfg.Host))
|
||||
}()
|
||||
|
||||
r, w := io.Pipe()
|
||||
|
||||
cmd := exec.Command("npm", "run", "dev")
|
||||
cmd.Stdout = w
|
||||
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
log.Printf(`[ViteJS] %s`, scanner.Text())
|
||||
}
|
||||
}()
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue