download proper tailwind cli
This commit is contained in:
parent
258566822e
commit
797c439244
5 changed files with 37 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ func main() {
|
|||
done := RegisterSignals()
|
||||
|
||||
commandMap := make(map[string]*flag.FlagSet)
|
||||
commands := []string{"template", "run", "watch", "build", "setup", "css", "schema", "generate"}
|
||||
commands := []string{"template", "run", "watch", "build", "setup", "css", "schema", "generate", "tailwind-cli"}
|
||||
|
||||
for _, command := range commands {
|
||||
commandMap[command] = flag.NewFlagSet(command, flag.ExitOnError)
|
||||
|
|
@ -54,7 +54,9 @@ func main() {
|
|||
slog.Debug("Running task:", slog.String("task", taskName))
|
||||
slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir()))
|
||||
|
||||
if taskName == "watch" {
|
||||
if taskName == "tailwind-cli" {
|
||||
_ = css.DownloadTailwindCli()
|
||||
} else if taskName == "watch" {
|
||||
os.Setenv("ENV", "development")
|
||||
os.Setenv("WATCH_MODE", "true")
|
||||
copyassets.CopyAssets()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package css
|
||||
|
||||
import "github.com/maddalax/htmgo/cli/htmgo/tasks/process"
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/maddalax/htmgo/cli/htmgo/tasks/process"
|
||||
"log"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func GenerateCss(flags ...process.RunFlag) error {
|
||||
return process.RunMany([]string{
|
||||
"chmod +x ./assets/css/tailwindcss",
|
||||
"./assets/css/tailwindcss -i ./assets/css/input.css -o ./assets/dist/main.css -c ./assets/css/tailwind.config.js",
|
||||
}, append(flags, process.Silent)...)
|
||||
}
|
||||
|
|
@ -14,3 +18,28 @@ func GenerateCssWatch(flags ...process.RunFlag) error {
|
|||
"./assets/css/tailwindcss -i ./assets/css/input.css -o ./assets/dist/main.css -c ./assets/css/tailwind.config.js --watch=always",
|
||||
}, append(flags, process.KillOnlyOnExit, process.Silent)...)
|
||||
}
|
||||
|
||||
func DownloadTailwindCli() error {
|
||||
distro := ""
|
||||
os := runtime.GOOS
|
||||
arch := runtime.GOARCH
|
||||
switch {
|
||||
case os == "darwin" && arch == "arm64":
|
||||
distro = "macos-arm64"
|
||||
case os == "darwin" && arch == "amd64":
|
||||
distro = "macos-x64"
|
||||
case os == "linux" && arch == "arm64":
|
||||
distro = "linux-arm64"
|
||||
case os == "linux" && arch == "amd64":
|
||||
distro = "linux-x64"
|
||||
default:
|
||||
log.Fatal(fmt.Sprintf("Unsupported OS/ARCH: %s/%s", os, arch))
|
||||
}
|
||||
fileName := fmt.Sprintf(`tailwindcss-%s`, distro)
|
||||
url := fmt.Sprintf(`https://github.com/tailwindlabs/tailwindcss/releases/latest/download/%s`, fileName)
|
||||
return process.RunMany([]string{
|
||||
fmt.Sprintf(`curl -sLO %s`, url),
|
||||
fmt.Sprintf(`chmod +x %s`, fileName),
|
||||
fmt.Sprintf(`mv %s ./assets/css/tailwindcss`, fileName),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import (
|
|||
)
|
||||
|
||||
func Build() {
|
||||
css.DownloadTailwindCli()
|
||||
|
||||
astgen.GenAst(process.ExitOnError)
|
||||
css.GenerateCss(process.ExitOnError)
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue