Hardening justfile and HTMX download method

This commit is contained in:
Imbus 2024-10-21 05:15:37 +02:00
parent 2fc8dd57cd
commit 3e6eefced0
2 changed files with 24 additions and 4 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
htmx.*
/build

View file

@ -1,8 +1,27 @@
run:
# See: https://github.com/bigskysoftware/htmx/releases
# For static latest: https://github.com/bigskysoftware/htmx/releases/latest/download/htmx.min.js
htmx-ver := "2.0.3"
htmx-sha256sum := "491955cd1810747d7d7b9ccb936400afb760e06d25d53e4572b64b6563b2784e"
htmx-file := "htmx.min.js"
htmx-url := "https://github.com/bigskysoftware/htmx/releases/download/v" + htmx-ver / htmx-file
[doc("Run the server")]
run: get-htmx
go run ./http-serve.go
get-htmx:
curl -O -lSSL https://unpkg.com/htmx.org@2.0.2/dist/htmx.min.js
[doc("Build a static binary with content bundled")]
build: get-htmx
go build -o build/htmx-server ./http-serve.go
# TODO: Maybe use shasum instead for FreeBSD support
[doc("Download the HTMX release")]
get-htmx:
@test -f htmx.min.js || echo "Getting HTMX..." && curl --silent -O -lSSL {{htmx-url}}
@sha256sum -c <<< "{{htmx-sha256sum}} {{htmx-file}}" || (echo "Checksum failed, check Justfile" && exit 1)
[doc("Cleanup source tree")]
[confirm("Are you sure? [y/N]:")]
clean:
rm -r .go
rm -rf .go
rm -rf build
rm -f htmx.min.js