Initial commit: Complete project-bootstrap tool
- 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
This commit is contained in:
178
bootstrap.sh
Executable file
178
bootstrap.sh
Executable file
@@ -0,0 +1,178 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Bootstrap script for creating a new monorepo project
|
||||
# Based on coding-agent-rules from https://git.prettyhefty.com/Bill/coding-agent-rules
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to create directory structure
|
||||
create_directory_structure() {
|
||||
local project_name=$1
|
||||
|
||||
print_info "Creating directory structure for: $project_name"
|
||||
|
||||
# Root directories
|
||||
mkdir -p "$project_name"/{deploy,scripts,backend,frontend,docs}
|
||||
|
||||
# Deploy structure
|
||||
mkdir -p "$project_name"/deploy/docker
|
||||
|
||||
# Scripts structure
|
||||
mkdir -p "$project_name"/scripts/{ci,dev,utils}
|
||||
|
||||
# Backend structure
|
||||
mkdir -p "$project_name"/backend/app/{api,core,db/models,services,schemas}
|
||||
mkdir -p "$project_name"/backend/tests/{unit/{test_api,test_core,test_db,test_services,test_schemas},integration/{test_api,test_db}}
|
||||
|
||||
# Frontend structure
|
||||
mkdir -p "$project_name"/frontend/{public/assets,src/{components/{common,estimating,scheduling,tasks},pages,services,store/{actions,reducers},utils,styles},tests/{components,pages,services}}
|
||||
|
||||
# Docs structure
|
||||
mkdir -p "$project_name"/docs/{api,architecture,user-guide}
|
||||
|
||||
print_info "Directory structure created successfully"
|
||||
}
|
||||
|
||||
# Function to create __init__.py files for Python packages
|
||||
create_python_init_files() {
|
||||
local project_name=$1
|
||||
|
||||
print_info "Creating Python __init__.py files"
|
||||
|
||||
# Backend app __init__.py files
|
||||
touch "$project_name"/backend/app/__init__.py
|
||||
touch "$project_name"/backend/app/api/__init__.py
|
||||
touch "$project_name"/backend/app/core/__init__.py
|
||||
touch "$project_name"/backend/app/db/__init__.py
|
||||
touch "$project_name"/backend/app/db/models/__init__.py
|
||||
touch "$project_name"/backend/app/services/__init__.py
|
||||
touch "$project_name"/backend/app/schemas/__init__.py
|
||||
|
||||
# Backend tests __init__.py files
|
||||
touch "$project_name"/backend/tests/__init__.py
|
||||
touch "$project_name"/backend/tests/unit/__init__.py
|
||||
touch "$project_name"/backend/tests/unit/test_api/__init__.py
|
||||
touch "$project_name"/backend/tests/unit/test_core/__init__.py
|
||||
touch "$project_name"/backend/tests/unit/test_db/__init__.py
|
||||
touch "$project_name"/backend/tests/unit/test_services/__init__.py
|
||||
touch "$project_name"/backend/tests/unit/test_schemas/__init__.py
|
||||
touch "$project_name"/backend/tests/integration/__init__.py
|
||||
touch "$project_name"/backend/tests/integration/test_api/__init__.py
|
||||
touch "$project_name"/backend/tests/integration/test_db/__init__.py
|
||||
}
|
||||
|
||||
# Function to copy template files
|
||||
copy_template_files() {
|
||||
local project_name=$1
|
||||
local template_dir="$(dirname "$0")/templates"
|
||||
|
||||
print_info "Copying template files"
|
||||
|
||||
if [ -d "$template_dir" ]; then
|
||||
# Copy all template files to the project (including hidden files)
|
||||
shopt -s dotglob
|
||||
cp -r "$template_dir"/* "$project_name"/
|
||||
shopt -u dotglob
|
||||
print_info "Template files copied"
|
||||
else
|
||||
print_warn "Template directory not found. Skipping template copy."
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to initialize git repository
|
||||
init_git_repo() {
|
||||
local project_name=$1
|
||||
|
||||
print_info "Initializing git repository"
|
||||
|
||||
cd "$project_name"
|
||||
git init
|
||||
git add .
|
||||
git commit -m "Initial commit: Bootstrap monorepo structure"
|
||||
cd ..
|
||||
|
||||
print_info "Git repository initialized"
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
if [ $# -eq 0 ]; then
|
||||
print_error "Usage: $0 <project-name> [--no-git]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local project_name=$1
|
||||
local init_git=true
|
||||
|
||||
# Parse arguments
|
||||
shift
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--no-git)
|
||||
init_git=false
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if project directory already exists
|
||||
if [ -d "$project_name" ]; then
|
||||
print_error "Directory '$project_name' already exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_info "Starting bootstrap for project: $project_name"
|
||||
|
||||
# Create directory structure
|
||||
create_directory_structure "$project_name"
|
||||
|
||||
# Create Python __init__.py files
|
||||
create_python_init_files "$project_name"
|
||||
|
||||
# Copy template files
|
||||
copy_template_files "$project_name"
|
||||
|
||||
# Initialize git repository if requested
|
||||
if [ "$init_git" = true ]; then
|
||||
if command -v git &> /dev/null; then
|
||||
init_git_repo "$project_name"
|
||||
else
|
||||
print_warn "Git not found. Skipping git initialization."
|
||||
fi
|
||||
fi
|
||||
|
||||
print_info "Bootstrap complete!"
|
||||
print_info "Next steps:"
|
||||
echo " 1. cd $project_name"
|
||||
echo " 2. Review and update configuration files"
|
||||
echo " 3. Install dependencies:"
|
||||
echo " - Backend: cd backend && uv sync"
|
||||
echo " - Frontend: cd frontend && npm install"
|
||||
echo " 4. Start development:"
|
||||
echo " - docker compose -f deploy/compose.yml up"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user