Skip to content

Commit f769e53

Browse files
ericyangpanclaude
andcommitted
refactor(metadata): consolidate duplicate metadata logic with helper functions
Introduced buildMetadataWithSocial helper to reduce code duplication across all metadata generators. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 173c4fe commit f769e53

File tree

3 files changed

+210
-209
lines changed

3 files changed

+210
-209
lines changed

scripts/README.md

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ scripts/
1616
│ └── generate-metadata.mjs
1717
├── refactor/
1818
│ ├── index.mjs # Entry point for all refactoring scripts
19-
│ └── sort-manifest-fields.mjs
20-
└── fetch/
21-
├── index.mjs # Entry point for all fetch scripts
22-
└── fetch-github-stars.mjs
19+
│ ├── sort-manifest-fields.mjs
20+
│ ├── sort-locales-fields.mjs
21+
│ └── export-vendors.mjs
22+
├── fetch/
23+
│ ├── index.mjs # Entry point for all fetch scripts
24+
│ └── fetch-github-stars.mjs
25+
├── _shared/
26+
│ └── runner.mjs # Shared script runner for entry points
27+
└── temp/ # Temporary experimental scripts
2328
```
2429

2530
## Usage
@@ -64,6 +69,11 @@ Or directly using Node:
6469
# Run generation/fetch scripts
6570
node scripts/generate/index.mjs metadata
6671
node scripts/fetch/index.mjs github-stars
72+
73+
# Run specific refactor scripts
74+
node scripts/refactor/index.mjs sort-manifest-fields
75+
node scripts/refactor/index.mjs sort-locales-fields
76+
node scripts/refactor/index.mjs export-vendors
6777
```
6878

6979
## Validation (Test-based)
@@ -172,13 +182,44 @@ Sorts fields in manifest JSON files according to their schema definitions.
172182

173183
```bash
174184
npm run refactor:sort-fields
185+
# or
186+
node scripts/refactor/index.mjs sort-manifest-fields
175187
```
176188

177189
**What it does:**
178190
- Reorders fields in manifest files to match schema property order
179191
- Ensures consistent field ordering across all manifests
180192
- Handles nested objects and arrays
181193

194+
### sort-locales-fields.mjs
195+
196+
Sorts fields in locale translation JSON files alphabetically for consistency.
197+
198+
```bash
199+
node scripts/refactor/index.mjs sort-locales-fields
200+
```
201+
202+
**What it does:**
203+
- Sorts keys in translation files (`translations/*/pages/*.json`, `translations/*/components.json`, etc.)
204+
- Ensures consistent ordering across all locale files
205+
- Helps with maintainability and git diff readability
206+
207+
### export-vendors.mjs
208+
209+
Exports vendor information from manifest files to vendor manifests.
210+
211+
```bash
212+
node scripts/refactor/index.mjs export-vendors
213+
```
214+
215+
**What it does:**
216+
- Extracts vendor data from ide, cli, extension, model, and provider manifests
217+
- Creates vendor files in `manifests/vendors/` if they don't already exist
218+
- Merges vendor information from multiple manifest sources
219+
- Skips existing vendor files (does not overwrite)
220+
221+
**Note:** This script only creates new vendor files. It will skip vendors that already have a manifest file.
222+
182223
## Data Fetching Scripts
183224

184225
### fetch-github-stars.mjs
@@ -187,6 +228,8 @@ Fetches GitHub star counts for projects listed in manifests.
187228

188229
```bash
189230
npm run fetch:github-stars
231+
# or
232+
node scripts/fetch/index.mjs github-stars
190233
```
191234

192235
**What it does:**
@@ -199,6 +242,23 @@ npm run fetch:github-stars
199242

200243
**Note:** Without a GitHub token, you may hit rate limits (60 requests/hour).
201244

245+
## Additional Tools
246+
247+
### Benchmark Fetcher
248+
249+
Fetching benchmark performance data is handled by a separate skill:
250+
251+
```bash
252+
node .claude/skills/benchmark-fetcher/scripts/fetch-benchmarks.mjs
253+
```
254+
255+
**What it does:**
256+
- Fetches benchmark scores from 6 leaderboard websites using Playwright MCP
257+
- Supports SWE-bench, TerminalBench, SciCode, LiveCodeBench, MMMU, MMMU Pro, and WebDevArena
258+
- Updates model manifests with latest benchmark scores
259+
260+
For full documentation, see `.claude/skills/benchmark-fetcher/SKILL.md`
261+
202262
## Build Process
203263

204264
The build process runs validation tests and generation scripts automatically:
@@ -251,6 +311,8 @@ npm run test:validate
251311
npm run generate:manifests
252312
npm run generate:metadata
253313
npm run refactor:sort-fields
314+
npm run refactor:sort-locales-fields
315+
npm run fetch:github-stars
254316
```
255317

256318
## Manual Execution

scripts/generate/generate-metadata.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ const rootDir = path.join(__dirname, '../..')
1919
function getSupportedLocales() {
2020
const configPath = path.join(rootDir, 'src/i18n/config.ts')
2121
const configContent = fs.readFileSync(configPath, 'utf8')
22-
// Extract locales array from: export const locales = ['en', 'zh-Hans', 'de'] as const;
23-
const match = configContent.match(/export const locales = \[([^\]]+)\]/)
24-
if (!match) {
22+
// Extract the content between "export const locales = [" and "] as const"
23+
const arrayMatch = configContent.match(/export const locales = \[([\s\S]*?)\] as const/)
24+
if (!arrayMatch) {
2525
throw new Error('Could not find locales export in src/i18n/config.ts')
2626
}
27-
// Parse the array: "'en', 'zh-Hans', 'de'" -> ['en', 'zh-Hans', 'de']
28-
return match[1].split(',').map(s => s.trim().replace(/['"]/g, ''))
27+
// Extract all quoted strings from the array content
28+
const stringMatches = arrayMatch[1].matchAll(/'([^']+)'/g)
29+
return Array.from(stringMatches, m => m[1])
2930
}
3031

3132
const SUPPORTED_LOCALES = getSupportedLocales()

0 commit comments

Comments
 (0)