Skip to content

Commit 75f13dd

Browse files
committed
fix(electron): detect dk by checking file existence instead of PATH
1 parent d5baf64 commit 75f13dd

3 files changed

Lines changed: 70 additions & 88 deletions

File tree

electron/electron-builder.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
appId: io.oroio.desktop
2+
productName: oroio
3+
copyright: Copyright © 2024
4+
5+
directories:
6+
output: release
7+
buildResources: assets
8+
9+
files:
10+
- dist/**/*
11+
- package.json
12+
13+
extraResources:
14+
- from: ../web/dist
15+
to: web
16+
- from: assets
17+
to: assets
18+
19+
mac:
20+
category: public.app-category.developer-tools
21+
icon: ../assets/icon.icns
22+
hardenedRuntime: true
23+
gatekeeperAssess: false
24+
entitlements: entitlements.mac.plist
25+
entitlementsInherit: entitlements.mac.plist
26+
artifactName: ${productName}-${version}-${arch}.${ext}
27+
target:
28+
- target: dmg
29+
arch:
30+
- arm64
31+
32+
dmg:
33+
sign: false
34+
contents:
35+
- x: 130
36+
y: 220
37+
- x: 410
38+
y: 220
39+
type: link
40+
path: /Applications
41+
42+
linux:
43+
target:
44+
- AppImage
45+
category: Development
46+
icon: ../assets/icons
47+
artifactName: ${productName}-${version}-x86_64.${ext}
48+
49+
win:
50+
target:
51+
- nsis
52+
icon: assets/icon.ico
53+
artifactName: ${productName}-${version}-x86_64.${ext}
54+
55+
nsis:
56+
oneClick: false
57+
perMachine: false
58+
allowToChangeInstallationDirectory: true

electron/main/ipc.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ipcMain, BrowserWindow, shell } from 'electron';
22
import * as fs from 'fs/promises';
33
import * as path from 'path';
44
import * as os from 'os';
5-
import { exec } from 'child_process';
5+
66
import {
77
getKeyList,
88
getCurrentKey,
@@ -365,15 +365,19 @@ Droid instructions here.
365365
await shell.openPath(filePath);
366366
});
367367

368-
// dk CLI check
368+
// dk CLI check - check file directly for faster detection
369369
ipcMain.handle('dk:check', async (): Promise<{ installed: boolean; installCmd: string; platform: string }> => {
370370
const platform = os.platform();
371-
const cmd = platform === 'win32'
372-
? 'powershell -NoProfile -Command "if (Get-Command dk -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"'
373-
: 'which dk';
374-
const installed = await new Promise<boolean>((resolve) => {
375-
exec(cmd, (error) => resolve(!error));
376-
});
371+
const dkPath = platform === 'win32'
372+
? path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'), 'oroio', 'bin', 'dk.ps1')
373+
: path.join(os.homedir(), '.local', 'bin', 'dk');
374+
let installed = false;
375+
try {
376+
await fs.access(dkPath);
377+
installed = true;
378+
} catch {
379+
// file not found
380+
}
377381
const installCmd = platform === 'win32'
378382
? 'irm https://raw.githubusercontent.com/notdp/oroio/main/install.ps1 | iex'
379383
: 'curl -fsSL https://raw.githubusercontent.com/notdp/oroio/main/install.sh | bash';

electron/package.json

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -30,85 +30,5 @@
3030
"electron": "^33.4.0",
3131
"electron-builder": "^26.0.0",
3232
"typescript": "^5.7.3"
33-
},
34-
"build": {
35-
"appId": "io.oroio.desktop",
36-
"productName": "oroio",
37-
"directories": {
38-
"output": "release",
39-
"buildResources": "assets"
40-
},
41-
"files": [
42-
"dist/**/*",
43-
"../web/dist/**/*"
44-
],
45-
"extraResources": [
46-
{
47-
"from": "../web/dist",
48-
"to": "web"
49-
},
50-
{
51-
"from": "assets",
52-
"to": "assets"
53-
}
54-
],
55-
"mac": {
56-
"category": "public.app-category.developer-tools",
57-
"icon": "../assets/icon.icns",
58-
"artifactName": "${productName}-${version}-${arch}.${ext}",
59-
"target": [
60-
{
61-
"target": "dmg",
62-
"arch": [
63-
"arm64"
64-
]
65-
}
66-
]
67-
},
68-
"linux": {
69-
"target": [
70-
{
71-
"target": "AppImage",
72-
"arch": [
73-
"x64"
74-
]
75-
}
76-
],
77-
"category": "Development",
78-
"icon": "../assets/icons",
79-
"artifactName": "${productName}-${version}-x64.${ext}"
80-
},
81-
"win": {
82-
"icon": "assets/icon.ico",
83-
"artifactName": "${productName}-${version}-x64.${ext}",
84-
"target": [
85-
{
86-
"target": "nsis",
87-
"arch": [
88-
"x64"
89-
]
90-
}
91-
]
92-
},
93-
"nsis": {
94-
"oneClick": false,
95-
"perMachine": false,
96-
"allowToChangeInstallationDirectory": true,
97-
"artifactName": "${productName}-${version}-x64.${ext}"
98-
},
99-
"dmg": {
100-
"contents": [
101-
{
102-
"x": 130,
103-
"y": 220
104-
},
105-
{
106-
"x": 410,
107-
"y": 220,
108-
"type": "link",
109-
"path": "/Applications"
110-
}
111-
]
112-
}
11333
}
11434
}

0 commit comments

Comments
 (0)