Initial commit: add .gitignore and README

This commit is contained in:
defiQUG
2026-02-09 21:51:52 -08:00
commit 5d47b3a5d9
49 changed files with 5633 additions and 0 deletions

62
utils/analyze-costs.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Script to analyze and optimize infrastructure costs
set -e
echo "💰 Analyzing infrastructure costs..."
# Check for cost tracking files
if [ -f "infrastructure/costs.md" ]; then
echo "✅ Cost tracking file found"
cat infrastructure/costs.md
else
echo "📝 Creating cost tracking template..."
cat > infrastructure/costs.md << 'EOF'
# Infrastructure Cost Tracking
## Monthly Costs
### Compute
- Kubernetes clusters: $XXX
- VMs: $XXX
- Containers: $XXX
### Storage
- Database: $XXX
- Object storage: $XXX
- Backups: $XXX
### Network
- Data transfer: $XXX
- CDN: $XXX
### Monitoring
- Prometheus/Grafana: $XXX
- Logging: $XXX
## Cost Optimization Opportunities
1. Consolidate infrastructure (30-40% savings)
2. Right-size resources (20-30% savings)
3. Use reserved instances (30-70% savings)
4. Optimize storage (10-20% savings)
## Targets
- **Current**: $XXX/month
- **Target**: $XXX/month (30-40% reduction)
- **Timeline**: 3-6 months
EOF
echo "✅ Cost tracking template created"
fi
echo ""
echo "📝 See docs/COST_OPTIMIZATION.md for optimization strategies"

61
utils/build-all.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Build All Projects Script
# Builds all projects that have build scripts
set -e
echo "🔨 Building all projects..."
PROJECTS_DIR="."
BUILT=0
FAILED=0
build_project() {
local project=$1
if [ -f "$project/package.json" ]; then
cd "$project"
# Check if build script exists
if grep -q "\"build\"" package.json; then
echo "🔨 Building $project..."
if npm run build 2>/dev/null || pnpm build 2>/dev/null; then
echo "$project - Build successful"
((BUILT++))
else
echo "$project - Build failed"
((FAILED++))
fi
else
echo " ⏭️ $project - No build script"
fi
cd ..
fi
}
echo "📋 Building projects..."
# Build all projects with package.json
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != "node_modules/" ] && [ "$dir" != ".git/" ] && [ "$dir" != "scripts/" ]; then
build_project "$dir"
fi
done
echo ""
echo "📊 Build Summary:"
echo " ✅ Built: $BUILT"
echo " ❌ Failed: $FAILED"
if [ $FAILED -gt 0 ]; then
exit 1
fi
echo "✅ All builds successful!"

62
utils/cleanup.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Cleanup Script
# Removes build artifacts, node_modules, and other generated files
set -e
echo "🧹 Cleaning workspace..."
read -p "This will remove node_modules, dist, build, and cache directories. Continue? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Cancelled."
exit 1
fi
PROJECTS_DIR="."
CLEANED=0
clean_project() {
local project=$1
if [ -d "$project" ]; then
cd "$project"
# Remove common build artifacts
[ -d "node_modules" ] && rm -rf node_modules && echo " 🧹 Removed $project/node_modules"
[ -d "dist" ] && rm -rf dist && echo " 🧹 Removed $project/dist"
[ -d "build" ] && rm -rf build && echo " 🧹 Removed $project/build"
[ -d ".next" ] && rm -rf .next && echo " 🧹 Removed $project/.next"
[ -d "coverage" ] && rm -rf coverage && echo " 🧹 Removed $project/coverage"
[ -d ".cache" ] && rm -rf .cache && echo " 🧹 Removed $project/.cache"
[ -d "artifacts" ] && rm -rf artifacts && echo " 🧹 Removed $project/artifacts"
[ -d "cache" ] && rm -rf cache && echo " 🧹 Removed $project/cache"
((CLEANED++))
cd ..
fi
}
echo "📋 Cleaning projects..."
# Clean all projects
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != ".git/" ] && [ "$dir" != "scripts/" ]; then
clean_project "$dir"
fi
done
# Clean root level
[ -d "node_modules" ] && rm -rf node_modules && echo " 🧹 Removed root node_modules"
[ -d "dist" ] && rm -rf dist && echo " 🧹 Removed root dist"
[ -d "build" ] && rm -rf build && echo " 🧹 Removed root build"
echo ""
echo "✅ Cleanup complete! Cleaned $CLEANED projects."
echo "💡 Run 'pnpm install' or 'npm install' in projects to restore dependencies."

147
utils/deps-analyze.sh Executable file
View File

@@ -0,0 +1,147 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Dependency Analysis Script
# Analyzes all package.json files and identifies common dependencies
set -e
echo "🔍 Analyzing dependencies across all projects..."
OUTPUT_DIR="reports"
OUTPUT_FILE="$OUTPUT_DIR/dependency-analysis.md"
mkdir -p "$OUTPUT_DIR"
# Temporary files
TEMP_DEPS="/tmp/all-deps.txt"
TEMP_DEV_DEPS="/tmp/all-dev-deps.txt"
# Clear temp files
> "$TEMP_DEPS"
> "$TEMP_DEV_DEPS"
# Extract dependencies from all package.json files
echo "📋 Extracting dependencies..."
find . -name "package.json" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/dist/*" ! -path "*/build/*" | while read -r file; do
project=$(dirname "$file" | sed 's|^\./||')
# Extract dependencies
if command -v jq &> /dev/null; then
jq -r '.dependencies // {} | keys[]' "$file" 2>/dev/null | while read -r dep; do
echo "$dep|$project" >> "$TEMP_DEPS"
done
jq -r '.devDependencies // {} | keys[]' "$file" 2>/dev/null | while read -r dep; do
echo "$dep|$project" >> "$TEMP_DEV_DEPS"
done
else
# Fallback: basic grep extraction (less accurate)
grep -o '"[^"]*":\s*"[^"]*"' "$file" | grep -v ":" | sed 's/"//g' | while read -r dep; do
echo "$dep|$project" >> "$TEMP_DEPS"
done
fi
done
# Generate report
cat > "$OUTPUT_FILE" << 'EOF'
# Dependency Analysis Report
**Generated**: $(date)
**Purpose**: Identify common dependencies across all projects
## Summary
This report analyzes dependencies across all projects in the workspace.
## Common Dependencies
### Most Frequently Used Dependencies
EOF
# Count and sort dependencies
echo "📊 Generating dependency statistics..."
if [ -f "$TEMP_DEPS" ]; then
echo "### Production Dependencies" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "| Dependency | Usage Count | Projects |" >> "$OUTPUT_FILE"
echo "|------------|-------------|----------|" >> "$OUTPUT_FILE"
sort "$TEMP_DEPS" | cut -d'|' -f1 | uniq -c | sort -rn | head -20 | while read -r count dep; do
projects=$(grep "^$dep|" "$TEMP_DEPS" | cut -d'|' -f2 | sort -u | tr '\n' ', ' | sed 's/,$//')
echo "| $dep | $count | $projects |" >> "$OUTPUT_FILE"
done
echo "" >> "$OUTPUT_FILE"
fi
if [ -f "$TEMP_DEV_DEPS" ]; then
echo "### Development Dependencies" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE"
echo "| Dependency | Usage Count | Projects |" >> "$OUTPUT_FILE"
echo "|------------|-------------|----------|" >> "$OUTPUT_FILE"
sort "$TEMP_DEV_DEPS" | cut -d'|' -f1 | uniq -c | sort -rn | head -20 | while read -r count dep; do
projects=$(grep "^$dep|" "$TEMP_DEV_DEPS" | cut -d'|' -f2 | sort -u | tr '\n' ', ' | sed 's/,$//')
echo "| $dep | $count | $projects |" >> "$OUTPUT_FILE"
done
echo "" >> "$OUTPUT_FILE"
fi
cat >> "$OUTPUT_FILE" << EOF
## Recommendations
### Candidates for Shared Packages
Based on usage frequency, these dependencies are good candidates for hoisting to workspace root or shared packages:
1. **TypeScript/JavaScript Tooling**:
- typescript
- eslint
- prettier
- @typescript-eslint/*
2. **Testing**:
- vitest / jest
- @testing-library/*
3. **Utilities**:
- zod (validation)
- dotenv (configuration)
- date-fns (date handling)
4. **Blockchain/Solidity**:
- ethers / viem
- @openzeppelin/contracts
- foundry (dev dependency)
### Version Consolidation
Review and consolidate versions for:
- Common dependencies with version mismatches
- Outdated dependencies
- Security vulnerabilities
## Next Steps
1. Create shared packages for common utilities
2. Hoist common devDependencies to workspace root
3. Consolidate dependency versions
4. Set up automated dependency updates (Dependabot)
---
**Generated**: $(date)
EOF
echo "✅ Dependency analysis complete!"
echo "📄 Report saved to: $OUTPUT_FILE"
# Cleanup
rm -f "$TEMP_DEPS" "$TEMP_DEV_DEPS"

69
utils/deps-audit.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Dependency Audit Script
# Audits dependencies across all projects for security vulnerabilities
set -e
echo "🔍 Auditing dependencies across all projects..."
PROJECTS_DIR="."
AUDITED=0
VULNERABILITIES=0
audit_project() {
local project=$1
if [ -f "$project/package.json" ]; then
cd "$project"
echo "🔍 Auditing $project..."
if command -v npm &> /dev/null; then
if npm audit --audit-level=moderate 2>/dev/null; then
echo "$project - No vulnerabilities"
else
echo " ⚠️ $project - Vulnerabilities found"
((VULNERABILITIES++))
fi
((AUDITED++))
elif command -v pnpm &> /dev/null; then
if pnpm audit --audit-level=moderate 2>/dev/null; then
echo "$project - No vulnerabilities"
else
echo " ⚠️ $project - Vulnerabilities found"
((VULNERABILITIES++))
fi
((AUDITED++))
fi
cd ..
fi
}
echo "📋 Auditing projects..."
# Audit all projects with package.json
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != "node_modules/" ] && [ "$dir" != ".git/" ] && [ "$dir" != "scripts/" ]; then
audit_project "$dir"
fi
done
echo ""
echo "📊 Audit Summary:"
echo " ✅ Audited: $AUDITED"
echo " ⚠️ With vulnerabilities: $VULNERABILITIES"
if [ $VULNERABILITIES -gt 0 ]; then
echo ""
echo "⚠️ Some projects have vulnerabilities. Run 'npm audit fix' or 'pnpm audit fix' in affected projects."
exit 1
fi
echo "✅ All dependencies secure!"

46
utils/optimize-builds.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Script to optimize build and test workflows
set -e
echo "⚡ Optimizing build and test workflows..."
# Check if Turborepo is configured
if [ -f "turbo.json" ]; then
echo "✅ Turborepo configuration found"
# Verify cache is working
echo "🧪 Testing build cache..."
pnpm build --force || echo "⚠️ Build test skipped"
echo "📊 Build optimization tips:"
echo " - Enable Turborepo caching"
echo " - Use parallel execution"
echo " - Enable incremental builds"
echo " - Cache dependencies"
else
echo "⚠️ Turborepo not configured"
echo " → Consider setting up Turborepo for build optimization"
fi
# Check for test optimization
echo "🧪 Test optimization:"
echo " - Run tests in parallel"
echo " - Use test filtering"
echo " - Cache test results"
echo " - Use test sharding for CI"
# Check CI/CD configuration
if [ -d ".github/workflows" ]; then
echo "✅ GitHub Actions workflows found"
echo " → Review workflows for optimization opportunities"
fi
echo ""
echo "📝 See docs/BUILD_OPTIMIZATION_GUIDE.md for detailed optimization strategies"

61
utils/test-all.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Test All Projects Script
# Runs tests for all projects that have test scripts
set -e
echo "🧪 Running tests for all projects..."
PROJECTS_DIR="."
TESTED=0
FAILED=0
test_project() {
local project=$1
if [ -f "$project/package.json" ]; then
cd "$project"
# Check if test script exists
if grep -q "\"test\"" package.json; then
echo "🧪 Testing $project..."
if npm test 2>/dev/null || pnpm test 2>/dev/null; then
echo "$project - Tests passed"
((TESTED++))
else
echo "$project - Tests failed"
((FAILED++))
fi
else
echo " ⏭️ $project - No test script"
fi
cd ..
fi
}
echo "📋 Testing projects..."
# Test all projects with package.json
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != "node_modules/" ] && [ "$dir" != ".git/" ] && [ "$dir" != "scripts/" ]; then
test_project "$dir"
fi
done
echo ""
echo "📊 Test Summary:"
echo " ✅ Tested: $TESTED"
echo " ❌ Failed: $FAILED"
if [ $FAILED -gt 0 ]; then
exit 1
fi
echo "✅ All tests passed!"

59
utils/verify-all.sh Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/bash
# Load shared libraries
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Verify All Projects Script
# Checks all projects for basic requirements (README, structure, etc.)
set -e
echo "🔍 Verifying all projects..."
PROJECTS_DIR="."
FAILED=0
PASSED=0
verify_project() {
local project=$1
local has_readme=false
local has_package=false
if [ -f "$project/README.md" ]; then
has_readme=true
fi
if [ -f "$project/package.json" ] || [ -f "$project/Cargo.toml" ] || [ -f "$project/go.mod" ]; then
has_package=true
fi
if [ "$has_readme" = true ]; then
echo "$project - Has README"
((PASSED++))
else
echo " ⚠️ $project - Missing README.md"
((FAILED++))
fi
}
echo "📋 Checking projects..."
# Check all directories
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != "node_modules/" ] && [ "$dir" != ".git/" ] && [ "$dir" != "scripts/" ]; then
verify_project "$dir"
fi
done
echo ""
echo "📊 Verification Summary:"
echo " ✅ Passed: $PASSED"
echo " ⚠️ Failed: $FAILED"
if [ $FAILED -gt 0 ]; then
exit 1
fi
echo "✅ All projects verified!"