add build command, upgrade dep
This commit is contained in:
parent
9e5d8edada
commit
7f056b1d5e
6 changed files with 53 additions and 13 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/maddalax/htmgo/cli/tasks/astgen"
|
"github.com/maddalax/htmgo/cli/tasks/astgen"
|
||||||
|
|
@ -61,23 +62,29 @@ func main() {
|
||||||
copyassets.CopyAssets()
|
copyassets.CopyAssets()
|
||||||
_ = astgen.GenAst(true)
|
_ = astgen.GenAst(true)
|
||||||
_ = css.GenerateCss(true)
|
_ = css.GenerateCss(true)
|
||||||
}
|
} else if taskName == "css" {
|
||||||
if taskName == "css" {
|
|
||||||
_ = css.GenerateCss(true)
|
_ = css.GenerateCss(true)
|
||||||
}
|
} else if taskName == "ast" {
|
||||||
if taskName == "ast" {
|
|
||||||
_ = astgen.GenAst(true)
|
_ = astgen.GenAst(true)
|
||||||
}
|
} else if taskName == "run" {
|
||||||
if taskName == "run" {
|
|
||||||
_ = astgen.GenAst(true)
|
_ = astgen.GenAst(true)
|
||||||
_ = css.GenerateCss(true)
|
_ = css.GenerateCss(true)
|
||||||
_ = run.Server(true)
|
_ = run.Server(true)
|
||||||
|
} else if taskName == "template" {
|
||||||
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
fmt.Print("What would you like to call your new app?: ")
|
||||||
|
text, _ := reader.ReadString('\n')
|
||||||
|
text = strings.TrimSuffix(text, "\n")
|
||||||
|
text = strings.ReplaceAll(text, " ", "-")
|
||||||
|
text = strings.ToLower(text)
|
||||||
|
downloadtemplate.DownloadTemplate(fmt.Sprintf("./%s", text))
|
||||||
|
} else if taskName == "build" {
|
||||||
|
run.Build()
|
||||||
|
} else {
|
||||||
|
fmt.Println(fmt.Sprintf("Usage: htmgo [%s]", strings.Join(commands, " | ")))
|
||||||
}
|
}
|
||||||
if taskName == "template" {
|
os.Exit(1)
|
||||||
downloadtemplate.DownloadTemplate("./my-app")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<-done
|
<-done
|
||||||
fmt.Println("Cleanup complete. Exiting.")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ func DownloadTemplate(outPath string) {
|
||||||
|
|
||||||
fmt.Println("Template downloaded successfully.")
|
fmt.Println("Template downloaded successfully.")
|
||||||
fmt.Println("To start the development server, run the following commands:")
|
fmt.Println("To start the development server, run the following commands:")
|
||||||
fmt.Printf("cd %s && htmgo run\n", outPath)
|
fmt.Printf("cd %s && htmgo watch\n", outPath)
|
||||||
|
|
||||||
fmt.Printf("To build the project, run the following command:\n")
|
fmt.Printf("To build the project, run the following command:\n")
|
||||||
fmt.Printf("cd %s && htmgo build\n", outPath)
|
fmt.Printf("cd %s && htmgo build\n", outPath)
|
||||||
|
|
|
||||||
17
cli/tasks/run/build.go
Normal file
17
cli/tasks/run/build.go
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
package run
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/maddalax/htmgo/cli/tasks/astgen"
|
||||||
|
"github.com/maddalax/htmgo/cli/tasks/css"
|
||||||
|
"github.com/maddalax/htmgo/cli/tasks/process"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Build() {
|
||||||
|
astgen.GenAst(true)
|
||||||
|
css.GenerateCss(true)
|
||||||
|
process.RunOrExit("rm -rf ./dist")
|
||||||
|
process.RunOrExit("mkdir -p ./dist/assets/dist")
|
||||||
|
process.RunOrExit("cp -r ./assets/dist/* ./dist/assets/dist/")
|
||||||
|
process.RunOrExit("go build -o \"./dist\" .")
|
||||||
|
process.RunOrExit("echo \"Build successful\"")
|
||||||
|
}
|
||||||
16
starter-template/Taskfile.yml
Normal file
16
starter-template/Taskfile.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
run:
|
||||||
|
cmds:
|
||||||
|
- go run github.com/maddalax/htmgo/cli@latest run
|
||||||
|
silent: true
|
||||||
|
|
||||||
|
build:
|
||||||
|
cmds:
|
||||||
|
- go run github.com/maddalax/htmgo/cli@latest build
|
||||||
|
|
||||||
|
watch:
|
||||||
|
cmds:
|
||||||
|
- go run github.com/maddalax/htmgo/cli@latest watch
|
||||||
|
silent: true
|
||||||
|
|
@ -4,7 +4,7 @@ go 1.23.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gofiber/fiber/v2 v2.52.5
|
github.com/gofiber/fiber/v2 v2.52.5
|
||||||
github.com/maddalax/htmgo/framework v0.0.0-20240914010415-2397bf9fb057
|
github.com/maddalax/htmgo/framework v0.0.0-20240916224719-9e5d8edada65
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func IndexPage(c *fiber.Ctx) *h.Page {
|
||||||
|
|
||||||
func Button() h.Renderable {
|
func Button() h.Renderable {
|
||||||
return h.Button(h.Class("btn bg-slate-500 p-4 rounded text-white"),
|
return h.Button(h.Class("btn bg-slate-500 p-4 rounded text-white"),
|
||||||
h.Text("Click here use my ytes"),
|
h.Text("Ctest"),
|
||||||
h.AfterRequest(
|
h.AfterRequest(
|
||||||
h.SetDisabled(true),
|
h.SetDisabled(true),
|
||||||
h.RemoveClass("bg-red-600"),
|
h.RemoveClass("bg-red-600"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue