# Initialization Scripts Reference

Complete reference for initializing slideshow projects with the frontend-slides skill.

## init_slideshow.py

The main initialization script that creates a complete slideshow project structure.

### Basic Usage

```bash
# Create new project with default settings
python scripts/init_slideshow.py my-presentation

# Create with specific brand preset
python scripts/init_slideshow.py phat-deck --brand phat

# Create in specific directory
python scripts/init_slideshow.py client-pitch --path /projects/ --brand ce
```

### Command Line Options

```bash
python scripts/init_slideshow.py <project_name> [options]

Required:
  project_name          Name of the slideshow project

Options:
  --brand {ce,phat,custom}    Brand preset to use (default: custom)
  --path PATH                 Base directory for project (default: current)
  --template TEMPLATE         Project template to use
  --content-source SOURCE     Initialize with content from source
  --no-examples               Skip example content creation
  --minimal                   Create minimal structure only
```

### Advanced Initialization

#### With Content Source

```bash
# Initialize with content from existing presentation
python scripts/init_slideshow.py new-deck \
  --content-source presentation.pptx \
  --brand ce

# Initialize with content from chat export
python scripts/init_slideshow.py strategy-deck \
  --content-source chat-export.json \
  --brand phat

# Initialize with content from API
python scripts/init_slideshow.py api-deck \
  --content-source "https://api.notion.com/v1/pages/123" \
  --brand custom
```

#### Custom Templates

```bash
# Use custom project template
python scripts/init_slideshow.py custom-deck \
  --template /templates/corporate-template/ \
  --brand ce

# Minimal setup for advanced users
python scripts/init_slideshow.py minimal-deck \
  --minimal \
  --no-examples
```

### Created Directory Structure

When you run `init_slideshow.py`, it creates:

```
project-name/
├── content/
│   ├── content.json              # Main content structure
│   ├── extracted/                # Content from external sources
│   └── templates/
│       └── slide-templates.json  # Slide type templates
├── assets/
│   ├── images/                   # Project images
│   ├── icons/                    # Brand icons and UI elements  
│   └── media/                    # Video/audio files
├── styles/
│   ├── brand-config.json         # Brand configuration
│   ├── brand-variables.css       # Generated brand CSS variables (after build)
│   ├── layout-engine.css         # Layout system CSS (after build)
│   └── custom.css                # Project-specific overrides
├── scripts/
│   ├── apis/
│   │   ├── content_api.py        # Content management API
│   │   └── asset_api.py          # Asset management API
│   ├── engines/
│   │   ├── style_engine.py       # Style Guide Engine
│   │   └── layout_engine.py      # Layout Engine (created when needed)
│   └── generators/
│       └── html_generator.py     # HTML slideshow generator
└── dist/                         # Generated output (after build)
    ├── index.html               # Generated slideshow
    ├── styles.css               # Compiled styles
    └── assets/                  # Optimized assets
```

## setup_project.py

Helper script for advanced project setup and configuration.

### Usage

```bash
# Setup development environment
python scripts/setup_project.py project-name --dev

# Setup for production deployment
python scripts/setup_project.py project-name --production

# Setup with specific configuration
python scripts/setup_project.py project-name --config config.json
```

### Configuration Options

```bash
python scripts/setup_project.py <project_name> [options]

Options:
  --dev                    Setup development environment
  --production            Setup for production deployment
  --config CONFIG_FILE    Use custom configuration file
  --install-deps          Install required dependencies
  --git-init              Initialize git repository
  --vercel-setup          Setup Vercel deployment
  --cdn-config            Configure CDN for assets
```

## apply_brand.py

Apply brand guidelines to existing projects.

### Usage

```bash
# Apply CE brand system
python scripts/apply_brand.py project-path --brand ce

# Apply PHAT liquid gold theme
python scripts/apply_brand.py project-path --brand phat --theme liquid-gold

# Apply custom brand from file
python scripts/apply_brand.py project-path --config custom-brand.json

# Apply brand with specific output
python scripts/apply_brand.py project-path \
  --brand ce \
  --output styles/ce-system.css \
  --include-components
```

### Advanced Brand Application

```bash
# Apply brand with validation
python scripts/apply_brand.py project-path \
  --brand ce \
  --validate \
  --compliance-report

# Apply brand with custom overrides
python scripts/apply_brand.py project-path \
  --brand phat \
  --override-colors "primary:#FFD700" \
  --override-fonts "primary:Custom Display Font"

# Apply brand to specific files only
python scripts/apply_brand.py project-path \
  --brand ce \
  --files "styles/main.css,styles/components.css"
```

## Environment Setup Scripts

### install_deps.py

```bash
# Install all required dependencies
python scripts/install_deps.py

# Install with specific package manager
python scripts/install_deps.py --package-manager npm
python scripts/install_deps.py --package-manager yarn

# Install development dependencies only
python scripts/install_deps.py --dev-only

# Install with specific versions
python scripts/install_deps.py --requirements requirements.txt
```

### configure_build.py

```bash
# Configure build system
python scripts/configure_build.py project-path

# Configure with specific build tool
python scripts/configure_build.py project-path --build-tool webpack
python scripts/configure_build.py project-path --build-tool vite

# Configure for specific deployment target
python scripts/configure_build.py project-path --target vercel
python scripts/configure_build.py project-path --target netlify
python scripts/configure_build.py project-path --target github-pages
```

## Integration Scripts

### integrate_content.py

```bash
# Integrate content from multiple sources
python scripts/integrate_content.py project-path \
  --chat-export /path/to/chat.json \
  --slides-export /path/to/slides.pptx \
  --api-source "https://api.example.com/content"

# Integrate with content transformation
python scripts/integrate_content.py project-path \
  --source /path/to/source \
  --transform extract-headings \
  --format json
```

### sync_assets.py

```bash
# Sync assets from external sources
python scripts/sync_assets.py project-path \
  --google-drive "folder-id:ABC123" \
  --figma-file "file-id:XYZ789" \
  --local-dir "/source/images"

# Sync with optimization
python scripts/sync_assets.py project-path \
  --source /images/ \
  --optimize \
  --generate-responsive
```

## Validation Scripts

### validate_project.py

```bash
# Validate complete project structure
python scripts/validate_project.py project-path

# Validate specific aspects
python scripts/validate_project.py project-path --check content
python scripts/validate_project.py project-path --check assets
python scripts/validate_project.py project-path --check styles

# Generate validation report
python scripts/validate_project.py project-path \
  --report validation-report.json \
  --verbose
```

### check_compliance.py

```bash
# Check brand compliance
python scripts/check_compliance.py project-path \
  --brand ce \
  --strict

# Check accessibility compliance
python scripts/check_compliance.py project-path \
  --accessibility \
  --level AA

# Check performance compliance
python scripts/check_compliance.py project-path \
  --performance \
  --target mobile
```

## Python API for Initialization

### ProjectInitializer Class

```python
from scripts.init_slideshow import ProjectInitializer

# Initialize project programmatically
initializer = ProjectInitializer()

project_config = {
    "name": "my-presentation",
    "brand": "ce",
    "template": "corporate",
    "content_source": "presentation.pptx"
}

project_path = initializer.create_project(project_config)
```

### Configuration Management

```python
# Load and modify project configuration
from scripts.setup_project import ProjectConfig

config = ProjectConfig.load("project-path")
config.set_brand("phat")
config.set_theme("liquid-gold")
config.add_integration("figma", {"file_id": "ABC123"})
config.save()
```

### Validation and Compliance

```python
# Validate project programmatically
from scripts.validate_project import ProjectValidator

validator = ProjectValidator("project-path")
results = validator.validate_all()

if results.is_valid:
    print("Project validation passed")
else:
    for error in results.errors:
        print(f"Error: {error.message}")
```

## Error Handling

### Common Initialization Errors

```python
# Handle initialization errors
try:
    initializer.create_project(config)
except ProjectExistsError:
    print("Project directory already exists")
except BrandNotFoundError as e:
    print(f"Brand '{e.brand}' not found. Available: {e.available_brands}")
except TemplateNotFoundError as e:
    print(f"Template '{e.template}' not found")
except ContentSourceError as e:
    print(f"Cannot access content source: {e.source}")
```

### Validation Error Details

```python
# Detailed validation error handling
try:
    validator.validate_content()
except ContentValidationError as e:
    print(f"Content validation failed:")
    for slide_error in e.slide_errors:
        print(f"  Slide {slide_error.slide_id}: {slide_error.message}")
        print(f"    Field: {slide_error.field}")
        print(f"    Expected: {slide_error.expected}")
        print(f"    Actual: {slide_error.actual}")
```

## Performance Considerations

### Initialization Optimization

```python
# Configure initialization for performance
initializer.configure({
    "parallel_asset_processing": True,
    "skip_image_optimization": False,  # Set to True for faster init
    "cache_brand_assets": True,
    "defer_style_generation": False
})
```

### Large Project Handling

```python
# Handle large projects efficiently
config = {
    "chunked_processing": True,
    "max_memory_usage": "1GB",
    "temp_directory": "/tmp/slideshow-init",
    "progress_callback": lambda p: print(f"Progress: {p}%")
}

initializer.create_project(project_config, optimization=config)
```