Skip to content

Commit

Permalink
chore: precommit hook and deps update
Browse files Browse the repository at this point in the history
  • Loading branch information
gyurielf committed Dec 7, 2024
1 parent f674fe3 commit b6069ec
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 63 deletions.
39 changes: 33 additions & 6 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
set -e

echo_color() {
color="$1"
shift
printf "\033[${color}m%s\033[0m\n" "$*"
}

echo_color "33" "Starting pre-commit checks."

# Check current branch
currentBranch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$currentBranch" = "main" ]; then
echo_color "31" "Error: You can't commit directly to the main branch"
exit 1
fi

# Check if node_modules directory is empty or doesn't exist
if [ ! -d "node_modules" ] || [ -z "$(ls -A node_modules)" ]; then
echo_color "33" "node_modules is empty or doesn't exist. Running pnpm install --frozen-lockfile..."
if ! pnpm install --frozen-lockfile; then
echo_color "31" "Error: pnpm install --frozen-lockfile failed. Aborting commit."
exit 1
fi
else
echo_color "32" "node_modules exists and is not empty. Skipping pnpm install --frozen-lockfile."
fi

echo_color "36" "Running lint command..."

# if [ "$currentBranch" = "main" ]; then
# echo "You can't commit directly to main branch"
# exit 1
# fi
# Corrected command chain with proper error handling
if ! (pnpm run package && pnpm install && pnpm lint); then
echo_color "31" "Error: Linting or package tasks failed. Please fix the issues and try committing again."
exit 1
fi

# pnpm install ; pnpm run package ; pnpm install ; pnpm lint
echo_color "32" "Pre-commit checks passed. Proceeding with commit."
2 changes: 1 addition & 1 deletion apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"svelte-tel-input": "workspace:*",
"svelte": "^5.7.1"
"svelte": "^5.8.1"
},
"devDependencies": {
"@macfja/svelte-persistent-store": "^2.4.2",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"lint:fix": "pnpm run eslint:fix && pnpm run prettier:fix",
"package": "pnpm -r package",
"package:watch": "pnpm -r package:watch",
"prepare": "husky install",
"prepare": "husky",
"sync": "pnpm -r sync",
"test": "pnpm test -r --filter=./packages/*"
},
Expand All @@ -71,5 +71,5 @@
},
"type": "module",
"license": "MIT",
"packageManager": "pnpm@9.14.4"
"packageManager": "pnpm@9.15.0"
}
2 changes: 1 addition & 1 deletion packages/svelte-tel-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"micromatch": "^4.0.8",
"postcss": "^8.4.49",
"publint": "^0.2.12",
"svelte": "^5.7.1",
"svelte": "^5.8.1",
"svelte-check": "^4.1.1",
"svelte2tsx": "^0.7.30",
"tailwindcss": "^3.4.16",
Expand Down
106 changes: 53 additions & 53 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6069ec

Please sign in to comment.