66 */
77
88import { envVars as env , EnvironmentVariable } from '@salesforce/core' ;
9- import { MetadataApiDeploy } from '@salesforce/source-deploy-retrieve' ;
9+ import { MetadataApiDeploy , MetadataApiDeployStatus } from '@salesforce/source-deploy-retrieve' ;
1010import { Messages } from '@salesforce/core' ;
1111import { Progress } from '@salesforce/sf-plugins-core' ;
1212
@@ -28,25 +28,14 @@ export class DeployProgress extends Progress {
2828
2929 public start ( ) : void {
3030 super . start ( 0 , { status : 'Waiting' } , DeployProgress . OPTIONS ) ;
31- this . deploy . onUpdate ( ( data ) => {
32- // the numCompTot. isn't computed right away, wait to start until we know how many we have
33- if ( data . numberComponentsTotal ) {
34- this . setTotal ( data . numberComponentsTotal + data . numberTestsTotal ) ;
35- this . update ( data . numberComponentsDeployed + data . numberTestsCompleted , {
36- status : mdTrasferMessages . getMessage ( data . status ) ,
37- } ) ;
38- } else {
39- this . update ( 0 , { status : mdTrasferMessages . getMessage ( data . status ) ?? 'Waiting' } ) ;
40- }
41-
42- // the numTestsTot. isn't computed until validated as tests by the server, update the PB once we know
43- if ( data . numberTestsTotal && data . numberComponentsTotal ) {
44- this . setTotal ( data . numberComponentsTotal + data . numberTestsTotal ) ;
45- }
46- } ) ;
4731
48- // any thing else should stop the progress bar
49- this . deploy . onFinish ( ( data ) => this . finish ( { status : mdTrasferMessages . getMessage ( data . response . status ) } ) ) ;
32+ this . deploy . onUpdate ( ( data ) => this . updateProgress ( data ) ) ;
33+
34+ // any thing else should make one final update, then stop the progress bar
35+ this . deploy . onFinish ( ( data ) => {
36+ this . updateProgress ( data . response ) ;
37+ this . finish ( { status : mdTrasferMessages . getMessage ( data . response . status ) } ) ;
38+ } ) ;
5039
5140 this . deploy . onCancel ( ( ) => this . stop ( ) ) ;
5241
@@ -55,4 +44,21 @@ export class DeployProgress extends Progress {
5544 throw error ;
5645 } ) ;
5746 }
47+
48+ private updateProgress ( data : MetadataApiDeployStatus ) : void {
49+ // the numCompTot. isn't computed right away, wait to start until we know how many we have
50+ if ( data . numberComponentsTotal ) {
51+ this . setTotal ( data . numberComponentsTotal + data . numberTestsTotal ) ;
52+ this . update ( data . numberComponentsDeployed + data . numberTestsCompleted , {
53+ status : mdTrasferMessages . getMessage ( data . status ) ,
54+ } ) ;
55+ } else {
56+ this . update ( 0 , { status : mdTrasferMessages . getMessage ( data . status ) ?? 'Waiting' } ) ;
57+ }
58+
59+ // the numTestsTot. isn't computed until validated as tests by the server, update the PB once we know
60+ if ( data . numberTestsTotal && data . numberComponentsTotal ) {
61+ this . setTotal ( data . numberComponentsTotal + data . numberTestsTotal ) ;
62+ }
63+ }
5864}
0 commit comments