prepare.sh: enhance prepare.sh to support argument-based builds and improve help output

This commit is contained in:
Carlos Santos 2025-05-22 14:40:34 +02:00
parent e08e30ee0b
commit 7df2ecd8d5

View File

@ -2,32 +2,127 @@
set -e set -e
# Build typings library # Colors for messages
cd typings BLUE='\033[0;34m'
npm install GREEN='\033[0;32m'
npm run sync-ce YELLOW='\033[1;33m'
cd .. NC='\033[0m' # No Color
# Build frontend # Initially, don't build anything
cd frontend BUILD_TYPINGS=false
npm install BUILD_FRONTEND=false
npm run build:prod BUILD_BACKEND=false
cd .. BUILD_WEBCOMPONENT=false
BUILD_TESTAPP=false
# Build backend # Function to display help
cd backend show_help() {
npm install echo -e "${BLUE}Usage:${NC} ./prepare.sh [options]"
npm run build:prod echo
cd .. echo "Options:"
echo " --typings Build types library"
echo " --frontend Build frontend"
echo " --backend Build backend"
echo " --webcomponent Build webcomponent"
echo " --testapp Build testapp"
echo " --all Build all artifacts (default)"
echo " --help Show this help"
echo
echo "If no arguments are provided, all artifacts will be built."
echo
echo -e "${YELLOW}Example:${NC} ./prepare.sh --frontend --backend"
}
# Build webcomponent # If no arguments, build everything
cd frontend/webcomponent if [ $# -eq 0 ]; then
npm install BUILD_TYPINGS=true
npm run build BUILD_FRONTEND=true
cd ../.. BUILD_BACKEND=true
BUILD_WEBCOMPONENT=true
BUILD_TESTAPP=true
else
# Process arguments
for arg in "$@"
do
case $arg in
--typings)
BUILD_TYPINGS=true
;;
--frontend)
BUILD_FRONTEND=true
;;
--backend)
BUILD_BACKEND=true
;;
--webcomponent)
BUILD_WEBCOMPONENT=true
;;
--testapp)
BUILD_TESTAPP=true
;;
--all)
BUILD_TYPINGS=true
BUILD_FRONTEND=true
BUILD_BACKEND=true
BUILD_WEBCOMPONENT=true
BUILD_TESTAPP=true
;;
--help)
show_help
exit 0
;;
*)
echo -e "${YELLOW}Unknown option: $arg${NC}"
show_help
exit 1
;;
esac
done
fi
# Build testapp # Build typings if selected
cd testapp if [ "$BUILD_TYPINGS" = true ]; then
npm install echo -e "${GREEN}Building types library...${NC}"
npm run build cd typings
cd .. npm install
npm run sync-ce
cd ..
fi
# Build frontend if selected
if [ "$BUILD_FRONTEND" = true ]; then
echo -e "${GREEN}Building frontend...${NC}"
cd frontend
npm install
npm run build:prod
cd ..
fi
# Build backend if selected
if [ "$BUILD_BACKEND" = true ]; then
echo -e "${GREEN}Building backend...${NC}"
cd backend
npm install
npm run build:prod
cd ..
fi
# Build webcomponent if selected
if [ "$BUILD_WEBCOMPONENT" = true ]; then
echo -e "${GREEN}Building webcomponent...${NC}"
cd frontend/webcomponent
npm install
npm run build
cd ../..
fi
# Build testapp if selected
if [ "$BUILD_TESTAPP" = true ]; then
echo -e "${GREEN}Building testapp...${NC}"
cd testapp
npm install
npm run build
cd ..
fi
echo -e "${BLUE}Preparation completed!${NC}"