This commit is contained in:
maddalax 2024-09-21 13:20:34 -05:00
parent f482f8f88a
commit 8a8844c6a3
3 changed files with 11 additions and 11 deletions

View file

@ -54,9 +54,7 @@ func main() {
slog.Debug("Running task:", slog.String("task", taskName)) slog.Debug("Running task:", slog.String("task", taskName))
slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir())) slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir()))
if taskName == "tailwind-cli" { if taskName == "watch" {
_ = css.DownloadTailwindCli()
} else if taskName == "watch" {
os.Setenv("ENV", "development") os.Setenv("ENV", "development")
os.Setenv("WATCH_MODE", "true") os.Setenv("WATCH_MODE", "true")
copyassets.CopyAssets() copyassets.CopyAssets()
@ -71,18 +69,18 @@ func main() {
}() }()
startWatcher(reloader.OnFileChange) startWatcher(reloader.OnFileChange)
} else { } else {
if taskName == "schema" { if taskName == "tailwind-cli" {
css.DownloadTailwindCli()
} else if taskName == "schema" {
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter entity name:") fmt.Print("Enter entity name:")
text, _ := reader.ReadString('\n') text, _ := reader.ReadString('\n')
text = strings.TrimSuffix(text, "\n") text = strings.TrimSuffix(text, "\n")
run.EntNewSchema(text) run.EntNewSchema(text)
} } else if taskName == "generate" {
if taskName == "generate" {
run.EntGenerate() run.EntGenerate()
astgen.GenAst(process.ExitOnError) astgen.GenAst(process.ExitOnError)
} } else if taskName == "setup" {
if taskName == "setup" {
run.Setup() run.Setup()
} else if taskName == "css" { } else if taskName == "css" {
_ = css.GenerateCss(process.ExitOnError) _ = css.GenerateCss(process.ExitOnError)

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/maddalax/htmgo/cli/htmgo/tasks/process" "github.com/maddalax/htmgo/cli/htmgo/tasks/process"
"log" "log"
"log/slog"
"runtime" "runtime"
) )
@ -19,7 +20,7 @@ func GenerateCssWatch(flags ...process.RunFlag) error {
}, append(flags, process.KillOnlyOnExit, process.Silent)...) }, append(flags, process.KillOnlyOnExit, process.Silent)...)
} }
func DownloadTailwindCli() error { func DownloadTailwindCli() {
distro := "" distro := ""
os := runtime.GOOS os := runtime.GOOS
arch := runtime.GOARCH arch := runtime.GOARCH
@ -37,9 +38,11 @@ func DownloadTailwindCli() error {
} }
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)
return process.RunMany([]string{ process.RunMany([]string{
fmt.Sprintf(`curl -LO %s`, url), fmt.Sprintf(`curl -LO %s`, url),
fmt.Sprintf(`chmod +x %s`, fileName), fmt.Sprintf(`chmod +x %s`, fileName),
fmt.Sprintf(`mv %s ./assets/css/tailwindcss`, fileName), fmt.Sprintf(`mv %s ./assets/css/tailwindcss`, fileName),
}, process.ExitOnError) }, process.ExitOnError)
slog.Debug("Successfully downloaded Tailwind CLI", slog.String("url", url))
} }

View file

@ -18,7 +18,6 @@ RUN go mod download
COPY . . COPY . .
# Build the Go binary for Linux # Build the Go binary for Linux
RUN GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest tailwind-cli
RUN GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest build RUN GOPRIVATE=github.com/maddalax LOG_LEVEL=debug go run github.com/maddalax/htmgo/cli/htmgo@latest build
# Stage 2: Create the smallest possible image # Stage 2: Create the smallest possible image