summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeo Goetz <dev@leogtz.de>2026-05-24 06:46:20 +0200
committerLeo Goetz <dev@leogtz.de>2026-05-24 06:46:20 +0200
commitd05bfaf95fb666fea02c8aceae3ce02c9e315d3d (patch)
tree936a69762c0c8275dc458e98a7c224c6049282b8 /src
parentfdc2bc6d47c751377d42ea2581bf249186a5b2e6 (diff)
feat: added types and renamed outputSummary file
Diffstat (limited to 'src')
-rw-r--r--src/actions/output.ts36
-rw-r--r--src/actions/outputSummary.ts20
-rw-r--r--src/commands/check.ts2
-rw-r--r--src/types.ts44
4 files changed, 79 insertions, 23 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);
+}
diff --git a/src/actions/outputSummary.ts b/src/actions/outputSummary.ts
index 6f29a5c..e69de29 100644
--- a/src/actions/outputSummary.ts
+++ b/src/actions/outputSummary.ts
@@ -1,20 +0,0 @@
-import chalk from "chalk";
-import type { Project } from "../types.js";
-
-export function outputSummary(projects: PromiseSettledResult<Project>[]) {
- 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);
-}
diff --git a/src/commands/check.ts b/src/commands/check.ts
index f39b0f8..7f92d7f 100644
--- a/src/commands/check.ts
+++ b/src/commands/check.ts
@@ -1,6 +1,6 @@
import type { Command } from "commander";
import { checkDependencies } from "../actions/checkDependencies.js";
-import { outputSummary } from "../actions/outputSummary.js";
+import { outputSummary } from "../actions/output.js";
import { sendAuditEmail } from "../actions/sendEmail.js";
export const check = (program: Command) => {
diff --git a/src/types.ts b/src/types.ts
index e6871c2..06d60c0 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -17,7 +17,8 @@ export interface Config {
email?: EmailConfig;
}
-export interface Output {
+export interface AuditOutput {
+ error?: string;
auditReportVersion: number;
vulnerabilities: object;
metadata: {
@@ -40,7 +41,46 @@ export interface Output {
};
}
-export interface Project extends Output {
+export interface ProjectAudit extends AuditOutput {
+ status?: string;
+ value?: {};
+ projectName: string;
+}
+
+export interface ProjectFix extends FixOutput {
projectName: string;
+}
+
+export interface FixOutput {
error?: string;
+ add: any[];
+ added: number;
+ audited: number;
+ change: any[];
+ changed: number;
+ funding: number;
+ remove: any[];
+ removed: number;
+ audit: {
+ auditReportVersion: number;
+ vulnerabilities: {};
+ metadata: {
+ vulnerabilities: {
+ info: number;
+ low: number;
+ moderate: number;
+ high: number;
+ critical: number;
+ total: number;
+ };
+ dependencies: {
+ prod: number;
+ dev: number;
+ optional: number;
+ peer: number;
+ peerOptional: number;
+ total: number;
+ };
+ };
+ };
}