From 005908710ea8a480369dddc1148688d61e843637 Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Sat, 14 Feb 2026 00:39:43 +0800 Subject: [PATCH] chore: add local dev script for Gateway + Desktop with Telegram bot Co-Authored-By: Claude Opus 4.6 --- .env.example | 9 ++++++++ package.json | 1 + scripts/dev-local.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .env.example create mode 100755 scripts/dev-local.sh diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..ea1360bb --- /dev/null +++ b/.env.example @@ -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 diff --git a/package.json b/package.json index 568bff9e..345fe5ac 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "dev:desktop:onboarding": "pnpm --filter @multica/desktop dev:onboarding", "dev:gateway": "pnpm --filter @multica/gateway dev", "dev:web": "pnpm --filter @multica/web dev", + "dev:local": "bash scripts/dev-local.sh", "dev:all": "concurrently \"pnpm dev:gateway\" \"pnpm dev:web\"", "build": "turbo build", "build:desktop": "pnpm --filter @multica/desktop build", diff --git a/scripts/dev-local.sh b/scripts/dev-local.sh new file mode 100755 index 00000000..85d856f5 --- /dev/null +++ b/scripts/dev-local.sh @@ -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"