-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJustfile
More file actions
203 lines (161 loc) · 6.13 KB
/
Justfile
File metadata and controls
203 lines (161 loc) · 6.13 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
set shell := ["zsh", "-cu"]
set dotenv-load := true
PORT := env_var_or_default("PORT", "3000")
VITE_PORT := env_var_or_default("VITE_PORT", "5173")
DB_PATH := env_var_or_default("DB_PATH", "./data/mapflow.duckdb")
UPLOAD_DIR := env_var_or_default("UPLOAD_DIR", "./uploads")
# Default: local dev (backend + frontend)
start: dev
# Run both backend and frontend in parallel (auto-selecting ports)
dev:
./scripts/dev.sh
# Dev backend only
dev-backend:
PORT={{PORT}} cargo run --manifest-path backend/Cargo.toml --bin backend
# Dev frontend only
dev-frontend:
PORT={{PORT}} VITE_PORT={{VITE_PORT}} npm --prefix frontend run dev
# Install dependencies (backend is automatic, frontend needs install)
install: install-frontend setup-dev
# Setup dev environment: download DuckDB spatial extension for current platform
setup-dev:
@set -euo pipefail; \
os="$(uname -s)"; \
arch="$(uname -m)"; \
if [ "$os" = "Linux" ] && [ "$arch" = "x86_64" ]; then \
duckdb_platform="linux_amd64"; \
elif [ "$os" = "Linux" ] && { [ "$arch" = "aarch64" ] || [ "$arch" = "arm64" ]; }; then \
duckdb_platform="linux_arm64"; \
elif [ "$os" = "Darwin" ] && [ "$arch" = "x86_64" ]; then \
duckdb_platform="osx_amd64"; \
elif [ "$os" = "Darwin" ] && [ "$arch" = "arm64" ]; then \
duckdb_platform="osx_arm64"; \
elif [[ "$os" == MINGW* || "$os" == MSYS* || "$os" == CYGWIN* ]] && [ "$arch" = "x86_64" ]; then \
duckdb_platform="windows_amd64"; \
else \
echo "unsupported host platform: os=$os arch=$arch" >&2; \
exit 1; \
fi; \
echo "Downloading DuckDB spatial extension for $duckdb_platform..."; \
bash scripts/release/spatial_extension_artifact.sh download "$duckdb_platform" "backend/extensions/spatial.duckdb_extension"
# Check code quality
check:
bash scripts/ci/check_spatial_extension_version.sh
cargo fmt --manifest-path backend/Cargo.toml -- --check
cargo clippy --manifest-path backend/Cargo.toml -- -D warnings
npm --prefix frontend run format:check
# Fix code quality issues
fix:
cargo fmt --manifest-path backend/Cargo.toml
cargo clippy --manifest-path backend/Cargo.toml --fix --allow-dirty --allow-staged
# Build local artifacts (no docker)
build:
npm --prefix frontend run build
cargo build --release --manifest-path backend/Cargo.toml
# Build release binary with embedded frontend dist + embedded DuckDB spatial extension
build-embed:
npm --prefix frontend run build
just setup-dev
cargo build --release --manifest-path backend/Cargo.toml --features embed-web-dist,embed-spatial-extension
# --- Docker Operations (Explicit) ---
# Start container (no rebuild by default)
docker-up:
docker compose up -d
@echo "MapFlow started at http://localhost:3000"
# Start container with forced rebuild
docker-up-build:
docker compose up -d --build
@echo "MapFlow rebuilt and started at http://localhost:3000"
# Stop container
docker-down:
docker compose down
# Show container logs
docker-logs:
docker compose logs -f
# Check container status
docker-ps:
docker compose ps
# Enter container shell
docker-shell:
docker compose exec mapflow /bin/bash
# --- Testing ---
# Run backend unit/integration tests
test-backend:
cargo test --manifest-path backend/Cargo.toml
# Run frontend unit tests
test-frontend-unit:
npm --prefix frontend run test:unit
# Run frontend e2e tests (requires build first or running server)
test-e2e:
npm --prefix frontend run test:e2e
# Run all tests
test: test-backend test-frontend-unit test-e2e
@echo "All tests complete"
# --- Cleanup ---
# Remove DuckDB file(s) (respects DB_PATH)
clean-db:
rm -f "{{DB_PATH}}" "{{DB_PATH}}.wal" "{{DB_PATH}}.tmp" "{{DB_PATH}}.shm" "{{DB_PATH}}-wal" "{{DB_PATH}}-shm"
# Remove uploads directory (respects UPLOAD_DIR)
clean-uploads:
rm -rf "{{UPLOAD_DIR}}"
# Clean local dev state (db + uploads)
clean: clean-db clean-uploads
# Remove frontend build output
clean-web:
rm -rf "frontend/dist"
# Remove local test artifacts (Playwright output)
clean-test-artifacts:
rm -rf "frontend/playwright-report" "frontend/test-results" "playwright-report" "test-results"
# Remove local tmp state (keeps tmp/osm_samples and other ad-hoc scratch)
clean-tmp:
rm -rf tmp/worker-* tmp/test-* tmp/release-* tmp/release-uploads tmp/test-uploads
# Clean typical local dev state (db + uploads + tmp + test artifacts + built web)
clean-all: clean clean-web clean-test-artifacts clean-tmp
# Optional: remove Node install caches (slow to rebuild)
clean-node:
rm -rf "node_modules" "frontend/node_modules"
# Optional: remove Rust build cache (slow to rebuild)
clean-target:
cargo clean
# --- Dependency Management ---
# Check for outdated dependencies (run daily)
outdated:
@echo "=== Frontend outdated ==="
npm outdated --prefix frontend || true
@echo "\n=== Backend outdated ==="
cargo update --dry-run --manifest-path backend/Cargo.toml
# Install frontend dependencies (first time or CI)
install-frontend:
cd frontend && npm install
# Update frontend dependencies (patch/minor versions only)
update-frontend:
@echo "Updating frontend dependencies..."
cd frontend && npm update
@echo "✅ Frontend dependencies updated"
@echo "Next steps:"
@echo " 1. Run tests: just test-frontend-unit"
@echo " 2. Build project: just build"
# Update backend dependencies
update-backend:
@echo "Updating backend dependencies..."
cargo update --manifest-path backend/Cargo.toml
@echo "✅ Backend dependencies updated"
@echo "Next: Run tests to verify"
@echo " just test-backend"
# Update all dependencies
update-all: update-frontend update-backend
@echo "\n✅ All dependencies updated"
@echo "Run full test suite: just test"
# Update specific frontend package
update-frontend-pkg PACKAGE:
cd frontend && npm update {{PACKAGE}}
@echo "✅ Updated {{PACKAGE}}"
@echo "Run tests to verify: just test-frontend-unit"
# Update specific backend package
update-backend-pkg PACKAGE:
cargo update --manifest-path backend/Cargo.toml --package {{PACKAGE}}
@echo "✅ Updated {{PACKAGE}}"
@echo "Run tests to verify: just test-backend"
# Bump DuckDB and sync spatial extension manifest
bump-duckdb VERSION:
bash scripts/release/bump_duckdb.sh {{VERSION}}