#!/usr/bin/env node

import { resolve, dirname } from "path";
import { fileURLToPath } from "url";
import { homedir } from "os";
import { existsSync, mkdirSync } from "fs";

const __dirname = dirname(fileURLToPath(import.meta.url));

// Project root (where package.json lives)
export const PROJECT_ROOT = resolve(__dirname, "..");

// User data directory (~/.arouter/)
export const DATA_DIR = resolve(homedir(), ".arouter");

// Ensure data dir exists
if (!existsSync(DATA_DIR)) mkdirSync(DATA_DIR, { recursive: true });

// Files in data dir
export const PID_FILE = resolve(DATA_DIR, "arouter.pid");
export const LOG_FILE = resolve(DATA_DIR, "arouter.log");
export const PORT = 20129;
export const DASHBOARD_URL = `http://localhost:${PORT}`;
