-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
88 lines (75 loc) · 3.25 KB
/
setup.sh
File metadata and controls
88 lines (75 loc) · 3.25 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
#!/usr/bin/env bash
# colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
WHITE='\033[0;37m'
RESET='\033[0m'
# log timestamps
timestamp() { date +"%Y-%m-%d %H:%M:%S"; }
# Check if npm is installed
if ! command -v npm &> /dev/null; then
echo -e "${RED}$(timestamp) :: Error: npm is not installed on your system${RESET}"
echo -e "${YELLOW}Please install Node.js and npm first, then run this script again${RESET}"
echo -e "${WHITE}You can download Node.js from: https://nodejs.org${RESET}"
exit 1
fi
# creating configuration file
touch src/configuration.json
# starting setup process
echo -e "${BLUE}
███████╗███████╗████████╗██╗ ██╗██████╗
██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
███████╗█████╗ ██║ ██║ ██║██████╔╝
╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝
███████║███████╗ ██║ ╚██████╔╝██║
╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝
${RESET}"
echo -e "${GREEN}Welcome to the setup process for your project${RESET}"
echo -e "${YELLOW}All the dependencies will be installed automatically.${RESET}"
echo -e "${YELLOW}Eventually, you will be guided to type some information to fill the configuration file.${RESET}"
echo -e "${GREEN}Please note that what you type here is not uploaded to anywhere or seen by anyone except yourself!\n${RESET}"
# ask for version preference
while true; do
echo -e "${YELLOW}Would you like to install stable or development versions?${RESET}"
echo -e "${WHITE}1) Stable${RESET}"
echo -e "${WHITE}2) Development${RESET}"
read -p "Enter your choice (1 or 2): " version_choice
case $version_choice in
1)
FORGE_VERSION="@tryforge/forgescript"
FORGEDB_VERSION="@tryforge/forgedb"
break
;;
2)
FORGE_VERSION="github:tryforge/forgescript#dev"
FORGEDB_VERSION="github:tryforge/forgedb#dev"
break
;;
*)
echo -e "${RED}Invalid choice. Please enter 1 or 2.${RESET}"
;;
esac
done
# installing deps
echo -e "${BLUE}$(timestamp) :: Installing dependencies...${RESET}"
npm i $FORGE_VERSION $FORGEDB_VERSION sqlite3
echo -e "${BLUE}$(timestamp) :: Finishing up...${RESET}"
npm cache clean --force
echo -e "${GREEN}$(timestamp) :: Successfully installed all the dependencies!${RESET}"
# beginning of config file setup
echo -e "${WHITE}Starting configuration file setup...${RESET}"
echo -e "${YELLOW}Info: currently you can only have one prefix!${RESET}"
# creating config file with proper JSON format
read -p "App Token: " -e A
read -p "App Prefix: " -e B
cat > src/configuration.json << EOF
{
"token": "${A}",
"prefix": ["${B}"]
}
EOF
echo -e "\n${GREEN}$(timestamp) :: Successfully set up configuration file.${RESET}"
echo -e "${YELLOW}Keep this file safe in a local folder!${RESET}"
echo -e "${RED}Do not share this file to anyone!${RESET}"