Skip to content

Commit 15594f8

Browse files
Small fixes to make global types and dugite work with dev and build scripts
1 parent 7e8923d commit 15594f8

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/main/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ Sentry.init({
1818

1919
class Main {
2020
constructor() {
21+
// Overwrite dugites resolved path to the embedded git directory
22+
// @see https://github.com/desktop/dugite/blob/0f5a4f11300fbfa8d2dd272b8ee9b771e5b34cd4/lib/git-environment.ts#L25
23+
// This seems to be necessary, since it resolves to `elek.io Client.app/Contents/Resources/app/git` instead of dugites git inside node_modules `elek.io Client.app/Contents/Resources/app/node_modules/dugite/git`
24+
process.env.LOCAL_GIT_DIRECTORY = Path.resolve(
25+
__dirname,
26+
'../../',
27+
'node_modules',
28+
'dugite',
29+
'git'
30+
);
31+
2132
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
2233
if (require('electron-squirrel-startup')) {
2334
app.quit();

src/renderer/react/app.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ import {
55
} from '@tanstack/react-router';
66
import { StrictMode } from 'react';
77
import ReactDOM from 'react-dom/client';
8+
import { type ContextBridgeApi } from '../preload';
89

910
// Import the generated route tree
1011
import { routeTree } from './routeTree.gen';
1112

13+
declare global {
14+
interface Window {
15+
ipc: ContextBridgeApi;
16+
}
17+
}
18+
1219
// Create a new router instance
1320
const hashHistory = createHashHistory(); // Use hash based routing since in production electron just loads the index.html via the file protocol
1421
const router = createRouter({

src/types.d.ts

-10
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,3 @@
33
// whether you're running in development or production).
44
declare const MAIN_WINDOW_VITE_DEV_SERVER_URL: string;
55
declare const MAIN_WINDOW_VITE_NAME: string;
6-
7-
// This file should augment the properties of the `Window` with the type of the
8-
// `ContextBridgeApi` from `Electron.contextBridge` declared in `./preload.ts`.
9-
import type { ContextBridgeApi } from './renderer/preload';
10-
11-
declare global {
12-
interface Window {
13-
ipc: ContextBridgeApi;
14-
}
15-
}

vite.main.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default defineConfig({
77
// Some libs that can run in both Web and Node.js, such as `axios`, we need to tell Vite to build them in Node.js.
88
browserField: false,
99
mainFields: ['module', 'jsnext:main', 'jsnext'],
10+
conditions: ['node'], // To get the resolution behavior of Node.js. Otherwise we get "getRandomValues() not supported" while creating UUIDs @see https://github.com/uuidjs/uuid/issues/544#issuecomment-740394448
1011
},
1112

1213
build: {

0 commit comments

Comments
 (0)