summaryrefslogtreecommitdiff
path: root/mcp-servers/simple-mcp-server/.claude/hooks/dev-watch.sh
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-01-16 08:30:14 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-01-16 08:30:14 +0900
commit3fbb9a18372f2b6a675dd6c039ba52be76f3eeb4 (patch)
treeaa694a36cdd323a7853672ee7a2ba60409ac3b06 /mcp-servers/simple-mcp-server/.claude/hooks/dev-watch.sh
updates
Diffstat (limited to 'mcp-servers/simple-mcp-server/.claude/hooks/dev-watch.sh')
-rwxr-xr-xmcp-servers/simple-mcp-server/.claude/hooks/dev-watch.sh93
1 files changed, 93 insertions, 0 deletions
diff --git a/mcp-servers/simple-mcp-server/.claude/hooks/dev-watch.sh b/mcp-servers/simple-mcp-server/.claude/hooks/dev-watch.sh
new file mode 100755
index 0000000..1d2b5fc
--- /dev/null
+++ b/mcp-servers/simple-mcp-server/.claude/hooks/dev-watch.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+# Development Watch Hook for Simple MCP Server
+# Automatically triggered on TypeScript file changes
+
+set -e
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+NC='\033[0m' # No Color
+
+echo -e "${GREEN}๐Ÿ”„ Development Watch Hook Triggered${NC}"
+
+# Get the modified file
+MODIFIED_FILE="$1"
+
+# Skip if not a TypeScript file
+if [[ ! "$MODIFIED_FILE" =~ \.ts$ ]]; then
+ exit 0
+fi
+
+# Skip node_modules and dist
+if [[ "$MODIFIED_FILE" =~ node_modules|dist|coverage ]]; then
+ exit 0
+fi
+
+echo "๐Ÿ“ File changed: $MODIFIED_FILE"
+
+# Type checking
+echo -e "${YELLOW}โœ… Running type check...${NC}"
+if npx tsc --noEmit 2>/dev/null; then
+ echo -e "${GREEN} โœ“ Type checking passed${NC}"
+else
+ echo -e "${RED} โœ— Type checking failed${NC}"
+ exit 1
+fi
+
+# Format with prettier
+if command -v prettier &> /dev/null; then
+ echo -e "${YELLOW}๐ŸŽจ Formatting with Prettier...${NC}"
+ npx prettier --write "$MODIFIED_FILE" 2>/dev/null || true
+ echo -e "${GREEN} โœ“ Formatted${NC}"
+fi
+
+# Lint with ESLint
+if [ -f .eslintrc.json ] || [ -f .eslintrc.js ]; then
+ echo -e "${YELLOW}๐Ÿ” Linting with ESLint...${NC}"
+ if npx eslint "$MODIFIED_FILE" --fix 2>/dev/null; then
+ echo -e "${GREEN} โœ“ Linting passed${NC}"
+ else
+ echo -e "${YELLOW} โš  Linting warnings${NC}"
+ fi
+fi
+
+# Run tests if it's a test file or if the corresponding test exists
+if [[ "$MODIFIED_FILE" =~ \.test\.ts$ ]] || [[ "$MODIFIED_FILE" =~ \.spec\.ts$ ]]; then
+ echo -e "${YELLOW}๐Ÿงช Running tests for $MODIFIED_FILE...${NC}"
+ if npx vitest run "$MODIFIED_FILE" 2>/dev/null; then
+ echo -e "${GREEN} โœ“ Tests passed${NC}"
+ else
+ echo -e "${RED} โœ— Tests failed${NC}"
+ exit 1
+ fi
+else
+ # Check if corresponding test file exists
+ TEST_FILE="${MODIFIED_FILE%.ts}.test.ts"
+ TEST_FILE_SPEC="${MODIFIED_FILE%.ts}.spec.ts"
+
+ if [ -f "$TEST_FILE" ]; then
+ echo -e "${YELLOW}๐Ÿงช Running related tests...${NC}"
+ npx vitest run "$TEST_FILE" 2>/dev/null || true
+ elif [ -f "$TEST_FILE_SPEC" ]; then
+ echo -e "${YELLOW}๐Ÿงช Running related tests...${NC}"
+ npx vitest run "$TEST_FILE_SPEC" 2>/dev/null || true
+ fi
+fi
+
+# Update tool/resource counts if applicable
+if [[ "$MODIFIED_FILE" =~ src/tools/ ]] || [[ "$MODIFIED_FILE" =~ src/resources/ ]] || [[ "$MODIFIED_FILE" =~ src/prompts/ ]]; then
+ echo -e "${YELLOW}๐Ÿ“Š Updating capability counts...${NC}"
+
+ TOOL_COUNT=$(find src/tools -name "*.ts" -not -name "index.ts" 2>/dev/null | wc -l || echo 0)
+ RESOURCE_COUNT=$(find src/resources -name "*.ts" -not -name "index.ts" 2>/dev/null | wc -l || echo 0)
+ PROMPT_COUNT=$(find src/prompts -name "*.ts" -not -name "index.ts" 2>/dev/null | wc -l || echo 0)
+
+ echo " Tools: $TOOL_COUNT"
+ echo " Resources: $RESOURCE_COUNT"
+ echo " Prompts: $PROMPT_COUNT"
+fi
+
+echo -e "${GREEN}โœ… Development checks complete${NC}"