Skip to content

Commit c886c3b

Browse files
authored
Merge pull request #623 from salesforcecli/wr/printDeployErrors
fix: print errors from server
2 parents 1c97017 + 8d77997 commit c886c3b

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/formatters/deployResultFormatter.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ import * as path from 'path';
99
import * as fs from 'fs';
1010
import { ux } from '@oclif/core';
1111
import { dim, underline, bold } from 'chalk';
12-
import { DeployResult, Failures, FileResponse, RequestStatus, Successes } from '@salesforce/source-deploy-retrieve';
12+
import {
13+
DeployResult,
14+
Failures,
15+
FileResponse,
16+
FileResponseFailure,
17+
RequestStatus,
18+
Successes,
19+
} from '@salesforce/source-deploy-retrieve';
1320
import { Org, SfError } from '@salesforce/core';
1421
import { ensureArray } from '@salesforce/kit';
1522
import {
@@ -234,6 +241,17 @@ export class DeployResultFormatter implements Formatter<DeployResultJson> {
234241
if (this.result.response.status === RequestStatus.Succeeded) return;
235242

236243
const failures = this.relativeFiles.filter(isSdrFailure);
244+
// .push returns a number, so push here
245+
failures.push(
246+
...ensureArray(this.result.response.details.componentFailures).map(
247+
(fail) =>
248+
({
249+
problemType: fail.problemType,
250+
fullName: fail.fullName,
251+
error: fail.problem,
252+
} as FileResponseFailure)
253+
)
254+
);
237255
if (!failures.length) return;
238256

239257
const columns = {

test/utils/output.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as path from 'path';
88
import { assert, expect, config } from 'chai';
99
import * as sinon from 'sinon';
1010
import { DeployResult } from '@salesforce/source-deploy-retrieve';
11+
import { ux } from '@oclif/core';
1112
import { getCoverageFormattersOptions } from '../../src/utils/coverage';
1213
import { DeployResultFormatter } from '../../src/formatters/deployResultFormatter';
1314
import { getDeployResult } from './deployResponses';
@@ -21,6 +22,29 @@ describe('deployResultFormatter', () => {
2122
sandbox.restore();
2223
});
2324

25+
describe('displayFailures', () => {
26+
const deployResultFailure = getDeployResult('failed');
27+
const tableStub = sandbox.stub(ux, 'table');
28+
29+
it('prints file responses, and messages from server', () => {
30+
const formatter = new DeployResultFormatter(deployResultFailure, { verbose: true });
31+
formatter.display();
32+
expect(tableStub.callCount).to.equal(1);
33+
expect(tableStub.firstCall.args[0]).to.deep.equal([
34+
{
35+
error: 'This component has some problems',
36+
fullName: 'ProductController',
37+
problemType: 'Error',
38+
},
39+
{
40+
error: 'This component has some problems',
41+
fullName: 'ProductController',
42+
problemType: 'Error',
43+
},
44+
]);
45+
});
46+
});
47+
2448
describe('coverage functions', () => {
2549
describe('getCoverageFormattersOptions', () => {
2650
it('clover, json', () => {

0 commit comments

Comments
 (0)