Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·72 lines (69 loc) · 3.79 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·72 lines (69 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# Prepares the real-world app benchmark in the README (Linux x64 or macOS arm64): the compilers, Bun canary and
# the apps at their measured commits, with dependencies installed without install scripts.
# usage: scripts/bench-apps/setup.sh <work-dir>
# Use a work dir whose name ends in .noindex, so Spotlight does not index the repos.
# BENCH_APPS selects repository names (for example "sentry" or "t3code"); default all.
set -euo pipefail
[[ $# == 1 ]] || { sed -n '4p' "$0" >&2; exit 2; }
mkdir -p "$1" && cd "$1"
mkdir -p repos logs
# Compilers. TypeScript 6 and 7 both name their bin tsc, so run.sh calls each one by path.
[[ -f package.json ]] || echo '{ "private": true }' >package.json
npm i -q --no-audit --no-fund tsc-rs@0.6.0 typescript@7.1.0-dev.20261008.1 ts6@npm:typescript@6.0.3
# Save the archive hash and revision: the canary download URL moves.
case "$(uname -s)/$(uname -m)" in
Linux/x86_64) bun_platform=linux-x64 ;;
Darwin/arm64) bun_platform=darwin-aarch64 ;;
*) echo "unsupported benchmark platform" >&2; exit 1 ;;
esac
curl -fsSL -o bun.zip "https://github.com/oven-sh/bun/releases/download/canary/bun-$bun_platform.zip"
if [[ -n ${BUN_SHA256:-} ]]; then
echo "$BUN_SHA256 bun.zip" | shasum -a 256 -c -
fi
shasum -a 256 bun.zip > logs/bun-archive.sha256
unzip -oq bun.zip && rm bun.zip
echo "bun $("bun-$bun_platform/bun" --revision)"
checkout() { # name url sha
[[ -d repos/$1 ]] && return
git init -q "repos/$1" && git -C "repos/$1" fetch -q --depth 1 "$2" "$3" && git -C "repos/$1" checkout -q FETCH_HEAD
}
install() { # name
cd "repos/$1"
if [[ -f pnpm-lock.yaml ]]; then pnpm install --frozen-lockfile --ignore-scripts
elif [[ -f yarn.lock ]]; then corepack yarn install --frozen-lockfile --ignore-scripts
else npm ci --ignore-scripts --no-audit --no-fund
fi
}
while read -r name url sha; do
[[ ${BENCH_APPS:-all} == all || " ${BENCH_APPS:-all} " == *" $name "* ]] || continue
checkout "$name" "$url" "$sha"
(install "$name") >"logs/install-$name.log" 2>&1 || { echo "install failed: $name (logs/install-$name.log)" >&2; exit 1; }
done <<'EOF'
vscode https://github.com/microsoft/vscode 3f07e1aba32acacb8b08ae91bfdc954b580ad1fd
sentry https://github.com/getsentry/sentry 8294650589dbd26f230c73f4ab26b62a68aede8f
playwright https://github.com/microsoft/playwright d469960fdfc461e2d5795a3fa48a58a52a91ecaf
typeorm https://github.com/typeorm/typeorm c64a1f052fc39f6688b6b73b83d065d7147ba8bb
excalidraw https://github.com/excalidraw/excalidraw 53973c3a423fbd75a4ce68107786b4fcb90e4968
trpc https://github.com/trpc/trpc d756e591a5e37ef20b8d75ecd4d736c195497289
EOF
# The fixes that make each config check with 0 errors under tsc 7. Nothing else changes.
# VS Code: its postinstall puts the electron typings in node_modules.
if [[ -d repos/vscode && ! -d repos/vscode/node_modules/electron ]]; then
mkdir -p tmp-electron && (cd tmp-electron && echo '{ "private": true }' >package.json &&
npm i -q --ignore-scripts --no-audit --no-fund electron@43.7.7)
cp -R tmp-electron/node_modules/electron repos/vscode/node_modules/electron && rm -rf tmp-electron
fi
# Playwright: its build generates the injected sources that the checked files import.
if [[ -d repos/playwright ]]; then (cd repos/playwright && node utils/generate_injected.js); fi
# Excalidraw: TS 7 removed baseUrl. The paths are already relative to the config.
if [[ -d repos/excalidraw ]]; then
grep -v '"baseUrl"' repos/excalidraw/tsconfig.json >repos/excalidraw/tsconfig.bench.json
fi
# TypeORM: TS 7 removed moduleResolution node (node10). The package is CommonJS, so nodenext keeps
# its extensionless imports.
if [[ -d repos/typeorm ]]; then
echo '{ "extends": "./tsconfig.json", "compilerOptions": { "module": "nodenext", "moduleResolution": "nodenext" } }' \
>repos/typeorm/packages/typeorm/tsconfig.bench.json
fi
echo ready