pre-commit-checklist.shโข2.46 kB
#!/bin/bash
# Pre-commit checklist for MCP ADR Analysis Server
echo "๐ Pre-commit checklist for MCP ADR Analysis Server"
echo "=================================================="
# Check 1: Build
echo "1. Testing build..."
if npm run build; then
echo " โ
Build successful"
else
echo " โ Build failed"
exit 1
fi
# Check 2: Tests
echo "2. Running tests..."
if npm test; then
echo " โ
All tests passing"
else
echo " โ Tests failed"
exit 1
fi
# Check 3: Linting
echo "3. Running linter..."
if npm run lint; then
echo " โ
Linting passed"
else
echo " โ Linting failed"
exit 1
fi
# Check 4: Package validation
echo "4. Validating package..."
if npm run test:package; then
echo " โ
Package validation passed"
else
echo " โ Package validation failed"
exit 1
fi
# Check 5: Git status
echo "5. Checking git status..."
if [ -n "$(git status --porcelain)" ]; then
echo " โ ๏ธ Uncommitted changes detected:"
git status --short
else
echo " โ
Working directory clean"
fi
# Check 6: Required files
echo "6. Checking required files..."
required_files=(
"README.md"
"package.json"
"LICENSE"
".github/workflows/lint.yml"
".github/workflows/test.yml"
".github/workflows/build.yml"
".github/workflows/publish.yml"
".github/workflows/dependencies.yml"
".npmignore"
"src/index.ts"
"dist/src/index.js"
)
for file in "${required_files[@]}"; do
if [ -f "$file" ]; then
echo " โ
$file exists"
else
echo " โ $file missing"
fi
done
# Check 7: Package.json validation
echo "7. Validating package.json..."
node -e "
const pkg = require('./package.json');
const required = ['name', 'version', 'description', 'main', 'bin', 'author', 'license', 'repository'];
const missing = required.filter(field => !pkg[field]);
if (missing.length > 0) {
console.log(' โ Missing package.json fields:', missing.join(', '));
process.exit(1);
} else {
console.log(' โ
Package.json is valid');
}
"
echo ""
echo "๐ฏ Pre-commit checklist complete!"
echo ""
echo "๐ Next steps:"
echo "1. Set up NPM token in GitHub repository secrets"
echo "2. Configure GitHub Actions permissions"
echo "3. Commit and push to trigger workflows"
echo ""
echo "๐ Repository: https://github.com/tosin2013/mcp-adr-analysis-server"
echo "๐ NPM Token: https://www.npmjs.com/settings/tokens"
echo "โ๏ธ GitHub Settings: https://github.com/tosin2013/mcp-adr-analysis-server/settings"