import fs from "node:fs";
import path from "node:path";
import { getConfigDir } from "../config/index.js";
export function getE2EDir() {
    return path.join(getConfigDir(), "e2e");
}
export function getE2ERunsDir() {
    return path.join(getE2EDir(), "runs");
}
export function getE2ERunDir(runId) {
    return path.join(getE2ERunsDir(), runId);
}
export function ensureE2ERunDir(runId) {
    const dir = getE2ERunDir(runId);
    fs.mkdirSync(dir, { recursive: true });
    return dir;
}
export function getE2EGuestTokensFile() {
    return path.join(getE2EDir(), "google-guest-tokens.json");
}
export function getE2EOAuthSetupsDir() {
    return path.join(getE2EDir(), "oauth-setups");
}
export function deleteE2ERunDir(runId) {
    const dir = getE2ERunDir(runId);
    if (!fs.existsSync(dir))
        return false;
    fs.rmSync(dir, { recursive: true, force: true });
    return true;
}
export function listRecentRunIds(limit = 10) {
    const runsDir = getE2ERunsDir();
    if (!fs.existsSync(runsDir))
        return [];
    return fs.readdirSync(runsDir, { withFileTypes: true })
        .filter((entry) => entry.isDirectory())
        .map((entry) => ({ name: entry.name, mtime: fs.statSync(path.join(runsDir, entry.name)).mtimeMs }))
        .sort((a, b) => b.mtime - a.mtime)
        .slice(0, limit)
        .map((entry) => entry.name);
}
//# sourceMappingURL=artifacts.js.map