@@ -14,12 +14,12 @@ import {
1414 ScratchOrgCache ,
1515 ScratchOrgLifecycleEvent ,
1616 scratchOrgLifecycleEventName ,
17+ scratchOrgLifecycleStages ,
1718 scratchOrgResume ,
1819 SfError ,
1920} from '@salesforce/core' ;
20- import { render } from 'ink' ;
21- import React from 'react' ;
22- import { Status } from '../../../components/stages.js' ;
21+ import terminalLink from 'terminal-link' ;
22+ import { MultiStageRenderer } from '../../../components/stages.js' ;
2323import { ScratchCreateResponse } from '../../../shared/orgTypes.js' ;
2424
2525Messages . importMessagesDirectoryFromMetaUrl ( import . meta. url ) ;
@@ -57,16 +57,46 @@ export default class OrgResumeScratch extends SfCommand<ScratchCreateResponse> {
5757
5858 // oclif doesn't know that the exactlyOne flag will ensure that one of these is set, and there we definitely have a jobID.
5959 assert ( jobId ) ;
60- const hubBaseUrl = cache . get ( jobId ) ?. hubBaseUrl ;
60+ const cached = cache . get ( jobId ) ;
61+ const hubBaseUrl = cached ?. hubBaseUrl ;
6162
62- let scratchOrgLifecycleData : ScratchOrgLifecycleEvent | undefined ;
63+ const ms = new MultiStageRenderer < ScratchOrgLifecycleEvent & { alias : string } > ( {
64+ stages : scratchOrgLifecycleStages ,
65+ title : 'Resuming Scratch Org' ,
66+ info : [
67+ {
68+ label : 'Request Id' ,
69+ get : ( data ) =>
70+ data . scratchOrgInfo ?. Id && terminalLink ( data . scratchOrgInfo . Id , `${ hubBaseUrl } /${ data . scratchOrgInfo . Id } ` ) ,
71+ isBold : true ,
72+ } ,
73+ {
74+ label : 'OrgId' ,
75+ get : ( data ) => data . scratchOrgInfo ?. ScratchOrg ,
76+ isBold : true ,
77+ color : 'cyan' ,
78+ } ,
79+ {
80+ label : 'Username' ,
81+ get : ( data ) => data . scratchOrgInfo ?. SignupUsername ,
82+ isBold : true ,
83+ color : 'cyan' ,
84+ } ,
85+ {
86+ label : 'Alias' ,
87+ get : ( data ) => data . alias ,
88+ isStatic : true ,
89+ } ,
90+ ] ,
91+ } ) ;
6392
64- const instance = ! this . jsonEnabled ( ) ? render ( < Status baseUrl = { hubBaseUrl } /> ) : undefined ;
93+ if ( ! this . jsonEnabled ( ) ) {
94+ ms . start ( { alias : cached ?. alias } ) ;
95+ }
6596 lifecycle . on < ScratchOrgLifecycleEvent > ( scratchOrgLifecycleEventName , async ( data ) : Promise < void > => {
66- scratchOrgLifecycleData = data ;
67- instance ?. rerender ( < Status data = { data } baseUrl = { hubBaseUrl } /> ) ;
97+ ms . goto ( data . stage , data ) ;
6898 if ( data . stage === 'done' ) {
69- instance ?. unmount ( ) ;
99+ ms . stop ( ) ;
70100 }
71101 return Promise . resolve ( ) ;
72102 } ) ;
@@ -77,10 +107,7 @@ export default class OrgResumeScratch extends SfCommand<ScratchCreateResponse> {
77107 this . logSuccess ( messages . getMessage ( 'success' ) ) ;
78108 return { username, scratchOrgInfo, authFields, warnings, orgId : authFields ?. orgId } ;
79109 } catch ( e ) {
80- if ( instance ) {
81- instance . rerender ( < Status data = { scratchOrgLifecycleData } error = { e as Error } baseUrl = { hubBaseUrl } /> ) ;
82- instance . unmount ( ) ;
83- }
110+ ms . stop ( e as Error ) ;
84111
85112 if ( cache . keys ( ) && e instanceof Error && e . name === 'CacheMissError' ) {
86113 // we have something in the cache, but it didn't match what the user passed in
0 commit comments