-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·64 lines (52 loc) · 1.6 KB
/
install.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
#!/bin/bash
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to prompt for user input
prompt() {
local promptText="$1"
local userInput
echo -n "${BLUE}$promptText (yes/no): ${NC}"
read userInput
while [[ "$userInput" != "yes" && "$userInput" != "no" && "$userInput" != "y" && "$userInput" != "n" ]]; do
echo -e "${RED}Please answer yes or no.${NC}"
echo -n "${BLUE}$promptText (yes/no): ${NC}"
read userInput
done
[[ "$userInput" == "yes" || "$userInput" == "y" ]] && return 0 || return 1
}
# Prompt for project name
echo -n "${BLUE}Enter project name: ${NC}"
read projectName
# Validate project name
if [ -z "$projectName" ]; then
echo -e "${RED}Project name cannot be empty. Exiting.${NC}"
exit 1
fi
# Get the current directory name
currentDir=$(basename "$PWD")
# Rename the current directory to the project name
if [ "$currentDir" != "$projectName" ]; then
echo -e "${YELLOW}Changing directory name...${NC}"
cd ..
mv "$currentDir" "$projectName"
cd "$projectName"
fi
echo -e "${GREEN}Initializing git...${NC}"
if [ -d ".git" ]; then
echo -e "${RED}Removing .git, need admin access${NC}"
sudo rm -r .git
fi
git init
echo -e "${GREEN}Installing packages...${NC}"
npm install
if prompt "Do you want to install MUI?"; then
npm install @mui/material @emotion/react @emotion/styled
node ./scripts/template.js "$projectName" mui
else
node ./scripts/template.js "$projectName"
fi
echo -e "${YELLOW}You can now safely delete content in scripts and install.sh${NC}"