@@ -22,44 +22,9 @@ import { MyDomainResolver } from '../status/myDomainResolver';
22
22
import { AuthInfo } from './authInfo' ;
23
23
import { Org } from './org' ;
24
24
import { checkScratchOrgInfoForErrors } from './scratchOrgErrorCodes' ;
25
- import SettingsGenerator , { ObjectSetting } from './scratchOrgSettingsGenerator' ;
26
- export interface ScratchOrgInfo {
27
- AdminEmail ?: string ;
28
- readonly CreatedDate ?: string ;
29
- ConnectedAppCallbackUrl ?: string ;
30
- ConnectedAppConsumerKey ?: string ;
31
- Country ?: string ;
32
- Description ?: string ;
33
- DurationDays ?: string ;
34
- Edition ?: string ;
35
- readonly ErrorCode ?: string ;
36
- readonly ExpirationDate ?: string ;
37
- Features ?: string ;
38
- HasSampleData ?: boolean ;
39
- readonly Id ?: string ;
40
- Language ?: string ;
41
- LoginUrl : string ;
42
- readonly Name ?: string ;
43
- Namespace ?: string ;
44
- OrgName ?: string ;
45
- Release ?: 'Current' | 'Previous' | 'Preview' ;
46
- readonly ScratchOrg ?: string ;
47
- SourceOrg ?: string ;
48
- readonly AuthCode : string ;
49
- Snapshot : string ;
50
- readonly Status : 'New' | 'Creating' | 'Active' | 'Error' | 'Deleted' ;
51
- readonly SignupEmail : string ;
52
- readonly SignupUsername : string ;
53
- readonly SignupInstance : string ;
54
- Username : string ;
55
- settings ?: Record < string , unknown > ;
56
- objectSettings ?: { [ objectName : string ] : ObjectSetting } ;
57
- orgPreferences ?: {
58
- enabled : string [ ] ;
59
- disabled : string [ ] ;
60
- } ;
61
- }
62
-
25
+ import SettingsGenerator from './scratchOrgSettingsGenerator' ;
26
+ import { ScratchOrgInfo } from './scratchOrgTypes' ;
27
+ import { emit } from './scratchOrgLifecycleEvents' ;
63
28
export interface JsForceError extends Error {
64
29
errorCode : string ;
65
30
fields : string [ ] ;
@@ -225,6 +190,7 @@ export const authorizeScratchOrg = async (options: {
225
190
retry ?: number ;
226
191
} ) : Promise < AuthInfo > => {
227
192
const { scratchOrgInfoComplete, hubOrg, clientSecret, signupTargetLoginUrlConfig, retry : maxRetries } = options ;
193
+ await emit ( { stage : 'authing' , scratchOrgInfo : scratchOrgInfoComplete } ) ;
228
194
const logger = await Logger . child ( 'authorizeScratchOrg' ) ;
229
195
logger . debug ( `scratchOrgInfoComplete: ${ JSON . stringify ( scratchOrgInfoComplete , null , 4 ) } ` ) ;
230
196
@@ -321,7 +287,8 @@ export const requestScratchOrgCreation = async (
321
287
322
288
await checkOrgDoesntExist ( scratchOrgInfo ) ; // throw if it does exist.
323
289
try {
324
- return await hubOrg . getConnection ( ) . sobject ( 'ScratchOrgInfo' ) . create ( scratchOrgInfo ) ;
290
+ await emit ( { stage : 'requested' } ) ;
291
+ return hubOrg . getConnection ( ) . sobject ( 'ScratchOrgInfo' ) . create ( scratchOrgInfo ) ;
325
292
} catch ( error ) {
326
293
// this is a jsforce error which contains the property "fields" which regular error don't
327
294
const jsForceError = error as JsForceError ;
@@ -356,11 +323,14 @@ export const pollForScratchOrgInfo = async (
356
323
logger . debug ( `polling client result: ${ JSON . stringify ( resultInProgress , null , 4 ) } ` ) ;
357
324
// Once it's "done" we can return it
358
325
if ( resultInProgress . Status === 'Active' || resultInProgress . Status === 'Error' ) {
326
+ await emit ( { stage : 'ready' , scratchOrgInfo : resultInProgress as unknown as ScratchOrgInfo } ) ;
359
327
return {
360
328
completed : true ,
361
329
payload : resultInProgress as unknown as AnyJson ,
362
330
} ;
363
331
}
332
+ await emit ( { stage : 'pending' , scratchOrgInfo : resultInProgress as unknown as ScratchOrgInfo } ) ;
333
+
364
334
logger . debug ( `Scratch org status is ${ resultInProgress . Status } ` ) ;
365
335
return {
366
336
completed : false ,
0 commit comments