Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Colors for output
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

echo "🚀 Running pre-commit checks..."

# Check for merge conflicts
if git diff --cached --name-only | xargs grep -E "^(<<<<<<<|=======|>>>>>>>)" 2>/dev/null; then
echo "${RED}❌ Merge conflict markers detected!${NC}"
echo "Please resolve merge conflicts before committing."
exit 1
fi

# Check for console.log statements (warning only)
CONSOLE_LOGS=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx)$' | xargs grep -n "console\.log" 2>/dev/null || true)
if [ -n "$CONSOLE_LOGS" ]; then
echo "${YELLOW}⚠️ Warning: console.log statements found:${NC}"
echo "$CONSOLE_LOGS" | while IFS= read -r line; do
echo " $line"
done
echo "${YELLOW}Consider removing console.log statements before committing.${NC}"
fi

# Check for large files (>5MB)
LARGE_FILES=$(git diff --cached --name-only | while read file; do
if [ -f "$file" ]; then
SIZE=$(wc -c < "$file" 2>/dev/null || echo 0)
if [ "$SIZE" -gt 5242880 ]; then
echo "$file ($(($SIZE / 1048576))MB)"
fi
fi
done)

if [ -n "$LARGE_FILES" ]; then
echo "${YELLOW}⚠️ Warning: Large files detected:${NC}"
echo "$LARGE_FILES"
echo "${YELLOW}Consider using Git LFS for large files.${NC}"
fi

# Run lint-staged for fast checks on staged files
echo "📝 Running lint and format checks on staged files..."
pnpm exec lint-staged

if [ $? -ne 0 ]; then
echo "${RED}❌ Pre-commit checks failed!${NC}"
echo "Please fix the issues above and try again."
exit 1
fi

echo "${GREEN}✅ Pre-commit checks passed!${NC}"
94 changes: 94 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Colors for output
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

echo "🚀 Running pre-push checks..."

# Get current branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)

# Branch naming validation (matching PR validation rules)
VALID_BRANCH_REGEX="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|release|hotfix|deps|wip)\/[a-z0-9._-]+$|^(main|develop|staging|release\/v[0-9]+\.[0-9]+\.[0-9]+|version\/[0-9]+)$"

if ! echo "$BRANCH" | grep -qE "$VALID_BRANCH_REGEX"; then
echo "${RED}❌ Invalid branch name: $BRANCH${NC}"
echo "Branch names must follow the pattern: type/description"
echo "Valid types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert, release, hotfix, deps, wip"
echo "Or be one of: main, develop, staging, release/vX.Y.Z, version/X"
exit 1
fi

# Get the remote and branch being pushed to
while read local_ref local_sha remote_ref remote_sha
do
# Check commit messages for conventional commit format
echo "${BLUE}📋 Validating commit messages...${NC}"

# Get all commits that will be pushed
if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
# New branch, check commits not in origin/develop
COMMITS=$(git rev-list origin/develop..HEAD 2>/dev/null || git rev-list HEAD)
else
# Existing branch, check new commits only
COMMITS=$(git rev-list "$remote_sha..$local_sha")
fi

INVALID_COMMITS=""
for commit in $COMMITS; do
MSG=$(git log --format=%s -n 1 "$commit")
# Check conventional commit format
if ! echo "$MSG" | grep -qE "^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .+$|^Merge |^Initial commit$"; then
INVALID_COMMITS="$INVALID_COMMITS\n - $commit: $MSG"
fi
done

if [ -n "$INVALID_COMMITS" ]; then
echo "${RED}❌ Invalid commit messages found:${NC}"
echo "$INVALID_COMMITS"
echo "${YELLOW}Commit messages must follow conventional commit format:${NC}"
echo " type(scope?): description"
echo " Valid types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
exit 1
fi
done

echo "${GREEN}✅ Branch name and commit messages are valid${NC}"

# Run comprehensive checks
echo "${BLUE}🧹 Running lint checks...${NC}"
pnpm lint
if [ $? -ne 0 ]; then
echo "${RED}❌ Linting failed!${NC}"
echo "Run 'pnpm lint:fix' to auto-fix issues"
exit 1
fi

echo "${BLUE}🔍 Running type checks...${NC}"
pnpm typecheck
if [ $? -ne 0 ]; then
echo "${RED}❌ Type checking failed!${NC}"
echo "Please fix TypeScript errors before pushing"
exit 1
fi

echo "${BLUE}🧪 Running tests...${NC}"
CI=true pnpm test
if [ $? -ne 0 ]; then
echo "${RED}❌ Tests failed!${NC}"
echo "Please fix failing tests before pushing"
exit 1
fi

echo "${BLUE}🏗️ Building project...${NC}"
pnpm build
if [ $? -ne 0 ]; then
echo "${RED}❌ Build failed!${NC}"
echo "Please fix build errors before pushing"
exit 1
fi

echo "${GREEN}✅ All pre-push checks passed!${NC}"
echo "${GREEN}🎉 Ready to push to $BRANCH${NC}"
193 changes: 193 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Dev: Start All Services",
"type": "shell",
"command": "pnpm",
"args": ["dev"],
"group": {
"kind": "none",
"isDefault": false
},
"presentation": {
"reveal": "always",
"panel": "new",
"focus": true,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": [],
"isBackground": true,
"detail": "Start all applications and packages in development mode using Turborepo"
},
{
"label": "Build: Entire Monorepo",
"type": "shell",
"command": "pnpm",
"args": ["build"],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": true
},
"problemMatcher": ["$tsc"],
"detail": "Build all packages and applications in dependency order"
},
{
"label": "Test: Run All Tests",
"type": "shell",
"command": "pnpm",
"args": ["test"],
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": true
},
"problemMatcher": [],
"detail": "Run all tests across the entire monorepo using Vitest"
},
{
"label": "Code Check: Full Validation",
"dependsOrder": "sequence",
"dependsOn": ["Code Check: Lint", "Code Check: Format", "Code Check: Type Check"],
"group": {
"kind": "none",
"isDefault": false
},
"presentation": {
"reveal": "always",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": [],
"detail": "Run linting, formatting, and type checking across the entire codebase"
},
{
"label": "Code Check: Lint",
"type": "shell",
"command": "pnpm",
"args": ["lint"],
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": [],
"detail": "Run Biome linter"
},
{
"label": "Code Check: Format",
"type": "shell",
"command": "pnpm",
"args": ["format"],
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": [],
"detail": "Format code using Biome"
},
{
"label": "Code Check: Type Check",
"type": "shell",
"command": "pnpm",
"args": ["typecheck"],
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": ["$tsc"],
"detail": "Run TypeScript type checking"
},
{
"label": "Code Check: Full Validation + Autofix",
"dependsOrder": "sequence",
"dependsOn": [
"Code Check: Lint Autofix",
"Code Check: Format Autofix",
"Code Check: Type Check"
],
"group": {
"kind": "none",
"isDefault": false
},
"presentation": {
"reveal": "always",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": [],
"detail": "Run linting, formatting with autofix, and type checking across the entire codebase"
},
{
"label": "Code Check: Lint Autofix",
"type": "shell",
"command": "pnpm",
"args": ["lint:fix"],
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": [],
"detail": "Run Biome linter with autofix"
},
{
"label": "Code Check: Format Autofix",
"type": "shell",
"command": "pnpm",
"args": ["format:fix"],
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "shared",
"focus": false,
"echo": true,
"showReuseMessage": false,
"clear": false
},
"problemMatcher": [],
"detail": "Format code using Biome with autofix"
}
]
}
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aicd",
"version": "0.2.1",
"private": true,
"private": false,
"description": "AI-powered continuous deployment platform",
"author": "zopio",
"license": "MIT",
Expand Down Expand Up @@ -33,10 +33,17 @@
"check": "biome check .",
"prepare": "husky install"
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
"biome check --write --no-errors-on-unmatched --files-ignore-unknown=true"
],
"**/*.{js,jsx,ts,tsx}": ["bash -c 'tsc --noEmit --skipLibCheck'"]
},
"devDependencies": {
"@biomejs/biome": "^1.5.0",
"@types/node": "^20.11.0",
"husky": "^9.0.0",
"lint-staged": "^16.1.2",
"tsup": "^8.0.0",
"turbo": "^1.12.0",
"typescript": "^5.3.0",
Expand Down
Loading