css working

This commit is contained in:
maddalax 2024-09-13 20:50:24 -05:00
parent 2af5809e33
commit 9423171ef8
4 changed files with 35 additions and 7 deletions

View file

@ -93,19 +93,26 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
assetDir := fmt.Sprintf("%s/go/pkg/mod/%s@%s/assets/dist", dirname, modulePath, version)
assetDir := fmt.Sprintf("%s/go/pkg/mod/%s@%s/assets", dirname, modulePath, version)
assetDistDir := fmt.Sprintf("%s/dist", assetDir)
assetCssDir := fmt.Sprintf("%s/css", assetDir)
cwd, err := os.Getwd() cwd, err := os.Getwd()
if err != nil { if err != nil {
log.Fatal("failed to get cwd") log.Fatal("failed to get cwd")
} }
destDir := fmt.Sprintf("%s/assets/dist", cwd) destDir := fmt.Sprintf("%s/assets", cwd)
destDirDist := fmt.Sprintf("%s/dist", destDir)
destDirCss := fmt.Sprintf("%s/css", destDir)
err = copyDir(assetDir, destDir) err = copyDir(assetDistDir, destDirDist)
err = copyDir(assetCssDir, destDirCss)
if err != nil { if err != nil {
log.Fatal(err.Error()) log.Fatalf("Error: %v", err)
} }
fmt.Printf("successfully copied assets to %s\n", destDir) fmt.Printf("successfully copied assets to %s\n", destDir)

View file

@ -1,3 +1,5 @@
module github.com/maddalax/htmgo/framework/tooling/copyassets module github.com/maddalax/htmgo/framework/tooling/copyassets
go 1.23.0 go 1.23.0
require golang.org/x/mod v0.21.0

View file

@ -20,6 +20,8 @@ tasks:
dir: '{{.USER_WORKING_DIR}}' dir: '{{.USER_WORKING_DIR}}'
- task: ast - task: ast
dir: '{{.USER_WORKING_DIR}}' dir: '{{.USER_WORKING_DIR}}'
- task: css
dir: '{{.USER_WORKING_DIR}}'
run: run:
dir: '{{.USER_WORKING_DIR}}' dir: '{{.USER_WORKING_DIR}}'
@ -46,6 +48,15 @@ tasks:
cmds: cmds:
- go run github.com/maddalax/htmgo/framework/tooling/copyassets@latest - go run github.com/maddalax/htmgo/framework/tooling/copyassets@latest
css:
dir: '{{.USER_WORKING_DIR}}'
desc: Generate CSS from source code
generates:
- '**/main.css'
cmds:
- chmod +x ./assets/css/tailwindcss
- ./assets/css/tailwindcss -i ./assets/css/input.css -o ./assets/dist/main.css -c ./assets/css/tailwind.config.js
ast: ast:
dir: '{{.USER_WORKING_DIR}}' dir: '{{.USER_WORKING_DIR}}'
desc: Generate AST from source code desc: Generate AST from source code

View file

@ -14,7 +14,7 @@ var taskFile string
func main() { func main() {
commandMap := make(map[string]*flag.FlagSet) commandMap := make(map[string]*flag.FlagSet)
commands := []string{"template", "run", "build", "setup"} commands := []string{"template", "run", "build", "setup", "css"}
for _, command := range commands { for _, command := range commands {
commandMap[command] = flag.NewFlagSet(command, flag.ExitOnError) commandMap[command] = flag.NewFlagSet(command, flag.ExitOnError)
@ -25,7 +25,15 @@ func main() {
os.Exit(1) os.Exit(1)
} }
err := commandMap[os.Args[1]].Parse(os.Args[2:]) c := commandMap[os.Args[1]]
if c == nil {
fmt.Println(fmt.Sprintf("Usage: htmgo [%s]", strings.Join(commands, " | ")))
os.Exit(1)
return
}
err := c.Parse(os.Args[2:])
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
os.Exit(1) os.Exit(1)