-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (93 loc) · 3.26 KB
/
Makefile
File metadata and controls
122 lines (93 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
clean: ## Clean up cache and temporary files
find . -type d -name "__pycache__" -delete
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type f -name ".coverage" -delete
rm -rf htmlcov/
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
# ==============================================================================
# Define dependencies
# ==============================================================================
YOUR_APP := your-api
BASE_IMAGE_NAME := docker-username
# VERSION := 0.1.1
VERSION := $(shell poetry version -s)
API_IMAGE := $(BASE_IMAGE_NAME)/$(YOUR_APP):$(VERSION)
# ==============================================================================
# General Commands
# ==============================================================================
init:
poetry new $(YOUR_APP)
track-tree:
poetry show --tree
track-latest:
poetry show --latest
install:
poetry add $(cat requirements.txt)
update:
poetry update package
dev-install:
poetry add --dev ruff
run:
lsof -i :8000 | awk 'NR!=1 {print $2}' | xargs -r kill -9
poetry run python3 app/main.py
# Use this when package is removed
lock:
poetry lock
ruff: ## Run ruff check (use 'make lint-fix' to auto-fix)
poetry run ruff check .
# ==============================================================================
# Versioning
# ==============================================================================
version:
@if [ -z "$(SEMVER)" ]; then \
poetry version; \
else \
poetry version $(SEMVER); \
fi
version-help:
@echo "Usage: make version SEMVER=<bump_type>"
@echo ""
@echo "Available bump types:"
@echo " show Show current version"
@echo " patch Bump patch version (0.0.X)"
@echo " minor Bump minor version (0.X.0)"
@echo " major Bump major version (X.0.0)"
@echo " preminor Bump preminor version (0.X.0a0)"
@echo " premajor Bump premajor version (X.0.0a0)"
@echo " prerelease Bump prerelease version (0.0.0aX)"
print-version:
@echo $(VERSION)
# make version SEMVER=x.x.x
# ==============================================================================
# Development Commands
# ==============================================================================
migrate:
poetry run alembic revision --autogenerate -m "$(msg)"
poetry run alembic upgrade head
migrate-generate: ## Generate a new migration file
@if [ -z "$(msg)" ]; then \
echo "Usage: make migrate-generate msg='your migration message'"; \
exit 1; \
fi
poetry run alembic revision --autogenerate -m "$(msg)"
migrate-up: ## Run database migrations
poetry run alembic upgrade head
migrate-down: ## Rollback last migration
poetry run alembic downgrade -1
migrate-status: ## Show migration status
poetry run alembic current
migrate-history: ## Show migration history
poetry run alembic history
migrate-reset: ## Reset database (WARNING: This will delete all data!)
@echo "WARNING: This will delete all data in the database!"
@read -p "Are you sure? (y/N): " confirm && [ "$confirm" = "y" ] || exit 1
poetry run alembic downgrade base
poetry run alembic upgrade head
prettier: lint-fix format
lint-fix: ## Run linting with auto-fix
poetry run ruff check --fix .
format: ## Format code
poetry run ruff format .