-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_app.command
More file actions
executable file
·99 lines (83 loc) · 3.12 KB
/
Copy pathrun_app.command
File metadata and controls
executable file
·99 lines (83 loc) · 3.12 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
#!/bin/bash
# ==============================================================================
# VOTESAFE BIO-METRIC VOTING SYSTEM - LAUNCH SCRIPT
# ==============================================================================
# This script automates the setup, build, and launch of the Votesafe application.
# It acts as a "One-Click Run" for the entire system.
# 1. Environment Setup (Attempt to find Node/NPM)
# ------------------------------------------------------------------------------
# Source common profile files to ensure PATH includes node/npm
if [ -f "$HOME/.zshrc" ]; then source "$HOME/.zshrc"; fi
if [ -f "$HOME/.bash_profile" ]; then source "$HOME/.bash_profile"; fi
if [ -f "$HOME/.bashrc" ]; then source "$HOME/.bashrc"; fi
# Try loading NVM if present
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Add common binary paths
export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin
# 2. Check Prerequisites
# ------------------------------------------------------------------------------
if ! command -v npm &> /dev/null
then
echo "❌ ERROR: 'npm' could not be found."
echo "Please install Node.js (https://nodejs.org/) or ensure it is in your PATH."
exit 1
fi
echo "=========================================="
echo " VOTESAFE BIO-METRIC VOTING SYSTEM"
echo "=========================================="
echo "🚀 Initializing environment..."
# Navigate to project root
cd "$(dirname "$0")"
PROJECT_ROOT=$(pwd)
# 3. Backend Setup
# ------------------------------------------------------------------------------
echo "------------------------------------------"
echo "📦 [1/4] Setting up Backend..."
echo "------------------------------------------"
cd backend
# Install dependencies if missing
if [ ! -d "node_modules" ]; then
echo "Installing backend dependencies..."
npm install
fi
# Build Backend (Typescript -> JS)
echo "Building backend..."
npm run build
if [ $? -ne 0 ]; then
echo "❌ Backend build failed."
exit 1
fi
# 4. Frontend Setup
# ------------------------------------------------------------------------------
echo "------------------------------------------"
echo "🎨 [2/4] Setting up Frontend..."
echo "------------------------------------------"
cd "$PROJECT_ROOT"
# Install dependencies if missing
if [ ! -d "node_modules" ]; then
echo "Installing frontend dependencies..."
npm install
fi
# Build Frontend (Vite -> /dist)
echo "Building frontend bundle..."
npm run build
if [ $? -ne 0 ]; then
echo "❌ Frontend build failed."
exit 1
fi
# 5. Launch Application
# ------------------------------------------------------------------------------
echo "------------------------------------------"
echo "🌐 [3/4] Launching Server..."
echo "------------------------------------------"
# Open browser in background after 5 seconds
(sleep 5 && open "http://localhost:3001") &
echo "🟢 App starting at http://localhost:3001"
echo " - Database will auto-seed on first run."
echo " - Press Ctrl+C to stop."
echo "------------------------------------------"
# Run Backend in Production Mode (serves frontend static files)
cd backend
export NODE_ENV=production
npm start