2023-12-20 15:39:25 +00:00
|
|
|
// TODO: add commands for build and run in dev/produciton mode
|
|
|
|
|
|
|
|
ROOT=$(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
|
|
|
|
2024-07-15 11:56:14 +00:00
|
|
|
confirm:
|
|
|
|
@echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
|
|
|
|
|
2023-12-20 15:39:25 +00:00
|
|
|
lint:
|
|
|
|
which golangci-lint || (go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.0)
|
|
|
|
golangci-lint run --config=$(ROOT)/.golangci.yml $(ROOT)/...
|
|
|
|
|
|
|
|
test:
|
|
|
|
go test -v ./...
|
|
|
|
|
|
|
|
format:
|
|
|
|
@which gofumpt || (go install mvdan.cc/gofumpt@latest)
|
|
|
|
@gofumpt -l -w $(ROOT)
|
|
|
|
@which gci || (go install github.com/daixiang0/gci@latest)
|
2024-09-09 09:09:57 +00:00
|
|
|
@gci write $(ROOT) --skip-generated --skip-vendor
|
2023-12-20 15:39:25 +00:00
|
|
|
@which golangci-lint || (go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.0)
|
|
|
|
@golangci-lint run --fix
|
2024-01-11 07:13:37 +00:00
|
|
|
|
|
|
|
build:
|
2024-05-14 13:07:09 +00:00
|
|
|
go build main.go --migrate
|
|
|
|
|
|
|
|
run:
|
|
|
|
go run main.go --migrate
|
|
|
|
|
|
|
|
docker:
|
2024-05-20 17:37:44 +00:00
|
|
|
sudo docker compose up -d
|
|
|
|
|
|
|
|
swagger:
|
2024-07-15 11:56:14 +00:00
|
|
|
swag init
|
|
|
|
|
|
|
|
# Live Reload
|
|
|
|
watch:
|
|
|
|
@if command -v CompileDaemon > /dev/null; then \
|
|
|
|
CompileDaemon -exclude-dir=.git -exclude=".#*" -command="./niki"; \
|
|
|
|
else \
|
|
|
|
read -p "Go's 'CompileDaemon' 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/githubnemo/CompileDaemon@latest; \
|
|
|
|
CompileDaemon -exclude-dir=.git -exclude=".#*" -command="./niki"; \
|
|
|
|
else \
|
|
|
|
echo "You chose not to install CompileDaemon. Exiting..."; \
|
|
|
|
exit 1; \
|
|
|
|
fi; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
migrate/status:
|
|
|
|
@sql-migrate status -env="production" -config=repository/mysql/dbconfig.yml
|
|
|
|
|
|
|
|
# Example: make migrate/new name=add_kindbox_permission
|
|
|
|
migrate/new:
|
|
|
|
@echo 'Creating migration file for ${name}...'
|
|
|
|
@sql-migrate new -env="production" -config=repository/mysql/dbconfig.yml ${name}
|
|
|
|
|
|
|
|
migrate/up: confirm
|
|
|
|
@echo 'Running all migrations...'
|
|
|
|
@sql-migrate up -env="production" -config=repository/mysql/dbconfig.yml
|
|
|
|
|
|
|
|
migrate/down: confirm
|
|
|
|
@echo 'Tearing down last migration...'
|
|
|
|
@sql-migrate down -env="production" -config=repository/mysql/dbconfig.yml -limit=1
|