Skip to content

Commit 6f5a8b8

Browse files
committed
Break out -pre script
1 parent 109f275 commit 6f5a8b8

6 files changed

Lines changed: 199 additions & 30 deletions

mflix/README-JAVA-SPRING.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ The `sample_mflix` dataset contains movies released up to **2016**. Searching fo
3030

3131
## Verify Requirements
3232

33-
Before getting started, you can run the verification script to check if you have all the necessary requirements:
33+
Before getting started, run the verification script to check if you have the required runtime:
3434

3535
```bash
36-
./check-requirements.sh
36+
./check-requirements-java.sh --pre
3737
```
3838

39-
This script checks for required tools (Java, Maven, Node.js), validates your environment configuration, and verifies dependencies. Run with `--help` for more options.
39+
This checks that Java and JAVA_HOME are configured correctly. Run with `--help` for more options.
4040

4141
## Getting Started
4242

@@ -191,6 +191,16 @@ cd client
191191
npm run lint
192192
```
193193

194+
## Verify Setup
195+
196+
After completing the setup, run the full verification to ensure everything is configured correctly:
197+
198+
```bash
199+
./check-requirements-java.sh
200+
```
201+
202+
This checks your Java environment, Maven dependencies, `.env` configuration, and frontend setup.
203+
194204
## Issues
195205

196206
If you have problems running the sample app, please check the following:

mflix/README-NODE-EXPRESS.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ The `sample_mflix` dataset contains movies released up to **2016**. Searching fo
2929

3030
## Verify Requirements
3131

32-
Before getting started, you can run the verification script to check if you have all the necessary requirements:
32+
Before getting started, run the verification script to check if you have the required runtime:
3333

3434
```bash
35-
./check-requirements.sh
35+
./check-requirements-js.sh --pre
3636
```
3737

38-
This script checks for required tools (Node.js, npm), validates your environment configuration, and verifies dependencies. Run with `--help` for more options.
38+
This checks that Node.js and npm are installed with the correct versions. Run with `--help` for more options.
3939

4040
## Getting Started
4141

@@ -224,6 +224,16 @@ cd client
224224
npm run lint
225225
```
226226

227+
## Verify Setup
228+
229+
After completing the setup, run the full verification to ensure everything is configured correctly:
230+
231+
```bash
232+
./check-requirements-js.sh
233+
```
234+
235+
This checks your Node.js environment, npm dependencies, `.env` configuration, and frontend setup.
236+
227237
## Issues
228238

229239
If you have problems running the sample app, please check the following:

mflix/README-PYTHON-FASTAPI.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ The `sample_mflix` dataset contains movies released up to **2016**. Searching fo
3333

3434
## Verify Requirements
3535

36-
Before getting started, you can run the verification script to check if you have all the necessary requirements:
36+
Before getting started, run the verification script to check if you have the required runtime:
3737

3838
```bash
39-
./check-requirements.sh
39+
./check-requirements-python.sh --pre
4040
```
4141

42-
This script checks for required tools (Python, pip, Node.js), validates your environment configuration, and verifies dependencies. Run with `--help` for more options.
42+
This checks that Python and pip are installed with the correct versions. Run with `--help` for more options.
4343

4444
## Getting Started
4545

@@ -206,6 +206,16 @@ cd client
206206
npm run lint
207207
```
208208

209+
## Verify Setup
210+
211+
After completing the setup, run the full verification to ensure everything is configured correctly:
212+
213+
```bash
214+
./check-requirements-python.sh
215+
```
216+
217+
This checks your Python environment, dependencies, `.env` configuration, and frontend setup.
218+
209219
## Issues
210220

211221
If you have problems running the sample app, please check the following:

mflix/check-requirements-java.sh

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# the mflix sample application with the Java/Spring Boot backend.
99
#
1010
# Usage:
11-
# ./check-requirements-java.sh # Check all requirements
11+
# ./check-requirements-java.sh # Check all requirements (post-setup)
12+
# ./check-requirements-java.sh --pre # Check only runtime requirements (pre-setup)
1213
# ./check-requirements-java.sh --setup # Check and auto-setup missing items
1314
# ./check-requirements-java.sh --help # Show help message
1415
#
@@ -92,18 +93,51 @@ show_help() {
9293
echo "Usage: $0 [OPTIONS]"
9394
echo ""
9495
echo "Options:"
96+
echo " --pre Check only runtime requirements (use before setup)"
9597
echo " --setup Attempt to automatically set up missing requirements"
9698
echo " --help Show this help message"
9799
echo ""
98100
echo "This script checks that all necessary requirements are installed"
99101
echo "to run the mflix sample application with the Java/Spring Boot backend."
102+
echo ""
103+
echo "Use --pre before starting setup to verify you have the required runtime."
104+
echo "Use without flags after completing setup to verify everything is ready."
100105
exit 0
101106
}
102107

108+
# =============================================================================
109+
# Check Runtime Requirements (Pre-Setup)
110+
# =============================================================================
111+
112+
check_runtime_requirements() {
113+
print_section "Runtime Requirements"
114+
115+
# Check Java version
116+
if command_exists java; then
117+
local java_version
118+
java_version=$(java -version 2>&1 | head -1 | grep -oE '"[0-9]+' | tr -d '"')
119+
if version_gte "$java_version" "$JAVA_MIN_VERSION"; then
120+
check_pass "Java $java_version installed (>= $JAVA_MIN_VERSION required)"
121+
else
122+
check_fail "Java $java_version installed but >= $JAVA_MIN_VERSION required"
123+
check_info "Install Java $JAVA_MIN_VERSION+: https://adoptium.net/"
124+
fi
125+
else
126+
check_fail "Java not installed"
127+
check_info "Install Java $JAVA_MIN_VERSION+: https://adoptium.net/"
128+
fi
103129

130+
# Check JAVA_HOME
131+
if [[ -n "$JAVA_HOME" ]]; then
132+
check_pass "JAVA_HOME is set: $JAVA_HOME"
133+
else
134+
check_warn "JAVA_HOME is not set"
135+
check_info "Set JAVA_HOME to your Java installation directory"
136+
fi
137+
}
104138

105139
# =============================================================================
106-
# Check Java/Spring Boot Backend Requirements
140+
# Check Java/Spring Boot Backend Requirements (Full)
107141
# =============================================================================
108142

109143
check_backend_requirements() {
@@ -391,10 +425,15 @@ cd "$SCRIPT_DIR"
391425

392426
# Default options
393427
SETUP_MODE=false
428+
PRE_CHECK_MODE=false
394429

395430
# Parse arguments
396431
while [[ $# -gt 0 ]]; do
397432
case $1 in
433+
--pre)
434+
PRE_CHECK_MODE=true
435+
shift
436+
;;
398437
--setup)
399438
SETUP_MODE=true
400439
shift
@@ -417,14 +456,20 @@ echo -e "${BLUE}║ mflix Sample Application - Requirements Check
417456
echo -e "${BLUE}║ Java/Spring Boot Backend ║${NC}"
418457
echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
419458

420-
if [[ "$SETUP_MODE" == true ]]; then
459+
if [[ "$PRE_CHECK_MODE" == true ]]; then
460+
echo -e "${YELLOW}Pre-setup check - verifying runtime requirements only${NC}"
461+
elif [[ "$SETUP_MODE" == true ]]; then
421462
echo -e "${YELLOW}Running in setup mode - will attempt to fix issues${NC}"
422463
fi
423464

424-
# Run all checks
425-
check_backend_requirements
426-
check_env_configuration
427-
check_frontend_requirements
465+
# Run checks based on mode
466+
if [[ "$PRE_CHECK_MODE" == true ]]; then
467+
check_runtime_requirements
468+
else
469+
check_backend_requirements
470+
check_env_configuration
471+
check_frontend_requirements
472+
fi
428473

429474
# Print summary
430475
print_summary

mflix/check-requirements-js.sh

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# the mflix sample application with the JavaScript/Express backend.
99
#
1010
# Usage:
11-
# ./check-requirements-js.sh # Check all requirements
11+
# ./check-requirements-js.sh # Check all requirements (post-setup)
12+
# ./check-requirements-js.sh --pre # Check only runtime requirements (pre-setup)
1213
# ./check-requirements-js.sh --setup # Check and auto-setup missing items
1314
# ./check-requirements-js.sh --help # Show help message
1415
#
@@ -91,18 +92,55 @@ show_help() {
9192
echo "Usage: $0 [OPTIONS]"
9293
echo ""
9394
echo "Options:"
95+
echo " --pre Check only runtime requirements (use before setup)"
9496
echo " --setup Attempt to automatically set up missing requirements"
9597
echo " --help Show this help message"
9698
echo ""
9799
echo "This script checks that all necessary requirements are installed"
98100
echo "to run the mflix sample application with the JavaScript/Express backend."
101+
echo ""
102+
echo "Use --pre before starting setup to verify you have the required runtime."
103+
echo "Use without flags after completing setup to verify everything is ready."
99104
exit 0
100105
}
101106

107+
# =============================================================================
108+
# Check Runtime Requirements (Pre-Setup)
109+
# =============================================================================
102110

111+
check_runtime_requirements() {
112+
print_section "Runtime Requirements"
113+
114+
# Check Node.js version
115+
if command_exists node; then
116+
local node_version
117+
node_version=$(node --version | sed 's/v//')
118+
local node_major
119+
node_major=$(echo "$node_version" | cut -d. -f1)
120+
if version_gte "$node_major" "$NODE_MIN_VERSION"; then
121+
check_pass "Node.js $node_version installed (>= $NODE_MIN_VERSION required)"
122+
else
123+
check_fail "Node.js $node_version installed but >= $NODE_MIN_VERSION required"
124+
check_info "Install Node.js $NODE_MIN_VERSION+: https://nodejs.org/"
125+
fi
126+
else
127+
check_fail "Node.js not installed"
128+
check_info "Install Node.js $NODE_MIN_VERSION+: https://nodejs.org/"
129+
fi
130+
131+
# Check npm
132+
if command_exists npm; then
133+
local npm_version
134+
npm_version=$(npm --version)
135+
check_pass "npm installed (version $npm_version)"
136+
else
137+
check_fail "npm not installed"
138+
check_info "npm should come with Node.js installation"
139+
fi
140+
}
103141

104142
# =============================================================================
105-
# Check JavaScript/Express Backend Requirements
143+
# Check JavaScript/Express Backend Requirements (Full)
106144
# =============================================================================
107145

108146
check_backend_requirements() {
@@ -382,10 +420,15 @@ cd "$SCRIPT_DIR"
382420

383421
# Default options
384422
SETUP_MODE=false
423+
PRE_CHECK_MODE=false
385424

386425
# Parse arguments
387426
while [[ $# -gt 0 ]]; do
388427
case $1 in
428+
--pre)
429+
PRE_CHECK_MODE=true
430+
shift
431+
;;
389432
--setup)
390433
SETUP_MODE=true
391434
shift
@@ -408,14 +451,20 @@ echo -e "${BLUE}║ mflix Sample Application - Requirements Check
408451
echo -e "${BLUE}║ JavaScript/Express Backend ║${NC}"
409452
echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
410453

411-
if [[ "$SETUP_MODE" == true ]]; then
454+
if [[ "$PRE_CHECK_MODE" == true ]]; then
455+
echo -e "${YELLOW}Pre-setup check - verifying runtime requirements only${NC}"
456+
elif [[ "$SETUP_MODE" == true ]]; then
412457
echo -e "${YELLOW}Running in setup mode - will attempt to fix issues${NC}"
413458
fi
414459

415-
# Run all checks
416-
check_backend_requirements
417-
check_env_configuration
418-
check_frontend_requirements
460+
# Run checks based on mode
461+
if [[ "$PRE_CHECK_MODE" == true ]]; then
462+
check_runtime_requirements
463+
else
464+
check_backend_requirements
465+
check_env_configuration
466+
check_frontend_requirements
467+
fi
419468

420469
# Print summary
421470
print_summary

0 commit comments

Comments
 (0)