Skip to content

Commit 167ea67

Browse files
authored
Merge pull request #17 from the-dev-tools/fix/desktop-startup
Fix Windows and MacOS startup issues by using a previous workaround
2 parents ccb8521 + 6646917 commit 167ea67

4 files changed

Lines changed: 24 additions & 22 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
desktop: patch
3+
---
4+
5+
Revert to manual ASAR binary unpacking and execution due to issues on Windows and MacOS

‎apps/desktop/build.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import { fileURLToPath } from 'node:url';
66

77
const config: Configuration = {
88
artifactName: '${productName}-${version}-${platform}-${arch}.${ext}',
9-
asarUnpack: ['resources/**'],
9+
asarUnpack: [
10+
'resources/**',
11+
'**/node_modules/@the-dev-tools/server/dist/server',
12+
'**/node_modules/@the-dev-tools/cli/dist/cli',
13+
],
1014
extraMetadata: {
1115
name: 'DevTools',
1216
},

‎apps/desktop/src/main/index.ts‎

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Command, FetchHttpClient, Path, Url } from '@effect/platform';
22
import * as NodeContext from '@effect/platform-node/NodeContext';
33
import * as NodeRuntime from '@effect/platform-node/NodeRuntime';
4-
import { Config, Console, Effect, pipe, Runtime } from 'effect';
4+
import { Config, Console, Effect, pipe, Runtime, String } from 'effect';
55
import { app, BrowserWindow, dialog, Dialog, globalShortcut, ipcMain, protocol, shell } from 'electron';
66
import { autoUpdater } from 'electron-updater';
7-
import child_process from 'node:child_process';
87
import os from 'node:os';
98
import { Agent } from 'undici';
109
import { CustomUpdateProvider, UpdateOptions } from './update';
@@ -99,19 +98,6 @@ const createWindow = Effect.gen(function* () {
9998
}
10099
});
101100

102-
// Only 'child_process.execFile' is supported for executing binaries inside ASAR archives
103-
// https://www.electronjs.org/docs/latest/tutorial/asar-archives#executing-binaries-inside-asar-archive
104-
const execFile = (file: string, args?: string[], options?: child_process.ExecFileOptions) =>
105-
Effect.async<void, child_process.ExecFileException>((resume) => {
106-
child_process.execFile(file, args, options, (error, stdout, stderr) => {
107-
Effect.gen(function* () {
108-
if (stdout) console.log(stdout);
109-
if (stderr) console.error(stderr);
110-
if (error) yield* Effect.fail(error);
111-
}).pipe(resume);
112-
});
113-
});
114-
115101
const server = pipe(
116102
Effect.gen(function* () {
117103
const path = yield* Path.Path;
@@ -122,16 +108,22 @@ const server = pipe(
122108
Effect.flatMap(path.fromFileUrl),
123109
);
124110

125-
yield* execFile(path.join(dist, 'server'), undefined, {
126-
env: {
111+
yield* pipe(
112+
path.join(dist, 'server'),
113+
String.replaceAll('app.asar', 'app.asar.unpacked'),
114+
Command.make,
115+
Command.env({
127116
// TODO: we probably shouldn't encrypt local database
128117
DB_ENCRYPTION_KEY: 'secret',
129118
DB_MODE: 'local',
130119
DB_NAME: 'state',
131120
DB_PATH: app.getPath('userData'),
132121
HMAC_SECRET: 'secret',
133-
},
134-
});
122+
}),
123+
Command.stdout('inherit'),
124+
Command.stderr('inherit'),
125+
Command.exitCode,
126+
);
135127

136128
yield* Effect.interrupt;
137129
}),
@@ -266,7 +258,9 @@ const cli = pipe(
266258
Effect.flatMap(path.fromFileUrl),
267259
);
268260

269-
yield* execFile(path.join(dist, 'cli'), args);
261+
const bin = pipe(path.join(dist, 'cli'), String.replaceAll('app.asar', 'app.asar.unpacked'));
262+
263+
yield* pipe(Command.make(bin, ...args), Command.stdout('inherit'), Command.stderr('inherit'), Command.exitCode);
270264

271265
app.quit();
272266
}),

‎tools/eslint/config.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ const rules = defineConfig({
9797
rules: {
9898
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreVoidOperator: true }],
9999
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
100-
'@typescript-eslint/no-invalid-void-type': 'off', // re-enable once improved https://github.com/typescript-eslint/typescript-eslint/issues/8113
101100
'@typescript-eslint/no-meaningless-void-operator': 'off',
102101
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
103102
'@typescript-eslint/no-non-null-assertion': 'off', // in protobuf everything is optional, requiring assertions

0 commit comments

Comments
 (0)