-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathMakefile
More file actions
142 lines (121 loc) · 3.46 KB
/
Makefile
File metadata and controls
142 lines (121 loc) · 3.46 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
142
# Makefile to check and set up Python 3.12 and a virtual environment
PYTHON_VERSION=3.12
VENV_DIR=.venv
# Check if Python 3.12 is installed, if not, install it
.PHONY: check-python
check-python:
@if ! python${PYTHON_VERSION} --version | grep -q "$(PYTHON_VERSION)"; then \
echo "Python $(PYTHON_VERSION) is not installed. Installing..."; \
sudo add-apt-repository -y ppa:deadsnakes/ppa && sudo apt update && sudo apt install -y python$(PYTHON_VERSION) python$(PYTHON_VERSION)-venv || { \
echo "Failed to install Python $(PYTHON_VERSION). Please install it manually."; \
exit 1; \
}; \
else \
echo "Python $(PYTHON_VERSION) is installed."; \
fi
.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
# 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
# run PasarGuard
.PHONY: run
run:
@uv run main.py
# run pasarguard-cli
.PHONY: run-cli
run-cli:
@uv run pasarguard-cli.py
# run pasarguard-tui
.PHONY: run-tui
run-tui:
@uv run pasarguard-tui.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" .
# 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: check-python install_uv requirements
# Format code (front-end)
.PHONY: fformat
fformat:
@cd dashboard && bun run prettier . --write