2022-05-11 22:47:31 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
BACKEND_ASSETS=backend/embed/assets
|
|
|
|
|
|
|
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
. "$DIR/../.common.sh"
|
|
|
|
|
|
|
|
|
|
docker_cmd() {
|
|
|
|
|
docker run --rm \
|
|
|
|
|
-e CI=true \
|
2023-07-20 05:11:41 +00:00
|
|
|
|
-e "VITE_APP_VERSION=${BUILD_VERSION:-0.0.0}" \
|
|
|
|
|
-e "VITE_APP_COMMIT=${BUILD_COMMIT:-0000000}" \
|
2022-05-11 22:47:31 +00:00
|
|
|
|
-v "$(pwd):/app" \
|
|
|
|
|
-w "/app/frontend" \
|
2024-05-07 23:41:32 +00:00
|
|
|
|
node:20 \
|
2022-05-11 22:47:31 +00:00
|
|
|
|
${*}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cd "${DIR}/../.." || exit 1
|
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Installing Frontend deps ...${RESET}"
|
|
|
|
|
rm -rf frontend/node_modules
|
|
|
|
|
docker_cmd yarn install
|
|
|
|
|
|
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Checking locales ...${RESET}"
|
|
|
|
|
docker_cmd node check-locales.js
|
|
|
|
|
|
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Compiling locales ...${RESET}"
|
|
|
|
|
docker_cmd yarn locale-compile
|
|
|
|
|
docker_cmd chown -R "$(id -u):$(id -g)" /app/frontend/src/locale/lang
|
|
|
|
|
|
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Running eslint ...${RESET}"
|
|
|
|
|
docker_cmd yarn eslint src
|
|
|
|
|
docker_cmd yarn eslint -f junit src -o eslint.xml
|
|
|
|
|
#echo -e "${BLUE}❯ ${CYAN}Running tests ...${RESET}"
|
|
|
|
|
#docker_cmd yarn test --coverage --watchAll=false --testResultsProcessor ./node_modules/jest-junit
|
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Building Frontend ...${RESET}"
|
|
|
|
|
docker_cmd yarn build
|
|
|
|
|
docker_cmd chown -R "$(id -u):$(id -g)" /app/frontend
|
|
|
|
|
echo -e "${BLUE}❯ ${GREEN}Building Frontend Complete${RESET}"
|
|
|
|
|
|
|
|
|
|
# to avoid CRA ejection, just copy these build files over to embed in the backend
|
|
|
|
|
rm -rf ${BACKEND_ASSETS}
|
2023-07-20 06:25:08 +00:00
|
|
|
|
cp -pr frontend/dist "${BACKEND_ASSETS}"
|
2022-05-11 22:47:31 +00:00
|
|
|
|
echo -e "${BLUE}❯ ${GREEN}Copied build to ${BACKEND_ASSETS}${RESET}"
|
|
|
|
|
|
|
|
|
|
rm -rf frontend/node_modules
|
|
|
|
|
|
|
|
|
|
trap "docker_cmd chown -R $(id -u):$(id -g) /app/frontend" EXIT
|