diff --git a/CLAUDE.md b/CLAUDE.md index 5968670..e3a5fa9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -94,8 +94,8 @@ This ensures consistent tooling versions across the team without system-wide ins ## Platform Requirements -Linux x86_64 only (currently). Requires: -- Modern libc for Go binaries +Linux or macOS on x86_64. Requires: +- Modern libc for Go binaries (Linux) - docker compose (for full stack) - fd, shellcheck, shfmt (for development) diff --git a/README.md b/README.md index 5b94767..ce4ffce 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,8 @@ Different situations require different getting started docs. ## Requirements -To run diachron, you currently need to have a Linux box running x86_64 with a -new enough libc to run golang binaries. Support for other platforms will come -eventually. +To run diachron, you need Linux or macOS on x86_64. Linux requires a new +enough libc to run golang binaries. To run a more complete system, you also need to have docker compose installed. diff --git a/framework/platform b/framework/platform new file mode 100644 index 0000000..35f429a --- /dev/null +++ b/framework/platform @@ -0,0 +1,26 @@ +# shellcheck shell=bash + +# Detect platform (OS and architecture) + +os=$(uname -s | tr '[:upper:]' '[:lower:]') +arch=$(uname -m) + +case "$os" in + linux) platform_os=linux ;; + darwin) platform_os=darwin ;; + *) echo "Unsupported OS: $os" >&2; exit 1 ;; +esac + +case "$arch" in + x86_64) platform_arch=x86_64 ;; + *) echo "Unsupported architecture: $arch" >&2; exit 1 ;; +esac + +platform="${platform_os}_${platform_arch}" + +# Platform-specific checksum command +if [ "$platform_os" = "darwin" ]; then + sha256_check() { shasum -a 256 -c -; } +else + sha256_check() { sha256sum -c -; } +fi diff --git a/framework/shims/node.common b/framework/shims/node.common index 3745766..ef55172 100644 --- a/framework/shims/node.common +++ b/framework/shims/node.common @@ -7,6 +7,15 @@ project_root="$node_common_DIR/../.." # shellcheck source=../versions source "$node_common_DIR"/../versions +# shellcheck source=../platform +source "$node_common_DIR"/../platform + +# Get platform-specific node directory +nodejs_dirname_var="nodejs_dirname_${platform}" +nodejs_dirname="${!nodejs_dirname_var}" +nodejs_dist_dir="framework/binaries/$nodejs_dirname" +nodejs_bin_dir="$nodejs_dist_dir/bin" + nodejs_binary_dir="$project_root/$nodejs_bin_dir" # This might be too restrictive. Or not restrictive enough. diff --git a/framework/versions b/framework/versions index de9fbd4..4fd1a9d 100644 --- a/framework/versions +++ b/framework/versions @@ -2,18 +2,25 @@ # This file belongs to the framework. You are not expected to modify it. +nodejs_version=v24.12.0 + # https://nodejs.org/dist nodejs_binary_linux_x86_64=https://nodejs.org/dist/v24.12.0/node-v24.12.0-linux-x64.tar.xz nodejs_checksum_linux_x86_64=bdebee276e58d0ef5448f3d5ac12c67daa963dd5e0a9bb621a53d1cefbc852fd -nodejs_dist_dir=framework/binaries/node-v22.15.1-linux-x64 -nodejs_bin_dir="$nodejs_dist_dir/bin" +nodejs_dirname_linux_x86_64=node-v24.12.0-linux-x64 + +nodejs_binary_darwin_x86_64=https://nodejs.org/dist/v24.12.0/node-v24.12.0-darwin-x64.tar.xz +nodejs_checksum_darwin_x86_64=1e4d54f706e0a3613d6415ffe2ccdfd4095d3483971dbbaa4ff909fac5fc211c +nodejs_dirname_darwin_x86_64=node-v24.12.0-darwin-x64 caddy_binary_linux_x86_64=fixme caddy_checksum_linux_x86_64=fixmetoo # https://github.com/pnpm/pnpm/releases pnpm_binary_linux_x86_64=https://github.com/pnpm/pnpm/releases/download/v10.28.0/pnpm-linux-x64 -pnpm_checksum_linux_x86_64=sha256:348e863d17a62411a65f900e8d91395acabae9e9237653ccc3c36cb385965f28 +pnpm_checksum_linux_x86_64=348e863d17a62411a65f900e8d91395acabae9e9237653ccc3c36cb385965f28 +pnpm_binary_darwin_x86_64=https://github.com/pnpm/pnpm/releases/download/v10.28.0/pnpm-macos-x64 +pnpm_checksum_darwin_x86_64=99431e91d721169c2050d5e46abefc6f0d23c49e635a5964dcb573d9fe89975a golangci_lint=v2.7.2-alpine \ No newline at end of file diff --git a/sync.sh b/sync.sh index 40d102e..4a750e9 100755 --- a/sync.sh +++ b/sync.sh @@ -9,6 +9,26 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=framework/versions source "$DIR/framework/versions" +# shellcheck source=framework/platform +source "$DIR/framework/platform" + +# Get platform-specific variables +nodejs_binary_var="nodejs_binary_${platform}" +nodejs_checksum_var="nodejs_checksum_${platform}" +nodejs_dirname_var="nodejs_dirname_${platform}" +nodejs_binary="${!nodejs_binary_var}" +nodejs_checksum="${!nodejs_checksum_var}" +nodejs_dirname="${!nodejs_dirname_var}" + +pnpm_binary_var="pnpm_binary_${platform}" +pnpm_checksum_var="pnpm_checksum_${platform}" +pnpm_binary_url="${!pnpm_binary_var}" +pnpm_checksum="${!pnpm_checksum_var}" + +# Set up paths for shims to use +nodejs_dist_dir="framework/binaries/$nodejs_dirname" +nodejs_bin_dir="$nodejs_dist_dir/bin" + # Ensure correct node version is installed node_installed_checksum_file="$DIR/framework/binaries/.node.checksum" node_installed_checksum="" @@ -16,19 +36,19 @@ if [ -f "$node_installed_checksum_file" ]; then node_installed_checksum=$(cat "$node_installed_checksum_file") fi -if [ "$node_installed_checksum" != "$nodejs_checksum_linux_x86_64" ]; then - echo "Downloading Node.js..." +if [ "$node_installed_checksum" != "$nodejs_checksum" ]; then + echo "Downloading Node.js for $platform..." node_archive="$DIR/framework/downloads/node.tar.xz" - curl -fsSL "$nodejs_binary_linux_x86_64" -o "$node_archive" + curl -fsSL "$nodejs_binary" -o "$node_archive" echo "Verifying checksum..." - echo "$nodejs_checksum_linux_x86_64 $node_archive" | sha256sum -c - + echo "$nodejs_checksum $node_archive" | sha256_check echo "Extracting Node.js..." tar -xf "$node_archive" -C "$DIR/framework/binaries" rm "$node_archive" - echo "$nodejs_checksum_linux_x86_64" >"$node_installed_checksum_file" + echo "$nodejs_checksum" >"$node_installed_checksum_file" fi # Ensure correct pnpm version is installed @@ -39,15 +59,12 @@ if [ -f "$pnpm_installed_checksum_file" ]; then pnpm_installed_checksum=$(cat "$pnpm_installed_checksum_file") fi -# pnpm checksum includes "sha256:" prefix, strip it for sha256sum -pnpm_checksum="${pnpm_checksum_linux_x86_64#sha256:}" - if [ "$pnpm_installed_checksum" != "$pnpm_checksum" ]; then - echo "Downloading pnpm..." - curl -fsSL "$pnpm_binary_linux_x86_64" -o "$pnpm_binary" + echo "Downloading pnpm for $platform..." + curl -fsSL "$pnpm_binary_url" -o "$pnpm_binary" echo "Verifying checksum..." - echo "$pnpm_checksum $pnpm_binary" | sha256sum -c - + echo "$pnpm_checksum $pnpm_binary" | sha256_check chmod +x "$pnpm_binary"