"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1260.0/src/lib/formatters/iac-output/text/utils.ts" (4 Dec 2023, 1037 Bytes) of package /linux/misc/snyk-cli-1.1260.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import chalk, { Chalk } from 'chalk';
    2 import { SEVERITY } from '../../../snyk-test/common';
    3 
    4 interface IacOutputColors {
    5   severities: SeverityColor;
    6   failure: Chalk;
    7   warning: Chalk;
    8   success: Chalk;
    9   info: Chalk;
   10   title: Chalk;
   11   suggestion: Chalk;
   12 }
   13 
   14 type SeverityColor = {
   15   [severity in SEVERITY]: Chalk;
   16 };
   17 
   18 export const colors: IacOutputColors = {
   19   severities: {
   20     critical: chalk.magenta,
   21     high: chalk.red,
   22     medium: chalk.yellow,
   23     low: chalk.reset,
   24   },
   25   failure: chalk.red,
   26   warning: chalk.yellow,
   27   success: chalk.green,
   28   info: chalk.reset,
   29   title: chalk.reset.bold,
   30   suggestion: chalk.gray,
   31 };
   32 
   33 export const contentPadding = ' '.repeat(2);
   34 
   35 export const maxLineWidth = process.stdout.columns
   36   ? Math.min(process.stdout.columns, 80)
   37   : 80;
   38 
   39 export const countSuppressedIssues = (
   40   suppressedIssues: Record<string, string[]>,
   41 ): number => {
   42   return Object.values(suppressedIssues).reduce(function(
   43     count,
   44     resourcesForRuleId,
   45   ) {
   46     return (count += resourcesForRuleId.length);
   47   },
   48   0);
   49 };