Skip to content

Commit 7c17c0a

Browse files
committed
fix metadata
1 parent 1c78b1f commit 7c17c0a

File tree

7 files changed

+73
-55
lines changed

7 files changed

+73
-55
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"metadata-batch-cli": "NODE_NO_WARNINGS=1 node --loader ts-node/esm utils/metadata-batch-cli.ts",
1717
"metadata-batch-cli:dry": "pnpm metadata-batch-cli --dry-run",
1818
"metadata-batch-cli:verbose": "pnpm metadata-batch-cli --verbose",
19-
"validate-metadata": "CHANGED_FILES=$(git diff --name-only HEAD) NODE_NO_WARNINGS=1 node --loader ts-node/esm utils/metadata-manager.ts",
19+
"validate-metadata": "CHANGED_FILES=$(git diff --name-only HEAD) pnpm metadata-batch-cli:dry",
2020
"validate-pr-metadata": "NODE_NO_WARNINGS=1 node --loader ts-node/esm utils/metadata-manager.ts --pr",
2121
"dev": "next dev",
2222
"build": "next build",

pages/app-developers/interop.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ personas:
99
- protocol-developer
1010
categories:
1111
- protocol
12-
- architecture
1312
- mainnet
1413
is_imported_content: 'true'
1514
---

pages/app-developers/tools/build/account-abstraction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ personas:
1111
categories:
1212
- account-abstraction
1313
- paymasters
14-
- Transactions
14+
- transactions
1515
is_imported_content: 'false'
1616
---
1717

pages/app-developers/tutorials.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ description: >-
55
topics such as bridging tokens, deploying contracts, and estimating
66
transaction costs.
77
lang: en-US
8-
content_type: guide
8+
content_type: landing-page
99
topic: app-dev-tutorials
1010
personas:
1111
- app-developer
1212
categories:
1313
- mainnet
1414
- testnet
15-
- reference
1615
is_imported_content: 'false'
1716
---
1817

pages/app-developers/tutorials/supersim.mdx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
---
22
title: Supersim guides and tutorials
3-
description: >-
4-
A collection of guides and tutorials to understanding and working with
5-
Supersim, including getting started, CLI reference, and chain environment.
3+
description: A collection of guides and tutorials to understanding and working with Supersim.
64
lang: en-US
75
content_type: tutorial
86
topic: supersim-guides-and-tutorials
9-
personas:
10-
- app-developer
11-
categories:
12-
- supersim
13-
- devnets
14-
- testing
15-
- protocol
7+
personas: app-developer
8+
categories: ['supersim', 'devnets', 'cli']
169
is_imported_content: 'false'
1710
---
1811

utils/metadata-batch-cli.ts

Lines changed: 61 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { updateMetadata as updateMetadataFile } from './metadata-manager'
77
import matter from 'gray-matter'
88
import { analyzeContent } from './metadata-analyzer'
99
import { MetadataResult } from './types/metadata-types'
10+
import { generateMetadata } from './metadata-manager'
11+
import globby from 'globby'
1012

1113
// @ts-ignore
1214
const globModule = await import('glob')
@@ -174,12 +176,12 @@ async function processFiles(files: string[], options: CliOptions): Promise<{
174176
const content = await fs.readFile(file, 'utf8')
175177
const { data: frontmatter } = matter(content)
176178
const analysis = analyzeContent(content, file, options.verbose)
177-
const result = await updateMetadataFile(file, {
178-
dryRun: true,
179-
verbose: false,
179+
const result = await updateMetadataFile(file, {
180+
dryRun: options.dryRun,
181+
verbose: options.verbose,
180182
analysis,
181-
validateOnly: true,
182-
prMode: true
183+
validateOnly: false,
184+
prMode: false
183185
})
184186

185187
console.log(`\n${colors.blue}📄 ${file}${colors.reset}`)
@@ -199,7 +201,7 @@ async function processFiles(files: string[], options: CliOptions): Promise<{
199201
stats.needsReview++
200202
} else {
201203
if (!options.dryRun) {
202-
await updateMetadataFile(file, {
204+
await updateMetadataFile(file, {
203205
dryRun: false,
204206
verbose: options.verbose || false,
205207
analysis,
@@ -231,50 +233,70 @@ async function processFiles(files: string[], options: CliOptions): Promise<{
231233

232234
async function main() {
233235
try {
234-
console.log('Checking metadata...')
236+
const isDryRun = process.argv.includes('--dry-run')
237+
const isVerbose = process.argv.includes('--verbose')
235238

236-
let modifiedFiles: string[] = []
237-
238-
// Check if we have a direct glob pattern argument
239-
const globPattern = process.argv.find(arg => arg.includes('*.mdx'))
240-
if (globPattern) {
241-
modifiedFiles = await globModule.glob(globPattern)
239+
// Get files from either CHANGED_FILES or command line glob patterns
240+
let mdxFiles = []
241+
if (process.env.CHANGED_FILES) {
242+
mdxFiles = process.env.CHANGED_FILES.split('\n').filter(Boolean)
242243
} else {
243-
// Fall back to CHANGED_FILES if no glob pattern
244-
const gitOutput = process.env.CHANGED_FILES || ''
245-
modifiedFiles = gitOutput
246-
.split('\n')
247-
.filter(file => file.trim())
248-
.filter(file => file.endsWith('.mdx'))
249-
.map(file => path.resolve(process.cwd(), file))
250-
}
251-
252-
if (modifiedFiles.length === 0) {
253-
console.log(`${colors.green}✓ No MDX files to check${colors.reset}`)
254-
process.exit(0)
244+
// Get glob patterns from command line args (skip the first two args)
245+
const patterns = process.argv.slice(2).filter(arg => !arg.startsWith('--'))
246+
if (patterns.length > 0) {
247+
mdxFiles = await globby(patterns)
248+
}
255249
}
256-
257-
// Validate file paths
258-
const validFiles = await validateFilePaths(modifiedFiles)
259250

260-
if (validFiles.length === 0) {
261-
console.log(`${colors.yellow}⚠️ No valid files to check${colors.reset}`)
251+
mdxFiles = mdxFiles.filter(file => file.endsWith('.mdx'))
252+
253+
if (mdxFiles.length === 0) {
254+
console.log('✓ No MDX files to check')
262255
process.exit(0)
263256
}
264257

265-
console.log(`Found ${validFiles.length} valid files to check`)
258+
console.log(`Found ${mdxFiles.length} valid files to check\n`)
266259

267-
const options: CliOptions = {
268-
dryRun: process.argv.includes('--dry-run'),
269-
verbose: process.argv.includes('--verbose')
260+
let processedCount = 0
261+
let needsReviewCount = 0
262+
263+
for (const file of mdxFiles) {
264+
try {
265+
const metadata = await generateMetadata(file)
266+
const result = await updateMetadataFile(file, {
267+
dryRun: isDryRun,
268+
verbose: isVerbose,
269+
validateOnly: false,
270+
prMode: false,
271+
analysis: metadata
272+
})
273+
274+
processedCount++
275+
276+
// Show metadata for each file
277+
console.log(`\nFile: ${file}`)
278+
console.log('Categories:', metadata.categories?.join(', ') || 'none')
279+
280+
if (!result.isValid) {
281+
needsReviewCount++
282+
console.log('\x1b[33m⚠️ Review needed:\x1b[0m')
283+
result.errors.forEach(error => console.log(` → ${error}`))
284+
}
285+
} catch (error) {
286+
console.error(`Error processing ${file}:`, error)
287+
}
270288
}
271289

272-
const { hasErrors, stats } = await processFiles(validFiles, options)
273-
// Don't exit with error code - we want this to be non-blocking
274-
process.exit(0)
290+
// Summary with colors
291+
console.log(`\n${processedCount} files processed`)
292+
if (needsReviewCount === 0) {
293+
console.log('\x1b[32m✓ All files have valid metadata\x1b[0m')
294+
} else {
295+
console.log(`\x1b[33m⚠️ ${needsReviewCount} files need review\x1b[0m`)
296+
}
275297
} catch (error) {
276-
console.error(`${colors.yellow}⚠️ Error: ${error}${colors.reset}`)
277-
process.exit(0)
298+
console.error('\x1b[31mError:\x1b[0m', error)
299+
process.exit(1)
278300
}
279301
}
280302

utils/metadata-manager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,19 @@ export async function generateMetadata(filePath: string): Promise<MetadataResult
106106
categories = categories.split(',').map(c => c.trim())
107107
}
108108

109+
let personas = existingMetadata.personas || []
110+
if (typeof personas === 'string') {
111+
personas = [personas]
112+
}
113+
109114
const metadata: MetadataResult = {
110115
...existingMetadata,
111116
...analysis,
112117
title: existingMetadata.title || '',
113118
lang: existingMetadata.lang || 'en',
114119
description: existingMetadata.description || '',
115120
topic: existingMetadata.topic || '',
116-
personas: existingMetadata.personas || [],
121+
personas: personas,
117122
content_type: existingMetadata.content_type || '',
118123
categories: categories,
119124
is_imported_content: existingMetadata.is_imported_content || 'false',

0 commit comments

Comments
 (0)