pathes
Build self-hosted HTTP Toolkit / build (linux-x64, ubuntu-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (macos-arm64, macos-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (windows-x64, windows-latest, false) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / release (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (linux-x64, ubuntu-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (macos-arm64, macos-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (windows-x64, windows-latest, false) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / release (push) Canceled after 0s
This commit is contained in:
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Apply our patches + overlay onto the pristine upstream submodules.
|
||||
#
|
||||
# Fails loudly if a patch no longer applies (i.e. upstream moved after a
|
||||
# submodule bump), so you know exactly which patch to refresh. Idempotent:
|
||||
# it resets each submodule's tracked files to the pinned commit first.
|
||||
#
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
echo "==> Ensuring submodules are initialised & at pinned commits"
|
||||
git submodule update --init --recursive
|
||||
|
||||
apply_patches() {
|
||||
local name="$1" dir="$2"
|
||||
if [ ! -d "patches/$name" ]; then return; fi
|
||||
|
||||
echo "==> [$name] resetting to pinned commit"
|
||||
git -C "$dir" checkout -- . 2>/dev/null || true
|
||||
git -C "$dir" clean -fd -e node_modules 2>/dev/null || true
|
||||
|
||||
echo "==> [$name] applying patches"
|
||||
local applied=0
|
||||
for patch in patches/"$name"/*.patch; do
|
||||
[ -e "$patch" ] || continue
|
||||
echo " - $(basename "$patch")"
|
||||
# --3way lets git fall back to a merge if context shifted slightly.
|
||||
git -C "$dir" apply --3way "$ROOT/$patch"
|
||||
applied=$((applied + 1))
|
||||
done
|
||||
echo "==> [$name] $applied patch(es) applied"
|
||||
}
|
||||
|
||||
apply_patches ui httptoolkit-ui
|
||||
apply_patches server httptoolkit-server
|
||||
|
||||
echo "==> Copying overlay files into httptoolkit-server"
|
||||
cp -v overlay/server/htk-entry.ts httptoolkit-server/htk-entry.ts
|
||||
cp -v overlay/server/src/htk-app.ts httptoolkit-server/src/htk-app.ts
|
||||
cp -v overlay/server/src/commands/app.ts httptoolkit-server/src/commands/app.ts
|
||||
|
||||
echo "==> apply.sh complete."
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build the self-hosted single-file HTTP Toolkit binary.
|
||||
#
|
||||
# Requires: node (>=22), npm, bun, tar. Runs per-OS in CI (native modules can't
|
||||
# be cross-compiled), so this builds for the *host* platform.
|
||||
#
|
||||
# Env:
|
||||
# OUT_NAME output binary basename (default: httptoolkit)
|
||||
# BUN_TARGET optional bun --target (default: host); e.g. bun-linux-x64
|
||||
#
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
OUT_NAME="${OUT_NAME:-httptoolkit}"
|
||||
BUN_TARGET="${BUN_TARGET:-}"
|
||||
|
||||
# The UI's postinstall pulls Puppeteer's Chromium (only needed for its own
|
||||
# integration tests) - skip it, it's large and irrelevant to the build.
|
||||
export PUPPETEER_SKIP_DOWNLOAD=true
|
||||
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
|
||||
EXT=""
|
||||
case "${BUN_TARGET}" in *windows*) EXT=".exe";; esac
|
||||
if [ -z "$BUN_TARGET" ] && [ "${OS:-}" = "Windows_NT" ]; then EXT=".exe"; fi
|
||||
|
||||
echo "==> 1/5 Apply patches + overlay"
|
||||
bash scripts/apply.sh
|
||||
|
||||
echo "==> 2/5 Build UI -> httptoolkit-ui/dist"
|
||||
( cd httptoolkit-ui && npm ci && npm run build )
|
||||
|
||||
echo "==> 3/5 Install server deps (+ tar for the entry) & embed the 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 "==> 4/5 Compile single-file binary with Bun"
|
||||
mkdir -p dist
|
||||
COMPILE=(build ./htk-entry.ts --compile --outfile "$ROOT/dist/${OUT_NAME}${EXT}")
|
||||
if [ -n "$BUN_TARGET" ]; then COMPILE+=(--target "$BUN_TARGET"); fi
|
||||
( cd httptoolkit-server && bun "${COMPILE[@]}" )
|
||||
|
||||
echo "==> 5/5 Done -> dist/${OUT_NAME}${EXT}"
|
||||
ls -lh "dist/${OUT_NAME}${EXT}"
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Smoke test: launch the built binary and verify it actually serves the UI and
|
||||
# starts the backend. Fails loudly (non-zero) if a native module won't load or
|
||||
# the server never comes up - this is the main guard for the single-file build.
|
||||
#
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
BIN="${1:-dist/httptoolkit}"
|
||||
PORT="${PORT:-8099}"
|
||||
SERVER_PORT="${SERVER_PORT:-45457}"
|
||||
|
||||
echo "==> --help must exit 0"
|
||||
"$BIN" --help
|
||||
|
||||
echo "==> launching $BIN on port $PORT"
|
||||
"$BIN" --port "$PORT" --server-port "$SERVER_PORT" --no-open &
|
||||
PID=$!
|
||||
trap 'kill "$PID" 2>/dev/null || true' EXIT
|
||||
|
||||
# Wait up to ~30s for the UI port to answer:
|
||||
ok=0
|
||||
for _ in $(seq 1 60); do
|
||||
if curl -fsS "http://127.0.0.1:${PORT}/" -o /tmp/htk-index.html 2>/dev/null; then
|
||||
ok=1; break
|
||||
fi
|
||||
if ! kill -0 "$PID" 2>/dev/null; then
|
||||
echo "!! binary exited early"; exit 1
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
[ "$ok" = 1 ] || { echo "!! UI never responded on :$PORT"; exit 1; }
|
||||
|
||||
echo "==> UI responded; checking it looks like the HTK app"
|
||||
grep -qi 'httptoolkit\|<div id="app"\|<title' /tmp/htk-index.html \
|
||||
|| { echo "!! served index.html doesn't look like the UI"; exit 1; }
|
||||
|
||||
echo "==> checking management API is listening on :$SERVER_PORT"
|
||||
# corsGate rejects requests without an allowed Origin with a JSON 403 - that's a
|
||||
# *successful* connection (the server is up), which is all we need to confirm.
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' \
|
||||
-H 'Origin: http://localhost:'"$PORT" \
|
||||
"http://127.0.0.1:${SERVER_PORT}/" || true)
|
||||
echo " management API HTTP status: $code"
|
||||
[ -n "$code" ] && [ "$code" != "000" ] \
|
||||
|| { echo "!! management API not reachable"; exit 1; }
|
||||
|
||||
echo "==> SMOKE TEST PASSED"
|
||||
Reference in New Issue
Block a user