"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/packages/snyk-fix/src/plugins/python/handlers/poetry/index.ts" (20 Feb 2024, 1277 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 * as debugLib from 'debug';
    2 import * as ora from 'ora';
    3 
    4 import { EntityToFix, FixOptions } from '../../../../types';
    5 import { checkPackageToolSupported } from '../../../package-tool-supported';
    6 import { PluginFixResponse } from '../../../types';
    7 import { updateDependencies } from './update-dependencies';
    8 
    9 const debug = debugLib('snyk-fix:python:Poetry');
   10 
   11 export async function poetry(
   12   fixable: EntityToFix[],
   13   options: FixOptions,
   14 ): Promise<PluginFixResponse> {
   15   debug(`Preparing to fix ${fixable.length} Python Poetry projects`);
   16   const handlerResult: PluginFixResponse = {
   17     succeeded: [],
   18     failed: [],
   19     skipped: [],
   20   };
   21 
   22   await checkPackageToolSupported('poetry', options);
   23   for (const [index, entity] of fixable.entries()) {
   24     const spinner = ora({ isSilent: options.quiet, stream: process.stdout });
   25     const spinnerMessage = `Fixing pyproject.toml ${index + 1}/${
   26       fixable.length
   27     }`;
   28     spinner.text = spinnerMessage;
   29     spinner.start();
   30 
   31     const { failed, succeeded, skipped } = await updateDependencies(
   32       entity,
   33       options,
   34     );
   35     handlerResult.succeeded.push(...succeeded);
   36     handlerResult.failed.push(...failed);
   37     handlerResult.skipped.push(...skipped);
   38     spinner.stop();
   39   }
   40 
   41   return handlerResult;
   42 }