- Bootstrap script for creating monorepo projects - FastAPI backend templates with uv, ruff, mypy, pytest - React frontend templates with TypeScript, ESLint, Prettier - Docker Compose setup with backend, frontend, and database - 9 development and CI scripts - Gitea Actions CI/CD workflows - Comprehensive documentation (8 files) - 45 template files for complete project structure - Automated verification script (all tests pass) - Based on coding-agent-rules standards
211 lines
5.1 KiB
Bash
Executable File
211 lines
5.1 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
# Verification script for project-bootstrap
|
||
# This script tests the bootstrap process
|
||
|
||
set -e
|
||
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
NC='\033[0m'
|
||
|
||
print_success() {
|
||
echo -e "${GREEN}✓${NC} $1"
|
||
}
|
||
|
||
print_error() {
|
||
echo -e "${RED}✗${NC} $1"
|
||
}
|
||
|
||
print_info() {
|
||
echo -e "${YELLOW}ℹ${NC} $1"
|
||
}
|
||
|
||
TEST_PROJECT="test-verify-project"
|
||
|
||
# Cleanup function
|
||
cleanup() {
|
||
if [ -d "$TEST_PROJECT" ]; then
|
||
print_info "Cleaning up test project..."
|
||
rm -rf "$TEST_PROJECT"
|
||
fi
|
||
}
|
||
|
||
# Set trap to cleanup on exit
|
||
trap cleanup EXIT
|
||
|
||
print_info "Starting bootstrap verification..."
|
||
echo
|
||
|
||
# Test 1: Bootstrap script exists and is executable
|
||
print_info "Test 1: Checking bootstrap script..."
|
||
if [ -x "./bootstrap.sh" ]; then
|
||
print_success "Bootstrap script is executable"
|
||
else
|
||
print_error "Bootstrap script is not executable"
|
||
exit 1
|
||
fi
|
||
|
||
# Test 2: Run bootstrap
|
||
print_info "Test 2: Running bootstrap..."
|
||
if ./bootstrap.sh "$TEST_PROJECT" --no-git > /dev/null 2>&1; then
|
||
print_success "Bootstrap completed successfully"
|
||
else
|
||
print_error "Bootstrap failed"
|
||
exit 1
|
||
fi
|
||
|
||
# Test 3: Check directory structure
|
||
print_info "Test 3: Verifying directory structure..."
|
||
REQUIRED_DIRS=(
|
||
"$TEST_PROJECT/backend"
|
||
"$TEST_PROJECT/frontend"
|
||
"$TEST_PROJECT/deploy"
|
||
"$TEST_PROJECT/scripts"
|
||
"$TEST_PROJECT/docs"
|
||
)
|
||
|
||
for dir in "${REQUIRED_DIRS[@]}"; do
|
||
if [ -d "$dir" ]; then
|
||
print_success "Directory exists: $dir"
|
||
else
|
||
print_error "Directory missing: $dir"
|
||
exit 1
|
||
fi
|
||
done
|
||
|
||
# Test 4: Check key files
|
||
print_info "Test 4: Verifying key files..."
|
||
REQUIRED_FILES=(
|
||
"$TEST_PROJECT/README.md"
|
||
"$TEST_PROJECT/LICENSE"
|
||
"$TEST_PROJECT/.gitignore"
|
||
"$TEST_PROJECT/backend/pyproject.toml"
|
||
"$TEST_PROJECT/backend/app/main.py"
|
||
"$TEST_PROJECT/frontend/package.json"
|
||
"$TEST_PROJECT/frontend/src/App.tsx"
|
||
"$TEST_PROJECT/deploy/compose.yml"
|
||
)
|
||
|
||
for file in "${REQUIRED_FILES[@]}"; do
|
||
if [ -f "$file" ]; then
|
||
print_success "File exists: $file"
|
||
else
|
||
print_error "File missing: $file"
|
||
exit 1
|
||
fi
|
||
done
|
||
|
||
# Test 5: Check scripts are executable
|
||
print_info "Test 5: Verifying scripts are executable..."
|
||
SCRIPT_FILES=(
|
||
"$TEST_PROJECT/scripts/dev/start-backend.sh"
|
||
"$TEST_PROJECT/scripts/dev/start-frontend.sh"
|
||
"$TEST_PROJECT/scripts/utils/lint-backend.sh"
|
||
"$TEST_PROJECT/scripts/ci/backend-test.sh"
|
||
)
|
||
|
||
for script in "${SCRIPT_FILES[@]}"; do
|
||
if [ -x "$script" ]; then
|
||
print_success "Script is executable: $script"
|
||
else
|
||
print_error "Script is not executable: $script"
|
||
exit 1
|
||
fi
|
||
done
|
||
|
||
# Test 6: Check Python __init__.py files
|
||
print_info "Test 6: Verifying Python __init__.py files..."
|
||
INIT_FILES=(
|
||
"$TEST_PROJECT/backend/app/__init__.py"
|
||
"$TEST_PROJECT/backend/app/api/__init__.py"
|
||
"$TEST_PROJECT/backend/app/core/__init__.py"
|
||
"$TEST_PROJECT/backend/tests/__init__.py"
|
||
)
|
||
|
||
for init_file in "${INIT_FILES[@]}"; do
|
||
if [ -f "$init_file" ]; then
|
||
print_success "Init file exists: $init_file"
|
||
else
|
||
print_error "Init file missing: $init_file"
|
||
exit 1
|
||
fi
|
||
done
|
||
|
||
# Test 7: Verify file contents (sample check)
|
||
print_info "Test 7: Verifying file contents..."
|
||
|
||
if grep -q "FastAPI" "$TEST_PROJECT/backend/app/main.py"; then
|
||
print_success "Backend main.py contains FastAPI"
|
||
else
|
||
print_error "Backend main.py missing FastAPI import"
|
||
exit 1
|
||
fi
|
||
|
||
if grep -qi "react" "$TEST_PROJECT/frontend/package.json"; then
|
||
print_success "Frontend package.json contains React"
|
||
else
|
||
print_error "Frontend package.json missing React"
|
||
exit 1
|
||
fi
|
||
|
||
# Test 8: Count files
|
||
print_info "Test 8: Counting generated files..."
|
||
FILE_COUNT=$(find "$TEST_PROJECT" -type f | wc -l)
|
||
if [ "$FILE_COUNT" -gt 50 ]; then
|
||
print_success "Generated $FILE_COUNT files (expected > 50)"
|
||
else
|
||
print_error "Only generated $FILE_COUNT files (expected > 50)"
|
||
exit 1
|
||
fi
|
||
|
||
# Test 9: Check documentation
|
||
print_info "Test 9: Verifying documentation..."
|
||
DOC_FILES=(
|
||
"$TEST_PROJECT/docs/api/README.md"
|
||
"$TEST_PROJECT/docs/architecture/README.md"
|
||
"$TEST_PROJECT/docs/user-guide/README.md"
|
||
)
|
||
|
||
for doc in "${DOC_FILES[@]}"; do
|
||
if [ -f "$doc" ]; then
|
||
print_success "Documentation exists: $doc"
|
||
else
|
||
print_error "Documentation missing: $doc"
|
||
exit 1
|
||
fi
|
||
done
|
||
|
||
# Test 10: Verify CI workflows
|
||
print_info "Test 10: Verifying CI workflows..."
|
||
if [ -f "$TEST_PROJECT/.gitea/workflows/backend-ci.yml" ]; then
|
||
print_success "Backend CI workflow exists"
|
||
else
|
||
print_error "Backend CI workflow missing"
|
||
exit 1
|
||
fi
|
||
|
||
if [ -f "$TEST_PROJECT/.gitea/workflows/frontend-ci.yml" ]; then
|
||
print_success "Frontend CI workflow exists"
|
||
else
|
||
print_error "Frontend CI workflow missing"
|
||
exit 1
|
||
fi
|
||
|
||
echo
|
||
print_success "All verification tests passed!"
|
||
echo
|
||
print_info "Summary:"
|
||
echo " - Bootstrap script: OK"
|
||
echo " - Directory structure: OK"
|
||
echo " - Key files: OK"
|
||
echo " - Scripts: OK"
|
||
echo " - Python packages: OK"
|
||
echo " - File contents: OK"
|
||
echo " - File count: $FILE_COUNT files"
|
||
echo " - Documentation: OK"
|
||
echo " - CI workflows: OK"
|
||
echo
|
||
print_success "Project bootstrap is working correctly!"
|