#!/bin/bash # Test Gluegun CLI build process # Usage: ./test-cli-build.sh set -e CLI_DIR="${1:-.}" ERRORS=0 echo "๐Ÿงช Testing Gluegun CLI build: $CLI_DIR" echo "" # Check if directory exists if [ ! -d "$CLI_DIR" ]; then echo "โŒ Directory not found: $CLI_DIR" exit 1 fi cd "$CLI_DIR" # Check for package.json if [ ! -f "package.json" ]; then echo "โŒ package.json not found" exit 1 fi echo "๐Ÿ“ฆ Checking dependencies..." # Check if node_modules exists if [ ! -d "node_modules" ]; then echo "โš ๏ธ node_modules not found, running npm install..." npm install fi # Check if gluegun is installed if [ -d "node_modules/gluegun" ]; then echo " โœ… gluegun installed" else echo " โŒ gluegun not installed" ((ERRORS++)) fi # Check for TypeScript if [ -f "tsconfig.json" ]; then echo "" echo "๐Ÿ”จ TypeScript detected, checking compilation..." if npm run build > /dev/null 2>&1; then echo " โœ… TypeScript compilation successful" else echo " โŒ TypeScript compilation failed" echo " Run 'npm run build' for details" ((ERRORS++)) fi fi # Check for tests echo "" echo "๐Ÿงช Checking for tests..." if [ -d "test" ] || [ -d "tests" ] || [ -d "__tests__" ]; then echo " โœ… Test directory found" # Try to run tests if npm test > /dev/null 2>&1; then echo " โœ… Tests passed" else echo " โš ๏ธ Tests failed or not configured" fi else echo " โš ๏ธ No test directory found" fi # Check CLI execution echo "" echo "๐Ÿš€ Testing CLI execution..." # Get CLI entry point cli_entry="" if [ -f "bin/cli" ]; then cli_entry="bin/cli" elif [ -f "bin/run" ]; then cli_entry="bin/run" elif [ -f "dist/cli.js" ]; then cli_entry="node dist/cli.js" fi if [ -n "$cli_entry" ]; then echo " Found CLI entry: $cli_entry" # Test help command if $cli_entry --help > /dev/null 2>&1; then echo " โœ… CLI --help works" else echo " โš ๏ธ CLI --help failed" ((ERRORS++)) fi # Test version command if $cli_entry --version > /dev/null 2>&1; then echo " โœ… CLI --version works" else echo " โš ๏ธ CLI --version failed" fi else echo " โš ๏ธ CLI entry point not found" fi # Summary echo "" echo "================================" if [ $ERRORS -eq 0 ]; then echo "โœ… All build tests passed!" exit 0 else echo "โŒ Found $ERRORS error(s) during build test" exit 1 fi