@@ -62,40 +62,13 @@ echo "${cyan}[$0] ${green}See all requisites: https://github.com/HawAPI/HawAPI/b
6262echo " ${cyan} [$0 ] ${green} Checking prerequisites for building website..."
6363echo
6464
65- # # Check all requisites
66- if ! type npm; then
67- echo " ${cyan} [$0 ] ${red} <npm> command not found!"
68- exit 1
69- else
70- if ! type yarn; then
71- # # Yarn is required. Ask to install (GLOBALLY)
72- echo " ${cyan} [$0 ] ${red} <Yarn> command not found!"
73- echo " ${cyan} [$0 ] ${green} Install yarn? (GLOBALLY) (Y/n)"
74- read -n1 -s -r yarn_response
75-
76- if ! echo " $yarn_response " | grep ' ^[Yy]\?$' ; then
77- echo ' No'
78- exit 1
79- fi
80-
81- echo " ${cyan} [$0 ] ${green} Installing yarn..."
82- npm install --global yarn
83- fi
84- fi
65+ # Check all requisites
8566
86- if ! type retype; then
87- # # Retype is required. Ask to install
88- echo " ${cyan} [$0 ] ${red} <Retype> command not found!"
89- echo " ${cyan} [$0 ] ${green} Install retype? (GLOBALLY) (Y/n)"
90- read -n1 -s -r retype_response
91-
92- if ! echo " $retype_response " | grep ' ^[Yy]\?$' ; then
93- echo ' No'
94- exit 1
95- fi
96-
97- echo " ${cyan} [$0 ] ${green} Installing retype..."
98- yarn global add retypeapp
67+ if ! type yarn; then
68+ # # Yarn is required. Ask to install (LOCALLY)
69+ echo " ${cyan} [$0 ] ${red} <Yarn> command not found!"
70+ echo " ${cyan} [$0 ] ${green} Install yarn to build the website"
71+ exit 1
9972fi
10073
10174echo
128101echo " ${cyan} [$0 ] ${green} Building the website..."
129102cd .hawapi/website/ || exit 1
130103
131- if ! [ -d " ./node_modules" ]; then
132- echo " ${cyan} [$0 ] ${green} Directory './node_modules' not found! Running 'yarn'!"
133- echo
134- yarn
135- echo
136- fi
104+ # # Yarn install into website and docs
105+ cd ./docs && yarn install
106+ cd ../ && yarn install
137107
108+ # # Build website and docs
138109echo
139- yarn build- all
110+ yarn build: all
140111echo
141112
142- # Website and Docs adaptation
143-
144- echo " ${cyan} [$0 ] ${green} Starting website/docs adaptation..."
145- echo
146-
147- echo " ${cyan} [$0 ] ${green} Removing '.nojekyll' file"
148- rm -rf ./build/docs/.nojekyll
149-
150- # # Try to unzip and modify the 'sitemap.xml.gz' file.
151- if ! type gunzip; then
152- # # If command 'gunzip' don't exist. Just remove the file.
153- echo " ${cyan} [$0 ] ${green} <gunzip> command not found! Removing 'sitemap.xml.gz' file"
154- rm -rf ./build/docs/sitemap.xml.gz
155- else
156- echo " ${cyan} [$0 ] ${green} Unzipping 'sitemap.xml.gz' file"
157- gunzip ./build/docs/sitemap.xml.gz
158- echo " ${cyan} [$0 ] ${green} Replacing '.id/' with '.id/docs/'"
159- echo " ${cyan} [$0 ] ${green} Moving 'sitemap.xml.gz' file to './build/sitemap-1.xml'"
160- sed ' s#.id/#.id/docs/#' ./build/docs/sitemap.xml > ./build/sitemap-1.xml
161-
162- echo " ${cyan} [$0 ] ${green} Adding 'https://hawapi.theproject.id/sitemap-1.xml' to './build/docs/robots.txt'"
163- echo ' Sitemap: https://hawapi.theproject.id/sitemap-1.xml' >> ./build/docs/robots.txt
164- fi
165-
166- echo " ${cyan} [$0 ] ${green} Moving 'robots.txt' to './build/robots.txt'"
167- sed ' s/sitemap.xml.gz/sitemap-0.xml/' ./build/docs/robots.txt > ./build/robots.txt
168- rm -rf ./build/docs/robots.txt
169- rm -rf ./build/sitemap-index.xml
170-
171113# Finalization
172114
173- if [ -d " ../../src/main/resources/static/" ]; then
115+ # # Spring root
116+ cd ../../
117+
118+ if [ -d " ./src/main/resources/static/" ]; then
174119 echo " ${cyan} [$0 ] ${green} Found files inside 'resources/static/'! Deleting all..."
175- rm -rf ../.. /src/main/resources/static/*
120+ rm -rf ./src/main/resources/static/*
176121fi
177122
178- if ! [ -d " ../.. /src/main/resources/static/" ]; then
179- mkdir -p ../.. /src/main/resources/static/
123+ if ! [ -d " ./src/main/resources/static/" ]; then
124+ mkdir -p ./src/main/resources/static/
180125fi
181126
182- echo " ${cyan} [$0 ] ${green} Moving files from './build/' to 'resources/static/'"
183- mv ./ build/* ../. ./src/main/resources/static/
127+ echo " ${cyan} [$0 ] ${green} Moving files from '.hawapi/website /build/' to 'resources/static/'"
128+ mv .hawapi/website/ build/* ./src/main/resources/static/
184129
185130# Clean
186131
187- cd ../..
188132./scripts/clean-website.sh " $@ "
0 commit comments