forked from clash-verge-rev/clash-verge-rev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.toml
More file actions
122 lines (100 loc) · 2.7 KB
/
Copy pathMakefile.toml
File metadata and controls
122 lines (100 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
[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 = '''
has_upstream = exec git rev-parse --abbrev-ref --symbolic-full-name @{u}
if not eq ${has_upstream.code} 0
echo "No upstream found, skipping diff-based checks"
exit 0
end
# rust related changes
has_rust = exec git diff @{u}..HEAD --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 @{u}..HEAD --quiet -- "*.js" "*.jsx" "*.ts" "*.tsx" "*.json" "*.css" "*.scss" "*.html"
if eq ${has_frontend.code} 1
cm_run_task typecheck
end
'''