Visual Studio Code, rebuilt in Rust
Rust
#!/bin/bash
# Writes the reference's core settings registry to native/crates/config/core-settings.json: every setting VS Code
# itself registers (no extensions), with its schema, default and scope, as the Settings editor reads it.
# Also writes the schemas the settings schemas $ref to native/crates/config/schemas, and
# native/crates/config/core-settings-stable.json: the settings a `stable` quality build registers differently
# (dumped again with product.overrides.json `{"quality":"stable"}`), null for one it does not register.
# Run on the Studio: port/tools/studio port/tools/dump-settings, then copy the files back.
set -euo pipefail
REF=${REF:-$HOME/Developer/vscode-ref-1.148.0}
electron="$REF/.build/electron/Code - OSS.app/Contents/MacOS/Code - OSS"
out=$(mktemp -d)
source port/tools/gui-lock.sh
dump() {
mkdir -p "$1"
# queryLocalFonts in a fresh window sometimes returns nothing (run.js then fails): try again.
for attempt in 1 2 3; do
DUMP_OUT=$1 VSCODE_DEV=1 NODE_ENV=development timeout 300 "$electron" "$REF" --user-data-dir "$(mktemp -d)" --disable-extensions \
--extensionDevelopmentPath="$PWD/port/tools/dump-core-settings" --extensionTestsPath="$PWD/port/tools/dump-core-settings/run.js" >"$1/electron.log" 2>&1 \
&& return
done
tail -20 "$1/electron.log"
exit 1
}
dump "$out/oss"
# bootstrap-meta.ts reads product.overrides.json out of sources only.
[ -e "$REF/product.overrides.json" ] && { echo "$REF/product.overrides.json exists, not overwriting it"; exit 1; }
trap 'rm -f "$REF/product.overrides.json"' EXIT
echo '{"quality":"stable"}' >"$REF/product.overrides.json"
dump "$out/stable"
rm -f "$REF/product.overrides.json"
cp "$out/oss/core-settings.json" native/crates/config/core-settings.json
mkdir -p native/crates/config/schemas && cp "$out"/oss/schemas/*.json native/crates/config/schemas/
jq -S --slurpfile oss "$out/oss/core-settings.json" '. as $stable | $oss[0] as $oss
| ([$stable, $oss] | map(keys) | add | unique)
| map(select($stable[.] != $oss[.]) | {key: ., value: $stable[.]}) | from_entries' \
"$out/stable/core-settings.json" >native/crates/config/core-settings-stable.json
echo "$(jq 'length' native/crates/config/core-settings.json) settings, $(jq 'length' native/crates/config/core-settings-stable.json) differ on stable, $out"