66 * This script automatically generates TypeScript index files for each manifest type.
77 * It scans the manifests directory and creates aggregated exports in src/lib/manifests/
88 *
9- * Usage: node scripts/generate-manifest-indexes.js
9+ * Usage: node scripts/generate-manifest-indexes.mjs
1010 */
1111
12- const fs = require ( 'fs' ) ;
13- const path = require ( 'path' ) ;
12+ import fs from 'fs' ;
13+ import path from 'path' ;
14+ import { fileURLToPath } from 'url' ;
15+
16+ const __filename = fileURLToPath ( import . meta. url ) ;
17+ const __dirname = path . dirname ( __filename ) ;
1418
1519const MANIFESTS_DIR = path . join ( __dirname , '../manifests' ) ;
1620const OUTPUT_DIR = path . join ( __dirname , '../src/lib/generated' ) ;
@@ -106,7 +110,7 @@ function generateIndexFile(typeName) {
106110
107111 const content = `/**
108112 * Auto-generated manifest index for ${ typeName }
109- * Generated by scripts/generate-manifest-indexes.js
113+ * Generated by scripts/generate-manifest-indexes.mjs
110114 * Do not edit manually - run the script to regenerate
111115 */
112116
@@ -137,7 +141,7 @@ export type { ${toPascalCase(typeName.replace(/s$/, ''))} } from './${typeName}'
137141
138142 const content = `/**
139143 * Auto-generated main manifest index
140- * Generated by scripts/generate-manifest-indexes.js
144+ * Generated by scripts/generate-manifest-indexes.mjs
141145 * Do not edit manually - run the script to regenerate
142146 */
143147
@@ -149,6 +153,53 @@ ${exports}
149153 console . log ( `✓ Generated index.ts` ) ;
150154}
151155
156+ /**
157+ * Generate GitHub stars TypeScript file from centralized JSON
158+ */
159+ function generateGithubStarsFile ( ) {
160+ const githubStarsPath = path . join ( MANIFESTS_DIR , 'github-stars.json' ) ;
161+
162+ if ( ! fs . existsSync ( githubStarsPath ) ) {
163+ console . log ( '⚠ github-stars.json not found, skipping stars generation' ) ;
164+ return ;
165+ }
166+
167+ const starsData = JSON . parse ( fs . readFileSync ( githubStarsPath , 'utf8' ) ) ;
168+
169+ const content = `/**
170+ * Auto-generated GitHub stars data
171+ * Generated by scripts/generate-manifest-indexes.mjs
172+ * Do not edit manually - run the script to regenerate
173+ */
174+
175+ export type GithubStarsData = Record<string, Record<string, number | null>>;
176+
177+ export const githubStarsData: GithubStarsData = ${ JSON . stringify ( starsData , null , 2 ) } ;
178+
179+ /**
180+ * Get GitHub stars for a specific product
181+ * @param category - The product category (extensions, clis, ides)
182+ * @param id - The product ID
183+ * @returns The number of stars (in thousands) or null if not available
184+ */
185+ export function getGithubStars(category: string, id: string): number | null {
186+ return githubStarsData[category]?.[id] ?? null;
187+ }
188+
189+ export default githubStarsData;
190+ ` ;
191+
192+ const outputPath = path . join ( OUTPUT_DIR , 'github-stars.ts' ) ;
193+ fs . writeFileSync ( outputPath , content , 'utf8' ) ;
194+
195+ // Count total entries
196+ const totalEntries = Object . values ( starsData ) . reduce ( ( sum , category ) => {
197+ return sum + Object . keys ( category ) . length ;
198+ } , 0 ) ;
199+
200+ console . log ( `✓ Generated github-stars.ts (${ totalEntries } entries)` ) ;
201+ }
202+
152203/**
153204 * Main execution
154205 */
@@ -171,6 +222,10 @@ function main() {
171222 console . log ( '' ) ;
172223 generateMainIndex ( ) ;
173224
225+ // Generate GitHub stars file
226+ console . log ( '' ) ;
227+ generateGithubStarsFile ( ) ;
228+
174229 console . log ( '\n' + '=' . repeat ( 60 ) ) ;
175230 console . log ( '✅ All index files generated successfully!' ) ;
176231 console . log ( '=' . repeat ( 60 ) ) ;
0 commit comments