-
Notifications
You must be signed in to change notification settings - Fork 0
/
express-install
executable file
·129 lines (111 loc) · 3.61 KB
/
express-install
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
#!/bin/bash
BASEDIR=$(basename $(pwd))
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
if [ "$SHELL" = "/bin/zsh" ]; then
SHELL_RC="${HOME}/.zshrc"
elif [ "$SHELL" = "/bin/bash" ]; then
SHELL_RC="${HOME}/.bashrc"
else
echo -e "${RED}Unsupported shell. Please use bash or zsh.${NC}"
exit 1
fi
if [ "$BASEDIR" != "express" ]; then
echo -e "${RED}Please run this script from the express directory.${NC}"
exit 1
fi
echo -e "${YELLOW}Updating express...${NC}"
if ! git pull
then
echo -e "${RED}Failed to update git.${NC}"
exit 1
fi
echo -e "${GREEN}Express updated.${NC}"
if [ ! -d venv ]; then
echo -e "${YELLOW}Setting up virtual environment...${NC}"
if ! python3 -m venv venv
then
echo -e "${RED}Failed to create virtual environment.${NC}"
exit 1
fi
echo -e "${GREEN}Virtual environment created.${NC}"
fi
echo -e "${YELLOW}Activating virtual environment...${NC}"
if ! source venv/bin/activate
then
echo -e "${RED}Failed to activate virtual environment.${NC}"
exit 1
fi
echo -e "${GREEN}Virtual environment activated.${NC}"
echo -e "${YELLOW}Installing requirements...${NC}"
if ! python3 -m pip install --upgrade pip
then
echo -e "${RED}Failed to upgrade pip.${NC}"
exit 1
fi
if ! python3 -m pip install -r requirements.txt
then
echo -e "${RED}Failed to install requirements.${NC}"
exit 1
fi
echo -e "${GREEN}Requirements installed.${NC}"
if [ -f express/_custom.py ]; then
echo -e "${YELLOW}Custom file already exists. Skipping...${NC}"
else
echo -e "${GREEN}Creating custom file...${NC}"
cat > express/_custom.py << EOF
class MyCustomActions:
"""
This is your own class. You can add any functions you want to this class, and they will be available to all tests.
"""
def __init__(self):
pass
def my_example_function(self, arg1):
"""
This is my first example function. This function can be called from any test using the following syntax:
actions.my_example_function("test")
Args:
arg1 (string): This is the first argument.
Returns:
None.
"""
pass
EOF
fi
if grep -q "export PATH=\$PATH:$(pwd)" "${SHELL_RC}"; then
echo -e "${YELLOW}Path already exists in ${SHELL_RC}. Skipping...${NC}"
else
echo -e "${GREEN}Adding path to ${SHELL_RC}...${NC}"
echo "export PATH=\$PATH:$(pwd)" >> "${SHELL_RC}"
fi
# enable powerful shell completion for zsh
if [ "$SHELL" = "/bin/zsh" ]; then
if grep -q "autoload -U compinit && compinit" "${SHELL_RC}"; then
echo -e "${YELLOW}Shell completion already enabled. Skipping...${NC}"
else
echo -e "${GREEN}Enabling shell completion...${NC}"
echo "autoload -U compinit && compinit" >> "${SHELL_RC}"
fi
if grep -q "source $(pwd)/express-completion.zsh" "${SHELL_RC}"; then
echo -e "${YELLOW}Autocomplete already exists in ${SHELL_RC}. Skipping...${NC}"
else
echo -e "${GREEN}Adding autocomplete to ${SHELL_RC}...${NC}"
echo "source $(pwd)/express-completion.zsh" >> "${SHELL_RC}"
fi
if grep -q "zstyle ':completion:\*' menu select" "${SHELL_RC}"; then
echo -e "${YELLOW}Autocomplete menu select already exists in ${SHELL_RC}. Skipping...${NC}"
else
echo -e "${GREEN}Adding autocomplete menu select to ${SHELL_RC}...${NC}"
echo "zstyle ':completion:*' menu select" >> "${SHELL_RC}"
fi
fi
echo -e "${GREEN}Done!${NC}"
echo ""
echo -e "Please restart your shell or run:"
echo -e " source ${SHELL_RC}"
echo ""
echo -e "To get familiar with express execute:"
echo -e " express-run -h"
echo ""