diff options
| author | Leo Goetz <dev@leogtz.de> | 2026-05-24 06:46:20 +0200 |
|---|---|---|
| committer | Leo Goetz <dev@leogtz.de> | 2026-05-24 06:46:20 +0200 |
| commit | d05bfaf95fb666fea02c8aceae3ce02c9e315d3d (patch) | |
| tree | 936a69762c0c8275dc458e98a7c224c6049282b8 /src/actions/output.ts | |
| parent | fdc2bc6d47c751377d42ea2581bf249186a5b2e6 (diff) | |
feat: added types and renamed outputSummary file
Diffstat (limited to 'src/actions/output.ts')
| -rw-r--r-- | src/actions/output.ts | 36 |
1 files changed, 36 insertions, 0 deletions
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<ProjectAudit>[]) { + 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<ProjectFix>[]) { + 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); +} |
