feat: expand secure runtime and workspace UX

This commit is contained in:
lofyer
2026-08-04 00:57:08 +08:00
parent 09e9fbf5e2
commit 2910d315f7
56 changed files with 6164 additions and 882 deletions
+34
View File
@@ -0,0 +1,34 @@
import { readFileSync, statSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
const portableMarkerName = '.goodbuddy-portable.json'
export function resolvePortableUserDataPath(input: {
packaged: boolean
platform: NodeJS.Platform
executablePath: string
}): string | undefined {
if (!input.packaged || input.platform !== 'win32') {
return undefined
}
const executableDirectory = dirname(resolve(input.executablePath))
const markerPath = join(executableDirectory, portableMarkerName)
try {
const markerFile = statSync(markerPath)
if (!markerFile.isFile() || markerFile.size > 4_096) {
return undefined
}
const marker = JSON.parse(
readFileSync(markerPath, 'utf8')
) as Record<string, unknown>
if (
marker.formatVersion !== 1 ||
marker.productName !== 'GoodBuddy'
) {
return undefined
}
return join(executableDirectory, 'data')
} catch {
return undefined
}
}