test_vscode.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. # Opencode VSCode Extension Test Runner Script
  3. set -e
  4. RED='\033[0;31m'
  5. GREEN='\033[0;32m'
  6. YELLOW='\033[1;33m'
  7. NC='\033[0m'
  8. print_status() {
  9. echo -e "${GREEN}[INFO]${NC} $1"
  10. }
  11. print_warn() {
  12. echo -e "${YELLOW}[WARN]${NC} $1"
  13. }
  14. print_error() {
  15. echo -e "${RED}[ERROR]${NC} $1"
  16. }
  17. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  18. ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
  19. PLUGIN_DIR="$ROOT_DIR/hosts/vscode-plugin"
  20. if [[ ! -f "$PLUGIN_DIR/package.json" ]]; then
  21. print_error "package.json not found. Please run this script from the repository root."
  22. exit 1
  23. fi
  24. cd "$PLUGIN_DIR"
  25. command="${1:-test}"
  26. case "$command" in
  27. test|t)
  28. print_status "Running full test suite..."
  29. pnpm test
  30. ;;
  31. compile|c)
  32. print_status "Compiling TypeScript..."
  33. pnpm run compile
  34. ;;
  35. lint|l)
  36. print_status "Running ESLint..."
  37. pnpm run lint
  38. ;;
  39. lint-fix|lf)
  40. print_status "Running ESLint with auto-fix..."
  41. npx eslint src --ext ts --fix
  42. ;;
  43. watch|w)
  44. print_status "Starting TypeScript watch mode..."
  45. pnpm run watch
  46. ;;
  47. clean)
  48. print_status "Cleaning build outputs..."
  49. rm -rf out/ .vscode-test/
  50. print_status "Clean complete"
  51. ;;
  52. install|i)
  53. print_status "Installing dependencies..."
  54. pnpm install
  55. ;;
  56. help|h|--help)
  57. cat <<EOF
  58. Opencode VSCode Extension Test Runner
  59. Usage: $0 [command]
  60. Commands:
  61. test, t Run full test suite (default)
  62. compile, c Compile TypeScript only
  63. lint, l Run ESLint only
  64. lint-fix, lf Run ESLint with auto-fix
  65. watch, w Start TypeScript watch mode
  66. clean Clean build outputs
  67. install, i Install dependencies
  68. help, h Show this help message
  69. EOF
  70. ;;
  71. *)
  72. print_error "Unknown command: $command"
  73. print_warn "Use '$0 help' to see available commands"
  74. exit 1
  75. ;;
  76. esac