|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Benefit Decision Toolkit - One-Step Developer Setup Script |
| 4 | +# This script streamlines setup of a development environment for the Benefit Decision Toolkit |
| 5 | + |
| 6 | +set -e # Exit on any error |
| 7 | + |
| 8 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 9 | + |
| 10 | +source "$SCRIPT_DIR/functions" |
| 11 | + |
| 12 | +print_status "🚀 Starting Benefit Decision Toolkit Developer Setup..." |
| 13 | + |
| 14 | +if [[ "$DEVBOX_SHELL_ENABLED" != "1" ]]; then |
| 15 | + if ask_user "This project is configured to use devbox (https://www.jetify.com/devbox) to manage system dependencies. Do you want to use devbox? (default=yes)" "y"; then |
| 16 | + echo "" |
| 17 | + echo "Devbox instructions:" |
| 18 | + echo "" |
| 19 | + echo "1. If you already have devbox installed, then run:" |
| 20 | + echo " \$ devbox run setup" |
| 21 | + echo "" |
| 22 | + echo "2. If you don't already have devbox installed (or you're not sure), then run:" |
| 23 | + echo " \$ bin/install-devbox && devbox run setup" |
| 24 | + echo "" |
| 25 | + exit 0 |
| 26 | + else |
| 27 | + print_warning "Setup won't use devbox; system dependencies are the developer's responsibility. See devbox.json for the list of dependencies needed." |
| 28 | + sleep 2 |
| 29 | + fi |
| 30 | +fi |
| 31 | + |
| 32 | +print_status "📦 Installing frontend dependencies..." |
| 33 | + |
| 34 | +if ! command_exists npm; then |
| 35 | + print_error "npm not found. Please install node manually or use devbox to manage dependencies." |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +print_status "Installing builder-frontend dependencies..." |
| 40 | +cd builder-frontend |
| 41 | +if [ -f "package.json" ]; then |
| 42 | + npm install |
| 43 | + print_success "builder-frontend dependencies installed" |
| 44 | +else |
| 45 | + print_error "package.json not found in builder-frontend" |
| 46 | + exit 1 |
| 47 | +fi |
| 48 | +cd .. |
| 49 | + |
| 50 | +print_status "Installing screener-frontend dependencies..." |
| 51 | +cd screener-frontend |
| 52 | +if [ -f "package.json" ]; then |
| 53 | + npm install |
| 54 | + print_success "screener-frontend dependencies installed" |
| 55 | +else |
| 56 | + print_error "package.json not found in screener-frontend" |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | +cd .. |
| 60 | + |
| 61 | +print_status "Finished installing frontend dependencies." |
| 62 | + |
| 63 | +print_status "📦 Installing backend dependencies..." |
| 64 | + |
| 65 | +if ! command_exists mvn; then |
| 66 | + print_error "mvn not found. Please install maven manually or use devbox to manage dependendcies." |
| 67 | + exit 1 |
| 68 | +fi |
| 69 | + |
| 70 | +print_status "Installing library-api dependencies..." |
| 71 | +cd library-api |
| 72 | +mvn clean package |
| 73 | +print_success "library-api dependencies installed" |
| 74 | +cd .. |
| 75 | + |
| 76 | +print_status "Installing builder-api dependencies..." |
| 77 | +cd builder-api |
| 78 | +# TODO: are the tests important to run here? (one of them was failing for me) |
| 79 | +mvn clean package -DskipTests |
| 80 | +print_success "builder-api dependencies installed" |
| 81 | +cd .. |
| 82 | + |
| 83 | +print_status "Installing screener-api dependencies..." |
| 84 | +cd screener-api |
| 85 | +mvn clean package |
| 86 | +print_success "screener-api dependencies installed" |
| 87 | +cd .. |
| 88 | + |
| 89 | +print_status "Finished installing backend dependencies." |
| 90 | + |
| 91 | +print_success "🎉 Developer setup completed successfully!" |
| 92 | +echo "" |
| 93 | +echo "📋 Next Steps:" |
| 94 | +echo "1. Ask a teammate to help you setup .env files in builder-frontend and screener-frontend." |
| 95 | +echo "2. If using devbox, then:" |
| 96 | +echo " a. Run 'devbox shell' within the project root directory to load dependencies. (https://www.jetify.com/docs/devbox/cli_reference/devbox_shell/)" |
| 97 | +echo " b. Consider using the direnv integration to load dependencies automatically. (https://www.jetify.com/docs/devbox/ide_configuration/direnv/)" |
| 98 | +echo " c. If you use VS Code, then consider installing the Devbox and Direnv extensions." |
| 99 | +echo "3. Run the web apps locally using 'npm run dev' from within builder-frontend and screener-frontend directories." |
| 100 | +echo "4. Run the library-api application using 'quarkus dev' within the library-api directory." |
| 101 | +echo "" |
| 102 | +print_status "Happy coding! 🚀" |
0 commit comments