Skip to content

Commit a73bae2

Browse files
committed
removing lint warning
1 parent bde204c commit a73bae2

File tree

1 file changed

+76
-64
lines changed
  • packages/b2c-cli/src/commands/sandbox

1 file changed

+76
-64
lines changed

packages/b2c-cli/src/commands/sandbox/get.ts

Lines changed: 76 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,31 @@ export default class SandboxGet extends OdsCommand<typeof SandboxGet> {
7979
return sandbox;
8080
}
8181

82-
private printSandboxDetails(sandbox: SandboxModel): void {
83-
const ui = cliui({width: process.stdout.columns || 80});
82+
private buildCloneFields(sandbox: SandboxModel): [string, string | undefined][] {
83+
const cloneFields: [string, string | undefined][] = [
84+
['Cloned From', sandbox.clonedFrom],
85+
['Source Instance ID', sandbox.sourceInstanceIdentifier],
86+
];
8487

85-
ui.div({text: 'Sandbox Details', padding: [1, 0, 0, 0]});
86-
ui.div({text: '─'.repeat(50), padding: [0, 0, 0, 0]});
88+
if (sandbox.cloneDetails) {
89+
const details = sandbox.cloneDetails;
90+
cloneFields.push(
91+
['Clone ID', details.cloneId],
92+
['Status', details.status],
93+
['Target Profile', details.targetProfile],
94+
['Created At', details.createdAt ? new Date(details.createdAt).toLocaleString() : undefined],
95+
['Progress', details.progressPercentage ? `${details.progressPercentage}%` : undefined],
96+
['Elapsed Time (sec)', details.elapsedTimeInSec?.toString()],
97+
['Custom Code Version', details.customCodeVersion],
98+
['Storefront Count', details.storefrontCount?.toString()],
99+
);
100+
}
101+
102+
return cloneFields;
103+
}
87104

88-
const fields: [string, string | undefined][] = [
105+
private buildSandboxFields(sandbox: SandboxModel): [string, string | undefined][] {
106+
return [
89107
['ID', sandbox.id],
90108
['Realm', sandbox.realm],
91109
['Instance', sandbox.instance],
@@ -100,80 +118,74 @@ export default class SandboxGet extends OdsCommand<typeof SandboxGet> {
100118
['App Version', sandbox.versions?.app],
101119
['Web Version', sandbox.versions?.web],
102120
];
121+
}
122+
123+
private printCloneDetailsSection(ui: ReturnType<typeof cliui>, sandbox: SandboxModel): void {
124+
if (!sandbox.clonedFrom && !sandbox.sourceInstanceIdentifier && !sandbox.cloneDetails) return;
103125

126+
ui.div({text: '', padding: [0, 0, 0, 0]});
127+
ui.div({text: 'Clone Details', padding: [1, 0, 0, 0]});
128+
ui.div({text: '─'.repeat(50), padding: [0, 0, 0, 0]});
129+
130+
const cloneFields = this.buildCloneFields(sandbox);
131+
this.printFieldsSection(ui, cloneFields, 25);
132+
}
133+
134+
private printFieldsSection(
135+
ui: ReturnType<typeof cliui>,
136+
fields: [string, string | undefined][],
137+
width: number,
138+
): void {
104139
for (const [label, value] of fields) {
105140
if (value !== undefined) {
106-
ui.div({text: `${label}:`, width: 20, padding: [0, 2, 0, 0]}, {text: value, padding: [0, 0, 0, 0]});
141+
ui.div({text: `${label}:`, width, padding: [0, 2, 0, 0]}, {text: value, padding: [0, 0, 0, 0]});
107142
}
108143
}
144+
}
145+
146+
private printLinksSection(ui: ReturnType<typeof cliui>, sandbox: SandboxModel): void {
147+
if (!sandbox.links) return;
109148

110-
// Tags
149+
ui.div({text: '', padding: [0, 0, 0, 0]});
150+
ui.div({text: 'Links', padding: [1, 0, 0, 0]});
151+
ui.div({text: '─'.repeat(50), padding: [0, 0, 0, 0]});
152+
153+
const links: [string, string | undefined][] = [
154+
['Business Manager', sandbox.links.bm],
155+
['OCAPI', sandbox.links.ocapi],
156+
['Impex', sandbox.links.impex],
157+
['Code', sandbox.links.code],
158+
['Logs', sandbox.links.logs],
159+
];
160+
161+
this.printFieldsSection(ui, links, 20);
162+
}
163+
164+
private printSandboxDetails(sandbox: SandboxModel): void {
165+
const ui = cliui({width: process.stdout.columns || 80});
166+
167+
ui.div({text: 'Sandbox Details', padding: [1, 0, 0, 0]});
168+
ui.div({text: '─'.repeat(50), padding: [0, 0, 0, 0]});
169+
170+
const fields = this.buildSandboxFields(sandbox);
171+
this.printFieldsSection(ui, fields, 20);
172+
this.printTagsAndEmails(ui, sandbox);
173+
this.printCloneDetailsSection(ui, sandbox);
174+
this.printLinksSection(ui, sandbox);
175+
176+
ux.stdout(ui.toString());
177+
}
178+
179+
private printTagsAndEmails(ui: ReturnType<typeof cliui>, sandbox: SandboxModel): void {
111180
if (sandbox.tags && sandbox.tags.length > 0) {
112181
ui.div({text: 'Tags:', width: 20, padding: [0, 2, 0, 0]}, {text: sandbox.tags.join(', '), padding: [0, 0, 0, 0]});
113182
}
114183

115-
// Emails
116184
if (sandbox.emails && sandbox.emails.length > 0) {
117185
ui.div(
118186
{text: 'Emails:', width: 20, padding: [0, 2, 0, 0]},
119187
{text: sandbox.emails.join(', '), padding: [0, 0, 0, 0]},
120188
);
121189
}
122-
123-
// Clone Details (if sandbox was cloned)
124-
if (sandbox.clonedFrom || sandbox.sourceInstanceIdentifier || sandbox.cloneDetails) {
125-
ui.div({text: '', padding: [0, 0, 0, 0]});
126-
ui.div({text: 'Clone Details', padding: [1, 0, 0, 0]});
127-
ui.div({text: '─'.repeat(50), padding: [0, 0, 0, 0]});
128-
129-
const cloneFields: [string, string | undefined][] = [
130-
['Cloned From', sandbox.clonedFrom],
131-
['Source Instance ID', sandbox.sourceInstanceIdentifier],
132-
];
133-
134-
// If cloneDetails is present (from expand=clonedetails), show additional information
135-
if (sandbox.cloneDetails) {
136-
const details = sandbox.cloneDetails;
137-
cloneFields.push(
138-
['Clone ID', details.cloneId],
139-
['Status', details.status],
140-
['Target Profile', details.targetProfile],
141-
['Created At', details.createdAt ? new Date(details.createdAt).toLocaleString() : undefined],
142-
['Progress', details.progressPercentage ? `${details.progressPercentage}%` : undefined],
143-
['Elapsed Time (sec)', details.elapsedTimeInSec?.toString()],
144-
['Custom Code Version', details.customCodeVersion],
145-
['Storefront Count', details.storefrontCount?.toString()],
146-
);
147-
}
148-
149-
for (const [label, value] of cloneFields) {
150-
if (value) {
151-
ui.div({text: `${label}:`, width: 25, padding: [0, 2, 0, 0]}, {text: value, padding: [0, 0, 0, 0]});
152-
}
153-
}
154-
}
155-
156-
// Links
157-
if (sandbox.links) {
158-
ui.div({text: '', padding: [0, 0, 0, 0]});
159-
ui.div({text: 'Links', padding: [1, 0, 0, 0]});
160-
ui.div({text: '─'.repeat(50), padding: [0, 0, 0, 0]});
161-
162-
const links: [string, string | undefined][] = [
163-
['Business Manager', sandbox.links.bm],
164-
['OCAPI', sandbox.links.ocapi],
165-
['Impex', sandbox.links.impex],
166-
['Code', sandbox.links.code],
167-
['Logs', sandbox.links.logs],
168-
];
169-
170-
for (const [label, value] of links) {
171-
if (value) {
172-
ui.div({text: `${label}:`, width: 20, padding: [0, 2, 0, 0]}, {text: value, padding: [0, 0, 0, 0]});
173-
}
174-
}
175-
}
176-
177-
ux.stdout(ui.toString());
178190
}
179191
}

0 commit comments

Comments
 (0)