diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-01-16 08:30:14 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-01-16 08:30:14 +0900 |
| commit | 3fbb9a18372f2b6a675dd6c039ba52be76f3eeb4 (patch) | |
| tree | aa694a36cdd323a7853672ee7a2ba60409ac3b06 /mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh | |
updates
Diffstat (limited to 'mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh')
| -rwxr-xr-x | mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh b/mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh new file mode 100755 index 0000000..a72ff45 --- /dev/null +++ b/mcp-servers/simple-mcp-server/.claude/hooks/pre-build.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +# Pre-Build Hook for Simple MCP Server +# Runs before building for production + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +echo -e "${BLUE}๐จ Pre-Build Hook${NC}" +echo "======================================" + +# Check for uncommitted changes +if git diff --quiet && git diff --staged --quiet; then + echo -e "${GREEN}โ Working directory clean${NC}" +else + echo -e "${YELLOW}โ Warning: Uncommitted changes detected${NC}" + git status --short +fi + +# Lint check +echo -e "\n${YELLOW}๐ Running lint check...${NC}" +if npx eslint src --ext .ts 2>/dev/null; then + echo -e "${GREEN} โ Linting passed${NC}" +else + echo -e "${RED} โ Linting failed${NC}" + echo " Run 'npm run lint:fix' to fix issues" + exit 1 +fi + +# Type validation +echo -e "\n${YELLOW}๐ Running type check...${NC}" +if npx tsc --noEmit; then + echo -e "${GREEN} โ Type checking passed${NC}" +else + echo -e "${RED} โ Type checking failed${NC}" + exit 1 +fi + +# Test suite +echo -e "\n${YELLOW}๐งช Running tests...${NC}" +if npm test 2>/dev/null; then + echo -e "${GREEN} โ All tests passed${NC}" +else + echo -e "${RED} โ Tests failed${NC}" + exit 1 +fi + +# Dependency audit +echo -e "\n${YELLOW}๐ Checking dependencies...${NC}" +AUDIT_RESULT=$(npm audit --production 2>&1) +if echo "$AUDIT_RESULT" | grep -q "found 0 vulnerabilities"; then + echo -e "${GREEN} โ No vulnerabilities found${NC}" +else + echo -e "${YELLOW} โ Security vulnerabilities detected${NC}" + echo " Run 'npm audit fix' to resolve" +fi + +# Version validation +echo -e "\n${YELLOW}๐ท๏ธ Checking version...${NC}" +PACKAGE_VERSION=$(node -p "require('./package.json').version") +echo " Current version: $PACKAGE_VERSION" + +# Check if version tag exists +if git rev-parse "v$PACKAGE_VERSION" >/dev/null 2>&1; then + echo -e "${GREEN} โ Version tag exists${NC}" +else + echo -e "${YELLOW} โ Version tag v$PACKAGE_VERSION not found${NC}" + echo " Create with: git tag v$PACKAGE_VERSION" +fi + +# Check package.json required fields +echo -e "\n${YELLOW}๐ฆ Validating package.json...${NC}" +NAME=$(node -p "require('./package.json').name" 2>/dev/null) +DESCRIPTION=$(node -p "require('./package.json').description" 2>/dev/null) +MAIN=$(node -p "require('./package.json').main" 2>/dev/null) + +if [ -z "$NAME" ]; then + echo -e "${RED} โ Missing 'name' field${NC}" + exit 1 +fi + +if [ -z "$DESCRIPTION" ]; then + echo -e "${YELLOW} โ Missing 'description' field${NC}" +fi + +if [ -z "$MAIN" ]; then + echo -e "${YELLOW} โ Missing 'main' field${NC}" +fi + +echo -e "${GREEN} โ Package metadata valid${NC}" + +# MCP specific checks +echo -e "\n${YELLOW}๐ Checking MCP implementation...${NC}" + +# Check for required MCP files +if [ -f "src/index.ts" ]; then + echo -e "${GREEN} โ Entry point exists${NC}" +else + echo -e "${RED} โ Missing src/index.ts${NC}" + exit 1 +fi + +# Count capabilities +TOOL_COUNT=0 +RESOURCE_COUNT=0 +PROMPT_COUNT=0 + +if [ -d "src/tools" ]; then + TOOL_COUNT=$(find src/tools -name "*.ts" -not -name "index.ts" | wc -l) +fi + +if [ -d "src/resources" ]; then + RESOURCE_COUNT=$(find src/resources -name "*.ts" -not -name "index.ts" | wc -l) +fi + +if [ -d "src/prompts" ]; then + PROMPT_COUNT=$(find src/prompts -name "*.ts" -not -name "index.ts" | wc -l) +fi + +echo " Capabilities:" +echo " - Tools: $TOOL_COUNT" +echo " - Resources: $RESOURCE_COUNT" +echo " - Prompts: $PROMPT_COUNT" + +if [ $TOOL_COUNT -eq 0 ] && [ $RESOURCE_COUNT -eq 0 ] && [ $PROMPT_COUNT -eq 0 ]; then + echo -e "${YELLOW} โ No MCP capabilities implemented${NC}" +fi + +# Final summary +echo "" +echo "======================================" +echo -e "${GREEN}โ
Pre-build checks complete${NC}" +echo "Ready to build for production!" +echo "" +echo "Next steps:" +echo " 1. npm run build" +echo " 2. npm test" +echo " 3. npm publish (if deploying to npm)" |
