repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
quickshell/nuguland/justfile
Rawdefault:
@just --list
# lint/typecheck/verify all Nuguland source; zero warnings
lint:
#!/usr/bin/env bash
set -euo pipefail
tmp=$(mktemp -d)
qs_pid=""
cleanup() {
[[ -z "$qs_pid" ]] || kill "$qs_pid" 2>/dev/null || true
rm -rf "$tmp"
}
trap cleanup EXIT
mapfile -t qml < <(find . -maxdepth 1 -name '*.qml' -print | sort)
mapfile -t sh < <(find . -maxdepth 1 -name '*.sh' -print | sort)
mapfile -t mjs < <(find . -name '*.mjs' -print | sort)
mapfile -t frag < <(find shaders -name '*.frag' -print 2>/dev/null | sort)
for file in "${qml[@]}"; do
/usr/lib/qt6/bin/qmllint --max-warnings 0 -I /usr/lib/qt6/qml "$file" || { echo "qmllint failed: $file" >&2; exit 1; }
done
((${#sh[@]} == 0)) || shellcheck "${sh[@]}"
for file in "${mjs[@]}"; do
node --check "$file"
done
((${#frag[@]} == 0)) || glslangValidator "${frag[@]}"
for file in "${qml[@]}"; do
out="$tmp/${file#./}"
/usr/lib/qt6/bin/qmlformat "$file" > "$out" || { echo "qmlformat failed: $file" >&2; exit 1; }
cmp -s "$file" "$out" || { echo "qmlformat changed: $file" >&2; diff -u "$file" "$out"; exit 1; }
done
for file in "${sh[@]}"; do
out="$tmp/${file#./}"
shfmt "$file" > "$out"
cmp -s "$file" "$out" || { diff -u "$file" "$out"; exit 1; }
done
shopt -s nullglob
for shader in shaders/*.frag; do
out="$tmp/${shader//\//__}.qsb"
/usr/lib/qt6/bin/qsb --glsl 330 --hlsl 50 --msl 12 -o "$out" "$shader"
cmp -s "$shader.qsb" "$out" || { echo "stale shader blob: $shader.qsb" >&2; exit 1; }
done
for blob in shaders/*.qsb; do
[[ -f "${blob%.qsb}" ]] || { echo "orphan shader blob: $blob" >&2; exit 1; }
done
if qs ipc -c nuguland call nuguland ping >/tmp/nuguland-lint.qs.out 2>/tmp/nuguland-lint.qs.err; then
: > /tmp/nuguland-lint.qs.err
else
QT_NO_XDG_DESKTOP_PORTAL=1 qs -p shell.qml >/tmp/nuguland-lint.qs.out 2>/tmp/nuguland-lint.qs.err &
qs_pid=$!
sleep 3
kill -0 "$qs_pid"
fi
if grep -E "WARN|ERROR|Error parsing|deprecated|Could not|failed" /tmp/nuguland-lint.qs.out /tmp/nuguland-lint.qs.err; then
echo "runtime warnings during lint" >&2
exit 1
fi
# run JS tests; pass a file, basename, or stem for one test
# examples: just test, just test network, just test network.test.js
test name="":
#!/usr/bin/env bash
set -euo pipefail
target={{quote(name)}}
if [[ -n "$target" ]]; then
case "$target" in
/*|*..*|*$'\n'*|*$'\r'*) echo "unsafe test: $target" >&2; exit 2 ;;
esac
if [[ "$target" != *.js && "$target" != *.mjs ]]; then
if [[ -f "$target.test.js" ]]; then
target="$target.test.js"
elif [[ -f "$target.test.mjs" ]]; then
target="$target.test.mjs"
else
target="$target.test.js"
fi
fi
[[ -f "$target" ]] || { echo "missing test: $target" >&2; exit 2; }
node "$target"
exit
fi
mapfile -t tests < <(find . -maxdepth 1 \( -name '*.test.js' -o -name '*.test.mjs' \) -print | sort)
((${#tests[@]} > 0)) || { echo "no tests" >&2; exit 1; }
for file in "${tests[@]}"; do
node "$file"
done
# format Nuguland QML and shell scripts in place
fmt:
#!/usr/bin/env bash
set -euo pipefail
mapfile -t qml < <(find . -maxdepth 1 -name '*.qml' -print | sort)
mapfile -t sh < <(find . -maxdepth 1 -name '*.sh' -print | sort)
for file in "${qml[@]}"; do
/usr/lib/qt6/bin/qmlformat -i "$file" || { echo "qmlformat failed: $file" >&2; exit 1; }
done
((${#sh[@]} == 0)) || shfmt -w "${sh[@]}"
# compile checked-in shaders
build:
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob
for shader in shaders/*.frag; do
/usr/lib/qt6/bin/qsb --glsl 330 --hlsl 50 --msl 12 -o "$shader.qsb" "$shader"
done