mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
change build web
This commit is contained in:
12
build-all.sh
12
build-all.sh
@@ -14,16 +14,20 @@ GOBIN="/usr/local/go/bin/go"
|
|||||||
|
|
||||||
$GOBIN version
|
$GOBIN version
|
||||||
|
|
||||||
$GOBIN run build_web.go
|
|
||||||
|
|
||||||
LDFLAGS="'-s -w'"
|
LDFLAGS="'-s -w'"
|
||||||
FAILURES=""
|
FAILURES=""
|
||||||
ROOT=${PWD}
|
ROOT=${PWD}
|
||||||
OUTPUT="${ROOT}/dist/TorrServer"
|
OUTPUT="${ROOT}/dist/TorrServer"
|
||||||
|
|
||||||
cd "${ROOT}/server"
|
#### Build web
|
||||||
|
echo "Build web"
|
||||||
|
cd "${ROOT}/web"
|
||||||
|
npm run --silent build-js
|
||||||
|
cp ${ROOT}/web/dest/index.html ${ROOT}/server/web/pages/template/pages/
|
||||||
|
|
||||||
$GOBIN clean -i -r -cache --modcache
|
echo "Build server"
|
||||||
|
cd "${ROOT}/server"
|
||||||
|
$GOBIN clean -i -r -cache #--modcache
|
||||||
$GOBIN mod tidy
|
$GOBIN mod tidy
|
||||||
|
|
||||||
BUILD_FLAGS="-ldflags=${LDFLAGS}"
|
BUILD_FLAGS="-ldflags=${LDFLAGS}"
|
||||||
|
|||||||
62
build_web.go
62
build_web.go
@@ -1,62 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
dir, _ := os.Getwd()
|
|
||||||
os.Chdir("web")
|
|
||||||
run("npm", "run", "build-js")
|
|
||||||
os.Chdir(dir)
|
|
||||||
|
|
||||||
run("cp", "web/dest/index.html", "server/web/pages/template/pages/")
|
|
||||||
// compileHtml := "web/dest/"
|
|
||||||
// fs, _ := ioutil.ReadDir(compileHtml)
|
|
||||||
// for _, f := range fs {
|
|
||||||
// if strings.HasSuffix(f.Name(), ".html") {
|
|
||||||
// name := filenameWithoutExtension(f.Name())
|
|
||||||
// fmt.Println("Create template go:", "server/web/pages/template/"+name+"_html.go")
|
|
||||||
// out, err := os.Create("server/web/pages/template/" + name + "_html.go")
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Println("Error create file", err)
|
|
||||||
// os.Exit(1)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fmt.Println("Read html:", compileHtml+f.Name())
|
|
||||||
// buf, err := ioutil.ReadFile(compileHtml + f.Name())
|
|
||||||
// if err != nil {
|
|
||||||
// fmt.Println("Error read file", err)
|
|
||||||
// os.Exit(1)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// fmt.Println("Write template...")
|
|
||||||
// out.Write([]byte("package template \n\nvar " + strings.Title(name) + "Html = []byte{"))
|
|
||||||
// for _, b := range buf {
|
|
||||||
// out.Write([]byte(strconv.Itoa(int(b)) + ", "))
|
|
||||||
// }
|
|
||||||
// out.Write([]byte("}"))
|
|
||||||
// out.Close()
|
|
||||||
//
|
|
||||||
// fmt.Println("go fmt template...")
|
|
||||||
// run("go", "fmt", "server/web/pages/template/"+name+"_html.go")
|
|
||||||
// fmt.Println("Complete OK")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
func run(name string, args ...string) {
|
|
||||||
cmd := exec.Command(name, args...)
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
func filenameWithoutExtension(fn string) string {
|
|
||||||
return strings.TrimSuffix(filepath.Base(fn), path.Ext(fn))
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user