Skip to content

Commit

Permalink
chore: fix column types
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Oct 23, 2024
1 parent e1f820b commit de5c345
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 44 deletions.
42 changes: 19 additions & 23 deletions src/commands/package/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,26 @@ export class PackageListCommand extends SfCommand<PackageListCommandResult> {

private displayResults(results: Package2Result[], verbose = false, apiVersion: string): void {
this.styledHeader(chalk.blue(`Packages [${results.length}]`));
let columns = [
{ key: 'NamespacePrefix', name: messages.getMessage('namespace') },
{ key: 'Name', name: messages.getMessage('name') },
{ key: 'Id', name: messages.getMessage('id') },
{ key: 'Alias', name: messages.getMessage('alias') },
{ key: 'Description', name: messages.getMessage('description') },
{ key: 'ContainerOptions', name: messages.getMessage('package-type') },
];

if (verbose) {
columns = columns.concat([
{ name: 'SubscriberPackageId', key: messages.getMessage('package-id') },
{ name: 'ConvertedFromPackageId', key: messages.getMessage('convertedFromPackageId') },
{ name: 'IsOrgDependent', key: messages.getMessage('isOrgDependent') },
{ name: 'PackageErrorUsername', key: messages.getMessage('error-notification-username') },
{ name: 'CreatedBy', key: messages.getMessage('createdBy') },
]);

if (parseInt(apiVersion, 10) >= 59) {
columns.push({ name: 'AppAnalyticsEnabled', key: messages.getMessage('app-analytics-enabled') });
}
}
// @ts-expect-error sdfsdfs
this.table({ data: results, columns });
const data = results.map((r) => ({
'Namespace Prefix': r.NamespacePrefix,
Name: r.Name,
Id: r.Id,
Alias: r.Alias,
Description: r.Description,
ContainerOptions: r.ContainerOptions,
...(verbose
? {
'Package Id': r.SubscriberPackageId,
'Converted From Package Id': r.ConvertedFromPackageId,
'Org-Dependent Unlocked Package': r.IsOrgDependent,
'Error Notification Username': r.PackageErrorUsername,
'Created By': r.CreatedBy,
...(parseInt(apiVersion, 10) >= 59 ? { 'App Analytics Enabled': r.AppAnalyticsEnabled } : {}),
}
: {}),
}));
this.table({ data });
}
}

Expand Down
35 changes: 16 additions & 19 deletions src/commands/package/version/create/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,31 @@ export class PackageVersionCreateListCommand extends SfCommand<CreateListCommand
this.warn('No results found');
} else {
this.styledHeader(chalk.blue(`Package Version Create Requests [${results.length}]`));
const columnData = [
{ name: 'Id', key: 'Id' },
{ name: 'Status', key: messages.getMessage('status') },
{ name: 'Package2Id', key: messages.getMessage('package-id') },
{ name: 'Package2VersionId', key: messages.getMessage('packageVersionId') },
{ name: 'SubscriberPackageVersionId', key: messages.getMessage('subscriberPackageVersionId') },
{ name: 'Tag', key: messages.getMessage('tag') },
{ name: 'Branch', key: messages.getMessage('branch') },
{ name: 'CreatedDate', key: 'Created Date' },
{ name: 'CreatedBy', key: messages.getMessage('createdBy') },
];

if (flags['show-conversions-only']) {
columnData.push({ name: 'ConvertedFromVersionId', key: messages.getMessage('convertedFromVersionId') });
}

if (flags.verbose) {
try {
results = await this.fetchVerboseData(results);
columnData.push({ key: 'VersionName', name: 'Version Name' });
columnData.push({ key: 'VersionNumber', name: 'Version Number' });
} catch (err) {
const errMsg = typeof err === 'string' ? err : err instanceof Error ? err.message : 'unknown error';
this.warn(`error when retrieving verbose data (package name and version) due to: ${errMsg}`);
}
} // @ts-expect-error sdfsdfs
}

const data = results.map((r) => ({
Id: r.Id,
Status: r.Status,
'Package Id': r.Package2Id,
'Package Version Id': r.Package2VersionId,
'Subscriber Package Version Id': r.SubscriberPackageVersionId,
Tag: r.Tag,
Branch: r.Branch,
'Created Date': r.CreatedDate,
'Created By': r.CreatedBy,
...(flags['show-conversions-only'] ? { 'Converted From Version Id': r.ConvertedFromVersionId } : {}),
...(flags.verbose ? { 'Version Name': r.VersionName, 'Version Number': r.VersionNumber } : {}),
}));

this.table({ data: results, columns: columnData });
this.table({ data });
}

return results;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/package/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ const getColumnData = (
}

if (!verbose) {
// @ts-expect-error sdfsdfs
// @ts-expect-error the default cols don't match 1:1 to the data in the table, but that's on purpose
return defaultCols;
} else {
// add additional columns for verbose output
// @ts-expect-error sdfsdfs
// @ts-expect-error the verbose match 1:1 to the data in the table, but that's on purpose, but the OCLIF types can't determine tha
return defaultCols.concat([
{ key: 'Package2Id', name: messages.getMessage('package-id') },
{ key: 'InstallUrl', name: messages.getMessage('installUrl') },
Expand Down

0 comments on commit de5c345

Please sign in to comment.