Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/demrum 440 dsyms list command #61

Merged
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this block needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which block? I'm seeing code that doesn't line up with a block above your comments, maybe the branch got out of sync with what's shown here(?).

.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);
});
});
Loading