fix: use owner-level unidesk state

This commit is contained in:
Codex
2026-07-10 05:09:13 +02:00
parent 01ff35d0f8
commit fbd9dbbae1
48 changed files with 133 additions and 148 deletions
+8 -1
View File
@@ -1,5 +1,6 @@
import { existsSync, readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { homedir } from "node:os";
import { dirname, isAbsolute, join } from "node:path";
import { fileURLToPath } from "node:url";
export interface UniDeskConfig {
@@ -101,8 +102,14 @@ export interface UniDeskMicroserviceConfig {
const moduleDir = dirname(fileURLToPath(import.meta.url));
export const repoRoot = join(moduleDir, "..", "..");
export const stateRoot = join(homedir(), ".unidesk", ".state");
export function rootPath(...parts: string[]): string {
const first = parts[0];
if (first === undefined) return repoRoot;
if (isAbsolute(first)) return join(first, ...parts.slice(1));
if (first === ".state") return join(stateRoot, ...parts.slice(1));
if (first.startsWith(".state/")) return join(stateRoot, first.slice(".state/".length), ...parts.slice(1));
return join(repoRoot, ...parts);
}