Skip to content

Commit 75b9ffd

Browse files
committed
chore: getting closer
1 parent 76d39f3 commit 75b9ffd

File tree

4 files changed

+136
-154
lines changed

4 files changed

+136
-154
lines changed
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,42 +171,38 @@ export default class OrgCreateScratch extends SfCommand<ScratchCreateResponse> {
171171
flags['client-id'] ? await this.secretPrompt({ message: messages.getMessage('prompt.secret') }) : undefined
172172
);
173173

174-
const ms = new MultiStageRenderer<ScratchOrgLifecycleEvent & { alias: string; edition: string }>({
174+
const ms = new MultiStageRenderer<ScratchOrgLifecycleEvent & { alias: string }>({
175175
stages: flags.async ? ['prepare request', 'send request', 'done'] : scratchOrgLifecycleStages,
176176
title: flags.async ? 'Creating Scratch Org (async)' : 'Creating Scratch Org',
177-
timeout: flags.wait,
178177
info: [
179178
{
180179
label: 'Request Id',
181180
get: (data) =>
182181
data.scratchOrgInfo?.Id && terminalLink(data.scratchOrgInfo.Id, `${baseUrl}/${data.scratchOrgInfo.Id}`),
183-
bold: true,
182+
isBold: true,
184183
},
185184
{
186185
label: 'OrgId',
187186
get: (data) => data.scratchOrgInfo?.ScratchOrg,
188-
bold: true,
187+
isBold: true,
189188
color: 'cyan',
190189
},
191190
{
192191
label: 'Username',
193192
get: (data) => data.scratchOrgInfo?.SignupUsername,
194-
bold: true,
193+
isBold: true,
195194
color: 'cyan',
196195
},
197196
{
198197
label: 'Alias',
199198
get: (data) => data.alias,
200-
},
201-
{
202-
label: 'Edition',
203-
get: (data) => data.edition,
199+
isStatic: true,
204200
},
205201
],
206202
});
207203

208204
if (!this.jsonEnabled()) {
209-
ms.start({ alias: flags.alias, edition: flags.edition });
205+
ms.start({ alias: flags.alias });
210206
}
211207

212208
lifecycle.on<ScratchOrgLifecycleEvent>(scratchOrgLifecycleEventName, async (data): Promise<void> => {
Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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';
2323
import { ScratchCreateResponse } from '../../../shared/orgTypes.js';
2424

2525
Messages.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

src/components/spinner.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ export function SpinnerOrErrorOrChildren({
9595
...props
9696
}: SpinnerProps & {
9797
readonly children?: React.ReactNode;
98-
readonly textStyle?: {
99-
readonly color?: string;
100-
readonly bold?: boolean;
101-
};
102-
readonly text?: string;
10398
readonly error?: Error;
10499
}): React.ReactElement {
105100
if (children) {

0 commit comments

Comments
 (0)