2024-06-04 10:16:51 +02:00
# Load environment variables from .env file
i f n e q ( , $( wildcard ./.env ) )
include .env
export
e n d i f
# run templ generation in watch mode to detect all .templ files and
# re-create _templ.txt files on change, then send reload event to browser.
# Default url: http://localhost:7331
2024-06-08 10:49:16 +02:00
templ :
2024-06-08 21:59:00 +02:00
@go run github.com/a-h/templ/cmd/templ@latest generate --watch --proxy= " http://localhost $( HTTP_LISTEN_ADDR) " --open-browser= false -v
2024-06-04 10:16:51 +02:00
# run air to detect any go file changes to re-build and re-run the server.
2024-06-08 10:49:16 +02:00
server :
2024-06-04 10:16:51 +02:00
@go run github.com/cosmtrek/air@v1.51.0 \
--build.cmd "go build --tags dev -o tmp/bin/main ./cmd/app/" --build.bin "tmp/bin/main" --build.delay "100" \
--build.exclude_dir "node_modules" \
--build.include_ext "go" \
--build.stop_on_error "false" \
--misc.clean_on_exit true
# run tailwindcss to generate the styles.css bundle in watch mode.
2024-06-08 10:49:16 +02:00
assets :
tailwindcss -i app/assets/app.css -o ./public/assets/styles.css --watch
2024-06-04 10:16:51 +02:00
# run esbuild to generate the index.js bundle in watch mode.
2024-06-08 10:49:16 +02:00
esbuild :
2024-06-04 10:16:51 +02:00
npx esbuild views/js/index.js --bundle --outdir= public/ --watch
# watch for any js or css change in the assets/ folder, then reload the browser via templ proxy.
2024-06-08 10:49:16 +02:00
sync_assets :
2024-06-04 10:16:51 +02:00
go run github.com/cosmtrek/air@v1.51.0 \
2024-06-08 21:59:00 +02:00
--build.cmd "go run github.com/a-h/templ/cmd/templ@latest generate --notify-proxy" \
2024-06-04 10:16:51 +02:00
--build.bin "true" \
--build.delay "100" \
--build.exclude_dir "" \
--build.include_dir "public" \
--build.include_ext "js,css"
# start the application in development
dev :
2024-06-08 22:46:37 +02:00
@make -j4 templ server assets sync_assets
2024-06-08 10:49:16 +02:00
# build the application for production. This will compile your app
# to a single binary with all its assets embedded.
build :
@tailwindcss -i app/assets/app.css -o ./public/assets/styles.css
@go build -o bin/app_release cmd/app/main.go
@echo "compiled you application with all its assets to a single binary => bin/app_release"
2024-06-04 10:16:51 +02:00
2024-06-06 10:04:51 +02:00
db-status :
2024-06-08 10:05:00 +02:00
@GOOSE_DRIVER= $( DB_DRIVER) GOOSE_DBSTRING = $( DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest status
2024-06-04 10:16:51 +02:00
2024-06-06 10:04:51 +02:00
db-reset :
2024-06-08 10:05:00 +02:00
@GOOSE_DRIVER= $( DB_DRIVER) GOOSE_DBSTRING = $( DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest -dir= $( MIGRATION_DIR) reset
2024-06-04 10:16:51 +02:00
2024-06-07 11:26:58 +02:00
db-down :
2024-06-08 10:05:00 +02:00
@GOOSE_DRIVER= $( DB_DRIVER) GOOSE_DBSTRING = $( DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest -dir= $( MIGRATION_DIR) down
2024-06-07 11:26:58 +02:00
2024-06-06 10:04:51 +02:00
db-up :
2024-06-08 10:05:00 +02:00
@GOOSE_DRIVER= $( DB_DRIVER) GOOSE_DBSTRING = $( DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest -dir= $( MIGRATION_DIR) up
2024-06-06 10:04:51 +02:00
2024-06-07 09:23:06 +02:00
db-mig :
2024-06-08 10:05:00 +02:00
@GOOSE_DRIVER= $( DB_DRIVER) GOOSE_DBSTRING = $( DB_NAME) go run github.com/pressly/goose/v3/cmd/goose@latest -dir= $( MIGRATION_DIR) create $( filter-out $@ ,$( MAKECMDGOALS) ) sql
2024-06-07 09:23:06 +02:00
2024-06-06 10:04:51 +02:00
db-seed :
@go run cmd/scripts/seed/main.go