@@ -8,7 +8,7 @@ import * as os from 'os';
88import * as path from 'path' ;
99import { flags , FlagsConfig } from '@salesforce/command' ;
1010import { Lifecycle , Messages } from '@salesforce/core' ;
11- import { SourceDeployResult } from '@salesforce/source-deploy-retrieve' ;
11+ import { DeployResult } from '@salesforce/source-deploy-retrieve' ;
1212import { Duration } from '@salesforce/kit' ;
1313import { asString , asArray } from '@salesforce/ts-types' ;
1414import * as chalk from 'chalk' ;
@@ -26,7 +26,6 @@ export class deploy extends SourceCommand {
2626 checkonly : flags . boolean ( {
2727 char : 'c' ,
2828 description : messages . getMessage ( 'flags.checkonly' ) ,
29- default : false ,
3029 } ) ,
3130 wait : flags . minutes ( {
3231 char : 'w' ,
@@ -48,12 +47,10 @@ export class deploy extends SourceCommand {
4847 ignoreerrors : flags . boolean ( {
4948 char : 'o' ,
5049 description : messages . getMessage ( 'flags.ignoreErrors' ) ,
51- default : false ,
5250 } ) ,
5351 ignorewarnings : flags . boolean ( {
5452 char : 'g' ,
5553 description : messages . getMessage ( 'flags.ignoreWarnings' ) ,
56- default : false ,
5754 } ) ,
5855 validateddeployrequestid : flags . id ( {
5956 char : 'q' ,
@@ -90,7 +87,7 @@ export class deploy extends SourceCommand {
9087 } ;
9188 protected readonly lifecycleEventNames = [ 'predeploy' , 'postdeploy' ] ;
9289
93- public async run ( ) : Promise < SourceDeployResult > {
90+ public async run ( ) : Promise < DeployResult > {
9491 if ( this . flags . validatedeployrequestid ) {
9592 // TODO: return this.doDeployRecentValidation();
9693 }
@@ -104,88 +101,82 @@ export class deploy extends SourceCommand {
104101
105102 await hookEmitter . emit ( 'predeploy' , { packageXmlPath : cs . getPackageXml ( ) } ) ;
106103
107- const results = await cs . deploy ( this . org . getUsername ( ) , {
108- wait : ( this . flags . wait as Duration ) . milliseconds ,
109- apiOptions : {
110- // TODO: build out more api options
111- checkOnly : this . flags . checkonly as boolean ,
112- ignoreWarnings : this . flags . ignorewarnings as boolean ,
113- runTests : this . flags . runtests as string [ ] ,
114- } ,
115- } ) ;
116-
104+ const results = await cs
105+ . deploy ( {
106+ usernameOrConnection : this . org . getUsername ( ) ,
107+ } )
108+ . start ( ) ;
117109 await hookEmitter . emit ( 'postdeploy' , results ) ;
118110
119- this . print ( results ) ;
111+ // skip a lot of steps that would do nothing
112+ if ( ! this . flags . json ) {
113+ this . print ( results ) ;
114+ }
120115
121116 return results ;
122117 }
123118
124- private printComponentFailures ( result : SourceDeployResult ) : void {
125- if ( result . status === 'Failed' && result . components ) {
119+ private printComponentFailures ( result : DeployResult ) : void {
120+ if ( result . response . status === 'Failed' && result . components ) {
126121 // sort by filename then fullname
127- const failures = result . components . sort ( ( i , j ) => {
128- if ( i . component . type . directoryName === j . component . type . directoryName ) {
122+ const failures = result . getFileResponses ( ) . sort ( ( i , j ) => {
123+ if ( i . filePath === j . filePath ) {
129124 // if the have the same directoryName then sort by fullName
130- return i . component . fullName < j . component . fullName ? 1 : - 1 ;
125+ return i . fullName < j . fullName ? 1 : - 1 ;
131126 }
132- return i . component . type . directoryName < j . component . type . directoryName ? 1 : - 1 ;
127+ return i . filePath < j . filePath ? 1 : - 1 ;
133128 } ) ;
134129 this . ux . log ( '' ) ;
135130 this . ux . styledHeader ( chalk . red ( `Component Failures [${ failures . length } ]` ) ) ;
136131 this . ux . table ( failures , {
137- // TODO: these accessors are temporary until library JSON fixes
138132 columns : [
139- { key : 'component.type.name ' , label : 'Type' } ,
140- { key : 'diagnostics[0].filePath ' , label : 'File' } ,
141- { key : 'component.name ' , label : 'Name' } ,
142- { key : 'diagnostics[0].message ' , label : 'Problem' } ,
133+ { key : 'componentType ' , label : 'Type' } ,
134+ { key : 'fileName ' , label : 'File' } ,
135+ { key : 'fullName ' , label : 'Name' } ,
136+ { key : 'problem ' , label : 'Problem' } ,
143137 ] ,
144138 } ) ;
145139 this . ux . log ( '' ) ;
146140 }
147141 }
148142
149- private printComponentSuccess ( result : SourceDeployResult ) : void {
150- if ( result . success && result . components ) {
151- if ( result . components . length > 0 ) {
152- // sort by type then filename then fullname
153- const files = result . components . sort ( ( i , j ) => {
154- if ( i . component . type . name === j . component . type . name ) {
155- // same metadata type, according to above comment sort on filename
156- if ( i . component . type . directoryName === j . component . type . directoryName ) {
157- // same filename's according to comment sort by fullName
158- return i . component . fullName < j . component . fullName ? 1 : - 1 ;
159- }
160- return i . component . type . directoryName < j . component . type . directoryName ? 1 : - 1 ;
143+ private printComponentSuccess ( result : DeployResult ) : void {
144+ if ( result . response . success && result . components ?. size ) {
145+ // sort by type then filename then fullname
146+ const files = result . getFileResponses ( ) . sort ( ( i , j ) => {
147+ if ( i . fullName === j . fullName ) {
148+ // same metadata type, according to above comment sort on filename
149+ if ( i . filePath === j . filePath ) {
150+ // same filename's according to comment sort by fullName
151+ return i . fullName < j . fullName ? 1 : - 1 ;
161152 }
162- return i . component . type . name < j . component . type . name ? 1 : - 1 ;
163- } ) ;
164- // get relative path for table output
165- files . forEach ( ( file ) => {
166- if ( file . component . content ) {
167- file . component . content = path . relative ( process . cwd ( ) , file . component . content ) ;
168- }
169- } ) ;
170- this . ux . log ( '' ) ;
171- this . ux . styledHeader ( chalk . blue ( 'Deployed Source' ) ) ;
172- this . ux . table ( files , {
173- // TODO: these accessors are temporary until library JSON fixes
174- columns : [
175- { key : 'component.name' , label : 'FULL NAME' } ,
176- { key : 'component.type.name ' , label : 'TYPE ' } ,
177- { key : 'component.content ' , label : 'PROJECT PATH ' } ,
178- ] ,
179- } ) ;
180- }
153+ return i . filePath < j . filePath ? 1 : - 1 ;
154+ }
155+ return i . type < j . type ? 1 : - 1 ;
156+ } ) ;
157+ // get relative path for table output
158+ files . forEach ( ( file ) => {
159+ if ( file . filePath ) {
160+ file . filePath = path . relative ( process . cwd ( ) , file . filePath ) ;
161+ }
162+ } ) ;
163+ this . ux . log ( '' ) ;
164+ this . ux . styledHeader ( chalk . blue ( 'Deployed Source' ) ) ;
165+ this . ux . table ( files , {
166+ columns : [
167+ { key : 'fullName ' , label : 'FULL NAME ' } ,
168+ { key : 'type ' , label : 'TYPE ' } ,
169+ { key : 'filePath' , label : 'PROJECT PATH' } ,
170+ ] ,
171+ } ) ;
181172 }
182173 }
183174
184- private print ( result : SourceDeployResult ) : SourceDeployResult {
175+ private print ( result : DeployResult ) : DeployResult {
185176 this . printComponentSuccess ( result ) ;
186177 this . printComponentFailures ( result ) ;
187178 // TODO: this.printTestResults(result); <- this has WI @W-8903671@
188- if ( result . success && this . flags . checkonly ) {
179+ if ( result . response . success && this . flags . checkonly ) {
189180 this . log ( messages . getMessage ( 'checkOnlySuccess' ) ) ;
190181 }
191182
0 commit comments