Skip to content

Commit

Permalink
fix: error and warning report for Vlocode CLI deploy action is not co…
Browse files Browse the repository at this point in the history
…nsistent
  • Loading branch information
Codeneos committed Sep 2, 2024
1 parent ef1a01b commit 36a52c9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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())) {
Expand Down

0 comments on commit 36a52c9

Please sign in to comment.