77import os from 'node:os' ;
88import { MultiStageOutput } from '@oclif/multi-stage-output' ;
99import { Lifecycle , Messages } from '@salesforce/core' ;
10- import {
11- Failures ,
12- MetadataApiDeploy ,
13- MetadataApiDeployStatus ,
14- RequestStatus ,
15- Successes ,
16- } from '@salesforce/source-deploy-retrieve' ;
10+ import { MetadataApiDeploy , MetadataApiDeployStatus , RequestStatus } from '@salesforce/source-deploy-retrieve' ;
1711import { SourceMemberPollingEvent } from '@salesforce/source-tracking' ;
1812import terminalLink from 'terminal-link' ;
1913import { ensureArray } from '@salesforce/kit' ;
2014import ansis from 'ansis' ;
21- import { getZipFileSize } from './output.js' ;
15+ import { testResultSort } from '../formatters/testResultsFormatter.js' ;
16+ import { check , getZipFileSize } from './output.js' ;
2217import { isTruthy } from './types.js' ;
2318
2419Messages . importMessagesDirectoryFromMetaUrl ( import . meta. url ) ;
@@ -27,6 +22,7 @@ const mdTransferMessages = Messages.loadMessages('@salesforce/plugin-deploy-retr
2722type Options = {
2823 title : string ;
2924 jsonEnabled : boolean ;
25+ verbose ?: boolean ;
3026} ;
3127
3228type Data = {
@@ -58,7 +54,7 @@ function formatProgress(current: number, total: number): string {
5854export class DeployStages {
5955 private mso : MultiStageOutput < Data > ;
6056
61- public constructor ( { title, jsonEnabled } : Options ) {
57+ public constructor ( { title, jsonEnabled, verbose } : Options ) {
6258 this . mso = new MultiStageOutput < Data > ( {
6359 title,
6460 stages : [
@@ -142,7 +138,8 @@ export class DeployStages {
142138 label : 'Successful' ,
143139 get : ( data ) : string | undefined =>
144140 data ?. mdapiDeploy ?. numberTestsTotal && data ?. mdapiDeploy ?. numberTestsCompleted
145- ? formatProgress ( data ?. mdapiDeploy ?. numberTestsCompleted , data ?. mdapiDeploy ?. numberTestsTotal )
141+ ? formatProgress ( data ?. mdapiDeploy ?. numberTestsCompleted , data ?. mdapiDeploy ?. numberTestsTotal ) +
142+ ( verbose && isCI ( ) ? os . EOL + formatTestSuccesses ( data ) : '' )
146143 : undefined ,
147144 stage : 'Running Tests' ,
148145 type : 'dynamic-key-value' ,
@@ -152,7 +149,7 @@ export class DeployStages {
152149 get : ( data ) : string | undefined =>
153150 data ?. mdapiDeploy ?. numberTestsTotal && data ?. mdapiDeploy ?. numberTestErrors
154151 ? formatProgress ( data ?. mdapiDeploy ?. numberTestErrors , data ?. mdapiDeploy ?. numberTestsTotal ) +
155- ( isTruthy ( process . env . CI ) ? os . EOL + formatTestFailures ( data ) : '' )
152+ ( isCI ( ) ? os . EOL + formatTestFailures ( data ) : '' )
156153 : undefined ,
157154 stage : 'Running Tests' ,
158155 type : 'dynamic-key-value' ,
@@ -253,8 +250,22 @@ export class DeployStages {
253250 }
254251}
255252
253+ function formatTestSuccesses ( data : Data ) : string {
254+ const successes = ensureArray ( data . mdapiDeploy . details . runTestResult ?. successes ) . sort ( testResultSort ) ;
255+
256+ let output = '' ;
257+
258+ if ( successes . length > 0 ) {
259+ for ( const test of successes ) {
260+ const testName = ansis . underline ( `${ test . name } .${ test . methodName } ` ) ;
261+ output += ` ${ check } ${ testName } ${ os . EOL } ` ;
262+ }
263+ }
264+
265+ return output ;
266+ }
267+
256268function formatTestFailures ( data : Data ) : string {
257- if ( data . mdapiDeploy . details . runTestResult ?. failures === undefined ) return '' ;
258269 const failures = ensureArray ( data . mdapiDeploy . details . runTestResult ?. failures ) . sort ( testResultSort ) ;
259270
260271 let output = '' ;
@@ -273,5 +284,14 @@ function formatTestFailures(data: Data): string {
273284 return output . slice ( 0 , - 1 ) ;
274285}
275286
276- const testResultSort = < T extends Successes | Failures > ( a : T , b : T ) : number =>
277- a . methodName === b . methodName ? a . name . localeCompare ( b . name ) : a . methodName . localeCompare ( b . methodName ) ;
287+ export function isCI ( ) : boolean {
288+ if (
289+ isTruthy ( process . env . CI ) &&
290+ ( 'CI' in process . env ||
291+ 'CONTINUOUS_INTEGRATION' in process . env ||
292+ Object . keys ( process . env ) . some ( ( key ) => key . startsWith ( 'CI_' ) ) )
293+ )
294+ return true ;
295+
296+ return false ;
297+ }
0 commit comments