// WHERE AN ARTICLE'S VIDEO PROJECTS LIVE when settings.generation.projectsRoot // is blank: `/articles` when REPORTS_DIR is set — a container // sets it to its reports volume (/data/reports, Dockerfile), so a fresh // container's projects land on the volume and not in its writable layer — // else `~/reports/articles`, the host default since release 27 S6 (demo epic // D1 item 3; D0 found a container's projects outside the reports volume). // // Plain JS (with JSDoc) so umtool's plain-node chain planner // (umtool/lib/report/chain.mjs) reads the same rule as the editor's TS. import os from "node:os"; import path from "node:path"; /** * @param {Record} [env] * @returns {string} */ export function defaultProjectsRoot(env = process.env) { const reports = env.REPORTS_DIR?.trim(); if (reports) return path.join(path.resolve(/* turbopackIgnore: true */ reports), "articles"); return path.join(/* turbopackIgnore: true */ os.homedir(), "reports", "articles"); } /** `~` and `~/` expanded against the home directory. */ export function expandHomeDir(p) { return p === "~" ? os.homedir() : p.startsWith("~/") ? path.join(os.homedir(), p.slice(2)) : p; } /** * The projects root a settings value names: `~` expanded; blank = the default. * @param {unknown} configured settings.generation.projectsRoot * @param {Record} [env] */ export function projectsRootFrom(configured, env = process.env) { if (typeof configured !== "string" || !configured.trim()) return defaultProjectsRoot(env); return expandHomeDir(configured.trim()); }