()
| 884 | // `{"state":"downloaded","version":"99.0.0"}`) seeds a status to exercise the |
| 885 | // renderer card and the install handler without one. Ignored in production. |
| 886 | const applyFakeUpdateFromEnv = () => { |
| 887 | // Never honor the fake seam in a packaged build: a stray env var would seed a |
| 888 | // phantom "downloaded" update whose install quits the app against nothing. |
| 889 | if (app.isPackaged) return; |
| 890 | const raw = process.env.EXECUTOR_DESKTOP_FAKE_UPDATE?.trim(); |
| 891 | if (!raw) return; |
| 892 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: dev-only env override is untrusted text; a malformed value is logged and ignored, not fatal |
| 893 | try { |
| 894 | // oxlint-disable-next-line executor/no-json-parse -- boundary: dev-only env override, shape-checked below |
| 895 | const parsed = JSON.parse(raw) as { readonly state?: string; readonly version?: string }; |
| 896 | const version = typeof parsed.version === "string" ? parsed.version : "0.0.0"; |
| 897 | const state = parsed.state ?? "downloaded"; |
| 898 | if ( |
| 899 | state === "available" || |
| 900 | state === "downloaded" || |
| 901 | state === "downloading" || |
| 902 | state === "error" || |
| 903 | state === "installing" |
| 904 | ) { |
| 905 | if (state === "downloaded") downloadedUpdateVersion = version; |
| 906 | setUpdateStatus( |
| 907 | state === "downloading" |
| 908 | ? { state, version, percent: 100 } |
| 909 | : state === "error" |
| 910 | ? { state, version, message: "Update failed" } |
| 911 | : { state, version }, |
| 912 | ); |
| 913 | } |
| 914 | } catch (error) { |
| 915 | log.warn("[updater] bad EXECUTOR_DESKTOP_FAKE_UPDATE", error); |
| 916 | } |
| 917 | }; |
| 918 | |
| 919 | const promptInstallUpdate = async (version: string) => { |
| 920 | if (updateDialogOpen) return; |
no test coverage detected