-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathMakefile
More file actions
116 lines (92 loc) · 2.41 KB
/
Copy pathMakefile
File metadata and controls
116 lines (92 loc) · 2.41 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
# Makefile for RequestRepo v2
# Variables
FRONTEND_DIR := frontend
RUST_DIR := src
HOOKS_DIR := .git/hooks
# Commands
FRONTEND_START_CMD := bun run dev
FORMAT_JS_CMD := cd $(FRONTEND_DIR) && bunx prettier --write --log-level silent
# Install dependencies and git hooks
.PHONY: install
install: install-deps install-hooks
# Install dependencies only
.PHONY: install-deps
install-deps:
cd $(RUST_DIR) && cargo build --release
cd $(FRONTEND_DIR) && bun install
# Install git hooks
.PHONY: install-hooks
install-hooks:
@mkdir -p $(HOOKS_DIR)
@echo "#!/bin/sh\nmake pre-commit" > $(HOOKS_DIR)/pre-commit
@echo "#!/bin/sh\nmake pre-push" > $(HOOKS_DIR)/pre-push
@chmod +x $(HOOKS_DIR)/pre-commit $(HOOKS_DIR)/pre-push
@echo "Git hooks installed successfully"
# Pre-commit hook: format and lint
.PHONY: pre-commit
pre-commit: format lint
@echo "Pre-commit checks passed!"
# Pre-push hook: format, lint, and test
.PHONY: pre-push
pre-push: format lint test
@echo "Pre-push checks passed!"
# Start the backend server
.PHONY: start-backend
start-backend:
if [ ! -f .env ]; then cp .env.example .env; fi
cd $(RUST_DIR) && cargo run --release
# Start the backend with hot reload (like bun dev)
.PHONY: dev-backend
dev-backend:
if [ ! -f .env ]; then cp .env.example .env; fi
cd $(RUST_DIR) && cargo watch -x run
# Start the frontend application
.PHONY: start-frontend
start-frontend:
cd $(FRONTEND_DIR) && $(FRONTEND_START_CMD)
# Build the backend
.PHONY: build
build:
cd $(RUST_DIR) && cargo build --release
# Run tests
.PHONY: test
test: test-backend test-frontend
.PHONY: test-backend
test-backend:
cd $(RUST_DIR) && JWT_SECRET=test_secret_for_ci_minimum_32_characters cargo test
.PHONY: test-frontend
test-frontend:
cd $(FRONTEND_DIR) && bun run test
# Lint the codebase
.PHONY: lint
lint: lint-js lint-rust
.PHONY: lint-js
lint-js:
cd $(FRONTEND_DIR) && bun run lint
.PHONY: lint-rust
lint-rust:
cd $(RUST_DIR) && cargo clippy -- -D warnings
# Format the codebase
.PHONY: format
format: format-js format-rust
.PHONY: format-js
format-js:
$(FORMAT_JS_CMD) .
.PHONY: format-rust
format-rust:
cd $(RUST_DIR) && cargo fmt
# Clean build artifacts
.PHONY: clean
clean:
cd $(RUST_DIR) && cargo clean
rm -rf $(FRONTEND_DIR)/node_modules $(FRONTEND_DIR)/build
# Docker commands
.PHONY: docker-build
docker-build:
docker compose build
.PHONY: docker-up
docker-up:
docker compose up -d
.PHONY: docker-down
docker-down:
docker compose down