-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBakefile.sh
More file actions
119 lines (101 loc) · 3.46 KB
/
Copy pathBakefile.sh
File metadata and controls
119 lines (101 loc) · 3.46 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
# shellcheck shell=bash
init() {
local setup_private=
setup_private=$(node ./utilities/print-dev-config.mjs paths.setupPrivate 2>/dev/null || true)
if [ -z "$setup_private" ]; then
setup_private="${HOME}/.dotfiles/config/setup-private.sh"
fi
if [ -f "$setup_private" ]; then
# shellcheck disable=SC1090
source "$setup_private"
fi
}
# Ran in `bootstrap-linux.sh`.
task.bootstrap() {
git config set --local filter.npmrc.clean './lscripts/npmrc-clean.sh'
git config set --local filter.oscrc.clean './lscripts/oscrc-clean.sh'
git config set --local filter.homedir.clean './lscripts/homedir-clean.sh'
git config set --local filter.homedir.smudge './lscripts/homedir-smudge.sh'
git config set --local filter.npmrc.required true
git config set --local filter.oscrc.required true
git config set --local filter.homedir.required true
}
task.init() {
pnpm install
if [ ! -f ./.git/info/lefthook.checksum ]; then
lefthook install
fi
}
task.build() {
./lscripts/lint-scripts.py --internal-test-regex
err=0
while read -r file; do
if grep -q ' _setup ' "$file" && grep -q '^main()' "$file"; then
printf 'Should not call _setup but define main(): %s\n' "$file"
err=1
fi
done < <(find . \( -name '*.sh' -not -name 'Bakefile.sh' \) -type f)
# Should have proper ordering of functions.
local node_binary=
node_binary=$(node ./utilities/print-dev-config.mjs paths.nodeBinary)
"$node_binary" --input-type=module <<'EOF'
import { readFileSync } from 'fs'
import { glob } from 'fs/promises'
const EXPECTED_ORDER = [
'install.any',
'install.debian',
'install.ubuntu',
'install.fedora',
'install.opensuse',
'install.arch',
'installed',
'configure',
'caveats',
]
let err = 0
for await (const file of glob('**/*.sh', { exclude: (p) => p === '.data' || p === 'vendor' })) {
const lines = readFileSync(file, 'utf8').split('\n')
if (!lines.some(l => l.includes('_setup '))) continue
const order = []
for (const line of lines) {
for (const name of EXPECTED_ORDER) {
if (line.startsWith(name + '(')) order.push(name)
}
}
for (let i = 0; i < order.length; i++) {
for (let j = i + 1; j < order.length; j++) {
const pi = EXPECTED_ORDER.indexOf(order[i])
const pj = EXPECTED_ORDER.indexOf(order[j])
if (pi > pj) {
console.log(`Bad ordering in ${file}: ${order[j]}() must be before ${order[i]}()`)
err = 1
}
}
}
}
process.exit(err)
EOF
# grep '-P' not compatible with with multiple arguments using '-e'.
for pattern in "${_private_forbidden_patterns[@]}"; do
if grep -IPr --exclude 'setup-private.*' --exclude .clangd --exclude-dir .git --exclude-dir node_modules --exclude-dir .data --exclude-dir vendor --exclude-dir target --exclude-dir .jekyll-cache --exclude-dir shell.d --exclude-dir bash.d --exclude-dir zsh.d "${_private_forbidden_patterns_exclude[@]}" --color=always "$pattern" ./ | grep -Ev '(#|//|") lint-ignore' | grep -v ./config-editor/.config/kate/formatting/settings.json | grep -v pnpm-lock.yaml | grep -v pnpm-workspace.yaml; then
printf 'Expected to find no matches for: %s\n' "$pattern"
err=1
fi
done
cd "./config-unused/.config/X11/resources" || exit
printf '%s\n' "! GENERATED BY 'bake build'" >uxterm.Xresources
sed 's/XTerm/UXTerm/g' xterm.Xresources >>uxterm.Xresources
return $err
}
task.lint() {
yamllint -c ./.yamllint.yaml .
}
task.test() {
bats -p './config-shell/.config/sh'
./lscripts/lint-scripts.py
}
task.commit() {
local date=
date=$(date '+%Y-%m-%d')
git commit -m "$date" "$@"
}