mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-06-03 21:02:05 +08:00
117 lines
2.5 KiB
TOML
117 lines
2.5 KiB
TOML
[config]
|
|
skip_core_tasks = true
|
|
skip_git_env_info = true
|
|
skip_rust_env_info = true
|
|
skip_crate_env_info = true
|
|
|
|
# --- Backend ---
|
|
|
|
[tasks.rust-format]
|
|
description = "Run rustfmt on Rust code"
|
|
install_crate = "rustfmt"
|
|
command = "cargo"
|
|
args = ["fmt", "--", "--emit=files"]
|
|
|
|
[tasks.rust-clippy]
|
|
description = "Run cargo clippy to lint the code"
|
|
command = "cargo"
|
|
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]
|
|
|
|
# --- Frontend ---
|
|
|
|
[tasks.typecheck]
|
|
description = "Run type checks"
|
|
command = "pnpm"
|
|
args = ["typecheck"]
|
|
|
|
[tasks.typecheck.windows]
|
|
command = "pnpm.cmd"
|
|
|
|
[tasks.lint-staged]
|
|
description = "Run lint-staged for staged files"
|
|
command = "pnpm"
|
|
args = ["exec", "lint-staged"]
|
|
|
|
[tasks.lint-staged.windows]
|
|
command = "pnpm.cmd"
|
|
|
|
[tasks.i18n-format]
|
|
description = "Format i18n keys"
|
|
command = "pnpm"
|
|
args = ["i18n:format"]
|
|
|
|
[tasks.i18n-format.windows]
|
|
command = "pnpm.cmd"
|
|
|
|
[tasks.i18n-types]
|
|
description = "Generate i18n key types"
|
|
command = "pnpm"
|
|
args = ["i18n:types"]
|
|
|
|
[tasks.i18n-types.windows]
|
|
command = "pnpm.cmd"
|
|
|
|
[tasks.git-add]
|
|
description = "Add generated files back to git index"
|
|
command = "git"
|
|
args = [
|
|
"add",
|
|
"src/locales",
|
|
"crates/clash-verge-i18n/locales",
|
|
"src/types/generated",
|
|
]
|
|
|
|
# --- Jobs ---
|
|
|
|
[tasks.frontend-format]
|
|
description = "Frontend format checks"
|
|
script_runner = "@duckscript"
|
|
script = '''
|
|
# i18n related changes
|
|
has_i18n = exec git diff --cached --quiet -- src/locales crates/clash-verge-i18n/locales
|
|
if eq ${has_i18n.code} 1
|
|
cm_run_task i18n-format
|
|
cm_run_task i18n-types
|
|
cm_run_task git-add
|
|
end
|
|
|
|
# frontend related changes
|
|
has_frontend = exec git diff --cached --quiet -- "*.js" "*.jsx" "*.ts" "*.tsx" "*.json" "*.css" "*.scss" "*.html"
|
|
if eq ${has_frontend.code} 1
|
|
cm_run_task lint-staged
|
|
end
|
|
'''
|
|
|
|
# --- Git Hooks ---
|
|
|
|
[tasks.pre-commit]
|
|
description = "Pre-commit checks: format only"
|
|
script_runner = "@duckscript"
|
|
script = '''
|
|
# rust related changes
|
|
has_rust = exec git diff --cached --quiet -- "*.rs" Cargo.toml Cargo.lock
|
|
if eq ${has_rust.code} 1
|
|
cm_run_task rust-format
|
|
end
|
|
|
|
# frontend checks
|
|
cm_run_task frontend-format
|
|
'''
|
|
|
|
[tasks.pre-push]
|
|
description = "Pre-push checks: lint and typecheck"
|
|
script_runner = "@duckscript"
|
|
script = '''
|
|
# rust related changes
|
|
has_rust = exec git diff --cached --quiet -- "*.rs" Cargo.toml Cargo.lock
|
|
if eq ${has_rust.code} 1
|
|
cm_run_task rust-clippy
|
|
end
|
|
|
|
# frontend related changes
|
|
has_frontend = exec git diff --cached --quiet -- "*.js" "*.jsx" "*.ts" "*.tsx" "*.json" "*.css" "*.scss" "*.html"
|
|
if eq ${has_frontend.code} 1
|
|
cm_run_task typecheck
|
|
end
|
|
'''
|