Files
query-orchestration/inventory_code.sh
T

47 lines
2.5 KiB
Bash
Raw Normal View History

#!/bin/bash
# inventory_code.sh - Count lines of code and config files in the project
# Excludes ./vendor and ./.git directories
set -e
echo "=== Project Line Count (excluding ./vendor) ==="
echo ""
# Count lines for each file type
GO_LINES=$(find . -type f -name "*.go" -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
GEN_GO_LINES=$(find . -type f -name "*.gen.go" -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
SQL_GO_LINES=$(find . -type f -name "*.sql.go" -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
YAML_LINES=$(find . -type f \( -name "*.yaml" -o -name "*.yml" \) -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
MD_LINES=$(find . -type f -name "*.md" -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
SQL_LINES=$(find . -type f -name "*.sql" -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
SH_LINES=$(find . -type f -name "*.sh" -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
JSON_LINES=$(find . -type f -name "*.json" -not -path "./vendor/*" -not -path "./.git/*" | xargs cat 2>/dev/null | wc -l | tr -d ' ')
# Count files
GO_FILES=$(find . -type f -name "*.go" -not -path "./vendor/*" -not -path "./.git/*" | wc -l | tr -d ' ')
# Calculate hand-written Go (total - generated - sqlc)
HAND_WRITTEN_GO=$((GO_LINES - GEN_GO_LINES - SQL_GO_LINES))
# Calculate total
TOTAL=$((GO_LINES + YAML_LINES + MD_LINES + SQL_LINES + SH_LINES + JSON_LINES))
echo "By file type:"
echo "-------------------------------------------"
printf "Go code (.go): %'8d lines\n" "$GO_LINES"
printf " → Generated (.gen.go): %'8d lines\n" "$GEN_GO_LINES"
printf " → SQLC (.sql.go): %'8d lines\n" "$SQL_GO_LINES"
printf " → Hand-written Go: %'8d lines\n" "$HAND_WRITTEN_GO"
printf "Markdown (.md): %'8d lines\n" "$MD_LINES"
printf "Shell scripts (.sh): %'8d lines\n" "$SH_LINES"
printf "YAML (.yaml/.yml): %'8d lines\n" "$YAML_LINES"
printf "JSON (.json): %'8d lines\n" "$JSON_LINES"
printf "SQL (.sql): %'8d lines\n" "$SQL_LINES"
echo "-------------------------------------------"
printf "TOTAL: %'8d lines\n" "$TOTAL"
echo ""
echo "File counts:"
echo "-------------------------------------------"
printf "Go files: %'8d files\n" "$GO_FILES"
echo ""