-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·100 lines (76 loc) · 1.91 KB
/
run
File metadata and controls
executable file
·100 lines (76 loc) · 1.91 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
#!/bin/bash
# Usage: ./run <component>
# Example: ./run core
set -e
component=$1
if [ -z "$component" ]; then
echo "Component name is required. Usage: ./run <component>"
exit 1
fi
if [ ! -d "$component" ]; then
echo "Component $component does not exist."
exit 1
fi
################ HELPERS ################
has_option() {
local option=$1
shift
for var in "$@"
do
if [ "$var" = "$option" ]; then
return 0
fi
done
return 1
}
################ CLEANUP ################
cleanup() {
echo "Cleaning up"
# kil all child processes
pkill -P $$ --signal 9
rm -rf $component/backend/packages/internal
rm -rf $component/frontend/src/design
}
trap cleanup EXIT
################ DESIGN SYSTEM ################
# if it has --design option
if has_option "--design" "$@"
then
echo "Watching and syncing design system"
cd design || exit
npm run package:watch &
cd ..
rsync -avz design/dist design/package.json $component/frontend/src/design
# Watch internal library for changes
if command -v fswatch >/dev/null 2>&1
then
echo "Using fswatch to sync design system"
fswatch -o design/dist --latency 1 | xargs -I{} rsync -avz design/dist design/package.json $component/frontend/src/design > /dev/null &
else
echo "NOTICE: fswatch is not available. Please install fswatch to watch & sync design system"
fi
fi
################ DOCKER COMPOSE ################
# Run compose
get_profile() {
while [[ $# -gt 0 ]]; do
case "$1" in
--profile) # --profile <name>
echo "$2"
return
;;
--profile=*) # --profile=<name>
echo "${1#*=}"
return
;;
esac
shift
done
# Default if no profile provided
echo "dev"
}
cd $component
PROFILE=$(get_profile "$@")
echo "Running $component with profile $PROFILE"
docker compose --profile "$PROFILE" up --build
cleanup