import chalk from "chalk"; import type { ProjectAudit, ProjectFix } from "../types.js"; export function outputSummary(projects: PromiseSettledResult[]) { const text = ` This is what i found: ${projects.map((project: any) => { if (project.status === "fulfilled") { let projectVulnerabilities = project.value.metadata.vulnerabilities.total; return ` ${project.value.projectName} has ${projectVulnerabilities > 0 ? chalk.bold.red(projectVulnerabilities) : chalk.bold.green(projectVulnerabilities)} Security Issues`; } return ` ${chalk.bold.yellow("WARN:")} ${project.reason}`; })} `; console.log(text); } export function outputFixes(fixes: PromiseSettledResult[]) { const text = ` This is what i found: ${fixes.map((project) => { if (project.status === "fulfilled") { return ` ${project.value.projectName} got fixed, added ${chalk.green(project.value.added)}, removed ${chalk.green(project.value.removed)} and changed ${chalk.green(project.value.changed)}`; } return ` ${chalk.red(project.reason)}`; })} `; console.log(text); }