CLAUDE: Add --network flag to dev-native.sh for cross-device testing
- Add ./dev-native.sh start --network for network-accessible development - Auto-detects network IP and configures all URLs accordingly - Create .env.network templates for backend and frontend - No manual environment variable editing needed - Shows Discord OAuth redirect URI to add Usage: ./dev-native.sh start # localhost only ./dev-native.sh start --network # accessible from network ./dev-native.sh restart --network # restart in network mode Benefits: - Test from phone/tablet/laptop on same network - One command to switch between local and network modes - Automatic IP detection and configuration
This commit is contained in:
parent
50bd998ecf
commit
8b05c238f6
24
backend/.env.network
Normal file
24
backend/.env.network
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Application
|
||||||
|
APP_ENV=development
|
||||||
|
DEBUG=true
|
||||||
|
SECRET_KEY=5yIKYt_x20Kk-9PrQVfRzDGc-RFT06vTgIGAz13I8pU
|
||||||
|
|
||||||
|
# Database
|
||||||
|
DATABASE_URL=postgresql+asyncpg://paperdynasty:Snugly9-Gem-Configure@10.10.0.42:5432/paperdynasty_dev
|
||||||
|
|
||||||
|
# Discord OAuth
|
||||||
|
DISCORD_CLIENT_ID=1441192438055178420
|
||||||
|
DISCORD_CLIENT_SECRET=oj1OzUo4Qksph6mq57zb-qDiMxtb1n48
|
||||||
|
DISCORD_REDIRECT_URI=http://10.0.0.206:3000/auth/callback
|
||||||
|
DISCORD_SERVER_REDIRECT_URI=http://10.0.0.206:8000/api/auth/discord/callback/server
|
||||||
|
FRONTEND_URL=http://10.0.0.206:3000
|
||||||
|
|
||||||
|
# League APIs
|
||||||
|
SBA_API_URL=https://api.sba.manticorum.com
|
||||||
|
SBA_API_KEY=Tp3aO3jhYve5NJF1IqOmJTmk
|
||||||
|
PD_API_URL=https://pd-api.example.com
|
||||||
|
PD_API_KEY=placeholder-pd-api-key
|
||||||
|
|
||||||
|
# CORS
|
||||||
|
CORS_ORIGINS=["http://localhost:3000","http://localhost:3001","http://10.0.0.206:3000"]
|
||||||
|
ALLOWED_DISCORD_IDS=258104532423147520,139926308644847616
|
||||||
118
dev-native.sh
118
dev-native.sh
@ -61,21 +61,48 @@ check_dependencies() {
|
|||||||
|
|
||||||
# Setup environment files
|
# Setup environment files
|
||||||
setup_env() {
|
setup_env() {
|
||||||
print_status "Setting up development environment files..."
|
local mode=${1:-local}
|
||||||
|
|
||||||
# Backend
|
if [[ "$mode" == "network" ]]; then
|
||||||
if [[ ! -f "backend/.env" ]] || ! grep -q "localhost:8000" "backend/.env" 2>/dev/null; then
|
print_status "Setting up NETWORK environment files..."
|
||||||
print_status "Copying backend/.env.dev -> backend/.env"
|
|
||||||
cp backend/.env.dev backend/.env
|
# Detect network IP
|
||||||
|
local network_ip=$(ip addr show | grep "inet " | grep -v "127.0.0.1" | grep -v "tailscale" | head -1 | awk '{print $2}' | cut -d'/' -f1)
|
||||||
|
|
||||||
|
if [[ -z "$network_ip" ]]; then
|
||||||
|
print_error "Could not detect network IP"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_status "Detected network IP: $network_ip"
|
||||||
|
|
||||||
|
# Backend
|
||||||
|
cp backend/.env.network backend/.env
|
||||||
|
sed -i "s|10\\.0\\.0\\.[0-9]*|$network_ip|g" backend/.env
|
||||||
|
|
||||||
|
# Frontend
|
||||||
|
cp frontend-sba/.env.network frontend-sba/.env
|
||||||
|
sed -i "s|10\\.0\\.0\\.[0-9]*|$network_ip|g" frontend-sba/.env
|
||||||
|
|
||||||
|
print_success "Network mode configured for $network_ip"
|
||||||
|
print_warning "Add to Discord OAuth: http://$network_ip:8000/api/auth/discord/callback/server"
|
||||||
|
else
|
||||||
|
print_status "Setting up development environment files..."
|
||||||
|
|
||||||
|
# Backend
|
||||||
|
if [[ ! -f "backend/.env" ]] || ! grep -q "localhost:8000" "backend/.env" 2>/dev/null; then
|
||||||
|
print_status "Copying backend/.env.dev -> backend/.env"
|
||||||
|
cp backend/.env.dev backend/.env
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Frontend
|
||||||
|
if [[ ! -f "frontend-sba/.env" ]] || ! grep -q "localhost:8000" "frontend-sba/.env" 2>/dev/null; then
|
||||||
|
print_status "Copying frontend-sba/.env.dev -> frontend-sba/.env"
|
||||||
|
cp frontend-sba/.env.dev frontend-sba/.env
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_success "Environment files ready"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Frontend
|
|
||||||
if [[ ! -f "frontend-sba/.env" ]] || ! grep -q "localhost:8000" "frontend-sba/.env" 2>/dev/null; then
|
|
||||||
print_status "Copying frontend-sba/.env.dev -> frontend-sba/.env"
|
|
||||||
cp frontend-sba/.env.dev frontend-sba/.env
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_success "Environment files ready"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start Redis (Docker)
|
# Start Redis (Docker)
|
||||||
@ -247,11 +274,13 @@ show_logs() {
|
|||||||
|
|
||||||
# Start all services
|
# Start all services
|
||||||
start_all() {
|
start_all() {
|
||||||
|
local mode=${1:-local}
|
||||||
|
|
||||||
print_status "Starting native development environment..."
|
print_status "Starting native development environment..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
check_dependencies
|
check_dependencies
|
||||||
setup_env
|
setup_env "$mode"
|
||||||
|
|
||||||
start_redis || exit 1
|
start_redis || exit 1
|
||||||
start_backend || exit 1
|
start_backend || exit 1
|
||||||
@ -260,14 +289,29 @@ start_all() {
|
|||||||
echo ""
|
echo ""
|
||||||
print_success "Development environment ready!"
|
print_success "Development environment ready!"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${GREEN}========================================${NC}"
|
|
||||||
echo -e "${GREEN} Native Development Mode${NC}"
|
if [[ "$mode" == "network" ]]; then
|
||||||
echo -e "${GREEN}========================================${NC}"
|
local network_ip=$(ip addr show | grep "inet " | grep -v "127.0.0.1" | grep -v "tailscale" | head -1 | awk '{print $2}' | cut -d'/' -f1)
|
||||||
echo ""
|
echo -e "${GREEN}========================================${NC}"
|
||||||
echo " Backend API: http://localhost:8000"
|
echo -e "${GREEN} Native Development Mode (NETWORK)${NC}"
|
||||||
echo " API Docs: http://localhost:8000/docs"
|
echo -e "${GREEN}========================================${NC}"
|
||||||
echo " Frontend: http://localhost:3000"
|
echo ""
|
||||||
echo ""
|
echo " Access from ANY device on your network:"
|
||||||
|
echo " Frontend: http://$network_ip:3000"
|
||||||
|
echo " Backend: http://$network_ip:8000"
|
||||||
|
echo " API Docs: http://$network_ip:8000/docs"
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}========================================${NC}"
|
||||||
|
echo -e "${GREEN} Native Development Mode${NC}"
|
||||||
|
echo -e "${GREEN}========================================${NC}"
|
||||||
|
echo ""
|
||||||
|
echo " Backend API: http://localhost:8000"
|
||||||
|
echo " API Docs: http://localhost:8000/docs"
|
||||||
|
echo " Frontend: http://localhost:3000"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
echo " Features:"
|
echo " Features:"
|
||||||
echo " ✓ Hot-reload enabled (backend + frontend)"
|
echo " ✓ Hot-reload enabled (backend + frontend)"
|
||||||
echo " ✓ No Docker rebuilds"
|
echo " ✓ No Docker rebuilds"
|
||||||
@ -287,22 +331,31 @@ start_all() {
|
|||||||
|
|
||||||
# Restart all services
|
# Restart all services
|
||||||
restart_all() {
|
restart_all() {
|
||||||
|
local mode=${1:-local}
|
||||||
stop_services
|
stop_services
|
||||||
sleep 2
|
sleep 2
|
||||||
start_all
|
start_all "$mode"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show usage
|
# Show usage
|
||||||
show_usage() {
|
show_usage() {
|
||||||
|
local network_ip=$(ip addr show | grep "inet " | grep -v "127.0.0.1" | grep -v "tailscale" | head -1 | awk '{print $2}' | cut -d'/' -f1)
|
||||||
|
|
||||||
echo "Paper Dynasty - Native Development Mode"
|
echo "Paper Dynasty - Native Development Mode"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: ./dev-native.sh <command>"
|
echo "Usage: ./dev-native.sh <command> [--network]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " start Start all services natively (instant, hot-reload)"
|
echo " start Start services (localhost only)"
|
||||||
echo " stop Stop all services"
|
echo " start --network Start services (accessible from network)"
|
||||||
echo " logs Tail logs from all services"
|
echo " stop Stop all services"
|
||||||
echo " restart Restart all services"
|
echo " logs Tail logs from all services"
|
||||||
|
echo " restart Restart services"
|
||||||
|
echo " restart --network Restart in network mode"
|
||||||
|
echo ""
|
||||||
|
echo "Network Mode:"
|
||||||
|
echo " Your IP: $network_ip"
|
||||||
|
echo " Access: http://$network_ip:3000"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Benefits:"
|
echo "Benefits:"
|
||||||
echo " • No Docker rebuilds (saves minutes)"
|
echo " • No Docker rebuilds (saves minutes)"
|
||||||
@ -318,9 +371,14 @@ show_usage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
|
MODE="local"
|
||||||
|
if [[ "${2:-}" == "--network" ]]; then
|
||||||
|
MODE="network"
|
||||||
|
fi
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
start)
|
start)
|
||||||
start_all
|
start_all "$MODE"
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
stop_services
|
stop_services
|
||||||
@ -329,7 +387,7 @@ case "${1:-}" in
|
|||||||
show_logs
|
show_logs
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
restart_all
|
restart_all "$MODE"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
show_usage
|
show_usage
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user