From d05bfaf95fb666fea02c8aceae3ce02c9e315d3d Mon Sep 17 00:00:00 2001 From: Leo Goetz Date: Sun, 24 May 2026 06:46:20 +0200 Subject: feat: added types and renamed outputSummary file --- src/actions/output.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/actions/output.ts (limited to 'src/actions/output.ts') diff --git a/src/actions/output.ts b/src/actions/output.ts new file mode 100644 index 0000000..348cb8e --- /dev/null +++ b/src/actions/output.ts @@ -0,0 +1,36 @@ +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); +} -- cgit v1.3.1