-
Notifications
You must be signed in to change notification settings - Fork 11
/
buildBlog
executable file
·59 lines (50 loc) · 1.3 KB
/
buildBlog
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
#!/bin/bash
GREEN='\033[32m'
RED='\033[0;31m'
NC='\033[0m' # No color
# check if the blog should be built for supertokens backend
target="blog_server"
while getopts ":hg" opt; do
case ${opt} in
h)
echo "Usage:"
echo "To build for local blog server run ./buildBlog"
echo "To build for main website run ./buildBlog -g"
exit 0
;;
g)
target="supertokens_backend"
;;
\?)
echo "Invalid Option: -$OPTARG" 1>&2
echo "Usage:"
echo "To build for local blog server run ./buildBlog"
echo "To build for main website run ./buildBlog -g"
exit 1
;;
esac
done
shift $((OPTIND - 1))
# build the blog
echo -e "${GREEN}Building blog...${NC}"
npm run build
doesBuild=$?
if [ $doesBuild -ne 0 ]
then
echo -e "${RED}Blog build failed.${NC}"
exit 1
fi
echo -e "${GREEN}Blog built successfully.${NC}"
if [ "$target" = "supertokens_backend" ]
then
projectDir=$(pwd)
cd ..
# check if the blog directory exists
if [ ! -d supertokens-backend-website/app/blog ]; then
mkdir supertokens-backend-website/app/blog
fi
# remove all the files of old blog and replace with newly built blog
rm -rf supertokens-backend-website/app/blog/*
cp -r $projectDir/public/* supertokens-backend-website/app/blog/
echo -e "${GREEN}Blog moved to supertokens-backend-website.${NC}"
fi