forked from PatLittle/OpenCanadaAPI
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlocal_install.sh
More file actions
executable file
·55 lines (49 loc) · 2.38 KB
/
Copy pathlocal_install.sh
File metadata and controls
executable file
·55 lines (49 loc) · 2.38 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
# vars
Cyan='\033[0;36m'
Yellow='\033[1;33m'
Red='\033[0;31m'
Orange='\033[0;33m'
Green='\033[0;32m'
NC='\033[0;0m'
EOL='\n'
SPACER='\n\n'
INDENT=' '
BOLD='\033[1m'
HAIR='\033[0m'
# setup python venv
PYCMD="python";
if command -v python3 >/dev/null 2>&1; then
PYCMD="python3";
printf "${EOL}${Cyan}${INDENT}Using python3 as python bash command...${NC}${EOL}";
else
printf "${EOL}${Cyan}${INDENT}Using python as python bash command...${NC}${EOL}";
fi
if [[ ! -d "${PWD}/venv/bin" ]]; then
printf "${EOL}${Cyan}${INDENT}Creating python virtual environment at venv...${NC}${EOL}";
${PYCMD} -m venv venv;
fi
. venv/bin/activate;
printf "${EOL}${Cyan}${INDENT}Installing python dependencies...${NC}${EOL}";
pip install -r requirements.txt;
# create tree
printf "${EOL}${Cyan}${INDENT}Refreshing directory tree...${NC}${EOL}";
mkdir _build _build/en _build/en/schemas _build/fr _build/fr/schemas _build/theme _build/examples;
# split the yaml
printf "${EOL}${Cyan}${INDENT}Splitting the YAML into respective locales...${NC}${EOL}";
${PYCMD} splityaml.py openapi.yaml en _build/en/openapi-en.json;
${PYCMD} splityaml.py openapi.yaml fr _build/fr/openapi-fr.json;
# Test that our specs are valid
printf "${EOL}${Cyan}${INDENT}Testing Open API specifications...${NC}${EOL}";
cp schemas/dataset-en.json schemas/resource-multipart-en.json _build/en/schemas;
cp schemas/dataset-fr.json schemas/resource-multipart-fr.json _build/fr/schemas;
openapi-spec-validator _build/en/openapi-en.json;
openapi-spec-validator _build/fr/openapi-fr.json;
cp index.html _build/index.html && cp index-en.html _build/en/index.html && cp index-fr.html _build/fr/index.html && cp fr.css _build/fr/fr.css && cp index-examples.html _build/examples/index.html;
# Download and unpack the theme
printf "${EOL}${Cyan}${INDENT}Downloading GoC theme files...${NC}${EOL}";
curl -L "https://github.com/wet-boew/themes-cdn/archive/v19.2.0-gcweb.tar.gz" | tar -zvx --strip-components 1 --directory=_build/theme;
printf "${EOL}${Cyan}${INDENT}Removing unused theme files...${NC}${EOL}";
find _build/theme -type f \! \( -name "favicon.ico" -o -name "theme.min.css" -o -name "messages.min.css" -o -name "sp-bg-2.jpg" -o -name "sig-spl.svg" -o -name "wmms-spl.svg" \) -delete -print;
printf "${EOL}${Cyan}${INDENT}Removing empty theme directories...${NC}${EOL}";
find _build/theme -empty -type d -delete -print;
printf "${EOL}${Cyan}${INDENT}DONE!${NC}${EOL}";