Skip to content

Commit

Permalink
Feature/demrum 440 dsyms list command (#61)
Browse files Browse the repository at this point in the history
* DEMRUM-439: add initial iOSInputValidations

* DEMRUM-439: implement iOS dSYMs upload

* DEMRUM-440: implement list command

* DEMRUM-440: restore listdSYMsDescription

* DEMRUM-439: remove unused validations

* DEMRUM-439: remove unused fields

* DEMRUM-440: restore axios import

* DEMRUM-440: fix missing semicolon

* DEMRUM-440: remove now-unused iOSInputValidations.ts

* DEMRUM-440: add basic iOS unit test

* DEMRUM-440: remove misplaced iOSCommand.parse() call

* DEMRUM: 440: restore debug option
  • Loading branch information
carlosmcevilly authored Jan 11, 2025
1 parent 3a716df commit 49ab8cc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/commands/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '../utils/inputValidations';
import { UserFriendlyError } from '../utils/userFriendlyErrors';
import { createLogger, LogLevel } from '../utils/logger';
import axios from 'axios';
import { uploadFile } from '../utils/httpUtils';

// Constants
Expand All @@ -35,10 +36,9 @@ export const iOSCommand = new Command('iOS');
const iOSUploadDescription = `This subcommand uploads the specified zipped dSYMs file.
`;

interface UploadiOSOptions {
'file': string,
'debug'?: boolean
}
const listdSYMsDescription = `This command retrieves and shows a list of the uploaded dSYM files.
By default, it returns the last 100 dSYM files uploaded, sorted in reverse chronological order based on the upload timestamp.
`;

const generateUrl = (): string => {
const realm = process.env.O11Y_REALM || DEFAULT_REALM;
Expand All @@ -49,6 +49,11 @@ iOSCommand
.name('ios')
.description('Upload and list zipped iOS symbolication files (dSYMs)');

interface UploadiOSOptions {
file: string;
debug?: boolean;
}

iOSCommand
.command('upload')
.showHelpAfterError(true)
Expand All @@ -75,9 +80,7 @@ iOSCommand
};

const url = generateUrl();

logger.info(`url: ${url}`);

logger.info(`Preparing to upload dSYMs file: ${options.file}`);

await uploadFile({
Expand All @@ -98,3 +101,25 @@ iOSCommand
}
}
});


iOSCommand
.command('list')
.summary('Retrieves list of metadata of all uploaded dSYM files')
.showHelpAfterError(true)
.description(listdSYMsDescription)
.option('--debug', 'Enable debug logs')
.action(async (options) => {
const logger = createLogger(options.debug ? LogLevel.DEBUG : LogLevel.INFO);
const url = `${API_BASE_URL}/${API_VERSION_STRING}/${API_PATH}`;

try {
logger.info('Fetching dSYM file data');
const response = await axios.get(url);
logger.info('Raw Response Data:', JSON.stringify(response.data, null, 2));
} catch (error) {
logger.error('Failed to fetch the list of uploaded files');
throw error;
}
});

23 changes: 23 additions & 0 deletions test/commands/ios.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Splunk Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { iOSCommand } from '../../src/commands/ios';

describe('ios command', () => {
test('has multiple sub-commands', () => {
expect(iOSCommand.commands.length).toBe(2);
});
});

0 comments on commit 49ab8cc

Please sign in to comment.