#!/bin/bash

# Windsurf Commands Script
# This script provides common development commands for the portfolio project

set -e

show_help() {
	echo "Usage: ./windsurf-commands.sh [COMMAND]"
	echo ""
	echo "Available commands:"
	echo "  lint              - Run ESLint to check for code issues"
	echo "  lintfix           - Run ESLint with auto-fix enabled"
	echo "  typecheck         - Run TypeScript type checking"
	echo "  security:audit    - Run security vulnerability scan"
	echo "  security:check    - Generate security report (JSON)"
	echo "  security:outdated - Check for outdated dependencies"
	echo "  help              - Show this help message"
	echo ""
}

run_lint() {
	echo "🔍 Running ESLint..."
	pnpm run lint
	echo "✅ Linting complete!"
}

run_lintfix() {
	echo "🔧 Running ESLint with auto-fix..."
	pnpm run lintfix
	echo "✅ Linting with auto-fix complete!"
}

run_typecheck() {
	echo "🔎 Running TypeScript type check..."
	pnpm run typecheck
	echo "✅ Type checking complete!"
}

run_security_audit() {
	echo "🔒 Running security audit..."
	pnpm run security:audit
	echo "✅ Security audit complete!"
}

run_security_check() {
	echo "📋 Generating security report..."
	pnpm run security:check
	echo "✅ Security report generated: security-report.json"
}

run_security_outdated() {
	echo "📦 Checking for outdated dependencies..."
	pnpm run security:outdated
	echo "✅ Outdated check complete!"
}

# Main script logic
case "${1:-help}" in
	lint)
		run_lint
		;;
	lintfix)
		run_lintfix
		;;
	typecheck)
		run_typecheck
		;;
	security:audit)
		run_security_audit
		;;
	security:check)
		run_security_check
		;;
	security:outdated)
		run_security_outdated
		;;
	help|--help|-h)
		show_help
		;;
	*)
		echo "❌ Unknown command: $1"
		echo ""
		show_help
		exit 1
		;;
esac
