-
Notifications
You must be signed in to change notification settings - Fork 376
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (119 loc) · 3.3 KB
/
Copy pathMakefile
File metadata and controls
141 lines (119 loc) · 3.3 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Makefile to check and set up Python 3.14 and a virtual environment
PYTHON_VERSION=3.14
VENV_DIR=.venv
.PHONY: install_uv
install_uv:
@if ! uv --help >/dev/null 2>&1; then \
echo "uv not found. Installing..."; \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
echo "uv installed. Ensure ~/.cargo/bin is in your PATH."; \
else \
echo "uv is already installed."; \
fi
# Install Python dependencies from pyproject.toml
.PHONY: requirements
requirements:
@uv sync
.PHONY: requirements-dev
requirements-dev:
@uv sync --group dev
# Check if nvm is installed, if not, install it
.PHONY: check-nvm
check-nvm:
@if ! command -v nvm > /dev/null 2>&1; then \
echo "nvm not found. Installing..."; \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash || { \
echo "Failed to install nvm. Please install it manually."; \
exit 1; \
}; \
export NVM_DIR="$$HOME/.nvm"; \
[ -s "$$NVM_DIR/nvm.sh" ] && . "$$NVM_DIR/nvm.sh"; \
[ -s "$$NVM_DIR/bash_completion" ] && . "$$NVM_DIR/bash_completion"; \
echo "nvm installed. Version: `nvm --version`"; \
else \
echo "nvm is already installed. Version: `nvm --version`"; \
fi
# Check if nodejs is installed, if not, install it
.PHONY: check-nodejs
check-nodejs: check-nvm
@if ! node -v > /dev/null 2>&1; then \
echo "nodejs not found. Installing..."; \
nvm install 22 || { \
echo "Failed to install nodejs. Please install it manually."; \
exit 1; \
}; \
else \
echo "nodejs is already installed."; \
fi
# Check if bun is installed, if not, install it
.PHONY: check-bun
check-bun: check-nodejs
@if ! bun --version > /dev/null 2>&1; then \
echo "bun not found. Installing..."; \
curl -fsSL https://bun.sh/install | bash || { \
echo "Failed to install bun. Please install it manually."; \
exit 1; \
}; \
else \
echo "bun is already installed."; \
fi
# Install frontend dependencies (Node.js packages)
.PHONY: install-front
install-front: check-bun
@cd dashboard && bun install
# Run database migrations using Alembic
.PHONY: run-migration
run-migration:
@uv run alembic upgrade head
.PHONY: check-migrations
check-migrations:
@uv run alembic check
# run PasarGuard
.PHONY: run
run:
@uv run main.py
# run pasarguard-cli
.PHONY: run-cli
run-cli:
@uv run pasarguard-cli.py
# Run tests
.PHONY: test
test:
@uv run pytest tests/
# Run tests-watch
.PHONY: test-whatch
test-whatch:
@uv run ptw
# Run PasarGuard with watchfiles
.PHONY: run-watch
run-watch:
@echo "Running application with watchfiles..."
@uv run watchfiles --filter python "uv run main.py" .
# Generate the API client (orval) WITHOUT running the server:
# dump the OpenAPI schema offline, then feed the file to orval.
# Cross-platform: the Python helper sets OPENAPI_INPUT and invokes orval itself.
.PHONY: gen-api
gen-api:
@uv run python scripts/export_openapi.py --gen-client
# Check code
.PHONY: check
check:
@uv run ruff check .
# Format code
.PHONY: format
format:
@uv run ruff format .
# Clean the environment
.PHONY: clean
clean:
@rm -rf $(VENV_DIR)
@echo "Virtual environment removed."
# Setup environment: check Python, install uv, and sync requirements
.PHONY: setup
setup: install_uv requirements
.PHONY: setup-test
setup-test: install_uv requirements-dev
# Format code (front-end)
.PHONY: fformat
fformat:
@cd dashboard && bun run prettier . --write