Skip to content

Commit f46a218

Browse files
ericyangpanclaude
andcommitted
style(scripts): apply biome formatting to build scripts
- Remove semicolons for consistency with project style - Adjust import ordering and spacing - Update locale key formatting with conditional quoting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5300175 commit f46a218

File tree

2 files changed

+56
-50
lines changed

2 files changed

+56
-50
lines changed

scripts/generate-manifest-indexes.mjs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function generateIndexFile(typeName) {
7373
const id = file.replace('.json', '')
7474
const varName = toPascalCase(id)
7575
const relativePath = `../../../manifests/${typeName}/${file}`
76-
return `import ${varName} from '${relativePath}';`
76+
return `import ${varName} from '${relativePath}'`
7777
})
7878
.join('\n')
7979

@@ -105,7 +105,7 @@ function generateIndexFile(typeName) {
105105

106106
const manifestType = typeImportMap[typeName]
107107
const typeImport = manifestType
108-
? `import type { ${manifestType} } from '../../types/manifests';\n\n`
108+
? `\nimport type { ${manifestType} } from '../../types/manifests'`
109109
: ''
110110

111111
const content = `/**
@@ -114,15 +114,15 @@ function generateIndexFile(typeName) {
114114
* Do not edit manually - run the script to regenerate
115115
*/
116116
117-
${typeImport}${imports}
117+
${imports}${typeImport}
118118
119119
export const ${typeName}Data = [
120-
${arrayItems}
121-
]${manifestType ? ` as unknown as ${manifestType}[]` : ''};
120+
${arrayItems},
121+
]${manifestType ? ` as unknown as ${manifestType}[]` : ''}
122122
123-
export type ${TypeName} = typeof ${firstVarName};
123+
export type ${TypeName} = typeof ${firstVarName}
124124
125-
export default ${typeName}Data;
125+
export default ${typeName}Data
126126
`
127127

128128
const outputPath = path.join(OUTPUT_DIR, `${typeName}.ts`)
@@ -135,8 +135,8 @@ export default ${typeName}Data;
135135
*/
136136
function generateMainIndex() {
137137
const exports = MANIFEST_TYPES.map(typeName => {
138-
return `export { ${typeName}Data } from './${typeName}';
139-
export type { ${toPascalCase(typeName.replace(/s$/, ''))} } from './${typeName}';`
138+
return `export { ${typeName}Data } from './${typeName}'
139+
export type { ${toPascalCase(typeName.replace(/s$/, ''))} } from './${typeName}'`
140140
}).join('\n')
141141

142142
const content = `/**
@@ -172,11 +172,11 @@ function generateGithubStarsFile() {
172172
* Do not edit manually - run the script to regenerate
173173
*/
174174
175-
import githubStarsJson from '../../../data/github-stars.json';
175+
import githubStarsJson from '../../../data/github-stars.json'
176176
177-
export type GithubStarsData = Record<string, Record<string, number | null>>;
177+
export type GithubStarsData = Record<string, Record<string, number | null>>
178178
179-
export const githubStarsData = githubStarsJson as GithubStarsData;
179+
export const githubStarsData = githubStarsJson as GithubStarsData
180180
181181
/**
182182
* Get GitHub stars for a specific product
@@ -185,10 +185,10 @@ export const githubStarsData = githubStarsJson as GithubStarsData;
185185
* @returns The number of stars (in thousands) or null if not available
186186
*/
187187
export function getGithubStars(category: string, id: string): number | null {
188-
return githubStarsData[category]?.[id] ?? null;
188+
return githubStarsData[category]?.[id] ?? null
189189
}
190190
191-
export default githubStarsData;
191+
export default githubStarsData
192192
`
193193

194194
const outputPath = path.join(OUTPUT_DIR, 'github-stars.ts')

scripts/generate-metadata.mjs

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,13 @@ function generateArticleComponentsCode(articles) {
254254
.join('\n')
255255

256256
if (componentEntries) {
257-
componentLines.push(` '${locale}': {\n${componentEntries}\n },`)
257+
// Quote locale keys that contain hyphens or special characters
258+
const localeKey = locale.includes('-') ? `'${locale}'` : locale
259+
componentLines.push(` ${localeKey}: {\n${componentEntries}\n },`)
258260
}
259261
}
260262

261-
return `const articleComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${componentLines.join('\n')}\n};`
263+
return `const articleComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${componentLines.join('\n')}\n}`
262264
}
263265

264266
// Generate component imports for docs
@@ -273,11 +275,13 @@ function generateDocComponentsCode(docs) {
273275
.join('\n')
274276

275277
if (componentEntries) {
276-
componentLines.push(` '${locale}': {\n${componentEntries}\n },`)
278+
// Quote locale keys that contain hyphens or special characters
279+
const localeKey = locale.includes('-') ? `'${locale}'` : locale
280+
componentLines.push(` ${localeKey}: {\n${componentEntries}\n },`)
277281
}
278282
}
279283

280-
return `const docComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${componentLines.join('\n')}\n};`
284+
return `const docComponents: Record<string, Record<string, () => Promise<{ default: React.ComponentType }>>> = {\n${componentLines.join('\n')}\n}`
281285
}
282286

283287
// Generate component import for manifesto (single index.mdx per locale)
@@ -287,13 +291,15 @@ function generateManifestoComponentsCode() {
287291
for (const locale of SUPPORTED_LOCALES) {
288292
const manifestoIndex = path.join(rootDir, `content/manifesto/${locale}/index.mdx`)
289293
if (fs.existsSync(manifestoIndex)) {
294+
// Quote locale keys that contain hyphens or special characters
295+
const localeKey = locale.includes('-') ? `'${locale}'` : locale
290296
componentLines.push(
291-
` '${locale}': () => import('@content/manifesto/${locale}/index.mdx'),`
297+
` ${localeKey}: () => import('@content/manifesto/${locale}/index.mdx'),`
292298
)
293299
}
294300
}
295301

296-
return ` const components: Record<string, () => Promise<{ default: React.ComponentType }>> = {\n${componentLines.join('\n')}\n };`
302+
return ` const components: Record<string, () => Promise<{ default: React.ComponentType }>> = {\n${componentLines.join('\n')}\n }`
297303
}
298304

299305
// Main execution
@@ -345,36 +351,36 @@ export const stackCounts: Record<string, number> = ${JSON.stringify(stackCounts,
345351
import { articlesMetadata } from './metadata';
346352
347353
export type ArticleMetadata = {
348-
title: string;
349-
description: string;
350-
date: string;
351-
slug: string;
352-
};
354+
title: string
355+
description: string
356+
date: string
357+
slug: string
358+
}
353359
354360
// Get articles for a specific locale with fallback to English
355361
export function getArticles(locale: string = 'en'): ArticleMetadata[] {
356-
return articlesMetadata[locale] || articlesMetadata['en'] || [];
362+
return articlesMetadata[locale] || articlesMetadata.en || []
357363
}
358364
359365
// Get all articles (backward compatibility)
360-
export const articles: ArticleMetadata[] = getArticles('en');
366+
export const articles: ArticleMetadata[] = getArticles('en')
361367
362368
// Get a specific article by slug for a given locale
363369
export function getArticleBySlug(slug: string, locale: string = 'en'): ArticleMetadata | undefined {
364-
const localeArticles = getArticles(locale);
365-
return localeArticles.find((article) => article.slug === slug);
370+
const localeArticles = getArticles(locale)
371+
return localeArticles.find(article => article.slug === slug)
366372
}
367373
368374
// MDX components mapping for all locales (dynamic imports)
369375
${articlesComponentsCode}
370376
371377
// Get a specific article component for a given locale and slug
372378
export async function getArticleComponent(locale: string = 'en', slug: string): Promise<React.ComponentType | null> {
373-
const loaders = articleComponents[locale] || articleComponents['en'];
374-
const loader = loaders?.[slug];
375-
if (!loader) return null;
376-
const mdxModule = await loader();
377-
return mdxModule.default;
379+
const loaders = articleComponents[locale] || articleComponents.en
380+
const loader = loaders?.[slug]
381+
if (!loader) return null
382+
const mdxModule = await loader()
383+
return mdxModule.default
378384
}
379385
`
380386

@@ -388,35 +394,35 @@ export async function getArticleComponent(locale: string = 'en', slug: string):
388394
import { docsMetadata } from './metadata';
389395
390396
export type DocSection = {
391-
id: string;
392-
title: string;
393-
slug: string;
394-
};
397+
id: string
398+
title: string
399+
slug: string
400+
}
395401
396402
// Get doc sections for a specific locale with fallback to English
397403
export function getDocSections(locale: string): DocSection[] {
398-
return docsMetadata[locale] || docsMetadata['en'] || [];
404+
return docsMetadata[locale] || docsMetadata.en || []
399405
}
400406
401407
// Get all doc sections (backward compatibility)
402-
export const docSections: DocSection[] = getDocSections('en');
408+
export const docSections: DocSection[] = getDocSections('en')
403409
404410
// Get a specific doc by slug for a given locale
405411
export function getDocBySlug(slug: string, locale: string = 'en'): DocSection | undefined {
406-
const sections = getDocSections(locale);
407-
return sections.find((doc) => doc.slug === slug);
412+
const sections = getDocSections(locale)
413+
return sections.find(doc => doc.slug === slug)
408414
}
409415
410416
// MDX components mapping for all locales (dynamic imports)
411417
${docsComponentsCode}
412418
413419
// Get a specific doc component for a given locale and slug
414420
export async function getDocComponent(locale: string = 'en', slug: string): Promise<React.ComponentType | null> {
415-
const loaders = docComponents[locale] || docComponents['en'];
416-
const loader = loaders?.[slug];
417-
if (!loader) return null;
418-
const mdxModule = await loader();
419-
return mdxModule.default;
421+
const loaders = docComponents[locale] || docComponents.en
422+
const loader = loaders?.[slug]
423+
if (!loader) return null
424+
const mdxModule = await loader()
425+
return mdxModule.default
420426
}
421427
`
422428

@@ -434,9 +440,9 @@ export async function getDocComponent(locale: string = 'en', slug: string): Prom
434440
export async function getManifestoComponent(locale: string = 'en'): Promise<React.ComponentType> {
435441
${manifestoComponentsCode}
436442
437-
const loader = components[locale] || components['en'];
438-
const mdxModule = await loader();
439-
return mdxModule.default;
443+
const loader = components[locale] || components.en
444+
const mdxModule = await loader()
445+
return mdxModule.default
440446
}
441447
`
442448

0 commit comments

Comments
 (0)