Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🔨 chore: replace husky with native git hooks (#14941)

Innei67cd05934010
diff --git a/.husky/pre-commit b/.githooks/pre-commit
similarity index 51%
rename from .husky/pre-commit
rename to .githooks/pre-commit
index 67538d4f4af..f929d3039a3 100755
--- a/.husky/pre-commit
+++ b/.githooks/pre-commit
@@ -1,5 +1,13 @@
+#!/usr/bin/env sh
+set -e
+
+[ "${HUSKY-}" = "0" ] && exit 0
+
+export PATH="node_modules/.bin:$PATH"
+
BRANCH=$(git branch --show-current)
if [ "$BRANCH" = "dev" ] || [ "$BRANCH" = "main" ]; then
npm run type-check
fi
-npx --no-install lint-staged
+
+lint-staged
diff --git a/.gitignore b/.gitignore
index 798a09c7b0b..ffe4d294a4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -96,7 +96,7 @@ sitemap*.xml
robots.txt
# Git hooks
-.husky/prepare-commit-msg
+.githooks/prepare-commit-msg
# Documents and media
*.pdf
diff --git a/.prettierignore b/.prettierignore
index ecdda4cd90e..e96269b4bc6 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -8,7 +8,7 @@
.history
.temp
.env.local
-.husky
+.githooks
.npmrc
.gitkeep
venv
@@ -59,4 +59,4 @@ Dockerfile*
# misc
# add other ignore file below
-.next
\ No newline at end of file
+.next
diff --git a/docs/development/basic/contributing-guidelines.mdx b/docs/development/basic/contributing-guidelines.mdx
index 0b4c1fb3bb3..7ef4f648952 100644
--- a/docs/development/basic/contributing-guidelines.mdx
+++ b/docs/development/basic/contributing-guidelines.mdx
@@ -41,7 +41,7 @@ We utilize stylelint to standardize the style of our CSS code. In the configurat
### Style Checking
-You don't need to manually run these checks. The project is configured with husky to automatically run lint-staged when you commit code, which will check if your committed files comply with the above standards.
+You don't need to manually run these checks. The project is configured with Git hooks to automatically run lint-staged when you commit code, which will check if your committed files comply with the above standards.
## Contribution Process
diff --git a/docs/development/basic/contributing-guidelines.zh-CN.mdx b/docs/development/basic/contributing-guidelines.zh-CN.mdx
index 9ae620ee66a..b512f11bf2d 100644
--- a/docs/development/basic/contributing-guidelines.zh-CN.mdx
+++ b/docs/development/basic/contributing-guidelines.zh-CN.mdx
@@ -39,7 +39,7 @@ Prettier 负责代码格式化,以保证代码的一致性。您可以在 `.pr
### 风格检查
-你不需要手动运行这些检查,项目配置了 husky 会在您提交代码时自动运行 lint-staged 检查你提交的文件是否符合以上规范。
+你不需要手动运行这些检查,项目配置了 Git hooks 会在您提交代码时自动运行 lint-staged 检查你提交的文件是否符合以上规范。
## 贡献流程
diff --git a/package.json b/package.json
index 34b2c49b9a1..cee1ef54b2c 100644
--- a/package.json
+++ b/package.json
@@ -89,7 +89,7 @@
"lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
"lint:ts": "eslint src/ tests/ --concurrency=auto",
"lint:unused": "knip --include files,exports,types,enumMembers,duplicates",
- "prepare": "husky",
+ "prepare": "git config core.hooksPath .githooks",
"prettier": "prettier -c --write \"**/**\"",
"pull": "git pull",
"qstash": "pnpx @upstash/qstash-cli@latest dev",
@@ -509,7 +509,6 @@
"fs-extra": "^11.3.3",
"glob": "^13.0.0",
"happy-dom": "^20.3.7",
- "husky": "^9.1.7",
"import-in-the-middle": "^2.0.5",
"just-diff": "^6.0.2",
"knip": "^5.82.1",
diff --git a/scripts/vercelIgnoredBuildStep.js b/scripts/vercelIgnoredBuildStep.js
index 1d85c9c7805..dd6859c2ebc 100644
--- a/scripts/vercelIgnoredBuildStep.js
+++ b/scripts/vercelIgnoredBuildStep.js
@@ -21,7 +21,7 @@ function shouldProceedBuild() {
":!./*.md" \
":!./Dockerfile" \
":!./.github" \
- ":!./.husky" \
+ ":!./.githooks" \
":!./scripts"';
execSync(diffCommand);