Skip to content

Commit bfd1049

Browse files
DEMRUM-1874: add formatting for iOS list subcommand (#127)
* DEMRUM-1874: add formatting for iOS list subcommand * DEMRUM-1874: remove output of raw list data
1 parent af3ebcd commit bfd1049

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

src/commands/ios.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { createSpinner } from '../utils/spinner';
2121
import { createLogger, LogLevel } from '../utils/logger';
2222
import { validateDSYMsPath, cleanupTemporaryZips, getZippedDSYMs } from '../dsyms/iOSdSYMUtils';
2323
import { UserFriendlyError } from '../utils/userFriendlyErrors';
24+
import { IOSdSYMMetadata, formatIOSdSYMMetadata } from '../utils/metadataFormatUtils';
2425
import { COMMON_ERROR_MESSAGES } from '../utils/inputValidations';
2526

2627
interface UploadCommandOptions {
@@ -225,12 +226,13 @@ iOSCommand
225226
});
226227

227228
try {
228-
await listDSYMs({
229+
const responseData: IOSdSYMMetadata[] = await listDSYMs({
229230
url,
230231
token: token as string,
231232
logger,
232233
TOKEN_HEADER,
233234
});
235+
logger.info(formatIOSdSYMMetadata(responseData));
234236
} catch (error) {
235237
if (error instanceof UserFriendlyError) {
236238
logger.error(error.message);

src/dsyms/dsymClient.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { handleAxiosError } from '../utils/httpUtils';
1919
import fs from 'fs';
2020
import { Logger } from '../utils/logger';
2121
import { Spinner } from '../utils/spinner';
22+
import { IOSdSYMMetadata } from '../utils/metadataFormatUtils';
2223
import { UserFriendlyError } from '../utils/userFriendlyErrors';
2324

2425
interface UploadParams {
@@ -63,15 +64,15 @@ interface ListParams {
6364
TOKEN_HEADER: string;
6465
}
6566

66-
export async function listDSYMs({ url, token, logger, TOKEN_HEADER }: ListParams): Promise<void> {
67+
export async function listDSYMs({ url, token, logger, TOKEN_HEADER }: ListParams): Promise<IOSdSYMMetadata[]> {
6768
try {
68-
const response = await axios.get(url, {
69+
const response = await axios.get<IOSdSYMMetadata[]>(url, {
6970
headers: {
7071
'Content-Type': 'application/json',
7172
[TOKEN_HEADER]: token,
7273
},
7374
});
74-
logger.info('Raw Response Data:', JSON.stringify(response.data, null, 2));
75+
return response.data; // Return the data if successful
7576
} catch (error) {
7677
const operationMessage = 'Unable to fetch the list of uploaded files.';
7778
const result = handleAxiosError(error, operationMessage, url, logger);
@@ -80,5 +81,7 @@ export async function listDSYMs({ url, token, logger, TOKEN_HEADER }: ListParams
8081
Please check your network connection or try again later.`;
8182
throw new UserFriendlyError(error, userFriendlyMessage);
8283
}
84+
logger.error('Unhandled error occurred while fetching dSYMs.');
85+
return [];
8386
}
8487
}

src/utils/metadataFormatUtils.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ export interface AndroidMappingMetadata {
2828
r8MappingFileFormatVersion?: string;
2929
fileSize?: number;
3030
}
31+
32+
export interface IOSdSYMMetadata {
33+
machoId: string;
34+
orgId: number;
35+
libraryName: string;
36+
createdOnMs: number;
37+
updatedOnMs: number;
38+
fileUri: string;
39+
fileSize: number;
40+
uploadUserAgent: string;
41+
createdBy: number;
42+
updatedBy: number;
43+
}
3144

3245
export function formatAndroidMappingMetadata(metadataList: AndroidMappingMetadata[]): string {
3346
if (!metadataList || metadataList.length === 0) {
@@ -54,6 +67,30 @@ export function formatAndroidMappingMetadata(metadataList: AndroidMappingMetadat
5467

5568
return summary + '\n' + formattedOutput;
5669
}
70+
71+
export function formatIOSdSYMMetadata(metadataList: IOSdSYMMetadata[]): string {
72+
if (!metadataList || metadataList.length === 0) {
73+
return 'No dSYM files found.';
74+
}
75+
76+
// Create formatted table-like output
77+
const formattedOutput = metadataList.map(item => {
78+
// Make timestamps readable
79+
const uploadDate = new Date(item.createdOnMs).toLocaleString();
80+
81+
// Format each item
82+
return `
83+
Library Name: ${item.libraryName}
84+
MachO ID: ${item.machoId}
85+
Uploaded: ${uploadDate}
86+
File Size: ${formatFileSize(item.fileSize)}
87+
`;
88+
}).join('\n' + '-'.repeat(50) + '\n');
89+
90+
const summary = `Found ${metadataList.length} dSYM file(s):\n` + '='.repeat(50);
91+
92+
return summary + '\n' + formattedOutput;
93+
}
5794

5895
function formatFileSize(bytes?: number): string {
5996
if (bytes === undefined) return 'Unknown';

0 commit comments

Comments
 (0)