refactor: move toolchain logic into scripts/
Assisted-by: Delta:zai-glm-5.3
This commit is contained in:
5 files changed
+85
-34
No files matched your search
+6
-1
@@ -1,5 +1,10 @@
|
||||
# Generated site and pinned toolchain
|
||||
public/
|
||||
tools/
|
||||
|
||||
# Calepin build artifacts
|
||||
.calepin/
|
||||
**/.calepin/
|
||||
.calepin-entry.*
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
@@ -1,41 +1,23 @@
|
||||
calepin-version := "0.0.61"
|
||||
typst-version := "0.15.1"
|
||||
|
||||
# Print available recipes
|
||||
# Show the available recipes
|
||||
default:
|
||||
@just --list
|
||||
@just --list
|
||||
|
||||
# Download and verify the pinned toolchain
|
||||
# Bootstrap the pinned calepin + typst binaries into tools/
|
||||
tools:
|
||||
mkdir -p tools
|
||||
cd tools && \
|
||||
if [ ! -f calepin ]; then \
|
||||
curl -sL "https://github.com/vincentarelbundock/calepin/releases/download/v{{calepin-version}}/calepin-x86_64-unknown-linux-gnu.tar.xz" -o calepin-x86_64-unknown-linux-gnu.tar.xz; \
|
||||
curl -sL "https://github.com/vincentarelbundock/calepin/releases/download/v{{calepin-version}}/calepin-x86_64-unknown-linux-gnu.tar.xz.sha256" -o calepin-x86_64-unknown-linux-gnu.tar.xz.sha256; \
|
||||
sha256sum -c calepin-x86_64-unknown-linux-gnu.tar.xz.sha256; \
|
||||
tar -xf calepin-x86_64-unknown-linux-gnu.tar.xz --strip-components=1 calepin-x86_64-unknown-linux-gnu/calepin; \
|
||||
rm calepin-x86_64-unknown-linux-gnu.tar.xz calepin-x86_64-unknown-linux-gnu.tar.xz.sha256; \
|
||||
fi
|
||||
cd tools && \
|
||||
if [ ! -f typst ]; then \
|
||||
curl -sL "https://github.com/typst/typst/releases/download/v{{typst-version}}/typst-x86_64-unknown-linux-musl.tar.xz" -o typst.tar.xz; \
|
||||
tar -xf typst.tar.xz --strip-components=1 typst-x86_64-unknown-linux-musl/typst; \
|
||||
rm typst.tar.xz; \
|
||||
fi
|
||||
./scripts/bootstrap.sh
|
||||
|
||||
# Build the site
|
||||
build:
|
||||
PATH="$PWD/tools:$PATH" calepin compile site public
|
||||
# Compile the site into public/
|
||||
build: tools
|
||||
./scripts/calepin.sh compile site public
|
||||
|
||||
# Preview the site locally
|
||||
preview:
|
||||
PATH="$PWD/tools:$PATH" calepin serve public
|
||||
# Build, then serve the site locally
|
||||
preview: build
|
||||
./scripts/calepin.sh serve public
|
||||
|
||||
# Watch for changes and preview
|
||||
watch:
|
||||
PATH="$PWD/tools:$PATH" calepin watch site public --serve
|
||||
# Rebuild on change and serve the result
|
||||
watch: tools
|
||||
./scripts/calepin.sh watch site public --serve
|
||||
|
||||
# Clean the output directory
|
||||
# Remove generated output and build caches
|
||||
clean:
|
||||
rm -rf public
|
||||
|
||||
./scripts/clean.sh
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bootstrap the pinned toolchain (Calepin + Typst) into tools/.
|
||||
# Idempotent: skips downloads when the binaries are already in place.
|
||||
set -euo pipefail
|
||||
|
||||
# Pinned toolchain -- bump both binaries together and re-verify checksums.
|
||||
calepin_version="0.0.61"
|
||||
typst_version="0.15.1"
|
||||
# Typst publishes no .sha256 assets; this digest comes from the official
|
||||
# release metadata (GitHub asset digest of typst-x86_64-unknown-linux-musl.tar.xz).
|
||||
typst_sha256="a6d077d0a95eed5a2eba715b2dae06be954f624ccbf85758a03f389ded33118c"
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
tools="$root/tools"
|
||||
|
||||
if [ "$(uname -m)" != "x86_64" ]; then
|
||||
echo "error: unsupported architecture $(uname -m), pinned binaries are x86_64" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$tools"
|
||||
|
||||
if [ ! -x "$tools/calepin" ]; then
|
||||
name="calepin-x86_64-unknown-linux-gnu.tar.xz"
|
||||
base="https://github.com/vincentarelbundock/calepin/releases/download/v$calepin_version"
|
||||
curl -fsSLo "$tools/$name" "$base/$name"
|
||||
curl -fsSLo "$tools/$name.sha256" "$base/$name.sha256"
|
||||
(cd "$tools" && sha256sum -c "$name.sha256")
|
||||
tar -xJf "$tools/$name" -C "$tools" --strip-components=1 "calepin-x86_64-unknown-linux-gnu/calepin"
|
||||
rm "$tools/$name" "$tools/$name.sha256"
|
||||
fi
|
||||
|
||||
if [ ! -x "$tools/typst" ]; then
|
||||
name="typst-x86_64-unknown-linux-musl.tar.xz"
|
||||
curl -fsSLo "$tools/$name" "https://github.com/typst/typst/releases/download/v$typst_version/$name"
|
||||
echo "$typst_sha256 $name" > "$tools/$name.sha256"
|
||||
(cd "$tools" && sha256sum -c "$name.sha256")
|
||||
tar -xJf "$tools/$name" -C "$tools" --strip-components=1 "typst-x86_64-unknown-linux-musl/typst"
|
||||
rm "$tools/$name" "$tools/$name.sha256"
|
||||
fi
|
||||
|
||||
"$tools/calepin" --version
|
||||
"$tools/typst" --version
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the pinned Calepin CLI from tools/, bootstrapping the toolchain on demand.
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
if [ ! -x "$root/tools/calepin" ]; then
|
||||
"$root/scripts/bootstrap.sh"
|
||||
fi
|
||||
|
||||
export PATH="$root/tools:$PATH"
|
||||
exec "$root/tools/calepin" "$@"
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Remove generated site output and build caches. Never touches tracked files.
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
rm -rf "$root/public"
|
||||
find "$root/site" -name '.calepin' -prune -exec rm -rf {} +
|
||||
find "$root/site" -type f -name '.calepin-entry.*' -delete
|
||||
Reference in new issue
Block a user