chore: add local dev script for Gateway + Desktop with Telegram bot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang 2026-02-14 00:39:43 +08:00
parent b39a0dd2ac
commit 005908710e
3 changed files with 60 additions and 0 deletions

9
.env.example Normal file
View file

@ -0,0 +1,9 @@
# Telegram Bot
# Get a token from @BotFather on Telegram
TELEGRAM_BOT_TOKEN=
# Optional: webhook secret token for production
# TELEGRAM_WEBHOOK_SECRET_TOKEN=
# Optional: webhook URL (if not set, uses long-polling mode for local dev)
# TELEGRAM_WEBHOOK_URL=https://your-domain.ngrok-free.dev/telegram/webhook

View file

@ -18,6 +18,7 @@
"dev:desktop:onboarding": "pnpm --filter @multica/desktop dev:onboarding", "dev:desktop:onboarding": "pnpm --filter @multica/desktop dev:onboarding",
"dev:gateway": "pnpm --filter @multica/gateway dev", "dev:gateway": "pnpm --filter @multica/gateway dev",
"dev:web": "pnpm --filter @multica/web dev", "dev:web": "pnpm --filter @multica/web dev",
"dev:local": "bash scripts/dev-local.sh",
"dev:all": "concurrently \"pnpm dev:gateway\" \"pnpm dev:web\"", "dev:all": "concurrently \"pnpm dev:gateway\" \"pnpm dev:web\"",
"build": "turbo build", "build": "turbo build",
"build:desktop": "pnpm --filter @multica/desktop build", "build:desktop": "pnpm --filter @multica/desktop build",

50
scripts/dev-local.sh Executable file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env bash
#
# Local development: Gateway (with Telegram bot) + Desktop
#
# Usage:
# pnpm dev:local
#
# Reads TELEGRAM_BOT_TOKEN from .env at the repo root.
# Gateway runs in long-polling mode (no TELEGRAM_WEBHOOK_URL needed).
# Desktop connects to the local Gateway at http://localhost:3000.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT_DIR="$SCRIPT_DIR/.."
ENV_FILE="$ROOT_DIR/.env"
# Load .env
if [ ! -f "$ENV_FILE" ]; then
echo "Error: .env file not found at $ENV_FILE"
echo "Copy .env.example to .env and fill in TELEGRAM_BOT_TOKEN"
exit 1
fi
set -a
source "$ENV_FILE"
set +a
if [ -z "${TELEGRAM_BOT_TOKEN:-}" ]; then
echo "Error: TELEGRAM_BOT_TOKEN not set in .env"
exit 1
fi
echo "Starting local dev environment..."
echo " Gateway: http://localhost:3000 (Telegram long-polling mode)"
echo " Desktop: connecting to local Gateway"
echo ""
# Build shared packages first
pnpm turbo build --filter=@multica/types --filter=@multica/utils --filter=@multica/core
# Start everything
exec pnpm concurrently \
-n types,utils,core,gateway,desktop \
-c blue,green,yellow,magenta,cyan \
"pnpm --filter @multica/types dev" \
"pnpm --filter @multica/utils dev" \
"pnpm --filter @multica/core dev" \
"pnpm --filter @multica/gateway dev" \
"GATEWAY_URL=http://localhost:3000 pnpm --filter @multica/desktop dev"