From 1347a924cc417045e0e85894c168a11610bc9efb Mon Sep 17 00:00:00 2001 From: Ujstor Date: Tue, 17 Sep 2024 17:43:30 +0200 Subject: [PATCH] update docs --- cmd/template/framework/files/README.md.tmpl | 19 ++++++++---- cmd/template/framework/files/makefile.tmpl | 2 +- docs/docs/advanced-flag/htmx-templ.md | 32 ++++++++++++++++++++- docs/docs/advanced-flag/tailwind.md | 2 +- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/cmd/template/framework/files/README.md.tmpl b/cmd/template/framework/files/README.md.tmpl index bd551bc2..181851b8 100644 --- a/cmd/template/framework/files/README.md.tmpl +++ b/cmd/template/framework/files/README.md.tmpl @@ -8,31 +8,38 @@ These instructions will get you a copy of the project up and running on your loc ## MakeFile -run all make commands with clean tests +Run build make command with tests ```bash -make all build +make all ``` -build the application +Build the application ```bash make build ``` -run the application +Run the application ```bash make run ``` +{- if and (ne .DBDriver "none") (ne .DBDriver "sqlite") }} Create DB container ```bash make docker-run ``` -Shutdown DB container +Shutdown DB Container ```bash make docker-down ``` +DB Integrations Test: +```bash +make itest +``` +{{ - end }} + live reload the application ```bash make watch @@ -46,4 +53,4 @@ make test clean up binary from the last build ```bash make clean -``` \ No newline at end of file +``` diff --git a/cmd/template/framework/files/makefile.tmpl b/cmd/template/framework/files/makefile.tmpl index 2e0f07dd..6ad83f32 100644 --- a/cmd/template/framework/files/makefile.tmpl +++ b/cmd/template/framework/files/makefile.tmpl @@ -1,7 +1,7 @@ # Simple Makefile for a Go project # Build the application -all: build +all: build test {{- if or .AdvancedOptions.htmx .AdvancedOptions.tailwind }} {{- if .OSCheck.UnixBased }} diff --git a/docs/docs/advanced-flag/htmx-templ.md b/docs/docs/advanced-flag/htmx-templ.md index e8641bed..a1a61492 100644 --- a/docs/docs/advanced-flag/htmx-templ.md +++ b/docs/docs/advanced-flag/htmx-templ.md @@ -41,8 +41,38 @@ templ generate make run ``` +## Makefile + +Automates templ with Makefile entries, which are automatically created if the htmx advanced flag is used. +It detects if templ is installed or not and generates templates with the make build command. +Both Windows and Unix-like OS are supported. + +```bash +all: build + +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 + +build: templ-install + @echo "Building..." + @templ generate + @go build -o main cmd/api/main.go +``` + ## Templating Templates are generated using the `templ generate` command after project creation. These templates are then compiled into Go code for efficient execution. -You can test HTMX functionality on `localhost:port/web` endpoint. +You can test HTMX functionality on `localhost:PORT/web` endpoint. diff --git a/docs/docs/advanced-flag/tailwind.md b/docs/docs/advanced-flag/tailwind.md index 55e8f3eb..9a349db1 100644 --- a/docs/docs/advanced-flag/tailwind.md +++ b/docs/docs/advanced-flag/tailwind.md @@ -39,7 +39,7 @@ The The idea is to avoid using Node.js and npm to build output.css. The Makefile will have entries for downloading and compiling CSS. It will automatically detect the OS and download the latest release from the [official repository](https://github.com/tailwindlabs/tailwindcss/releases). -## Linux Makefile example: +## Linux Makefile Example ```bash all: build templ-install: