lmjtfy.git / tools / check-versions.sh
1#!/usr/bin/env bash

Fail if a version written outside mise.toml differs from the one in it. mise.toml is the one place versions live; these are the few other files that cannot read it and so repeat one.

tools/check-versions.sh

Needs only POSIX tools: it reads mise.toml's key = "value" lines, not a TOML parser.

8set -euo pipefail
9cd "$(dirname "$0")/.."
10fail=0
11bad() { echo "check-versions: $*" >&2; fail=1; }
12tool() { grep -m1 -E "^\"?$1\"? *= *\"" mise.toml | sed -E 's/^[^=]*= *"([^"]*)".*/\1/'; }
14wb="$(tool 'cargo:wasm-bindgen-cli')"
15[ -n "$wb" ] || bad "mise.toml has no cargo:wasm-bindgen-cli"
16pin="$(grep -m1 -E '^wasm-bindgen *= *"=' Cargo.toml | sed -E 's/.*"=([^"]*)".*/\1/')"
17[ "$pin" = "$wb" ] || bad "Cargo.toml pins wasm-bindgen $pin, mise.toml installs the CLI $wb"
18
19hk="$(tool hk)"
20grep -q "hk@$hk#" hk.pkl || bad "hk.pkl does not reference hk $hk (the release mise.toml installs)"

Nothing may pin a tool version in the flake: it only wraps mise.

23if grep -vE '^[[:space:]]*#' flake.nix | grep -nE 'fenix|rust\.stable|pkgs\.(wasm-bindgen-cli|worker-build|binaryen|esbuild|nodejs|rustc|cargo)' >&2; then
24  bad "flake.nix provides a toolchain; the toolchain is mise.toml's"
25fi
26[ "$fail" = 0 ] && echo "check-versions: ok"
27exit "$fail"