-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathprepare_asar
More file actions
executable file
·45 lines (44 loc) · 3.02 KB
/
Copy pathprepare_asar
File metadata and controls
executable file
·45 lines (44 loc) · 3.02 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
#!/usr/bin/env bash
set -euxo pipefail
unzip -o "$HOSTED_CODEX_APP_ZIP" -d scratch/
asar extract "scratch/ChatGPT.app/Contents/Resources/app.asar" "scratch/asar"
cp assets/* scratch/asar/webview/
PWA_SOURCE_ICON="scratch/asar/webview/assets/app-f483cb0295ed.png"
PWA_TARGET_ICON="scratch/asar/webview/assets/pwa-icon-512.png"
PWA_ICON_SIZE=512
PWA_TOTAL_PADDING_PERCENT=25
PWA_CONTENT_SIZE=$((PWA_ICON_SIZE * (100 - PWA_TOTAL_PADDING_PERCENT) / 100))
PWA_PADDING_TOTAL=$((PWA_ICON_SIZE - PWA_CONTENT_SIZE))
PWA_PADDING_BEFORE=$((PWA_PADDING_TOTAL / 2))
PWA_PADDING_AFTER=$((PWA_PADDING_TOTAL - PWA_PADDING_BEFORE))
sharp -i "$PWA_SOURCE_ICON" -o "$PWA_TARGET_ICON" -f png resize "$PWA_CONTENT_SIZE" "$PWA_CONTENT_SIZE" --fit inside -- flatten white -- extend "$PWA_PADDING_BEFORE" "$PWA_PADDING_AFTER" "$PWA_PADDING_BEFORE" "$PWA_PADDING_AFTER" --background white -- removeAlpha
if [[ -n "${DEV:-}" ]]; then
prettier --ignore-path /dev/null --ignore-unknown --write "scratch/asar"
else
patched_files=()
while IFS= read -r patched_file; do
patched_files+=("$patched_file")
done < <(
awk '/^\+\+\+ b\//{sub(/^\+\+\+ b\//, "scratch/asar/"); print}' patches/*.patch | sort -u
)
prettier --ignore-path /dev/null --ignore-unknown --write "${patched_files[@]}"
fi
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-remove-csp.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-style.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-preload.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-favicon.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-pwa.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-thread-title.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-initial-route.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-electron-shim-close-sidebar.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-prosemirror-inputmode.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-use-atfs-for-local-files.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-statsig-override-adapter.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-prompt-search-param.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/sentry-disable-shell.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/sentry-disable-webview.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/preload-disable-device-check.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/webview-safe-header-left.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/app-host-json-rpc.patch
patch --batch --forward --strip 1 --directory scratch/asar < patches/app-host-browser-windows.patch
rm -rf scratch/asar/node_modules/better-sqlite3