-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhk.pkl
More file actions
116 lines (107 loc) · 3.87 KB
/
Copy pathhk.pkl
File metadata and controls
116 lines (107 loc) · 3.87 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
amends "package://github.com/jdx/hk/releases/download/v1.53.0/hk@1.53.0#/Config.pkl"
import "package://github.com/jdx/hk/releases/download/v1.53.0/hk@1.53.0#/Builtins.pkl"
local bash: String = "bash -c"
// No `shell` override: these builtins are `hk util` subcommands, so they need
// no shell, and the structured form is what lets hk auto-batch `{{files}}`.
// Under a shell hk sizes batches from ARG_MAX (128KB fallback on Windows), so
// a whole-repo run renders one ~15KB command that Windows rejects with "The
// command line is too long."
local sharedGuards = new Mapping<String, Step> {
["check-merge-conflict"] = (Builtins.check_merge_conflict) {}
["detect-private-key"] = (Builtins.detect_private_key) {}
["check-added-large-files"] = (Builtins.check_added_large_files) {
exclude = List(
"pnpm-lock.yaml",
"src/typegen.d.ts",
"src/oxlint/typegen.d.ts",
"test/__snapshots__/eslint-snapshot.spec.ts.snap",
"test/__snapshots__/oxlint.spec.ts.snap",
)
}
}
// `isentinel-lint` shims to `dist/lint-cli.mjs`, so the bin does not exist
// until something builds it — a fresh clone would otherwise fail the lint step.
// Skips `nr gen`: the typegen files it writes are tracked, so they are already
// present, and regenerating them here would rewrite tracked files mid-commit.
// `tsdown.config.ts` sets `clean: true`, so `dist` is emptied at build start
// and is briefly absent — the lint step's `depends` is what keeps that window
// from being observable, not the omitted `--clean` flag.
local build = new Step {
check = "pnpm exec tsdown"
shell = bash
}
// The hybrid CLI sequences oxlint then ESLint itself, dropping the
// oxlint-covered rules from the ESLint pass, so a separate oxlint step would
// only double-lint. GIT_HOOK pins hook runs to the no-agent cache variant.
// `depends` is load-bearing: hk runs steps concurrently by default, so without
// it the build could still be writing `dist` as this step loads it.
local lint = new Step {
glob = List("*.ts", "*.tsx", "*.js", "*.mjs", "*.cjs", "*.json", "*.jsonc", "*.md", "*.toml", "*.yaml", "*.yml")
depends = List("build")
check = "isentinel-lint {{files}}"
fix = "isentinel-lint --fix {{files}}"
shell = bash
env = new Mapping<String, String> { ["GIT_HOOK"] = "1" }
}
local typecheck = new Step {
glob = List("*.ts", "*.tsx")
check = "tsc --noEmit"
shell = bash
}
// Runs `vitest` directly rather than the `test` script, which prefixes `nr
// gen` and would rewrite tracked typegen files mid-commit.
local test = new Step {
glob = List("*.ts", "*.tsx")
check = "pnpm exec vitest run"
shell = bash
}
local renovateConfig = new Step {
glob = List("renovate.json")
check = "pnpm dlx --package renovate renovate-config-validator --strict"
shell = bash
}
hooks {
["pre-commit"] {
fix = true
stash = "none"
steps {
...sharedGuards
["renovate-config"] = renovateConfig
["build"] = build
["lint"] = lint
["typecheck"] = typecheck
["test"] = test
}
}
["pre-push"] {
steps {
...sharedGuards
["build"] = build
["lint"] = lint
["typecheck"] = typecheck
}
}
["post-merge"] {
steps {
["install-deps"] {
glob = List("pnpm-lock.yaml")
check = "pnpm install"
shell = bash
}
["mise-install"] {
glob = List("mise.toml")
check = "mise install"
shell = bash
}
}
}
["check"] {
steps {
...sharedGuards
["renovate-config"] = renovateConfig
["build"] = build
["lint"] = lint
["typecheck"] = typecheck
}
}
}