diff --git a/.gitignore b/.gitignore index 574bc1f..c8d8c97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ tmp .DS_Store .idea +*templ.go +conf.yaml +output.css +compose.yaml +tailwindcss diff --git a/cmd/cmd b/cmd/cmd deleted file mode 100755 index c47bde0..0000000 Binary files a/cmd/cmd and /dev/null differ diff --git a/justfile b/justfile new file mode 100644 index 0000000..723f2c8 --- /dev/null +++ b/justfile @@ -0,0 +1,78 @@ +# Build the application +all: build test + +templ-install: + @if ! command -v templ > /dev/null; then \ + read -p "Go's 'templ' is not installed on your machine. Do you want to install it? [Y/n] " choice; \ + if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \ + go install github.com/a-h/templ/cmd/templ@latest; \ + if [ ! -x "$$(command -v templ)" ]; then \ + echo "templ installation failed. Exiting..."; \ + exit 1; \ + fi; \ + else \ + echo "You chose not to install templ. Exiting..."; \ + exit 1; \ + fi; \ + fi + +tailwind: + @if [ ! -f tailwindcss ]; then curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-macos-x64 -o tailwindcss; fi + @chmod +x tailwindcss + +build: + @echo "Building..." + @templ generate + @./tailwindcss -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css + @go build -o main cmd/main.go + +run: + @templ generate + @go run cmd/main.go + +test: build + @echo "Testing..." + @go test ./... -v + +# Clean the binary +clean: + @echo "Cleaning..." + @rm -f main + +# Create DB container +docker-run: + @if docker compose up --build 2>/dev/null; then \ + : ; \ + else \ + echo "Falling back to Docker Compose V1"; \ + docker-compose up --build; \ + fi + +# Shutdown DB container +docker-down: + @if docker compose down 2>/dev/null; then \ + : ; \ + else \ + echo "Falling back to Docker Compose V1"; \ + docker-compose down; \ + fi + +watch-templ: + templ generate --watch --proxy="http://localhost:8080" --cmd="go run ." + +# Live Reload +watch: + @if command -v air > /dev/null; then \ + air; \ + echo "Watching...";\ + else \ + read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \ + if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \ + go install github.com/air-verse/air@latest; \ + air; \ + echo "Watching...";\ + else \ + echo "You chose not to install air. Exiting..."; \ + exit 1; \ + fi; \ + fi