feat: sync httpdns sdk/platform updates without large binaries
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -112,10 +113,12 @@ func main() {
|
||||
}
|
||||
})
|
||||
app.On("generate", func() {
|
||||
prepareGenerateRoot()
|
||||
|
||||
err := gen.Generate()
|
||||
if err != nil {
|
||||
fmt.Println("generate failed: " + err.Error())
|
||||
return
|
||||
os.Exit(1)
|
||||
}
|
||||
})
|
||||
app.On("dev", func() {
|
||||
@@ -214,3 +217,32 @@ func main() {
|
||||
adminNode.Run()
|
||||
})
|
||||
}
|
||||
|
||||
func prepareGenerateRoot() {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
candidates := []string{
|
||||
wd,
|
||||
filepath.Clean(filepath.Join(wd, "..")),
|
||||
}
|
||||
|
||||
for _, root := range candidates {
|
||||
componentsDir := filepath.Join(root, "web", "public", "js", "components")
|
||||
stat, statErr := os.Stat(componentsDir)
|
||||
if statErr != nil || !stat.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
// In testing mode, generator reads from Tea.Root + "/../web/...",
|
||||
// so keep Root under build dir to make relative path stable.
|
||||
buildRoot := filepath.Join(root, "build")
|
||||
Tea.UpdateRoot(buildRoot)
|
||||
Tea.SetPublicDir(filepath.Join(root, "web", "public"))
|
||||
Tea.SetViewsDir(filepath.Join(root, "web", "views"))
|
||||
Tea.SetTmpDir(filepath.Join(root, "web", "tmp"))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user