#!/usr/bin/env bash # # Clone upstream, patch, and build the single-file binary -> dist/httptoolkit # Requires: node (>=22), npm, bun, tar, git. # set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" export PUPPETEER_SKIP_DOWNLOAD=true export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true echo "==> Cloning upstream sources" rm -rf httptoolkit-ui httptoolkit-server git clone --depth 1 https://github.com/httptoolkit/httptoolkit-ui.git git clone --depth 1 https://github.com/httptoolkit/httptoolkit-server.git echo "==> Applying patches + overlay" bash scripts/patch.sh echo "==> Building UI" ( cd httptoolkit-ui && npm ci && npm run build ) echo "==> Preparing server + embedding UI" ( cd httptoolkit-server \ && npm ci \ && npm install --no-save tar@^7 \ && tar -czf ui.tar.gz -C ../httptoolkit-ui/dist . \ && rm -rf ui && cp -r ../httptoolkit-ui/dist ui ) echo "==> Compiling single-file binary -> dist/httptoolkit" mkdir -p dist ( cd httptoolkit-server && bun build ./htk-entry.ts --compile --outfile "$ROOT/dist/httptoolkit" ) echo "==> Done: dist/httptoolkit" ls -lh dist/httptoolkit