-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (120 loc) · 5.18 KB
/
Makefile
File metadata and controls
146 lines (120 loc) · 5.18 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
143
144
145
146
# =============================================================================
# Makefile for Tauri FastAPI Full Stack Template
# =============================================================================
.PHONY: setup dev package dev-frontend fastapi init-db clean generate-client package-backend
# Project root directory
PROJECT_ROOT := $(shell pwd)
# =============================================================================
# Setup
# =============================================================================
##@ Setup 📦
# Install all dependencies (Rust, Frontend, Backend)
setup:
@echo "==> 📦 Installing dependencies..."
@echo " - 🔧 Installing Tauri CLI..."
cargo install tauri-cli
@echo " - ⚛️ Installing frontend dependencies (bun)..."
cd frontend && bun install
@echo " - 🐍 Installing backend dependencies (uv)..."
cd fastapi && uv sync
@echo "==> ✅ Setup complete!"
# =============================================================================
# Development
# =============================================================================
##@ Development 🚀
# Run the full app in development mode (Tauri + Frontend dev server)
# Uses embedded Python for backend, no pre-built sidecar binary needed
dev:
@echo "==> 🚀 Starting Tauri development mode..."
TAURI_CONFIG='{"bundle":{"externalBin":[]}}' cargo tauri dev
# Run only the frontend dev server (useful when backend is already running)
dev-frontend:
@echo "==> ⚛️ Starting frontend dev server on http://localhost:1420..."
cd frontend && bun run dev
# Run only the FastAPI backend (for development/debugging)
fastapi:
@echo "==> 🐍 Starting FastAPI backend on http://localhost:1430..."
cd fastapi && DATA_DIR=$(PROJECT_ROOT)/.data uv run uvicorn app.main:app --reload --port 1430
# =============================================================================
# Code Generation
# =============================================================================
##@ Code Generation 🔮
# Generate API clients (TypeScript + Rust) from FastAPI OpenAPI schema
# This reads the backend models and generates typed client code
generate-client:
@./scripts/generate-client.sh
# =============================================================================
# Database
# =============================================================================
##@ Database 🗄️
# Initialize database (run migrations + create default user)
init-db:
@echo "==> 🗄️ Initializing database..."
cd fastapi && DATA_DIR=$(PROJECT_ROOT)/.data uv run python -m app.prestart
@echo "==> ✅ Database initialized!"
# =============================================================================
# Package
# =============================================================================
##@ Package 📦
# Package the FastAPI sidecar binary (PyInstaller)
package-backend:
@echo "==> 📦 Packaging FastAPI sidecar binary..."
cd fastapi && uv run --with build build.py
# Package the desktop application for production
# This will create platform-specific installers in tauri/target/release/bundle/
package: package-backend
@echo "==> 📦 Packaging Tauri desktop bundle..."
cargo tauri build
@echo "==> ✅ Package complete! Check tauri/target/release/bundle/ for output."
# =============================================================================
# Maintenance
# =============================================================================
##@ Maintenance 🧹
# Clean all build artifacts and local database
clean:
@echo "==> 🧹 Cleaning build artifacts..."
@echo " - 🔨 Cleaning Rust cargo builds..."
cd tauri && cargo clean 2>/dev/null || true
@echo " - ⚛️ Cleaning frontend dist and node_modules..."
rm -rf frontend/dist frontend/node_modules
@echo " - 🐍 Cleaning Python venv, data, and PyInstaller build..."
rm -rf fastapi/.venv fastapi/.data fastapi/build
@echo " - 🔧 Cleaning Tauri binaries..."
rm -rf tauri/binaries/fastapi-server*
@echo " - 🗄️ Cleaning local databases..."
rm -rf .data/*.db* .data/*.db-wal .data/*.db-shm
@echo " - 📄 Cleaning generated openapi.json..."
rm -f frontend/openapi.json openapi.json
@echo "==> ✅ Clean complete!"
# =============================================================================
# Help
# =============================================================================
##@ Help ❓
# Display this help message
help:
@echo ""
@echo " 🦀 Tauri FastAPI Full Stack Template"
@echo ""
@echo " Usage: make [target]"
@echo ""
@echo " Setup 📦"
@echo " setup Install all dependencies"
@echo ""
@echo " Development 🚀"
@echo " dev Run Tauri development mode"
@echo " dev-frontend Run frontend dev server only"
@echo " fastapi Run FastAPI backend only"
@echo ""
@echo " Code Generation 🔮"
@echo " generate-client Generate TypeScript + Rust API clients"
@echo ""
@echo " Database 🗄️"
@echo " init-db Initialize database"
@echo ""
@echo " Package 📦"
@echo " package Package production bundle"
@echo " package-backend Package FastAPI backend binary"
@echo ""
@echo " Maintenance 🧹"
@echo " clean Clean build artifacts"
@echo ""