The best way to control Claude Code, Codex and more from any computer or phone

main
sh 42 lines 1.34 KB
Raw
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 # Runs the CI bundle-size comparison locally (see the Bundle job in
5 # .github/workflows/check.yml): builds the current checkout, builds the base
6 # ref in a cached git worktree under tmp/, then compares fixture bundle sizes.
7 #
8 # Usage: scripts/bundle-compare.sh [base-ref] (default: main)
9 #
10 # The base worktree is reused across runs while it points at the same commit.
11 # Remove it with: git worktree remove --force tmp/bundle-base
12
13 BASE_REF="${1:-main}"
14 ROOT="$(git rev-parse --show-toplevel)"
15 BASE_DIR="$ROOT/tmp/bundle-base"
16 OUTPUT_PATH="$ROOT/tmp/bundle-stats.txt"
17
18 cd "$ROOT"
19
20 echo "Building current checkout..."
21 pnpm build
22
23 BASE_COMMIT="$(git rev-parse "$BASE_REF")"
24
25 if [ -d "$BASE_DIR/packages/effect/dist" ] && [ "$(git -C "$BASE_DIR" rev-parse HEAD)" = "$BASE_COMMIT" ]; then
26 echo "Reusing built base worktree at $BASE_DIR ($BASE_REF @ ${BASE_COMMIT:0:8})"
27 else
28 if [ -d "$BASE_DIR" ]; then
29 git worktree remove --force "$BASE_DIR"
30 fi
31 echo "Creating base worktree at $BASE_DIR ($BASE_REF @ ${BASE_COMMIT:0:8})"
32 git worktree add --detach "$BASE_DIR" "$BASE_COMMIT"
33 echo "Building base checkout..."
34 (cd "$BASE_DIR" && pnpm install && pnpm build)
35 fi
36
37 node packages/tools/bundle/src/bin.ts compare \
38 --base-dir "$BASE_DIR/packages/tools/bundle/fixtures" \
39 --output-path "$OUTPUT_PATH"
40
41 echo
42 cat "$OUTPUT_PATH"