Examples โ
Learn how to use Plexr through practical examples. These examples cover common use cases and demonstrate best practices.
Available Examples โ
Basic Setup โ
A simple example showing how to set up a basic development environment with common tools.
What you'll learn:
- Creating your first plan
- Using platform-specific scripts
- Basic step dependencies
Advanced Patterns โ
Advanced techniques for complex setups.
What you'll learn:
- Complex dependency chains
- Conditional execution
- Error handling strategies
- State management
Real World Examples โ
Production-ready examples from actual projects.
What you'll learn:
- Full-stack application setup
- Database migrations
- CI/CD integration
- Team collaboration patterns
Quick Start Example โ
Here's a minimal example to get you started:
yaml
name: "Quick Start"
version: "1.0.0"
executors:
shell:
type: shell
steps:
- id: hello_world
description: "Say hello"
executor: shell
files:
- path: "hello.sh"With hello.sh:
bash
#!/bin/bash
echo "Hello from Plexr! ๐"Run it:
bash
plexr execute quickstart.ymlCommon Patterns โ
1. Tool Installation with Verification โ
yaml
steps:
- id: install_node
description: "Install Node.js"
executor: shell
check_command: "node --version"
files:
- path: "install_node.sh"2. Platform-Specific Scripts โ
yaml
steps:
- id: install_deps
description: "Install dependencies"
executor: shell
files:
- path: "install_linux.sh"
platform: linux
- path: "install_mac.sh"
platform: darwin
- path: "install_windows.ps1"
platform: windows3. Sequential Dependencies โ
yaml
steps:
- id: step1
description: "First step"
executor: shell
files:
- path: "step1.sh"
- id: step2
description: "Second step"
depends_on: [step1]
executor: shell
files:
- path: "step2.sh"
- id: step3
description: "Third step"
depends_on: [step2]
executor: shell
files:
- path: "step3.sh"4. Parallel Execution โ
yaml
steps:
- id: download_tools
description: "Download tools"
executor: shell
files:
- path: "download.sh"
- id: create_dirs
description: "Create directories"
executor: shell
files:
- path: "mkdirs.sh"
- id: setup_configs
description: "Setup configurations"
depends_on: [download_tools, create_dirs]
executor: shell
files:
- path: "configure.sh"Best Practices from Examples โ
1. Always Use Check Commands โ
yaml
check_command: "command -v docker >/dev/null 2>&1"2. Make Scripts Idempotent โ
bash
# Bad
mkdir ~/workspace
# Good
mkdir -p ~/workspace3. Handle Errors Gracefully โ
bash
set -euo pipefail
if ! command -v node &> /dev/null; then
echo "Node.js is required but not installed"
exit 1
fi4. Use Descriptive Step IDs โ
yaml
# Bad
id: step1
# Good
id: install_postgresql_14Example Repository Structure โ
A typical project using Plexr:
my-project/
โโโ setup.yml # Main plan file
โโโ scripts/ # Execution scripts
โ โโโ install/
โ โ โโโ node.sh
โ โ โโโ docker.sh
โ โ โโโ postgres.sh
โ โโโ configure/
โ โ โโโ git.sh
โ โ โโโ env.sh
โ โโโ verify/
โ โโโ health_check.sh
โโโ sql/ # SQL scripts
โ โโโ create_db.sql
โ โโโ migrations/
โโโ configs/ # Configuration templates
โโโ .env.template
โโโ docker-compose.ymlContributing Examples โ
Have a great example? We'd love to include it!
- Fork the repository
- Add your example to
examples/ - Include a README explaining the use case
- Submit a pull request
Next Steps โ
- Try the Basic Setup Example
- Read the Configuration Guide
- Check the API Reference for detailed options