Skip to content

Commit a9409b9

Browse files
committed
fixing lint
1 parent eceace0 commit a9409b9

File tree

6 files changed

+45
-76
lines changed

6 files changed

+45
-76
lines changed

packages/b2c-cli/src/commands/ods/clone/create.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ import {t} from '../../../i18n/index.js';
1212
* Command to create a sandbox clone.
1313
*/
1414
export default class CloneCreate extends OdsCommand<typeof CloneCreate> {
15-
static description = t(
16-
'commands.clone.create.description',
17-
'Create a new sandbox clone from an existing sandbox',
18-
);
15+
static args = {
16+
sandboxId: Args.string({
17+
description: 'Sandbox ID (UUID or friendly format like realm-instance) to clone from',
18+
required: true,
19+
}),
20+
};
21+
22+
static description = t('commands.clone.create.description', 'Create a new sandbox clone from an existing sandbox');
1923

2024
static enableJsonFlag = true;
2125

@@ -26,13 +30,6 @@ export default class CloneCreate extends OdsCommand<typeof CloneCreate> {
2630
'<%= config.bin %> <%= command.id %> <sandboxId> --target-profile large --ttl 48 --emails dev@example.com,qa@example.com',
2731
];
2832

29-
static args = {
30-
sandboxId: Args.string({
31-
description: 'Sandbox ID (UUID or friendly format like realm-instance) to clone from',
32-
required: true,
33-
}),
34-
};
35-
3633
static flags = {
3734
'target-profile': Flags.string({
3835
description: 'Resource profile for the cloned sandbox (defaults to source sandbox profile)',
@@ -116,11 +113,11 @@ export default class CloneCreate extends OdsCommand<typeof CloneCreate> {
116113

117114
// Prepare request body
118115
const requestBody: {
119-
targetProfile?: 'medium' | 'large' | 'xlarge' | 'xxlarge';
116+
targetProfile?: 'large' | 'medium' | 'xlarge' | 'xxlarge';
120117
emails?: string[];
121118
ttl: number;
122119
} = {
123-
targetProfile: targetProfile as 'medium' | 'large' | 'xlarge' | 'xxlarge',
120+
targetProfile: targetProfile as 'large' | 'medium' | 'xlarge' | 'xxlarge',
124121
ttl,
125122
};
126123

@@ -137,9 +134,7 @@ export default class CloneCreate extends OdsCommand<typeof CloneCreate> {
137134

138135
if (!result.data) {
139136
const message = getApiErrorMessage(result.error, result.response);
140-
this.error(
141-
t('commands.clone.create.error', 'Failed to create sandbox clone: {{message}}', {message}),
142-
);
137+
this.error(t('commands.clone.create.error', 'Failed to create sandbox clone: {{message}}', {message}));
143138
}
144139

145140
const cloneId = result.data.data?.cloneId;
@@ -148,12 +143,7 @@ export default class CloneCreate extends OdsCommand<typeof CloneCreate> {
148143
return {cloneId};
149144
}
150145

151-
this.log(
152-
t(
153-
'commands.clone.create.success',
154-
'✓ Sandbox clone creation started successfully',
155-
),
156-
);
146+
this.log(t('commands.clone.create.success', '✓ Sandbox clone creation started successfully'));
157147
this.log(t('commands.clone.create.cloneId', 'Clone ID: {{cloneId}}', {cloneId}));
158148
this.log(
159149
t(

packages/b2c-cli/src/commands/ods/clone/get.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ type SandboxCloneGetModel = OdsComponents['schemas']['SandboxCloneGetModel'];
1515
* Command to get details of a specific sandbox clone.
1616
*/
1717
export default class CloneGet extends OdsCommand<typeof CloneGet> {
18-
static description = t(
19-
'commands.clone.get.description',
20-
'Get detailed information about a specific sandbox clone',
21-
);
22-
23-
static enableJsonFlag = true;
24-
25-
static examples = [
26-
'<%= config.bin %> <%= command.id %> <sandboxId> <cloneId>',
27-
'<%= config.bin %> <%= command.id %> abcd-123 aaaa-002-1642780893121',
28-
];
29-
3018
static args = {
3119
sandboxId: Args.string({
3220
description: 'Sandbox ID (UUID or friendly format like realm-instance)',
@@ -38,6 +26,15 @@ export default class CloneGet extends OdsCommand<typeof CloneGet> {
3826
}),
3927
};
4028

29+
static description = t('commands.clone.get.description', 'Get detailed information about a specific sandbox clone');
30+
31+
static enableJsonFlag = true;
32+
33+
static examples = [
34+
'<%= config.bin %> <%= command.id %> <sandboxId> <cloneId>',
35+
'<%= config.bin %> <%= command.id %> abcd-123 aaaa-002-1642780893121',
36+
];
37+
4138
async run(): Promise<{data?: SandboxCloneGetModel}> {
4239
const {sandboxId: rawSandboxId, cloneId} = this.args;
4340

@@ -54,9 +51,7 @@ export default class CloneGet extends OdsCommand<typeof CloneGet> {
5451

5552
if (!result.data) {
5653
const message = getApiErrorMessage(result.error, result.response);
57-
this.error(
58-
t('commands.clone.get.error', 'Failed to get clone details: {{message}}', {message}),
59-
);
54+
this.error(t('commands.clone.get.error', 'Failed to get clone details: {{message}}', {message}));
6055
}
6156

6257
const clone = result.data.data;
@@ -81,10 +76,7 @@ export default class CloneGet extends OdsCommand<typeof CloneGet> {
8176
['Source Instance', clone?.sourceInstance],
8277
['Target Instance', clone?.targetInstance],
8378
['Realm', clone?.realm],
84-
[
85-
'Progress',
86-
clone?.progressPercentage !== undefined ? `${clone.progressPercentage}%` : '-',
87-
],
79+
['Progress', clone?.progressPercentage === undefined ? '-' : `${clone.progressPercentage}%`],
8880
['Created At', clone?.createdAt ? new Date(clone.createdAt).toLocaleString() : undefined],
8981
['Created By', clone?.createdBy],
9082
];

packages/b2c-cli/src/commands/ods/clone/list.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const COLUMNS: Record<string, ColumnDef<SandboxCloneGetModel>> = {
3333
},
3434
progressPercentage: {
3535
header: 'Progress %',
36-
get: (c) => (c.progressPercentage !== undefined ? `${c.progressPercentage}%` : '-'),
36+
get: (c) => (c.progressPercentage === undefined ? '-' : `${c.progressPercentage}%`),
3737
},
3838
createdAt: {
3939
header: 'Created At',
@@ -49,7 +49,7 @@ const COLUMNS: Record<string, ColumnDef<SandboxCloneGetModel>> = {
4949
},
5050
elapsedTimeInSec: {
5151
header: 'Elapsed Time (sec)',
52-
get: (c) => (c.elapsedTimeInSec !== undefined ? c.elapsedTimeInSec.toString() : '-'),
52+
get: (c) => (c.elapsedTimeInSec === undefined ? '-' : c.elapsedTimeInSec.toString()),
5353
},
5454
realm: {
5555
header: 'Realm',
@@ -63,6 +63,13 @@ const DEFAULT_COLUMNS = ['cloneId', 'status', 'sourceInstance', 'targetInstance'
6363
* Command to list sandbox clones for a specific sandbox.
6464
*/
6565
export default class CloneList extends OdsCommand<typeof CloneList> {
66+
static args = {
67+
sandboxId: Args.string({
68+
description: 'Sandbox ID (UUID or friendly format like realm-instance)',
69+
required: true,
70+
}),
71+
};
72+
6673
static description = t('commands.clone.list.description', 'List all clones for a specific sandbox');
6774

6875
static enableJsonFlag = true;
@@ -74,13 +81,6 @@ export default class CloneList extends OdsCommand<typeof CloneList> {
7481
'<%= config.bin %> <%= command.id %> <sandboxId> --extended',
7582
];
7683

77-
static args = {
78-
sandboxId: Args.string({
79-
description: 'Sandbox ID (UUID or friendly format like realm-instance)',
80-
required: true,
81-
}),
82-
};
83-
8484
static flags = {
8585
from: Flags.string({
8686
description: 'Filter clones created on or after this date (ISO 8601 date format, e.g., 2024-01-01)',
@@ -108,11 +108,7 @@ export default class CloneList extends OdsCommand<typeof CloneList> {
108108

109109
async run(): Promise<{data?: SandboxCloneGetModel[]}> {
110110
const {sandboxId: rawSandboxId} = this.args;
111-
const {
112-
from: fromDate,
113-
to: toDate,
114-
status,
115-
} = this.flags;
111+
const {from: fromDate, to: toDate, status} = this.flags;
116112

117113
// Resolve sandbox ID (handles both UUID and friendly format)
118114
const sandboxId = await this.resolveSandboxId(rawSandboxId);
@@ -125,16 +121,14 @@ export default class CloneList extends OdsCommand<typeof CloneList> {
125121
query: {
126122
fromDate,
127123
toDate,
128-
status: status as 'Pending' | 'InProgress' | 'Failed' | 'Completed' | undefined,
124+
status: status as 'Completed' | 'Failed' | 'InProgress' | 'Pending' | undefined,
129125
},
130126
},
131127
});
132128

133129
if (!result.data) {
134130
const message = getApiErrorMessage(result.error, result.response);
135-
this.error(
136-
t('commands.clone.list.error', 'Failed to list sandbox clones: {{message}}', {message}),
137-
);
131+
this.error(t('commands.clone.list.error', 'Failed to list sandbox clones: {{message}}', {message}));
138132
}
139133

140134
if (this.jsonEnabled()) {
@@ -151,9 +145,7 @@ export default class CloneList extends OdsCommand<typeof CloneList> {
151145
const tableRenderer = new TableRenderer(COLUMNS);
152146
tableRenderer.render(clones, columns);
153147

154-
this.log(
155-
t('commands.clone.list.total', '\nTotal: {{total}} clone(s)', {total: clones.length}),
156-
);
148+
this.log(t('commands.clone.list.total', '\nTotal: {{total}} clone(s)', {total: clones.length}));
157149

158150
return {data: clones};
159151
}

packages/b2c-cli/test/commands/ods/clone/create.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,7 @@ describe('ods clone create', () => {
9292
it('should have target-profile flag (optional)', () => {
9393
expect(CloneCreate.flags).to.have.property('target-profile');
9494
expect(CloneCreate.flags['target-profile'].required).to.be.false;
95-
expect(CloneCreate.flags['target-profile'].options).to.deep.equal([
96-
'medium',
97-
'large',
98-
'xlarge',
99-
'xxlarge',
100-
]);
95+
expect(CloneCreate.flags['target-profile'].options).to.deep.equal(['medium', 'large', 'xlarge', 'xxlarge']);
10196
});
10297

10398
it('should have optional ttl flag with default', () => {

packages/b2c-cli/test/commands/ods/clone/get.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ describe('ods clone get', () => {
104104
lastUpdated: '2025-02-27T11:00:00Z',
105105
customCodeVersion: '1.0.0',
106106
storefrontCount: 5,
107-
filesystemUsageSize: 1073741824, // 1 GB
108-
databaseTransferSize: 2147483648, // 2 GB
107+
filesystemUsageSize: 1_073_741_824, // 1 GB
108+
databaseTransferSize: 2_147_483_648, // 2 GB
109109
};
110110

111111
stubOdsClientGet(command, async (path: string, options?: any) => {
@@ -133,7 +133,7 @@ describe('ods clone get', () => {
133133
stubResolveSandboxId(command, async (id) => id);
134134

135135
const outputs: string[] = [];
136-
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ...args: string[]) => {
136+
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ..._args: string[]) => {
137137
if (str) {
138138
const output = Array.isArray(str) ? str.join('') : str;
139139
outputs.push(output);
@@ -190,7 +190,7 @@ describe('ods clone get', () => {
190190
stubResolveSandboxId(command, async (id) => id);
191191

192192
const outputs: string[] = [];
193-
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ...args: string[]) => {
193+
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ..._args: string[]) => {
194194
if (str) {
195195
const output = Array.isArray(str) ? str.join('') : str;
196196
outputs.push(output);
@@ -209,8 +209,8 @@ describe('ods clone get', () => {
209209
lastKnownState: 'finalizing',
210210
customCodeVersion: '1.0.0',
211211
storefrontCount: 5,
212-
filesystemUsageSize: 1073741824,
213-
databaseTransferSize: 2147483648,
212+
filesystemUsageSize: 1_073_741_824,
213+
databaseTransferSize: 2_147_483_648,
214214
};
215215

216216
stubOdsClientGet(command, async () => {
@@ -256,7 +256,7 @@ describe('ods clone get', () => {
256256
stubResolveSandboxId(command, async (id) => id);
257257

258258
const outputs: string[] = [];
259-
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ...args: string[]) => {
259+
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ..._args: string[]) => {
260260
if (str) {
261261
const output = Array.isArray(str) ? str.join('') : str;
262262
outputs.push(output);

packages/b2c-cli/test/commands/ods/clone/list.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ describe('ods clone list', () => {
139139
};
140140

141141
// Stub ux.stdout to capture table output
142-
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ...args: string[]) => {
142+
const stdoutStub = sinon.stub(ux, 'stdout').callsFake((str?: string | string[], ..._args: string[]) => {
143143
if (str) {
144144
const output = Array.isArray(str) ? str.join('') : str;
145145
logs.push(output);

0 commit comments

Comments
 (0)