2024-04-08 16:59:42 +07:00
|
|
|
.ONESHELL:
|
|
|
|
|
|
|
|
# Variables
|
|
|
|
export PATH := $(shell pwd)/node_modules/.bin:$(shell pwd)/bin:$(PATH)
|
|
|
|
export GOBIN := $(shell pwd)/bin
|
2024-04-09 21:49:23 +07:00
|
|
|
export GOOSE_DRIVER=sqlite3
|
|
|
|
export GOOSE_DBSTRING=./data.db
|
|
|
|
export GOOSE_MIGRATION_DIR=db/migrations
|
2024-04-08 16:59:42 +07:00
|
|
|
|
|
|
|
start: dev-dependencies
|
|
|
|
@air
|
|
|
|
|
|
|
|
dev-dependencies: build-dependencies
|
|
|
|
@if ! command -v air > /dev/null; then
|
|
|
|
mkdir -p bin
|
|
|
|
echo "Modd not found in PATH, installing it to $(shell pwd)/bin/air"
|
|
|
|
go install github.com/cosmtrek/air@latest
|
|
|
|
fi
|
|
|
|
|
|
|
|
build-dependencies:
|
|
|
|
@if ! command -v templ > /dev/null; then
|
|
|
|
mkdir -p bin
|
|
|
|
echo "Templ not found in PATH, installing it to $(shell pwd)/bin/templ"
|
|
|
|
go install github.com/a-h/templ/cmd/templ@v0.2.648
|
|
|
|
fi
|
|
|
|
@if [ ! -d "node_modules" ]; then
|
|
|
|
echo "Node modules not found, installing them"
|
|
|
|
npm install
|
|
|
|
fi
|
|
|
|
@if [ ! -f "public/htmx-1.9.11.min.js" ]; then
|
|
|
|
mkdir -p public
|
|
|
|
echo "Htmx not found, installing it"
|
|
|
|
curl -o public/htmx-1.9.11.min.js https://unpkg.com/htmx.org@1.9.11/dist/htmx.min.js
|
|
|
|
fi
|
|
|
|
@if [ ! -f "public/htmx-response-targets-1.9.11.min.js" ]; then
|
|
|
|
mkdir -p public
|
|
|
|
echo "Htmx response targets not found, installing it"
|
|
|
|
curl -o public/htmx-response-targets-1.9.11.min.js https://cdnjs.cloudflare.com/ajax/libs/htmx/1.9.11/ext/response-targets.min.js
|
|
|
|
fi
|
|
|
|
|
2024-04-23 22:26:03 +07:00
|
|
|
build: build-dependencies prepare
|
|
|
|
go build -o redmage
|
|
|
|
|
|
|
|
prepare: gen
|
2024-04-08 16:59:42 +07:00
|
|
|
mkdir -p public
|
2024-04-24 13:01:13 +07:00
|
|
|
tailwindcss -i views/style.css -o public/style.css
|
2024-04-08 16:59:42 +07:00
|
|
|
templ generate
|
2024-04-23 22:26:03 +07:00
|
|
|
|
|
|
|
gen:
|
|
|
|
@go run github.com/stephenafamo/bob/gen/bobgen-sqlite@latest
|
2024-04-09 21:49:23 +07:00
|
|
|
|
|
|
|
migrate-new:
|
|
|
|
@read -p "Name new migration: " name
|
|
|
|
if [[ $$name ]]; then goose create "$$name" sql; fi
|
|
|
|
|
|
|
|
migrate-redo:
|
2024-04-23 22:26:03 +07:00
|
|
|
@goose redo
|