some fixes
This commit is contained in:
parent
a1a335691d
commit
8e4afbede0
4 changed files with 13 additions and 39 deletions
|
|
@ -7,7 +7,6 @@ require (
|
||||||
github.com/fsnotify/fsnotify v1.7.0
|
github.com/fsnotify/fsnotify v1.7.0
|
||||||
golang.org/x/mod v0.21.0
|
golang.org/x/mod v0.21.0
|
||||||
golang.org/x/net v0.29.0
|
golang.org/x/net v0.29.0
|
||||||
|
golang.org/x/sys v0.25.0
|
||||||
golang.org/x/tools v0.25.0
|
golang.org/x/tools v0.25.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/sys v0.25.0 // indirect
|
|
||||||
|
|
|
||||||
|
|
@ -55,15 +55,18 @@ func main() {
|
||||||
slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir()))
|
slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir()))
|
||||||
|
|
||||||
if taskName == "watch" {
|
if taskName == "watch" {
|
||||||
|
fmt.Printf("Running in watch mode\n")
|
||||||
os.Setenv("ENV", "development")
|
os.Setenv("ENV", "development")
|
||||||
os.Setenv("WATCH_MODE", "true")
|
os.Setenv("WATCH_MODE", "true")
|
||||||
|
fmt.Printf("Starting processes...")
|
||||||
copyassets.CopyAssets()
|
copyassets.CopyAssets()
|
||||||
astgen.GenAst(process.ExitOnError)
|
astgen.GenAst(process.ExitOnError)
|
||||||
css.GenerateCss(process.ExitOnError, process.Silent)
|
css.GenerateCss(process.ExitOnError)
|
||||||
run.EntGenerate()
|
run.EntGenerate()
|
||||||
go func() {
|
go func() {
|
||||||
css.GenerateCssWatch(process.ExitOnError)
|
css.GenerateCssWatch(process.ExitOnError)
|
||||||
}()
|
}()
|
||||||
|
fmt.Printf("Starting server...\n")
|
||||||
go func() {
|
go func() {
|
||||||
_ = run.Server()
|
_ = run.Server()
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
|
|
@ -90,22 +90,18 @@ func downloadTailwindCli() {
|
||||||
}
|
}
|
||||||
fileName := fmt.Sprintf(`tailwindcss-%s`, distro)
|
fileName := fmt.Sprintf(`tailwindcss-%s`, distro)
|
||||||
url := fmt.Sprintf(`https://github.com/tailwindlabs/tailwindcss/releases/latest/download/%s`, fileName)
|
url := fmt.Sprintf(`https://github.com/tailwindlabs/tailwindcss/releases/latest/download/%s`, fileName)
|
||||||
if os == "windows" {
|
process.Run(fmt.Sprintf(`curl -LO %s`, url), process.ExitOnError)
|
||||||
process.RunMany([]string{
|
|
||||||
fmt.Sprintf(`curl -LO %s`, url),
|
|
||||||
}, process.ExitOnError)
|
|
||||||
} else {
|
|
||||||
process.RunMany([]string{
|
|
||||||
fmt.Sprintf(`curl -LO %s`, url),
|
|
||||||
fmt.Sprintf(`chmod +x %s`, fileName),
|
|
||||||
}, process.ExitOnError)
|
|
||||||
}
|
|
||||||
|
|
||||||
outputFileName := GetTailwindExecutableName()
|
outputFileName := GetTailwindExecutableName()
|
||||||
|
newPath := filepath.Join(process.GetWorkingDir(), outputFileName)
|
||||||
|
|
||||||
err := dirutil.MoveFile(
|
err := dirutil.MoveFile(
|
||||||
filepath.Join(process.GetWorkingDir(), fileName),
|
filepath.Join(process.GetWorkingDir(), fileName),
|
||||||
filepath.Join(process.GetWorkingDir(), outputFileName))
|
newPath)
|
||||||
|
|
||||||
|
if os != "windows" {
|
||||||
|
err = process.Run(fmt.Sprintf(`chmod +x %s`, newPath), process.ExitOnError)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error moving file: %s\n", err.Error())
|
log.Fatalf("Error moving file: %s\n", err.Error())
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,9 @@
|
||||||
package h
|
package h
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/maddalax/htmgo/framework/hx"
|
"github.com/maddalax/htmgo/framework/hx"
|
||||||
"github.com/maddalax/htmgo/framework/internal/process"
|
|
||||||
"github.com/maddalax/htmgo/framework/service"
|
"github.com/maddalax/htmgo/framework/service"
|
||||||
"log/slog"
|
|
||||||
"os/exec"
|
|
||||||
"runtime"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RequestContext struct {
|
type RequestContext struct {
|
||||||
|
|
@ -91,27 +85,9 @@ func (a App) start() {
|
||||||
port := ":3000"
|
port := ":3000"
|
||||||
err := a.Echo.Start(port)
|
err := a.Echo.Start(port)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
// If we are in watch mode, just try to kill any processes holding that port
|
|
||||||
// and try again
|
|
||||||
if IsDevelopment() && IsWatchMode() {
|
|
||||||
slog.Info("Port already in use, trying to kill the process and start again")
|
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
cmd := exec.Command("cmd", "/C", fmt.Sprintf(`for /F "tokens=5" %%i in ('netstat -aon ^| findstr :%s') do taskkill /F /PID %%i`, port))
|
|
||||||
cmd.Run()
|
|
||||||
} else {
|
|
||||||
process.RunOrExit(fmt.Sprintf("kill -9 $(lsof -t -i%s)", port))
|
|
||||||
}
|
|
||||||
|
|
||||||
time.Sleep(time.Millisecond * 50)
|
|
||||||
err = a.Echo.Start(port)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HtmlView(c echo.Context, page *Page) error {
|
func HtmlView(c echo.Context, page *Page) error {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue