superkit/bootstrap/Makefile

68 lines
2.6 KiB
Makefile
Raw Normal View History

2024-06-04 10:16:51 +02:00
# Load environment variables from .env file
ifneq (,$(wildcard ./.env))
include .env
export
endif
# 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:
@templ 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.
watch-assets:
npx 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-12 20:02:44 +02:00
watch-esbuild:
npx esbuild app/assets/index.js --bundle --outdir=public/assets --watch
2024-06-04 10:16:51 +02:00
# 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 \
--build.cmd "templ 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:
@make -j5 templ server watch-assets watch-esbuild 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:
@npx tailwindcss -i app/assets/app.css -o ./public/assets/styles.css
2024-06-12 20:02:44 +02:00
@npx esbuild app/assets/index.js --bundle --outdir=public/assets
2024-06-11 21:12:12 +02:00
@go build -o bin/app_prod cmd/app/main.go
@echo "compiled you application with all its assets to a single binary => bin/app_prod"
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-11 21:12:12 +02:00
db-mig-create:
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