import chalk from "chalk"; import { DeletedEndpointInfo } from "../models/import.model"; import { getMethodChalkColor } from "./httpMethodColor"; const METHOD_HEADER = "Method"; const PATH_HEADER = "Path"; const TITLE_HEADER = "Title"; const COLUMN_GAP = 2; export function printDeletedEndpoints(endpoints: DeletedEndpointInfo[]): void { if (!endpoints || endpoints.length === 0) { return; } const methodWidth = Math.max( METHOD_HEADER.length, ...endpoints.map((e) => (e.method ?? "").length), ); const pathWidth = Math.max( PATH_HEADER.length, ...endpoints.map((e) => (e.path ?? "").length), ); const gap = " ".repeat(COLUMN_GAP); const header = chalk.bold(METHOD_HEADER.padEnd(methodWidth)) + gap + chalk.bold(PATH_HEADER.padEnd(pathWidth)) + gap + chalk.bold(TITLE_HEADER); console.log(""); console.log(header); for (const endpoint of endpoints) { const method = (endpoint.method ?? "").toUpperCase(); const colored = getMethodChalkColor(method); const methodCell = colored(method.padEnd(methodWidth)); const pathCell = (endpoint.path ?? "").padEnd(pathWidth); const titleCell = endpoint.title ?? ""; console.log(`${methodCell}${gap}${pathCell}${gap}${titleCell}`); } console.log(""); }