Melkeydev / go-blueprint

Go-blueprint allows users to spin up a quick Go project using a popular framework
https://docs.go-blueprint.dev/
MIT License
5.5k stars 318 forks source link

[Feature Request] Update Makefile (make build) #275

Closed Ujstor closed 2 months ago

Ujstor commented 4 months ago

Tell us about your feature request

There are a couple of things that can be done to improve user experience:

  1. When using Tailwind with the advanced flag, check the user's operating system and provide an option to download the Tailwind CLI binary and generate CSS.

  2. When using HTMX or Tailwind, provide an option to install the templ if it is not detected on the system.

  3. Update .PHONY for missing commands

Disclaimer

Ujstor commented 4 months ago

PR #283 introduces the CheckOs function, which can be expanded and used for more granular templating. It would simplify the proposed changes' implementation.

jexroid commented 4 months ago

If PR #283 seems convenient to merge, I would be happy to code further and develop this feature cause PR #283 is adding a bool type UnixBased to the Project type and is necessary for further coding on this feature. and it needs to be approved by the team

Ujstor commented 4 months ago

The PR will be merged after you address the changes that we discussed. Then you can work on this implementation. I am assigning the issue to you.

Ujstor commented 3 months ago

@jexroid Do you plan to work on this ticket in the near future? I'm just asking because I assigned it to you.

jexroid commented 3 months ago

sorry for not following up this feature request I was a bit busy. yes, I would be glad to help. i have been asked couple of question about this feature in discord and I like to collaborate on this.

Ujstor commented 3 months ago

The reasoning behind this ticket is to automate the Tailwind config, which for now needs to be done manually. The steps are documented in the docs:

https://docs.go-blueprint.dev/advanced-flag/tailwind/

checkOS function in program.go that can return whether we are running a Windows or Unix-like OS. Expanding the func to verify if we are on Windows, Linux, or Darwin can solve complexities with Makefile templating.

There is also a tmpl requirement for the HTMX advanced flag. We can check if it is installed and provide the user with an option when make build is run. This one is pretty simple:

     if command -v templ > /dev/null; then \
            templ generate; \
    else \
        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; \
            templ generate; \
        else \
            echo "You chose not to install templ. Exiting..."; \
            exit 1; \
        fi; \
    fi
Ujstor commented 2 months ago

Tailwind Linux implementation:

tailwind: 
    @curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
    @mv tailwindcss-linux-x64 tailwindcss
    @chmod +x tailwindcss

build: tailwind
    @echo "Building..."
    @templ generate
    @./tailwindcss -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css
    @go build -o main cmd/api/main.go