@@ -2,6 +2,7 @@ import { Icon } from 'office-ui-fabric-react/lib/Icon';
2
2
import * as React from 'react' ;
3
3
import ReactMarkdown from 'react-markdown' ;
4
4
import timeago from 'timeago.js' ;
5
+ import { gt } from 'semver' ;
5
6
6
7
import { config } from '../config' ;
7
8
import Dependencies from './Dependencies' ;
@@ -116,10 +117,10 @@ class DisplayPackage extends React.Component<IDisplayPackageProps, IDisplayPacka
116
117
117
118
const results = json as Registration . IRegistrationIndex ;
118
119
119
- const latestVersion = results . items [ 0 ] . upper ;
120
120
let currentItem : Registration . IRegistrationPageItem | undefined ;
121
121
let lastUpdate : Date | undefined ;
122
122
123
+ const latestVersion = this . latestVersion ( results ) ;
123
124
const versions : IPackageVersion [ ] = [ ] ;
124
125
125
126
for ( const entry of results . items [ 0 ] . items ) {
@@ -147,7 +148,7 @@ class DisplayPackage extends React.Component<IDisplayPackageProps, IDisplayPacka
147
148
}
148
149
}
149
150
150
- if ( currentItem && lastUpdate ) {
151
+ if ( latestVersion && currentItem && lastUpdate ) {
151
152
let readme = "" ;
152
153
153
154
const isDotnetTool = ( currentItem . catalogEntry . packageTypes &&
@@ -315,6 +316,19 @@ class DisplayPackage extends React.Component<IDisplayPackageProps, IDisplayPacka
315
316
? version
316
317
: version . substring ( 0 , buildMetadataStart ) ;
317
318
}
319
+
320
+ private latestVersion ( index : Registration . IRegistrationIndex ) : string | null {
321
+ let latestVersion : string | null = null ;
322
+ for ( const entry of index . items [ 0 ] . items ) {
323
+ if ( ! entry . catalogEntry . listed ) continue ;
324
+
325
+ if ( latestVersion === null || gt ( entry . catalogEntry . version , latestVersion ) ) {
326
+ latestVersion = entry . catalogEntry . version ;
327
+ }
328
+ }
329
+
330
+ return latestVersion ;
331
+ }
318
332
}
319
333
320
334
interface IExpandableSectionProps {
0 commit comments