From 36a52c9bebafe5be845b6a8a9bbb4e37fe1e2309 Mon Sep 17 00:00:00 2001 From: Peter van Gulik Date: Mon, 2 Sep 2024 18:08:57 +0200 Subject: [PATCH] fix: error and warning report for Vlocode CLI deploy action is not consistent --- packages/cli/src/commands/deploy.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/commands/deploy.ts b/packages/cli/src/commands/deploy.ts index d65fcfa7..24d99e34 100644 --- a/packages/cli/src/commands/deploy.ts +++ b/packages/cli/src/commands/deploy.ts @@ -7,7 +7,7 @@ import { stat } from 'fs/promises'; import { Logger, LogLevel, LogManager } from '@vlocode/core'; import { DatapackDeployer, ForkedSassCompiler, DatapackDeploymentOptions } from '@vlocode/vlocity-deploy'; import { DatapackLoader } from '@vlocode/vlocity'; -import { countDistinct, groupBy, mapAsync, Timer } from '@vlocode/util'; +import { groupBy, mapAsync, partition, pluralize, Timer } from '@vlocode/util'; import { Argument, Option } from '../command'; import { SalesforceCommand } from '../salesforceCommand'; @@ -107,17 +107,19 @@ export default class extends SalesforceCommand { // done!! const deploymentMessages = deployment.getMessages().filter(({ type }) => type === 'error' || type === 'warn'); - const recordCount = countDistinct(deploymentMessages, ({ record }) => record?.sourceKey); + const [ errorMessages, warningsMessages ] = partition(deploymentMessages, ({ type }) => type === 'error'); const groupedSortedMessages = Object.entries( - groupBy(deploymentMessages, ({ message }) => message.toLowerCase()) + groupBy(deploymentMessages, ({ message, type }) => message.toLowerCase() + type) ).sort((a,b) => a[0].localeCompare(b[0])); if (groupedSortedMessages.length) { this.logger.warn( `${logSymbols.warning} DataPack deployment completed in ${deployTimer.toString('seconds')} with ${ - groupedSortedMessages.length} unique message(s) on ${recordCount} record(s)`); + pluralize(errorMessages.length, 'error')} and ${ + pluralize(warningsMessages.length, 'warning')}` + ); } else { - this.logger.info(`${logSymbols.success} DataPack deployment completed in ${deployTimer.toString('seconds')}`); + this.logger.info(`${logSymbols.success} DataPack deployment completed in ${deployTimer.toString('seconds')} without errors or warnings`); } for (const [datapack, messages] of Object.entries(deployment.getMessagesByDatapack())) {