-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_unix.sh
More file actions
executable file
Β·134 lines (117 loc) Β· 3.64 KB
/
Copy pathrun_unix.sh
File metadata and controls
executable file
Β·134 lines (117 loc) Β· 3.64 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env bash
set -euo pipefail
# Detect OS
OS="unknown"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
fi
# Small helper
have() { command -v "$1" >/dev/null 2>&1; }
echo ""
echo "π ============================================"
echo " π¨ VIBRANT WAVE MINI π¨"
echo "============================================"
echo ""
echo "π [vibrant-wave-mini] Checking bun..."
if ! have bun; then
echo "β οΈ bun not found. Installing..."
if [[ "$OS" == "macos" ]] && have brew; then
echo "π¦ Installing via Homebrew..."
brew tap oven-sh/bun || true
brew install bun || true
else
echo "π¦ Installing via curl script..."
curl -fsSL https://bun.sh/install | bash
fi
export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
export PATH="$BUN_INSTALL/bin:$PATH"
fi
if ! have bun; then
echo "β bun is not on PATH. Add \"$HOME/.bun/bin\" to PATH or restart your shell."
exit 1
else
echo "β
bun found and ready!"
fi
echo "π¦ [vibrant-wave-mini] Checking dependencies..."
if [ ! -d "node_modules" ]; then
echo "π Installing dependencies..."
bun install
echo "β
Dependencies installed!"
else
echo "β
Dependencies already installed!"
fi
echo "π [vibrant-wave-mini] Checking OPENROUTER_API_KEY..."
if [ -z "${OPENROUTER_API_KEY:-}" ]; then
FOUND_KEY=0
if [ -f ".env.local" ] && grep -qE '^OPENROUTER_API_KEY=.*' .env.local; then
FOUND_KEY=1
fi
if [ -f ".env" ] && grep -qE '^OPENROUTER_API_KEY=.*' .env; then
FOUND_KEY=1
fi
if [ $FOUND_KEY -eq 0 ]; then
echo "β Missing OPENROUTER_API_KEY in environment or .env files"
echo "Create .env or .env.local with:"
echo "OPENROUTER_API_KEY=sk-or-..."
echo "# Optional:"
echo "OPENROUTER_IMAGE_MODEL=google/gemini-2.5-flash-image-preview"
exit 1
else
echo "β
OPENROUTER_API_KEY found in .env files"
fi
fi
echo ""
echo "π [vibrant-wave-mini] Starting dev server..."
echo "β³ [vibrant-wave-mini] Waiting for server to start..."
# Start dev server in background and capture output
bun run dev > dev_output.log 2>&1 &
DEV_PID=$!
# Wait for server to start (check for typical Next.js output)
wait_for_server() {
while true; do
if grep -q "Local:" dev_output.log 2>/dev/null || grep -q "ready" dev_output.log 2>/dev/null; then
break
fi
sleep 2
done
}
wait_for_server
# Extract port from dev output (default 3000)
PORT=3000
if grep -q "Local:" dev_output.log; then
PORT=$(grep "Local:" dev_output.log | sed -n 's/.*Local:[[:space:]]*[^:]*:\([0-9]*\).*/\1/p' | head -1)
fi
echo "β
[vibrant-wave-mini] Server started on port $PORT"
echo "π [vibrant-wave-mini] Opening browser..."
# Open browser (OS-specific)
if [[ "$OS" == "macos" ]]; then
open "http://localhost:$PORT"
elif [[ "$OS" == "linux" ]]; then
if command -v xdg-open >/dev/null 2>&1; then
xdg-open "http://localhost:$PORT"
elif command -v firefox >/dev/null 2>&1; then
firefox "http://localhost:$PORT" &
elif command -v google-chrome >/dev/null 2>&1; then
google-chrome "http://localhost:$PORT" &
else
echo "β οΈ [vibrant-wave-mini] Could not find browser command. Please open http://localhost:$PORT manually."
fi
else
echo "β οΈ [vibrant-wave-mini] Unknown OS. Please open http://localhost:$PORT manually."
fi
# Show the log output
echo ""
echo "π [vibrant-wave-mini] Development server output:"
echo "============================================"
cat dev_output.log
echo "============================================"
# Clean up on exit
cleanup() {
kill $DEV_PID 2>/dev/null || true
rm -f dev_output.log
}
trap cleanup EXIT
# Wait for the dev server process
wait $DEV_PID