-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathlaunch_fe.sh
More file actions
83 lines (75 loc) · 2.59 KB
/
launch_fe.sh
File metadata and controls
83 lines (75 loc) · 2.59 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
#!/bin/bash
# Terminal control sequences for clearing and moving cursor
clear_screen() {
tput clear
}
move_to_bottom() {
lines=$(tput lines)
tput cup $((lines-2)) 0
}
# Kill frontend processes function
kill_frontend() {
move_to_bottom
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🛑 Killing frontend processes..."
pkill -f 'npm run'
echo "✅ Done"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
tput cup $((lines-1)) 0
}
# Display menu at the bottom of the screen
display_menu() {
move_to_bottom
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📋 Options: [d]ev | [b]uild | [p]review | [s]torybook | build-[S]torybook | [k]ill | [q]uit"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
}
# Run commands with clear screen preparation
run_command() {
clear_screen
echo "🚀 Running: $1"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
eval "$1"
echo ""
display_menu
}
# Auto-run the development server at startup
clear_screen
echo "🚀 Auto-starting development server..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
npm run dev &
while true; do
display_menu
read -n 1 -s key
case $key in
d)
kill_frontend
run_command "npm run dev"
;;
b)
kill_frontend
run_command "npm run build"
;;
p)
kill_frontend
run_command "npm run preview"
;;
s)
kill_frontend
run_command "npm run storybook"
;;
S)
kill_frontend
run_command "npm run build-storybook"
;;
k)
kill_frontend
;;
q)
kill_frontend
clear_screen
echo "👋 Goodbye!"
exit 0
;;
esac
done