@@ -8,7 +8,7 @@ import * as os from 'os';
8
8
import * as path from 'path' ;
9
9
import { flags , FlagsConfig } from '@salesforce/command' ;
10
10
import { Lifecycle , Messages } from '@salesforce/core' ;
11
- import { SourceDeployResult } from '@salesforce/source-deploy-retrieve' ;
11
+ import { DeployResult } from '@salesforce/source-deploy-retrieve' ;
12
12
import { Duration } from '@salesforce/kit' ;
13
13
import { asString , asArray } from '@salesforce/ts-types' ;
14
14
import * as chalk from 'chalk' ;
@@ -26,7 +26,6 @@ export class deploy extends SourceCommand {
26
26
checkonly : flags . boolean ( {
27
27
char : 'c' ,
28
28
description : messages . getMessage ( 'flags.checkonly' ) ,
29
- default : false ,
30
29
} ) ,
31
30
wait : flags . minutes ( {
32
31
char : 'w' ,
@@ -48,12 +47,10 @@ export class deploy extends SourceCommand {
48
47
ignoreerrors : flags . boolean ( {
49
48
char : 'o' ,
50
49
description : messages . getMessage ( 'flags.ignoreErrors' ) ,
51
- default : false ,
52
50
} ) ,
53
51
ignorewarnings : flags . boolean ( {
54
52
char : 'g' ,
55
53
description : messages . getMessage ( 'flags.ignoreWarnings' ) ,
56
- default : false ,
57
54
} ) ,
58
55
validateddeployrequestid : flags . id ( {
59
56
char : 'q' ,
@@ -90,7 +87,7 @@ export class deploy extends SourceCommand {
90
87
} ;
91
88
protected readonly lifecycleEventNames = [ 'predeploy' , 'postdeploy' ] ;
92
89
93
- public async run ( ) : Promise < SourceDeployResult > {
90
+ public async run ( ) : Promise < DeployResult > {
94
91
if ( this . flags . validatedeployrequestid ) {
95
92
// TODO: return this.doDeployRecentValidation();
96
93
}
@@ -104,88 +101,82 @@ export class deploy extends SourceCommand {
104
101
105
102
await hookEmitter . emit ( 'predeploy' , { packageXmlPath : cs . getPackageXml ( ) } ) ;
106
103
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 ( ) ;
117
109
await hookEmitter . emit ( 'postdeploy' , results ) ;
118
110
119
- this . print ( results ) ;
111
+ // skip a lot of steps that would do nothing
112
+ if ( ! this . flags . json ) {
113
+ this . print ( results ) ;
114
+ }
120
115
121
116
return results ;
122
117
}
123
118
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 ) {
126
121
// 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 ) {
129
124
// 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 ;
131
126
}
132
- return i . component . type . directoryName < j . component . type . directoryName ? 1 : - 1 ;
127
+ return i . filePath < j . filePath ? 1 : - 1 ;
133
128
} ) ;
134
129
this . ux . log ( '' ) ;
135
130
this . ux . styledHeader ( chalk . red ( `Component Failures [${ failures . length } ]` ) ) ;
136
131
this . ux . table ( failures , {
137
- // TODO: these accessors are temporary until library JSON fixes
138
132
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' } ,
143
137
] ,
144
138
} ) ;
145
139
this . ux . log ( '' ) ;
146
140
}
147
141
}
148
142
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 ;
161
152
}
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
+ } ) ;
181
172
}
182
173
}
183
174
184
- private print ( result : SourceDeployResult ) : SourceDeployResult {
175
+ private print ( result : DeployResult ) : DeployResult {
185
176
this . printComponentSuccess ( result ) ;
186
177
this . printComponentFailures ( result ) ;
187
178
// TODO: this.printTestResults(result); <- this has WI @W-8903671@
188
- if ( result . success && this . flags . checkonly ) {
179
+ if ( result . response . success && this . flags . checkonly ) {
189
180
this . log ( messages . getMessage ( 'checkOnlySuccess' ) ) ;
190
181
}
191
182
0 commit comments