Website/app/frontend/mod.just

92 lines
2.6 KiB
Text
Raw Normal View History

2024-07-12 22:56:04 +00:00
__default:
2024-07-21 12:03:21 +00:00
@../../bin/just/choose.sh {{ source_file() }} choose
2024-07-12 22:56:04 +00:00
# Checks whether the requriements are met
[group('main')]
check:
#!/bin/bash
2024-07-21 12:03:21 +00:00
source ../../bin/just/colors.sh
source ../../bin/just/check.sh
2024-07-12 22:56:04 +00:00
printf "${BLUE_BG}${BLACK_FG} Checking Frontend Requirements ${CLEAR}\n"
2024-07-21 12:03:21 +00:00
check_cmd "screen" "screen"
2024-07-12 22:56:04 +00:00
check_cmd "volta" "Volta"
check_cmd "node" "Node"
check_cmd "npm" "NPM"
required_node_version=$( \
cat ../package.json \
| jq .volta.node \
| cut -c 2- \
| cut -d '.' -f 1 \
)
current_major_node_version=$(node -v | cut -c 2- | cut -d '.' -f 1)
current_node_version=$(node -v | cut -c 2-)
if [ "${current_major_node_version}" = "${required_node_version}" ]; then
printf >&2 "${GREEN_FG}✔ Node${BLUE_FG} Version ${GREEN_FG}${current_node_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
else
printf >&2 "${RED_FG}✘ Wrong Node Version${YELLOW_FG} is installed!\n Version ${RED_FG}${required_node_version}${YELLOW_FG} is ${RED_FG}required${YELLOW_FG}.\n"
error = 1
fi
echo ""
# Installs the dependencies
[group('main')]
install:
cd .. && npm i --no-fund
session_name := "euph-website_frontend"
# Starts the local Development Setup
[group('main')]
up: halt
#!/bin/bash
2024-07-21 12:03:21 +00:00
source ../../bin/just/colors.sh
2024-07-12 22:56:04 +00:00
cd .. && screen -dmS {{ session_name }} npm run watch >> /dev/null
if [ $? -eq 0 ]; then
printf "${GREEN_FG}Frontend was started${CLEAR}\n"
else
printf "${RED_FG}Frontend didn't start${CLEAR}\n"
fi
# Stops the local Development Setup
[group('main')]
halt:
#!/bin/bash
2024-07-21 12:03:21 +00:00
source ../../bin/just/colors.sh
2024-07-12 22:56:04 +00:00
screen -XS {{ session_name }} quit >> /dev/null
if [ $? -eq 0 ]; then
printf "${GREEN_FG}Frontend was stopped${CLEAR}\n"
fi
[group('main')]
attach:
#!/bin/bash
2024-07-21 12:03:21 +00:00
source ../../bin/just/colors.sh
2024-07-12 22:56:04 +00:00
if screen -ls | grep -q {{ session_name }}; then
screen -r {{ session_name }}
else
printf "${RED_FG}Frontend is down${CLEAR}\n"
fi
linter_options := "All\nTS\nSCSS\nTwig"
# Lints all Files, or if specified only a specifc Set
[group('utility')]
lint linter="":
#!/bin/bash
chosen_linter=$(
printf "{{ linter_options }}" |\
fzf --header="Which linters should be run?" --height 6 -i -q "{{ linter }}" -1
)
cd ..
case "$chosen_linter" in
*All*) \
npm run lint:ts:fix && \
npm run lint:scss:fix && \
vendor/bin/twig-cs-fixer lint --fix && php bin/console lint:twig ;;
*TS*) npm run lint:ts:fix ;;
*SCSS*) npm run lint:scss:fix ;;
*Twig*) vendor/bin/twig-cs-fixer lint --fix && php bin/console lint:twig ;;
esac