@@ -44,8 +44,14 @@ export interface PackageComparisonData {
4444 * but a maintainer was removed last week, this would show the '3 years ago' time.
4545 */
4646 lastUpdated ?: string
47+ /** Creation date of the package (ISO 8601 date-time string) */
48+ createdAt ?: string
4749 engines ?: { node ?: string ; npm ?: string }
4850 deprecated ?: string
51+ github ?: {
52+ stars ?: number
53+ issues ?: number
54+ }
4955 }
5056 /** Whether this is a binary-only package (CLI without library entry points) */
5157 isBinaryOnly ?: boolean
@@ -115,12 +121,13 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
115121 try {
116122 // Fetch basic package info first (required)
117123 const { data : pkgData } = await $npmRegistry < Packument > ( `/${ encodePackageName ( name ) } ` )
118-
119124 const latestVersion = pkgData [ 'dist-tags' ] ?. latest
120125 if ( ! latestVersion ) return null
121126
122127 // Fetch fast additional data in parallel (optional - failures are ok)
123- const [ downloads , analysis , vulns , likes ] = await Promise . all ( [
128+ const repoInfo = parseRepositoryInfo ( pkgData . repository )
129+ const isGitHub = repoInfo ?. provider === 'github'
130+ const [ downloads , analysis , vulns , likes , ghStars , ghIssues ] = await Promise . all ( [
124131 $fetch < { downloads : number } > (
125132 `https://api.npmjs.org/downloads/point/last-week/${ encodePackageName ( name ) } ` ,
126133 ) . catch ( ( ) => null ) ,
@@ -133,6 +140,20 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
133140 $fetch < PackageLikes > ( `/api/social/likes/${ encodePackageName ( name ) } ` ) . catch (
134141 ( ) => null ,
135142 ) ,
143+ isGitHub
144+ ? $fetch < { repo : { stars : number } } > (
145+ `https://ungh.cc/repos/${ repoInfo . owner } /${ repoInfo . repo } ` ,
146+ )
147+ . then ( res => ( typeof res ?. repo ?. stars === 'number' ? res . repo . stars : null ) )
148+ . catch ( ( ) => null )
149+ : Promise . resolve ( null ) ,
150+ isGitHub
151+ ? $fetch < { issues : number | null } > (
152+ `/api/github/issues/${ repoInfo . owner } /${ repoInfo . repo } ` ,
153+ )
154+ . then ( res => ( typeof res ?. issues === 'number' ? res . issues : null ) )
155+ . catch ( ( ) => null )
156+ : Promise . resolve ( null ) ,
136157 ] )
137158 const versionData = pkgData . versions [ latestVersion ]
138159 const packageSize = versionData ?. dist ?. unpackedSize
@@ -179,8 +200,13 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
179200 // Use version-specific publish time, NOT time.modified (which can be
180201 // updated by metadata changes like maintainer additions)
181202 lastUpdated : pkgData . time ?. [ latestVersion ] ,
203+ createdAt : pkgData . time ?. created ,
182204 engines : analysis ?. engines ,
183205 deprecated : versionData ?. deprecated ,
206+ github : {
207+ stars : ghStars ?? undefined ,
208+ issues : ghIssues ?? undefined ,
209+ } ,
184210 } ,
185211 isBinaryOnly : isBinary ,
186212 totalLikes : likes ?. totalLikes ,
@@ -252,6 +278,7 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
252278
253279 return packagesData . value . map ( pkg => {
254280 if ( ! pkg ) return null
281+
255282 return computeFacetValue (
256283 facet ,
257284 pkg ,
@@ -538,6 +565,33 @@ function computeFacetValue(
538565 status : totalDepCount > 50 ? 'warning' : 'neutral' ,
539566 }
540567 }
568+ case 'githubStars' : {
569+ const stars = data . metadata ?. github ?. stars
570+ if ( stars == null ) return null
571+ return {
572+ raw : stars ,
573+ display : formatCompactNumber ( stars ) ,
574+ status : 'neutral' ,
575+ }
576+ }
577+ case 'githubIssues' : {
578+ const issues = data . metadata ?. github ?. issues
579+ if ( issues == null ) return null
580+ return {
581+ raw : issues ,
582+ display : formatCompactNumber ( issues ) ,
583+ status : 'neutral' ,
584+ }
585+ }
586+ case 'createdAt' : {
587+ const createdAt = data . metadata ?. createdAt
588+ if ( ! createdAt ) return null
589+ return {
590+ raw : createdAt ,
591+ display : createdAt ,
592+ type : 'date' ,
593+ }
594+ }
541595 default : {
542596 return null
543597 }
0 commit comments