77
88import ansis from 'ansis' ;
99import { EnvironmentVariable , Lifecycle , Messages , OrgConfigProperties , SfError } from '@salesforce/core' ;
10- import { DeployVersionData } from '@salesforce/source-deploy-retrieve' ;
10+ import { type DeployVersionData , DeployZipData } from '@salesforce/source-deploy-retrieve' ;
1111import { Duration } from '@salesforce/kit' ;
1212import { SfCommand , toHelpSection , Flags } from '@salesforce/sf-plugins-core' ;
1313import { SourceConflictError } from '@salesforce/source-tracking' ;
1414import { AsyncDeployResultFormatter } from '../../../formatters/asyncDeployResultFormatter.js' ;
1515import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js' ;
16+ import { AsyncDeployResultJson , DeployResultJson , TestLevel } from '../../../utils/types.js' ;
1617import { DeployProgress } from '../../../utils/progressBar.js' ;
17- import { DeployResultJson , TestLevel } from '../../../utils/types.js' ;
1818import { executeDeploy , resolveApi , validateTests , determineExitCode } from '../../../utils/deploy.js' ;
1919import { DeployCache } from '../../../utils/deployCache.js' ;
2020import { DEPLOY_STATUS_CODES_DESCRIPTIONS } from '../../../utils/errorCodes.js' ;
2121import { ConfigVars } from '../../../configMeta.js' ;
2222import { coverageFormattersFlag , fileOrDirFlag , testLevelFlag , testsFlag } from '../../../utils/flags.js' ;
2323import { writeConflictTable } from '../../../utils/conflicts.js' ;
2424import { getOptionalProject } from '../../../utils/project.js' ;
25+ import { getZipFileSize } from '../../../utils/output.js' ;
2526
2627Messages . importMessagesDirectoryFromMetaUrl ( import . meta. url ) ;
2728const messages = Messages . loadMessages ( '@salesforce/plugin-deploy-retrieve' , 'deploy.metadata' ) ;
@@ -176,6 +177,9 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
176177
177178 public static errorCodes = toHelpSection ( 'ERROR CODES' , DEPLOY_STATUS_CODES_DESCRIPTIONS ) ;
178179
180+ private zipSize ?: number ;
181+ private zipFileCount ?: number ;
182+
179183 public async run ( ) : Promise < DeployResultJson > {
180184 const { flags } = await this . parse ( DeployMetadata ) ;
181185 const project = await getOptionalProject ( ) ;
@@ -214,6 +218,16 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
214218 ) ;
215219 } ) ;
216220
221+ // eslint-disable-next-line @typescript-eslint/require-await
222+ Lifecycle . getInstance ( ) . on ( 'deployZipData' , async ( zipData : DeployZipData ) => {
223+ this . zipSize = zipData . zipSize ;
224+ if ( flags . verbose && this . zipSize ) this . log ( `Deploy size: ${ getZipFileSize ( this . zipSize ) } of ~39 MB limit` ) ;
225+ if ( zipData . zipFileCount ) {
226+ this . zipFileCount = zipData . zipFileCount ;
227+ if ( flags . verbose && this . zipSize ) this . log ( `Deployed files count: ${ this . zipFileCount } of 10,000 limit` ) ;
228+ }
229+ } ) ;
230+
217231 const { deploy } = await executeDeploy (
218232 {
219233 ...flags ,
@@ -239,7 +253,8 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
239253 }
240254 const asyncFormatter = new AsyncDeployResultFormatter ( deploy . id ) ;
241255 if ( ! this . jsonEnabled ( ) ) asyncFormatter . display ( ) ;
242- return asyncFormatter . getJson ( ) ;
256+
257+ return this . mixinZipMeta ( await asyncFormatter . getJson ( ) ) ;
243258 }
244259
245260 new DeployProgress ( deploy , this . jsonEnabled ( ) ) . start ( ) ;
@@ -255,7 +270,7 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
255270
256271 await DeployCache . update ( deploy . id , { status : result . response . status } ) ;
257272
258- return formatter . getJson ( ) ;
273+ return this . mixinZipMeta ( await formatter . getJson ( ) ) ;
259274 }
260275
261276 protected catch ( error : Error | SfError ) : Promise < never > {
@@ -281,4 +296,14 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
281296 }
282297 return super . catch ( error ) ;
283298 }
299+
300+ private mixinZipMeta ( json : AsyncDeployResultJson | DeployResultJson ) : AsyncDeployResultJson | DeployResultJson {
301+ if ( this . zipSize ) {
302+ json . zipSize = this . zipSize ;
303+ }
304+ if ( this . zipFileCount ) {
305+ json . zipFileCount = this . zipFileCount ;
306+ }
307+ return json ;
308+ }
284309}
0 commit comments