Skip to content

Commit b5ea30e

Browse files
committed
Fix: allow native modules to install properly for ARM64
1 parent 3a31952 commit b5ea30e

4 files changed

Lines changed: 6 additions & 38 deletions

File tree

.github/workflows/desktop-arm64-portable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: |
2424
$env:RUST_TARGET = "aarch64-pc-windows-msvc"
2525
bun ./scripts/prepare.ts
26-
bun install --ignore-scripts
26+
bun install
2727
bun run build
2828
npx electron-builder --win --arm64 --publish never --config electron-builder.config.ts
2929

packages/desktop/src/main/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ const main = Effect.gen(function* () {
164164
return
165165
}
166166

167-
const dataPath = app.isPackaged
168-
? join(dirname(app.getPath("exe")), "data")
169-
: app.getPath("userData")
170-
if (app.isPackaged && !existsSync(dataPath)) {
171-
mkdirSync(dataPath, { recursive: true })
172-
}
173-
preferAppEnv(dataPath)
167+
preferAppEnv(app.getPath("userData"))
174168

175169
app.on("second-instance", (_event: Event, argv: string[]) => {
176170
const urls = argv.filter((arg: string) => arg.startsWith("opencode://"))
@@ -309,7 +303,7 @@ const main = Effect.gen(function* () {
309303
},
310304
{
311305
needsMigration,
312-
userDataPath: dataPath,
306+
userDataPath: app.getPath("userData"),
313307
onSqliteProgress: (progress) => initEmitter.emit("sqlite", progress),
314308
onStdout: (message) => logger.log("sidecar stdout", { message }),
315309
onStderr: (message) => logger.warn("sidecar stderr", { message }),

packages/desktop/src/main/logging.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
import { MainLogger } from "electron-log"
22
import log from "electron-log/main.js"
3-
import { app } from "electron"
4-
import { mkdirSync, readFileSync, readdirSync, statSync, unlinkSync, existsSync } from "node:fs"
5-
import { dirname, join } from "node:path"
3+
import { readFileSync, readdirSync, statSync, unlinkSync } from "node:fs"
4+
import { dirname } from "node:path"
65

76
const MAX_LOG_AGE_DAYS = 7
87
const TAIL_LINES = 1000
98

109
let logger: MainLogger
1110
export const getLogger = () => logger
1211

13-
function getPortableLogPath(): string {
14-
if (app.isPackaged) {
15-
const exePath = app.getPath("exe")
16-
const exeDir = dirname(exePath)
17-
const logDir = join(exeDir, "data", "logs")
18-
if (!existsSync(logDir)) {
19-
mkdirSync(logDir, { recursive: true })
20-
}
21-
return logDir
22-
}
23-
return log.transports.file.getFile().path.replace(/[^\\\/]+$/, "")
24-
}
25-
2612
export function initLogging() {
27-
const logDir = getPortableLogPath()
28-
log.transports.file.resolvePathFn = () => join(logDir, "opencode.log")
2913
log.transports.file.maxSize = 5 * 1024 * 1024
3014
initConsoleTransport()
3115
cleanup()

packages/desktop/src/main/store.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
import Store from "electron-store"
22
import { app } from "electron"
3-
import { dirname, join } from "node:path"
43

54
import { SETTINGS_STORE } from "./constants"
65

76
const cache = new Map<string, Store>()
87

9-
function getPortableDataPath(): string {
10-
if (app.isPackaged) {
11-
const exePath = app.getPath("exe")
12-
const exeDir = dirname(exePath)
13-
return join(exeDir, "data")
14-
}
15-
return app.getPath("userData")
16-
}
17-
188
export function getStore(name = SETTINGS_STORE) {
199
const cached = cache.get(name)
2010
if (cached) return cached
2111
const next = new Store({
2212
name,
23-
cwd: getPortableDataPath(),
13+
cwd: app.getPath("userData"),
2414
fileExtension: "",
2515
accessPropertiesByDotNotation: false,
2616
})

0 commit comments

Comments
 (0)