"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/src/lib/formatters/show-fix-tip.ts" (20 Feb 2024, 1009 Bytes) of package /linux/misc/snyk-cli-1.1280.1.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 from 'chalk';
    2 
    3 import { isLocalFolder } from '../detect';
    4 import { TestResult } from '../snyk-test/legacy';
    5 import { Options, SupportedProjectTypes, TestOptions } from '../types';
    6 
    7 export function showFixTip(
    8   projectType: SupportedProjectTypes,
    9   res: TestResult,
   10   options: TestOptions & Options,
   11 ): string {
   12   const snykFixSupported: SupportedProjectTypes[] = ['pip', 'poetry'];
   13   if (!snykFixSupported.includes(projectType) || !isLocalFolder(options.path)) {
   14     return '';
   15   }
   16 
   17   if (!res.ok && res.vulnerabilities.length > 0) {
   18     return (
   19       `Tip: Try ${chalk.bold(
   20         '`snyk fix`',
   21       )} to address these issues.${chalk.bold(
   22         '`snyk fix`',
   23       )} is a new CLI command in that aims to automatically apply the recommended updates for supported ecosystems.` +
   24       '\nSee documentation on how to enable this beta feature: https://docs.snyk.io/snyk-cli/fix-vulnerabilities-from-the-cli/automatic-remediation-with-snyk-fix#enabling-snyk-fix'
   25     );
   26   }
   27 
   28   return '';
   29 }