mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 07:14:40 +08:00
feat: update Makefile.toml to add i18n-check and lint-staged tasks; modify pre-commit script
This commit is contained in:
@@ -6,37 +6,9 @@ if ! command -v "cargo-make" >/dev/null 2>&1; then
|
||||
cargo install --force cargo-make
|
||||
fi
|
||||
|
||||
ROOT_DIR="$(git rev-parse --show-toplevel)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
if ! command -v pnpm >/dev/null 2>&1; then
|
||||
echo "❌ pnpm is required for pre-commit checks."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOCALE_DIFF="$(git diff --cached --name-only --diff-filter=ACMR | grep -E '^src/locales/' || true)"
|
||||
if [ -n "$LOCALE_DIFF" ]; then
|
||||
echo "[pre-commit] Locale changes detected. Regenerating i18n types..."
|
||||
pnpm i18n:types
|
||||
if [ -d src/types/generated ]; then
|
||||
echo "[pre-commit] Staging regenerated i18n type artifacts..."
|
||||
git add src/types/generated
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[pre-commit] Running pnpm format before lint..."
|
||||
pnpm format
|
||||
|
||||
echo "[pre-commit] Running lint-staged for JS/TS files..."
|
||||
pnpm exec lint-staged
|
||||
|
||||
|
||||
cargo make pre-commit
|
||||
|
||||
TS_FILES="$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(ts|tsx)$' || true)"
|
||||
if [ -n "$TS_FILES" ]; then
|
||||
echo "[pre-commit] Running TypeScript type check..."
|
||||
pnpm typecheck
|
||||
fi
|
||||
|
||||
echo "[pre-commit] All checks completed successfully."
|
||||
|
||||
@@ -18,6 +18,11 @@ args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]
|
||||
|
||||
# --- Frontend ---
|
||||
|
||||
[tasks.format]
|
||||
description = "Run code formatter"
|
||||
command = "pnpm"
|
||||
args = ["format"]
|
||||
|
||||
[tasks.format-check]
|
||||
description = "Run format checks"
|
||||
command = "pnpm"
|
||||
@@ -35,44 +40,50 @@ files_modified = { input = [
|
||||
description = "Run ESLint to lint the code"
|
||||
command = "pnpm"
|
||||
args = ["lint"]
|
||||
[tasks.eslint.condition]
|
||||
files_modified = { input = [
|
||||
"./src/**/*",
|
||||
"./package.json",
|
||||
"./pnpm-lock.yaml",
|
||||
], output = [
|
||||
"./node_modules/.eslintcache",
|
||||
] }
|
||||
|
||||
[tasks.typecheck]
|
||||
description = "Run type checks"
|
||||
command = "pnpm"
|
||||
args = ["typecheck"]
|
||||
[tasks.typecheck.condition]
|
||||
files_modified = { input = [
|
||||
"./src/**/*",
|
||||
"./tsconfig.json",
|
||||
], output = [
|
||||
"./node_modules/.last_typecheck",
|
||||
] }
|
||||
|
||||
[tasks.lint-staged]
|
||||
description = "Run lint-staged for staged files"
|
||||
command = "pnpm"
|
||||
args = ["exec", "lint-staged"]
|
||||
|
||||
[tasks.i18n-check]
|
||||
description = "Check i18n consistency"
|
||||
command = "pnpm"
|
||||
args = ["i18n:types"]
|
||||
[tasks.i18n-check.condition]
|
||||
files_modified.input = ["./src/locales/**/*.ts", "./src/locales/**/*.json"]
|
||||
files_modified.output = ["./src/types/generated/*.ts"]
|
||||
|
||||
# --- Jobs ---
|
||||
[tasks.rust]
|
||||
dependencies = ["rust-format", "rust-clippy"]
|
||||
[tasks.rust.condition]
|
||||
files_modified = { input = [
|
||||
files_modified.input = [
|
||||
"./src-tauri/**/*.rs",
|
||||
"./crates/**/*.rs",
|
||||
"**/Cargo.toml",
|
||||
], output = [
|
||||
"./target/**/clash-verge",
|
||||
] }
|
||||
# TODO add frontend jobs conditions
|
||||
]
|
||||
files_modified.output = ["./target/**/clash-verge"]
|
||||
|
||||
[tasks.typescript]
|
||||
dependencies = ["format", "format-check", "eslint", "lint-staged", "typecheck"]
|
||||
[tasks.typescript.condition]
|
||||
files_modified.input = [
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"./package.json",
|
||||
"./pnpm-lock.yaml",
|
||||
"./tsconfig.json",
|
||||
]
|
||||
|
||||
[tasks.pre-push]
|
||||
description = "Pre-push checks"
|
||||
dependencies = ["rust", "format-check", "eslint", "typecheck"]
|
||||
|
||||
[tasks.pre-commit]
|
||||
dependencies = ["rust"]
|
||||
dependencies = ["rust", "typescript", "i18n-check"]
|
||||
|
||||
Reference in New Issue
Block a user