55 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66 */
77
8- import { MultiStageOutput } from '@oclif/multi-stage-output ' ;
8+ import ansis from 'ansis ' ;
99import { EnvironmentVariable , Lifecycle , Messages , OrgConfigProperties , SfError } from '@salesforce/core' ;
10- import { DeployVersionData , MetadataApiDeployStatus } from '@salesforce/source-deploy-retrieve' ;
10+ import { DeployVersionData } from '@salesforce/source-deploy-retrieve' ;
1111import { Duration } from '@salesforce/kit' ;
1212import { SfCommand , toHelpSection , Flags } from '@salesforce/sf-plugins-core' ;
13- import { SourceConflictError , SourceMemberPollingEvent } from '@salesforce/source-tracking' ;
14- import { DeployStages } from '../../../utils/deployStages.js' ;
13+ import { SourceConflictError } from '@salesforce/source-tracking' ;
1514import { AsyncDeployResultFormatter } from '../../../formatters/asyncDeployResultFormatter.js' ;
1615import { DeployResultFormatter } from '../../../formatters/deployResultFormatter.js' ;
16+ import { DeployProgress } from '../../../utils/progressBar.js' ;
1717import { DeployResultJson , TestLevel } from '../../../utils/types.js' ;
1818import { executeDeploy , resolveApi , validateTests , determineExitCode } from '../../../utils/deploy.js' ;
1919import { DeployCache } from '../../../utils/deployCache.js' ;
@@ -176,16 +176,6 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
176176
177177 public static errorCodes = toHelpSection ( 'ERROR CODES' , DEPLOY_STATUS_CODES_DESCRIPTIONS ) ;
178178
179- protected ms ! : MultiStageOutput < {
180- mdapiDeploy : MetadataApiDeployStatus ;
181- sourceMemberPolling : SourceMemberPollingEvent ;
182- status : string ;
183- apiData : DeployVersionData ;
184- targetOrg : string ;
185- } > ;
186-
187- protected stages ! : DeployStages ;
188-
189179 public async run ( ) : Promise < DeployResultJson > {
190180 const { flags } = await this . parse ( DeployMetadata ) ;
191181 const project = await getOptionalProject ( ) ;
@@ -207,30 +197,23 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
207197
208198 const api = await resolveApi ( this . configAggregator ) ;
209199 const username = flags [ 'target-org' ] . getUsername ( ) ;
210- const title = flags [ 'dry-run' ] ? 'Deploying Metadata (dry-run)' : 'Deploying Metadata ' ;
200+ const action = flags [ 'dry-run' ] ? 'Deploying (dry-run)' : 'Deploying' ;
211201
212- this . stages = new DeployStages ( {
213- title,
214- jsonEnabled : this . jsonEnabled ( ) ,
202+ // eslint-disable-next-line @typescript-eslint/require-await
203+ Lifecycle . getInstance ( ) . on ( 'apiVersionDeploy' , async ( apiData : DeployVersionData ) => {
204+ this . log (
205+ messages . getMessage ( 'apiVersionMsgDetailed' , [
206+ action ,
207+ // technically manifestVersion can be undefined, but only on raw mdapi deployments.
208+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
209+ flags [ 'metadata-dir' ] ? '<version specified in manifest>' : `v${ apiData . manifestVersion } ` ,
210+ username ,
211+ apiData . apiVersion ,
212+ apiData . webService ,
213+ ] )
214+ ) ;
215215 } ) ;
216216
217- const lifecycle = Lifecycle . getInstance ( ) ;
218- lifecycle . on ( 'apiVersionDeploy' , async ( apiData : DeployVersionData ) =>
219- Promise . resolve (
220- this . stages . update ( {
221- message : messages . getMessage ( 'apiVersionMsgDetailed' , [
222- flags [ 'dry-run' ] ? 'Deploying (dry-run)' : 'Deploying' ,
223- // technically manifestVersion can be undefined, but only on raw mdapi deployments.
224- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
225- flags [ 'metadata-dir' ] ? '<version specified in manifest>' : `v${ apiData . manifestVersion } ` ,
226- username ,
227- apiData . apiVersion ,
228- apiData . webService ,
229- ] ) ,
230- } )
231- )
232- ) ;
233-
234217 const { deploy } = await executeDeploy (
235218 {
236219 ...flags ,
@@ -241,20 +224,16 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
241224 ) ;
242225
243226 if ( ! deploy ) {
244- this . stages . stop ( ) ;
245227 this . log ( 'No changes to deploy' ) ;
246228 return { status : 'Nothing to deploy' , files : [ ] } ;
247229 }
248230
249231 if ( ! deploy . id ) {
250232 throw new SfError ( 'The deploy id is not available.' ) ;
251233 }
252-
253- this . stages . start ( { username, deploy } ) ;
234+ this . log ( `Deploy ID: ${ ansis . bold ( deploy . id ) } ` ) ;
254235
255236 if ( flags . async ) {
256- this . stages . done ( { status : 'Queued' , username } ) ;
257- this . stages . stop ( ) ;
258237 if ( flags [ 'coverage-formatters' ] ) {
259238 this . warn ( messages . getMessage ( 'asyncCoverageJunitWarning' ) ) ;
260239 }
@@ -263,6 +242,8 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
263242 return asyncFormatter . getJson ( ) ;
264243 }
265244
245+ new DeployProgress ( deploy , this . jsonEnabled ( ) ) . start ( ) ;
246+
266247 const result = await deploy . pollStatus ( { timeout : flags . wait } ) ;
267248 process . exitCode = determineExitCode ( result ) ;
268249 const formatter = new DeployResultFormatter ( result , flags ) ;
@@ -280,8 +261,6 @@ export default class DeployMetadata extends SfCommand<DeployResultJson> {
280261 protected catch ( error : Error | SfError ) : Promise < never > {
281262 if ( error instanceof SourceConflictError && error . data ) {
282263 if ( ! this . jsonEnabled ( ) ) {
283- this . stages . update ( { status : 'Failed' } ) ;
284- this . stages . stop ( error ) ;
285264 writeConflictTable ( error . data ) ;
286265 // set the message and add plugin-specific actions
287266 return super . catch ( {
0 commit comments