import { Config } from "../models/Config"; import { EnvBuilder } from "./EnvBuilder"; export class ConfigBuilder { /** * Builds a full XML config file with all environments and template. */ public static buildFullXml(config: Config): string { const lines: string[] = []; lines.push(""); // Add all environments for (const env of config.envs) { const envXml = new EnvBuilder().buildEnv(env); lines.push(envXml); } // Add template lines.push(" "); lines.push(""); return lines.join("\r\n"); } /** * Generates filename with timestamp: config_yy-dd-MM-HHmm.json.xml */ public static generateFilename(): string { const now = new Date(); const yy = now.getFullYear().toString().slice(-2); const dd = String(now.getDate()).padStart(2, '0'); const MM = String(now.getMonth() + 1).padStart(2, '0'); const HH = String(now.getHours()).padStart(2, '0'); const mm = String(now.getMinutes()).padStart(2, '0'); return `config_${yy}-${dd}-${MM}-${HH}${mm}.json.xml`; } }