-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
setup.sh
111 lines (110 loc) · 3.24 KB
/
setup.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
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
#!/bin/bash
# Setup script for the genealogy-laravel project.
#
# This script prepares the project environment by copying the .env.example to .env (if necessary),
# installing dependencies, generating application keys, running database migrations, seeding the database,
# and executing Laravel optimization commands. It ensures the application is ready for development or production use.
clear
echo "=================================="
echo "===== USER: [$(whoami)]"
echo "===== [PHP $(php -r 'echo phpversion();')]"
echo "=================================="
echo ""
echo ""
echo "=================================="
echo "===== PREPARING YOUR PROJECT..."
echo "=================================="
echo ""
# Setup the .env file
copy=true
while $yn; do
read -p "🎬 DEV ---> DID YOU WANT TO COPY THE .ENV.EXAMPLE TO .ENV? (y/n) " yn
case $yn in
[Yy]* ) echo -e "\e[92mCopying .env.example to .env \e[39m"; cp .env.example .env; copy=true; break;;
[Nn]* ) echo -e "\e[92mContinuing with your .env configuration \e[39m"; copy=false; break;;
* ) echo "Please answer yes or no."; copy=true; ;;
esac
done
echo ""
echo "=================================="
echo ""
echo ""
# Ask user to confirm that .env file is properly setup before continuing
if [ "$copy" = true ]; then
answ=true
while $cond; do
read -p "🎬 DEV ---> DID YOU SETUP YOUR DATABASE CREDENTIALS IN THE .ENV FILE? (y/n) " cond
case $cond in
[Yy]* ) echo -e "\e[92mPerfect let's continue with the setup"; answ=false; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no."; answ=false; ;;
esac
done
fi
echo ""
echo "=================================="
echo ""
echo ""
# Install laravel dependencies with composer
echo "🎬 DEV ---> COMPOSER INSTALL"
composer install
echo ""
echo "=================================="
echo ""
echo ""
# Generate larave key
echo "🎬 DEV ---> PHP ARTISAN KEY:GENERATE"
php artisan key:generate
echo ""
echo "=================================="
echo ""
echo ""
# Run database migrations
echo "🎬 DEV ---> php artisan migrate:fresh"
php artisan migrate:fresh
echo ""
echo ""
echo "=================================="
echo ""
echo ""
# Seeding database
echo "🎬 DEV ---> php artisan db:seed"
if ! php artisan db:seed; then
echo "Database seeding failed."
exit 1
fi
php artisan db:seed
if ! php artisan db:seed; then
echo "Database seeding failed."
exit 1
fi
php artisan db:seed
echo ""
echo "🎬 DEV ---> Running PHPUnit tests"
if ! ./vendor/bin/phpunit; then
echo "PHPUnit tests failed."
exit 1
fi
echo ""
echo "=================================="
echo ""
echo ""
# Run optimization commands for laravel
echo "🎬 DEV ---> php artisan optimize:clear"
php artisan optimize:clear
php artisan route:clear
echo ""
echo ""
echo "\e[92m==================================\e[39m"
echo "\e[92m============== DONE ==============\e[39m"
echo "\e[92m==================================\e[39m"
echo ""
echo ""
while $cond; do
read -p "🎬 DEV ---> DID YOU WANT TO START THE SERVER? (y/n) " cond
case $cond in
[Yy]* ) echo -e "\e[92mStarting server\e[39m"; php artisan serve; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no."; ;;
esac
done