Skip to content

Commit

Permalink
show pre-release data in show command (#921)
Browse files Browse the repository at this point in the history
fixes #899
  • Loading branch information
joaomoreno authored Dec 15, 2023
1 parent b18c620 commit 4df2693
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function show(extensionId: string, json: boolean = false): Promise<any> {
ExtensionQueryFlags.IncludeMetadata,
ExtensionQueryFlags.IncludeStatistics,
ExtensionQueryFlags.IncludeVersions,
ExtensionQueryFlags.IncludeVersionProperties,
];
return getPublicGalleryAPI()
.getExtension(extensionId, flags)
Expand Down Expand Up @@ -74,9 +75,22 @@ function showOverview({
const [{ version = 'unknown' } = {}] = versions;

// Create formatted table list of versions
const versionList = <ViewTable>(
versions.slice(0, limitVersions).map(({ version, lastUpdated }) => [version, formatDate(lastUpdated!)])
);
const versionList = versions
.slice(0, limitVersions)
.map(({ version, lastUpdated, properties }) => [version, formatDate(lastUpdated!), properties?.some(p => p.key === 'Microsoft.VisualStudio.Code.PreRelease')]);

// Only show pre-release column if there are any pre-releases
if (versionList.every(v => !v[2])) {
for (const version of versionList) {
version.pop();
}
versionList.unshift(['Version', 'Last Updated']);
} else {
for (const version of versionList) {
version[2] = version[2] ? `✔️` : '';
}
versionList.unshift(['Version', 'Last Updated', 'Pre-release']);
}

const { install: installs = 0, averagerating = 0, ratingcount = 0 } = statistics.reduce(
(map, { statisticName, value }) => ({ ...map, [statisticName!]: value }),
Expand All @@ -93,8 +107,7 @@ function showOverview({
'',
`${shortDescription}`,
'',
'Recent versions:',
...(versionList.length ? tableView(versionList).map(indentRow) : ['no versions found']),
...(versionList.length ? tableView(<ViewTable>versionList).map(indentRow) : ['no versions found']),
'',
'Categories:',
` ${categories.join(', ')}`,
Expand Down

0 comments on commit 4df2693

Please sign in to comment.