make fmt and make fmt-check cover Markdown with prettier (closes #39)
check / check (push) Successful in 2m37s

make fmt and make fmt-check now cover the Markdown files with prettier as well as the Go source: prettier 3.8.1 pinned in package.json and yarn.lock, four-space indents and proseWrap always in .prettierrc, all three copied unchanged from the sneak/prompts templates. script/bootstrap adds pinned node (through nvm from a hash-checked archive when none is installed), yarn and prettier after the pinned Go. README.md is reformatted by make fmt and its Entrypoints section says what each step needs.

Model: opus-5-5
This commit was merged in pull request #45.
This commit is contained in:
2026-10-04 05:42:46 +02:00
parent 7280ee35f4
commit 1ddc2c747a
7 changed files with 194 additions and 65 deletions
+66 -4
View File
@@ -4,10 +4,13 @@
# are already there are left alone. Base tooling comes from nix, apt,
# brew, or apk, detected in that order, and nothing is assumed to be
# present. Go is installed at the version the Dockerfile's Go image
# carries, from the official release archive, into ~/.local/go. The
# linter is not installed here: linting and testing run only as phases
# of the Dockerfile, so Docker is what is needed for them, and that is
# checked for rather than installed.
# carries, from the official release archive, into ~/.local/go. Node is
# used directly if installed; otherwise it is installed at a pinned
# version via nvm (installing nvm itself first, from a hash-verified
# release archive, never curl | sh). The linter is not installed here:
# linting and testing run only as phases of the Dockerfile, so Docker is
# what is needed for them, and that is checked for rather than
# installed.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
@@ -22,6 +25,13 @@ GO_VERSION="1.26.8"
GO_DIR="$HOME/.local/go"
PATH="$GO_DIR/bin:$PATH"
# Pinned versions, 2026-07-06
NODE_VERSION="22.17.0"
NVM_VERSION="0.40.3"
# sha256 of https://github.com/nvm-sh/nvm/archive/refs/tags/v0.40.3.tar.gz
NVM_SHA256="5f4d6aaa04a177dc93c985e31dbc411ab6b8c6e1e21d8015dbc1372625fcd1d0"
YARN_VERSION="1.22.22"
PKGMGR=""
SUDO=""
@@ -126,6 +136,54 @@ install_go() {
rm -rf "$tmp"
}
# nvm is a bash script; run a command in a bash with nvm loaded
nvm_sh() {
bash -c ". \"\$HOME/.nvm/nvm.sh\" && $*"
}
ensure_nvm() {
[ -s "$HOME/.nvm/nvm.sh" ] && return 0
# nvm prerequisites; nvm itself requires bash
if missing bash; then pkg_install bash bash bash bash; fi
if missing curl; then pkg_install curl curl curl curl; fi
if missing git; then pkg_install git git git git; fi
tmp="$(mktemp -d)"
curl -fsSL -o "$tmp/nvm.tar.gz" \
"https://github.com/nvm-sh/nvm/archive/refs/tags/v${NVM_VERSION}.tar.gz"
verify_sha256 "$tmp/nvm.tar.gz" "$NVM_SHA256"
mkdir -p "$HOME/.nvm"
tar -xzf "$tmp/nvm.tar.gz" -C "$HOME/.nvm" --strip-components=1
rm -rf "$tmp"
}
ensure_node() {
if ! missing node; then return 0; fi
ensure_nvm
nvm_sh "nvm install $NODE_VERSION"
}
ensure_yarn() {
if ! missing yarn; then return 0; fi
if ! missing corepack; then
corepack enable
corepack prepare "yarn@$YARN_VERSION" --activate
elif [ -s "$HOME/.nvm/nvm.sh" ]; then
nvm_sh "nvm use $NODE_VERSION >/dev/null && corepack enable && \
corepack prepare yarn@$YARN_VERSION --activate"
else
npm install -g "yarn@$YARN_VERSION"
fi
}
install_js_deps() {
if missing yarn && [ -s "$HOME/.nvm/nvm.sh" ]; then
nvm_sh "nvm use $NODE_VERSION >/dev/null && cd \"$ROOT\" && \
yarn install --frozen-lockfile"
else
yarn install --frozen-lockfile
fi
}
main() {
cd "$ROOT"
@@ -144,6 +202,10 @@ main() {
go mod download
ensure_node
ensure_yarn
install_js_deps
if missing docker; then
echo "bootstrap: docker is not installed; make lint and make test need it" >&2
fi
+22 -1
View File
@@ -1,5 +1,6 @@
#!/bin/sh
# script/fmt: format all files (writes).
# script/fmt: format all files (writes): the Go source with go fmt, then
# the Markdown files with prettier.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
@@ -7,9 +8,29 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
# Where script/bootstrap installs Go; it cannot put it on our PATH.
PATH="$HOME/.local/go/bin:$PATH"
# Must match the pin in script/bootstrap.
NODE_VERSION="22.17.0"
# script/bootstrap installs node and yarn under nvm and leaves neither
# on the PATH of the shell that called it, so resolve the pinned
# toolchain here the way bootstrap's own install step does. nvm is a
# bash script, hence the subshell.
run_yarn() {
if command -v yarn >/dev/null 2>&1; then
exec yarn "$@"
fi
if [ ! -s "$HOME/.nvm/nvm.sh" ]; then
echo "fmt: no yarn; run script/bootstrap first" >&2
exit 1
fi
exec bash -c '. "$HOME/.nvm/nvm.sh" && nvm use "$1" >/dev/null &&
shift && exec yarn "$@"' bash "$NODE_VERSION" "$@"
}
main() {
cd "$ROOT"
go fmt ./...
run_yarn run prettier --write '**/*.md' --tab-width 4 --prose-wrap always
}
main "$@"
+20
View File
@@ -8,6 +8,25 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
# Where script/bootstrap installs Go; it cannot put it on our PATH.
PATH="$HOME/.local/go/bin:$PATH"
# Must match the pin in script/bootstrap.
NODE_VERSION="22.17.0"
# script/bootstrap installs node and yarn under nvm and leaves neither
# on the PATH of the shell that called it, so resolve the pinned
# toolchain here the way bootstrap's own install step does. nvm is a
# bash script, hence the subshell.
run_yarn() {
if command -v yarn >/dev/null 2>&1; then
exec yarn "$@"
fi
if [ ! -s "$HOME/.nvm/nvm.sh" ]; then
echo "fmt-check: no yarn; run script/bootstrap first" >&2
exit 1
fi
exec bash -c '. "$HOME/.nvm/nvm.sh" && nvm use "$1" >/dev/null &&
shift && exec yarn "$@"' bash "$NODE_VERSION" "$@"
}
main() {
cd "$ROOT"
if [ -n "$(gofmt -l .)" ]; then
@@ -15,6 +34,7 @@ main() {
gofmt -l .
exit 1
fi
run_yarn run prettier --check '**/*.md' --tab-width 4 --prose-wrap always
}
main "$@"