blob: 1d2b5fcb3b4f6bc95c1dc4398e64a1c8e01713f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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}"
|