Skip to content

Commit

Permalink
feat: col, line numbers on mdapi deploy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Oct 5, 2023
1 parent f933129 commit b7f6ee6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
23 changes: 9 additions & 14 deletions src/formatters/deployResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import * as path from 'path';
import { EOL } from 'node:os';
import * as fs from 'fs';
import { ux } from '@oclif/core';
import { DeployResult, FileResponse, FileResponseFailure, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { DeployResult, FileResponse, RequestStatus } from '@salesforce/source-deploy-retrieve';
import { Org, SfError, Lifecycle } from '@salesforce/core';
import { Duration, ensureArray } from '@salesforce/kit';
import { Duration, ensureArray, sortBy } from '@salesforce/kit';
import {
CodeCoverageResult,
CoverageReporter,
Expand Down Expand Up @@ -264,28 +264,23 @@ export class DeployResultFormatter extends TestResultsFormatter implements Forma
if (this.result.response.status === RequestStatus.Succeeded) return;

const failures = this.relativeFiles.filter(isSdrFailure);
// .push returns a number, so push here
failures.push(
...ensureArray(this.result.response.details.componentFailures).map(
(fail) =>
({
problemType: fail.problemType,
fullName: fail.fullName,
error: fail.problem,
} as FileResponseFailure)
)
);
if (!failures.length) return;

const columns = {
problemType: { header: 'Type' },
fullName: { header: 'Name' },
error: { header: 'Problem' },
loc: { header: 'Line:Column' },
};
const options = { title: error(`Component Failures [${failures.length}]`), 'no-truncate': true };
ux.log();
ux.table(
failures.map((f) => ({ problemType: f.problemType, fullName: f.fullName, error: f.error })),
sortBy(failures, ['problemType', 'fullName', 'lineNumber', 'columnNumber', 'error']).map((f) => ({
problemType: f.problemType,
fullName: f.fullName,
error: f.error,
loc: f.lineNumber ? `${f.lineNumber}:${f.columnNumber}` : '',
})),
columns,
options
);
Expand Down
6 changes: 1 addition & 5 deletions test/utils/output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ describe('deployResultFormatter', () => {
{
error: 'This component has some problems',
fullName: 'ProductController',
problemType: 'Error',
},
{
error: 'This component has some problems',
fullName: 'ProductController',
loc: '27:18',
problemType: 'Error',
},
]);
Expand Down

0 comments on commit b7f6ee6

Please sign in to comment.