From 8fd823d2af4ebbcea00b159c399711692135c3e0 Mon Sep 17 00:00:00 2001 From: Francesco Mari Date: Wed, 5 Oct 2022 12:37:55 +0200 Subject: [PATCH] feat: use short link to the Integrated IaC docs --- src/lib/iac/test/v2/output.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/lib/iac/test/v2/output.ts b/src/lib/iac/test/v2/output.ts index e61658a8b6..df04e601bb 100644 --- a/src/lib/iac/test/v2/output.ts +++ b/src/lib/iac/test/v2/output.ts @@ -33,6 +33,7 @@ import { colors, contentPadding, } from '../../../formatters/iac-output/text/utils'; +import * as wrapAnsi from 'wrap-ansi'; export function buildOutput({ scanResult, @@ -188,24 +189,22 @@ function buildTextOutput({ response += EOL; response += colors.title('Info') + EOL; response += EOL; - response += - contentPadding + - `Your organization ${orgSettings.meta.org} is using Integrated IaC. To switch to Current IaC,` + - EOL; - response += - contentPadding + - `use --org= to select a different organization. For more information about Integrated IaC, see:` + - EOL; - response += EOL; - response += - contentPadding + - contentPadding + - 'https://docs.snyk.io/products/snyk-infrastructure-as-code/snyk-cli-for-infrastructure-as-code/integrated-infrastructure-as-code' + - EOL; + response += wrapWithPadding(infoMessage(orgSettings), 80) + EOL; return response; } +function wrapWithPadding(s: string, columns: number): string { + return wrapAnsi(s, columns) + .split('\n') + .map((s) => contentPadding + s) + .join('\n'); +} + +function infoMessage(orgSettings: IacOrgSettings): string { + return `Your organization ${orgSettings.meta.org} is using Integrated IaC. To switch to Current IaC, use --org= to select a different organization. For more information about Integrated IaC, see https://snyk.co/integrated-iac.`; +} + function assertHasSuccessfulScans( scanResult: TestOutput, responseData: Omit,