provisioning/tools/README-analyze-codebase.md

2 lines
6.3 KiB
Markdown
Raw Normal View History

# Codebase Analysis Script\n\nScript to analyze the technology distribution in the provisioning codebase.\n\n## Usage\n\n### Basic Usage\n\n```\n# From provisioning directory (analyzes current directory)\ncd provisioning\nnu tools/analyze-codebase.nu\n\n# From project root, analyze provisioning\nnu provisioning/tools/analyze-codebase.nu --path provisioning\n\n# Analyze any path\nnu provisioning/tools/analyze-codebase.nu --path /absolute/path/to/directory\n```\n\n### Output Formats\n\n```\n# Table format (default) - colored, visual bars\nnu provisioning/tools/analyze-codebase.nu --format table\n\n# JSON format - for programmatic use\nnu provisioning/tools/analyze-codebase.nu --format json\n\n# Markdown format - for documentation\nnu provisioning/tools/analyze-codebase.nu --format markdown\n```\n\n### From provisioning directory\n\n```\ncd provisioning\nnu tools/analyze-codebase.nu\n```\n\n### Direct execution (if in PATH)\n\n```\n# Make it globally available (one time)\nln -sf "$(pwd)/provisioning/tools/analyze-codebase.nu" /usr/local/bin/analyze-codebase\n\n# Then run from anywhere\nanalyze-codebase\nanalyze-codebase --format json\nanalyze-codebase --format markdown > CODEBASE_STATS.md\n```\n\n## Output\n\nThe script analyzes:\n\n- **Nushell** (.nu files)\n- **KCL** (.k files)\n- **Rust** (.rs files)\n- **Templates** (.j2, .tera files)\n\nAcross these sections:\n\n- `core/` - CLI interface, core libraries\n- `extensions/` - Providers, taskservs, clusters\n- `platform/` - Rust services (orchestrator, control-center, etc.)\n- `templates/` - Template files\n- `kcl/` - KCL configuration schemas\n\n## Example Output\n\n### Table Format\n\n```\n📊 Analyzing Codebase: provisioning\n\n📋 Lines of Code by Section\n\n╭─────────────┬─────────┬────────────┬─────┬─────────┬─────┬──────────┬───────────┬───────────────┬───────────┬───────╮\n│ section │ nushell │ nushell_pct│ kcl │ kcl_pct │ rust│ rust_pct │ templates │ templates_pct │ total │ │\n├─────────────┼─────────┼────────────┼─────┼─────────┼─────┼──────────┼───────────┼───────────────┼───────────┼───────┤\n│ core │ 53843 │ 99.87 │ 71 │ 0.13 │ 0 │ 0.00 │ 0 │ 0.00 │ 53914 │ │\n│ extensions │ 10202 │ 43.21 │3946 │ 16.72 │ 0 │ 0.00 │ 9456 │ 40.05 │ 23604 │ │\n│ platform │ 5759 │ 0.19 │ 0 │ 0.00 │2992107│ 99.81 │ 0 │ 0.00 │ 2997866 │ │\n│ templates │ 4197 │ 72.11 │ 834 │ 14.33 │ 0 │ 0.00 │ 789 │ 13.56 │ 5820 │ │\n│ kcl │ 0 │ 0.00 │5594 │ 100.00 │ 0 │ 0.00 │ 0 │ 0.00 │ 5594 │ │\n╰─────────────┴─────────┴────────────┴─────┴─────────┴─────┴──────────┴───────────┴───────────────┴───────────┴───────╯\n\n📊 Overall Technology Distribution\n\n╭──────────────────────┬──────────┬────────────┬────────────────────────────────────────────────────╮\n│ technology │ lines │ percentage │ vis