forked from dansysanalyst/wireui-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·137 lines (101 loc) · 3.37 KB
/
run.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
#╔═════════════════════╗#
#║ WireUI Setup ║#
#╚═════════════════════╝#
# ══════════════ STYLES ═════════
NC='\033[0m'
WHITE='\033[1;37m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
LABEL_OK="\n\033[048;5;64m OK ${NC} "
LABEL_WARNING="\n\033[048;5;208m WARNING ${NC} "
LABEL_ERROR="\n\033[048;5;9m ERROR ${NC} "
LABEL_WIREUI="\n\033[48;5;29m\033[1m WireUI ${NC} "
# ══════════════ FUNCTIONS ═════════
checkPhp () {
if ! php --version >/dev/null 2>&1; then
echo -e "${LABEL_ERROR}PHP is required!"
exit 1;
fi
}
checkYarn () {
if ! yarn --version >/dev/null 2>&1; then
echo -e "${LABEL_ERROR}Yarn is required! Visit: https://yarnpkg.com for instructions."
exit 1;
fi
}
checkComposer () {
if ! composer --version >/dev/null 2>&1; then
echo -e "${LABEL_ERROR}Yarn is required! Visit: https://getcomposer.org for instructions."
exit 1;
fi
}
composerInstall () {
if [ ! -d ./vendor ]; then
echo -e "${LABEL_WIREUI}Installing project dependencies with composer..."
composer install
if [ ! $? -eq 0 ]; then
echo -e "${LABEL_ERROR}Error installing dependencies with composer!"
exit 1;
fi
fi
}
compileAssets () {
echo -e "${LABEL_WIREUI}Compiling assets..."
yarn install
yarn run prod
if [ ! $? -eq 0 ]; then
echo -e "${LABEL_ERROR}Error compiling assets..."
exit 1;
fi
}
generateAppKey(){
HAS_KEY=$(grep APP_KEY=base64 .env)
if [ -f ./.env ] && [ -z "$HAS_KEY" ]; then
echo -e "${LABEL_WIREUI}generating Laravel App Key... 🗝️"
php artisan key:generate --ansi
if [ ! $? -eq 0 ]; then
echo -e "${LABEL_ERROR}App Key was not generated!"
exit 1;
fi
fi
}
TorchlightToken(){
HAS_TOKEN=$(grep TORCHLIGHT_TOKEN=torch_ .env)
if [ -f ./.env ] && [ -z "$HAS_TOKEN" ]; then
read -p "$(echo -e "${LABEL_WIREUI}Enter your ${YELLOW}Torchlight TOKEN${NC} (get it at https://torchlight.dev)\n${YELLOW}➔${NC}")" TOKEN
if [ -z "$TOKEN" ]; then
echo -e "${LABEL_ERROR}Token is required!"
exit 1;
fi
if [[ ! $TOKEN == torch_* ]]; then
echo -e "${LABEL_ERROR}Token seems to be invalid!"
exit 1;
fi
ENVFILE=$(sed -e "s/TORCHLIGHT_TOKEN=[^\"]*/TORCHLIGHT_TOKEN=$TOKEN/" .env)
echo -e "$ENVFILE"> .env
echo -e "${LABEL_OK}TOKEN was successfully added to your ${YELLOW}.env${NC} file!"
fi
}
serveProject(){
echo -e "${LABEL_WIREUI}Would you like to start the ${YELLOW}Artisan Server${NC} [y/N]?"
read ANSWER
if [ "$ANSWER" != "${ANSWER#[Yy]}" ]; then
php artisan serve
fi
}
# ══════════════ SCRIPT ═════════
echo -e "${LABEL_WIREUI}${YELLOW}Let's begin!${NC}"
if [ ! -f ./.env ] && [ -f .env.example ]; then
echo -e "${LABEL_WIREUI}Copying ${YELLOW}.env.example${NC} into ${YELLOW}.env${NC}"
cp .env.example .env
fi
checkYarn
checkComposer
composerInstall
TorchlightToken
generateAppKey
compileAssets
echo -e "${LABEL_OK}WireUI Doc is configured!"
echo -e "${LABEL_WIREUI}🙏 Thank you for contributing!"
serveProject