From 8688ef9fe1199b09ae4b06b588778e93a6ceea1b Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 13 Apr 2026 17:34:08 -0500 Subject: [PATCH] feat(makefile): add development commands for Vite and Python backend, including help instructions and new script for local development --- Makefile | 25 ++++++++++++++++++++++++- scripts/dev-local.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 scripts/dev-local.sh diff --git a/Makefile b/Makefile index 569565e..9c99b84 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,38 @@ -.PHONY: install run build lint test test-be-perf clean +.PHONY: install run dev dev-fe build lint test test-be-perf clean help dist-linux dist-linux-x64 install: pnpm install poetry install +# Python backend only. For HMR, use: make dev OR make run in one terminal and pnpm run dev in another. run: poetry run python -m meshchatx.meshchat +# Vite dev server (live reload) + backend. Open http://localhost:5173 — proxies /api and /ws to MESHCHAT_PORT (default 8000). +dev: + bash scripts/dev-local.sh + +# Vite only; expects backend already running (e.g. make run on port 8000). +dev-fe: + pnpm run dev -- --host 127.0.0.1 --port 5173 + build: pnpm run build +# Linux AppImage + deb (see package.json dist:linux). +dist-linux: + pnpm run dist:linux + +dist-linux-x64: + pnpm run dist:linux-x64 + +help: + @echo "make dev - Vite HMR + backend (http://localhost:5173)" + @echo "make run - backend only" + @echo "make dev-fe - Vite only (pair with make run)" + @echo "make dist-linux - AppImage + deb (electron-builder)" + @echo "Env: MESHCHAT_PORT, E2E_BACKEND_PORT (vite proxy; script sets both), VITE_DEV_HOST, VITE_DEV_PORT" + lint: pnpm run lint poetry run ruff check . diff --git a/scripts/dev-local.sh b/scripts/dev-local.sh new file mode 100644 index 0000000..2b03222 --- /dev/null +++ b/scripts/dev-local.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Vite dev server (HMR) + MeshChat Python backend. Open http://localhost:5173 (or VITE_DEV_PORT). +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$ROOT" + +export MESHCHAT_PORT="${MESHCHAT_PORT:-8000}" +export E2E_BACKEND_PORT="$MESHCHAT_PORT" + +BE_PID="" +cleanup() { + if [[ -n "$BE_PID" ]] && kill -0 "$BE_PID" 2>/dev/null; then + kill "$BE_PID" 2>/dev/null || true + wait "$BE_PID" 2>/dev/null || true + fi +} +trap cleanup EXIT INT TERM + +poetry run python -m meshchatx.meshchat & +BE_PID=$! + +sleep "${DEV_BACKEND_WAIT:-1}" + +VITE_HOST="${VITE_DEV_HOST:-127.0.0.1}" +VITE_PORT="${VITE_DEV_PORT:-5173}" + +pnpm run dev -- --host "$VITE_HOST" --port "$VITE_PORT"