This directory contains example scripts demonstrating different use cases for the Code Evolution Analyzer.
File: analyze-multiple-repos.sh
Demonstrates analyzing multiple repositories and organizing outputs:
cd examples
./analyze-multiple-repos.shFeatures:
- Analyzes multiple repos in sequence
- Organizes outputs by repository name
- Provides summary of all generated visualizations
File: daily-update.sh
Perfect for CI/CD pipelines - demonstrates incremental updates:
cd examples
./daily-update.shFeatures:
- Automatic incremental detection
- Fast updates (only new commits)
- Optional deployment hooks (GitHub Pages, S3)
# Using npx (recommended)
npx @slepp/code-evolution https://github.com/yourusername/yourrepo ./my-analysis
# Or from cloned repo
cd examples
node ../analyze.mjs https://github.com/yourusername/yourrepo ./my-analysisnpx @slepp/code-evolution https://github.com/yourusername/yourrepo ./my-analysis --force-full#!/bin/bash
# weekly-update.sh
REPOS=(
"https://github.com/org/frontend"
"https://github.com/org/backend"
"https://github.com/org/mobile"
)
for repo in "${REPOS[@]}"; do
name=$(basename "$repo")
echo "Updating $name..."
npx @slepp/code-evolution "$repo" "./weekly-metrics/$name"
donename: Weekly Metrics
on:
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday
workflow_dispatch:
jobs:
update-metrics:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install scc
run: sudo snap install scc
- name: Update metrics
run: |
npx @slepp/code-evolution https://github.com/${{ github.repository }} ./metrics
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./metricsmetrics:
stage: deploy
script:
- apt-get update && apt-get install -y cloc
- npx @slepp/code-evolution https://gitlab.com/$CI_PROJECT_PATH ./metrics
- cp -r ./metrics public/
artifacts:
paths:
- public
only:
- schedules- First Run: Allow extra time for full analysis (15min+ for large repos)
- Incremental Updates: Subsequent runs complete in seconds
- Scheduling: Daily/weekly updates work great with incremental mode
- Storage: Keep data.json in version control to track historical changes
- Sharing: The visualization.html is self-contained - just send the file!
example-output/
├── repo-name-1/
│ ├── data.json
│ └── visualization.html
├── repo-name-2/
│ ├── data.json
│ └── visualization.html
└── repo-name-3/
├── data.json
└── visualization.html
Issue: Script fails with "cloc: command not found"
Solution: Install cloc first: sudo apt install cloc (Ubuntu) or brew install cloc (macOS)
Issue: "Permission denied" error
Solution: Make scripts executable: chmod +x examples/*.sh
Issue: Slow analysis Solution: Use incremental mode (automatic on second run) or analyze smaller repos