mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 20:32:20 +03:00
Turbopack (Next.js 15) does not process node: URL prefixes correctly when
bundling server-side files that get transitively included. Removed the node:
prefix from 17 files:
- src/lib/db/migrationRunner.ts (node:fs, node:path, node:url)
- src/lib/db/core.ts (node:path, node:fs)
- src/lib/db/backup.ts (node:path, node:fs)
- src/lib/db/prompts.ts (node:fs)
- src/lib/dataPaths.ts (node:path, node:os)
- src/app/api/settings/route.ts
- src/app/api/storage/health/route.ts
- src/app/api/oauth/[provider]/[action]/route.ts
- src/app/api/db-backups/{exportAll,import,export}/route.ts
- src/shared/middleware/correlationId.ts
- src/shared/utils/requestId.ts
- src/lib/apiBridgeServer.ts
- src/lib/cacheLayer.ts
- src/lib/semanticCache.ts
- src/lib/oauth/providers/kimi-coding.ts
Also updated generate-release.md: Docker Hub sync and dual-VPS deploy
are now mandatory steps in every release.
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import path from "path";
|
|
import os from "os";
|
|
|
|
export const APP_NAME = "omniroute";
|
|
|
|
function safeHomeDir() {
|
|
try {
|
|
return os.homedir();
|
|
} catch {
|
|
return process.cwd();
|
|
}
|
|
}
|
|
|
|
function normalizeConfiguredPath(dir: unknown): string | null {
|
|
if (typeof dir !== "string") return null;
|
|
const trimmed = dir.trim();
|
|
if (!trimmed) return null;
|
|
return path.resolve(trimmed);
|
|
}
|
|
|
|
export function getLegacyDotDataDir() {
|
|
return path.join(safeHomeDir(), `.${APP_NAME}`);
|
|
}
|
|
|
|
export function getDefaultDataDir() {
|
|
const homeDir = safeHomeDir();
|
|
|
|
if (process.platform === "win32") {
|
|
const appData = process.env.APPDATA || path.join(homeDir, "AppData", "Roaming");
|
|
return path.join(appData, APP_NAME);
|
|
}
|
|
|
|
// Support XDG on Linux/macOS when explicitly configured.
|
|
const xdgConfigHome = normalizeConfiguredPath(process.env.XDG_CONFIG_HOME);
|
|
if (xdgConfigHome) {
|
|
return path.join(xdgConfigHome, APP_NAME);
|
|
}
|
|
|
|
return getLegacyDotDataDir();
|
|
}
|
|
|
|
export function resolveDataDir({ isCloud = false }: { isCloud?: boolean } = {}): string {
|
|
if (isCloud) return "/tmp";
|
|
|
|
const configured = normalizeConfiguredPath(process.env.DATA_DIR);
|
|
if (configured) return configured;
|
|
|
|
return getDefaultDataDir();
|
|
}
|
|
|
|
export function isSamePath(a: string | null | undefined, b: string | null | undefined): boolean {
|
|
if (!a || !b) return false;
|
|
const normalizedA = path.resolve(a);
|
|
const normalizedB = path.resolve(b);
|
|
|
|
if (process.platform === "win32") {
|
|
return normalizedA.toLowerCase() === normalizedB.toLowerCase();
|
|
}
|
|
|
|
return normalizedA === normalizedB;
|
|
}
|