Automation Scripts Reference

This comprehensive reference covers all automation scripts available in the HostingCo system, providing detailed usage instructions, examples, and best practices.

Script Overview

The HostingCo project includes a complete suite of automation scripts that handle every aspect of the development lifecycle, from initial setup to deployment and maintenance.

Script Categories

Category Scripts Purpose
Database db-migrate.sh, db-seed.sh, db-reset.sh Database operations and management
Development dev.sh, dev-backend.sh, dev-frontend.sh Development server management
Build & Deploy build.sh, deploy.sh Application building and deployment
Testing test.sh, test-watch.sh, test-coverage.sh Test execution and coverage analysis
Docker docker-build.sh, docker-up.sh, docker-down.sh Docker container management
Maintenance clean.sh, setup.sh, health-check.sh System maintenance and monitoring

Database Management Scripts

db-migrate.sh

Run database migrations for specific environments with safety checks and rollback capabilities.

Usage

./scripts/db-migrate.sh [environment]

Environments

development: Local development database
staging: Staging environment database
production: Production database (requires confirmation)

Examples

# Migrate development database
./scripts/db-migrate.sh development

# Migrate production database
./scripts/db-migrate.sh production

# Rollback last migration
./scripts/db-migrate.sh production --rollback

db-seed.sh

Populate database with seed data for development and testing.

# Seed development database
./scripts/db-seed.sh development

# Seed specific data types
./scripts/db-seed.sh development --users --servers

Development Scripts

dev.sh

Start both frontend and backend development servers concurrently.

# Start all development servers
./scripts/dev.sh

# Start with specific environment
./scripts/dev.sh --env=development

# Start with hot reload
./scripts/dev.sh --hot-reload

dev-backend.sh

Start only the backend development server.

# Start backend server
./scripts/dev-backend.sh

# Start with debug mode
./scripts/dev-backend.sh --debug

# Start with specific port
./scripts/dev-backend.sh --port=3004

dev-frontend.sh

Start only the frontend development server.

# Start frontend server
./scripts/dev-frontend.sh

# Start with specific port
./scripts/dev-frontend.sh --port=3001

# Start with production build
./scripts/dev-frontend.sh --build

🔨 Build & Deploy Scripts

build.sh

Build the application for production deployment.

# Build for production
./scripts/build.sh

# Build with optimization
./scripts/build.sh --optimize

# Build specific packages
./scripts/build.sh --frontend --backend

deploy.sh

Deploy the application to specified environment.

# Deploy to staging
./scripts/deploy.sh staging

# Deploy to production
./scripts/deploy.sh production

# Deploy with backup
./scripts/deploy.sh production --backup

Testing Scripts

test.sh

Run all tests with comprehensive reporting.

# Run all tests
./scripts/test.sh

# Run specific test suites
./scripts/test.sh --unit --integration

# Run tests with coverage
./scripts/test.sh --coverage

test-watch.sh

Run tests in watch mode for continuous testing.

# Watch for changes and run tests
./scripts/test-watch.sh

# Watch specific files
./scripts/test-watch.sh --src --test

test-coverage.sh

Generate detailed test coverage reports.

# Generate coverage report
./scripts/test-coverage.sh

# Generate HTML coverage report
./scripts/test-coverage.sh --html

# Check coverage thresholds
./scripts/test-coverage.sh --check-thresholds

Docker Scripts

docker-build.sh

Build Docker images for all services.

# Build all images
./scripts/docker-build.sh

# Build specific services
./scripts/docker-build.sh --frontend --backend

# Build with custom tag
./scripts/docker-build.sh --tag=v1.0.0

docker-up.sh

Start Docker containers for development.

# Start all containers
./scripts/docker-up.sh

# Start specific services
./scripts/docker-up.sh --db --redis

# Start with detached mode
./scripts/docker-up.sh --detach

docker-down.sh

Stop and remove Docker containers.

# Stop all containers
./scripts/docker-down.sh

# Remove volumes
./scripts/docker-down.sh --volumes

# Force remove
./scripts/docker-down.sh --force

Maintenance Scripts

clean.sh

Clean up temporary files, logs, and build artifacts.

# Clean all temporary files
./scripts/clean.sh

# Clean specific directories
./scripts/clean.sh --logs --cache

# Deep clean
./scripts/clean.sh --deep

setup.sh

Set up development environment and dependencies.

# Full setup
./scripts/setup.sh

# Setup without database
./scripts/setup.sh --no-db

# Setup for production
./scripts/setup.sh --production

health-check.sh

Perform comprehensive health checks on all system components.

# Basic health check
./scripts/health-check.sh

# Detailed health check
./scripts/health-check.sh --detailed

# Continuous monitoring
./scripts/health-check.sh --watch

Script Best Practices

Usage Guidelines

Environment Safety: Production operations require explicit confirmation
Error Handling: All scripts include comprehensive error handling
Logging: Detailed logging for debugging and audit trails
Idempotency: Scripts can be run multiple times safely

Security Considerations

Permissions: Scripts run with minimum required permissions
Secrets: Sensitive data handled securely
Validation: Input validation for all parameters
Audit Trail: All operations logged for compliance