-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
init.sh
71 lines (61 loc) · 2.65 KB
/
init.sh
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
#!/bin/bash
# Default instance value
instance="dev"
# Default port value
port="3000"
# Parsing command-line options
while getopts ":i:p:" opt; do
case $opt in
i)
instance="$OPTARG"
;;
p)
port="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
echo "-------------------------------------- INIT SCRIPT --------------------------------------"
echo "Dont forget to set the environment variables in the .env file and the .env.local file!!"
echo "Before running this script, make sure you have installed pm2 globally with npm install -g pm2"
echo "-----------------------------------------------------------------------------------------"
# This script is used to initialize the project
echo "-------------------------------------- INIT SCRIPT --------------------------------------"
echo "Initializing the project..."
echo "-----------------------------------------------------------------------------------------"
pnpm install
# This script is used to generate the prisma client and schema
echo "-------------------------------------- PRISMA SCRIPT ------------------------------------"
echo "Generating the prisma client and schema..."
echo "-----------------------------------------------------------------------------------------"
pnpm prisma generate
# This script is used to initialize the database
echo "-------------------------------------- PRISMA - DB PUSH SCRIPT --------------------------"
echo "Initializing the database..."
echo "-----------------------------------------------------------------------------------------"
pnpm prisma db push
# This script is used to seed the database with default data
echo "-------------------------------------- PRISMA - DB SEED SCRIPT --------------------------"
echo "Seeding the database..."
echo "-----------------------------------------------------------------------------------------"
pnpm prisma db seed
# This script builds the project
echo "-------------------------------------- BUILD SCRIPT -------------------------------------"
echo "Building the project..."
echo "-----------------------------------------------------------------------------------------"
pnpm run build
# This script is used to start the server
echo "-------------------------------------- START SCRIPT --------------------------------------"
echo "Starting the server..."
echo " Instance: https://$instance.nextcrm.online"
echo " Port: $port"
echo "------------------------------------------------------------------------------------------"
pm2 start pnpm --name "nextcrm-$instance" -- start --port $port
pm2 save