build: git钩子
This commit is contained in:
2
.husky/_/applypatch-msg
Normal file
2
.husky/_/applypatch-msg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/commit-msg
Normal file
2
.husky/_/commit-msg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
22
.husky/_/h
Normal file
22
.husky/_/h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
[ "$HUSKY" = "2" ] && set -x
|
||||||
|
n=$(basename "$0")
|
||||||
|
s=$(dirname "$(dirname "$0")")/$n
|
||||||
|
|
||||||
|
[ ! -f "$s" ] && exit 0
|
||||||
|
|
||||||
|
if [ -f "$HOME/.huskyrc" ]; then
|
||||||
|
echo "husky - '~/.huskyrc' is DEPRECATED, please move your code to ~/.config/husky/init.sh"
|
||||||
|
fi
|
||||||
|
i="${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh"
|
||||||
|
[ -f "$i" ] && . "$i"
|
||||||
|
|
||||||
|
[ "${HUSKY-}" = "0" ] && exit 0
|
||||||
|
|
||||||
|
export PATH="node_modules/.bin:$PATH"
|
||||||
|
sh -e "$s" "$@"
|
||||||
|
c=$?
|
||||||
|
|
||||||
|
[ $c != 0 ] && echo "husky - $n script failed (code $c)"
|
||||||
|
[ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
|
||||||
|
exit $c
|
||||||
9
.husky/_/husky.sh
Normal file
9
.husky/_/husky.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
echo "husky - DEPRECATED
|
||||||
|
|
||||||
|
Please remove the following two lines from $0:
|
||||||
|
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
. \"\$(dirname -- \"\$0\")/_/husky.sh\"
|
||||||
|
|
||||||
|
They WILL FAIL in v10.0.0
|
||||||
|
"
|
||||||
2
.husky/_/post-applypatch
Normal file
2
.husky/_/post-applypatch
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/post-checkout
Normal file
2
.husky/_/post-checkout
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/post-commit
Normal file
2
.husky/_/post-commit
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/post-merge
Normal file
2
.husky/_/post-merge
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/post-rewrite
Normal file
2
.husky/_/post-rewrite
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/pre-applypatch
Normal file
2
.husky/_/pre-applypatch
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/pre-auto-gc
Normal file
2
.husky/_/pre-auto-gc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/pre-commit
Normal file
2
.husky/_/pre-commit
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/pre-merge-commit
Normal file
2
.husky/_/pre-merge-commit
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/pre-push
Normal file
2
.husky/_/pre-push
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/pre-rebase
Normal file
2
.husky/_/pre-rebase
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
2
.husky/_/prepare-commit-msg
Normal file
2
.husky/_/prepare-commit-msg
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname "$0")/h"
|
||||||
12
.husky/pre-push
Normal file
12
.husky/pre-push
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname -- "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
# 获取最新的 tag
|
||||||
|
TAG=$(git describe --tags --abbrev=0 2>/dev/null)
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "🏷️ 检查最新的 tag: $TAG"
|
||||||
|
node .husky/scripts/verifyTagVersion.js $TAG
|
||||||
|
else
|
||||||
|
echo "⚠️ 没有找到任何 tag,跳过版本校验"
|
||||||
|
fi
|
||||||
30
.husky/scripts/verifyTagVersion.js
Normal file
30
.husky/scripts/verifyTagVersion.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 读取 package.json 中的版本号
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
||||||
|
const packageVersion = packageJson.version;
|
||||||
|
|
||||||
|
// 获取命令行参数中的 tag 名称
|
||||||
|
const tag = process.argv[2];
|
||||||
|
|
||||||
|
if (!tag) {
|
||||||
|
console.log('⚠️ 未提供 tag 参数,跳过版本校验');
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查 tag 是否与 package.json 版本匹配
|
||||||
|
const validTags = [`v${packageVersion}`, packageVersion];
|
||||||
|
|
||||||
|
if (!validTags.includes(tag)) {
|
||||||
|
console.log('🏷️ Git tag 版本校验不通过');
|
||||||
|
console.error(`当前 package.json 版本为: ${packageVersion}`);
|
||||||
|
console.error(`提供的 tag 为: ${tag}`);
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
console.log('✅ Git tag 版本校验通过');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ 校验过程中发生错误:', error.message);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import antfu from '@antfu/eslint-config'
|
|||||||
|
|
||||||
export default antfu(
|
export default antfu(
|
||||||
{
|
{
|
||||||
ignores: ['**/node_modules', '**/build', '**/public', '**/dist', '**/package.json', '**/*.yaml', '**/.gitignore', '**/.env*', '**/tsconfig*', '**/*.config.js'],
|
ignores: ['**/node_modules', '**/build', '**/.husky', '**/public', '**/dist', '**/package.json', '**/*.yaml', '**/.gitignore', '**/.env*', '**/tsconfig*', '**/*.config.js'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
rules: {
|
rules: {
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
"test:ui": "vitest --ui",
|
"test:ui": "vitest --ui",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"lint": "eslint ./src",
|
"lint": "eslint ./src",
|
||||||
"lint:fix": "eslint ./src --fix"
|
"lint:fix": "eslint ./src --fix",
|
||||||
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tweenjs/tween.js": "^23.1.2",
|
"@tweenjs/tween.js": "^23.1.2",
|
||||||
@@ -68,6 +69,7 @@
|
|||||||
"@vue/tsconfig": "^0.8.1",
|
"@vue/tsconfig": "^0.8.1",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"baseline-browser-mapping": "^2.8.32",
|
"baseline-browser-mapping": "^2.8.32",
|
||||||
|
"child_process": "^1.0.2",
|
||||||
"daisyui": "^5.1.13",
|
"daisyui": "^5.1.13",
|
||||||
"eslint": "^9.15.0",
|
"eslint": "^9.15.0",
|
||||||
"eslint-plugin-vue": "^10.4.0",
|
"eslint-plugin-vue": "^10.4.0",
|
||||||
|
|||||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@@ -156,6 +156,9 @@ importers:
|
|||||||
baseline-browser-mapping:
|
baseline-browser-mapping:
|
||||||
specifier: ^2.8.32
|
specifier: ^2.8.32
|
||||||
version: 2.8.32
|
version: 2.8.32
|
||||||
|
child_process:
|
||||||
|
specifier: ^1.0.2
|
||||||
|
version: 1.0.2
|
||||||
daisyui:
|
daisyui:
|
||||||
specifier: ^5.1.13
|
specifier: ^5.1.13
|
||||||
version: 5.1.13
|
version: 5.1.13
|
||||||
@@ -2554,6 +2557,9 @@ packages:
|
|||||||
character-entities@2.0.2:
|
character-entities@2.0.2:
|
||||||
resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
|
resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
|
||||||
|
|
||||||
|
child_process@1.0.2:
|
||||||
|
resolution: {integrity: sha512-Wmza/JzL0SiWz7kl6MhIKT5ceIlnFPJX+lwUGj7Clhy5MMldsSoJR0+uvRzOS5Kv45Mq7t1PoE8TsOA9bzvb6g==}
|
||||||
|
|
||||||
chokidar@4.0.1:
|
chokidar@4.0.1:
|
||||||
resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==}
|
resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==}
|
||||||
engines: {node: '>= 14.16.0'}
|
engines: {node: '>= 14.16.0'}
|
||||||
@@ -8235,6 +8241,8 @@ snapshots:
|
|||||||
|
|
||||||
character-entities@2.0.2: {}
|
character-entities@2.0.2: {}
|
||||||
|
|
||||||
|
child_process@1.0.2: {}
|
||||||
|
|
||||||
chokidar@4.0.1:
|
chokidar@4.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
readdirp: 4.0.2
|
readdirp: 4.0.2
|
||||||
|
|||||||
Reference in New Issue
Block a user