-
Notifications
You must be signed in to change notification settings - Fork 265
fix metadata #1440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix metadata #1440
Conversation
✅ Deploy Preview for docs-optimism ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
📝 WalkthroughWalkthroughThis pull request updates multiple aspects of the metadata handling and validation workflow. In the Sequence Diagram(s)sequenceDiagram
participant Dev as Developer/CLI
participant npm as Package Manager
participant CLI as metadata-batch-cli Main
participant MM as metadata-manager.generateMetadata
participant UMD as updateMetadataFile Function
Dev->>npm: Run "validate-metadata"
npm->>CLI: Execute pnpm metadata-batch-cli:dry
CLI->>CLI: Check for CHANGED_FILES environment variable
CLI->>CLI: Retrieve file list via globby if necessary
loop For each file in mdxFiles
CLI->>MM: Generate metadata for file
MM-->>CLI: Return metadata object
CLI->>UMD: Update metadata file using metadata and options
end
CLI->>Dev: Output processing summary with stats
sequenceDiagram
participant GM as generateMetadata
participant EM as existingMetadata
GM->>EM: Read metadata properties
alt personas is a string
GM->>GM: Convert personas into an array
else personas is already an array
GM->>GM: Use personas as-is
end
GM-->>Caller: Return metadata with consistent personas format
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
utils/metadata-manager.ts (1)
109-112
: Good enhancement to ensure consistent type handling.This change ensures the
personas
property is always an array, addressing a potential type inconsistency that could occur ifexistingMetadata.personas
was a string.The implementation is good. For even more robustness, you could also handle the case when
personas
is a non-array, non-string value:let personas = existingMetadata.personas || [] if (typeof personas === 'string') { personas = [personas] +} else if (!Array.isArray(personas)) { + personas = [] }pages/app-developers/tutorials/supersim.mdx (1)
16-16
: Note: Description inconsistency between frontmatter and page content.The page content still contains the longer description that was removed from the frontmatter. Consider updating the page content to match the simplified description in the frontmatter for consistency.
-This is a collection of guides and tutorials to understanding and working with Supersim, including getting started, CLI reference, and chain environment. +This is a collection of guides and tutorials to understanding and working with Supersim.utils/metadata-batch-cli.ts (1)
236-238
: Simple CLI argument parsing implemented.The argument parsing approach is straightforward and effective for the current needs. If the CLI grows in complexity, consider using a dedicated argument parsing library like
yargs
orcommander
for more robust handling.- const isDryRun = process.argv.includes('--dry-run') - const isVerbose = process.argv.includes('--verbose') + import yargs from 'yargs' + const argv = yargs + .option('dry-run', { + alias: 'd', + description: 'Run without making changes', + type: 'boolean' + }) + .option('verbose', { + alias: 'v', + description: 'Show detailed output', + type: 'boolean' + }) + .help() + .argv + + const isDryRun = argv['dry-run'] + const isVerbose = argv.verbose
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
package.json
(1 hunks)pages/app-developers/interop.mdx
(0 hunks)pages/app-developers/tools/build/account-abstraction.mdx
(1 hunks)pages/app-developers/tutorials.mdx
(1 hunks)pages/app-developers/tutorials/supersim.mdx
(1 hunks)utils/metadata-batch-cli.ts
(4 hunks)utils/metadata-manager.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- pages/app-developers/interop.mdx
✅ Files skipped from review due to trivial changes (1)
- pages/app-developers/tools/build/account-abstraction.mdx
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.mdx`: "ALWAYS review Markdown content THOROUGHLY with ...
**/*.mdx
: "ALWAYS review Markdown content THOROUGHLY with the following criteria:
- First, check the frontmatter section at the top of the file:
- For regular pages, ensure ALL these fields are present and not empty:
--- title: [non-empty] lang: [non-empty] description: [non-empty] topic: [non-empty] personas: [non-empty array] categories: [non-empty array] content_type: [valid type] ---
- For landing pages (index.mdx or files with ), only these fields are required:
--- title: [non-empty] lang: [non-empty] description: [non-empty] topic: [non-empty] ---
- If any required fields are missing or empty, comment:
'This file appears to be missing required metadata. You can fix this by running:Review the changes, then run without :dry to apply them.'pnpm metadata-batch-cli:dry "path/to/this/file.mdx"
- Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
- Avoid gender-specific language and use the imperative form.
- Monitor capitalization for emphasis. Avoid using all caps, italics, or bold for emphasis.
- Ensure proper nouns are capitalized in sentences.
- Apply the Oxford comma.
- Use proper title case for buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
- Use correct spelling and grammar at all times (IMPORTANT).
- For H1, H2, and H3 headers:
- Use sentence case, capitalizing only the first word.
- Preserve the capitalization of proper nouns, technical terms, and acronyms as defined in the 'nouns.txt' file located in the root directory of the project.
- Do not automatically lowercase words that appear in the 'nouns.txt' file, regardless of their position in the header.
- Flag any headers that seem to inconsistently apply these rules for manual review.
- When reviewing capitalization, always refer to the 'nouns.txt' file for the correct capitalization of proper nouns and technical terms specific to the project.
"
pages/app-developers/tutorials.mdx
pages/app-developers/tutorials/supersim.mdx
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - docs-optimism
- GitHub Check: Header rules - docs-optimism
- GitHub Check: Pages changed - docs-optimism
🔇 Additional comments (12)
utils/metadata-manager.ts (1)
121-121
: Correctly implemented type-safe assignment.This line now uses the properly processed
personas
variable, ensuring consistent array handling.package.json (1)
19-19
:✅ Verification successful
Improved metadata validation process.
The script now uses the git diff command to identify changed files and passes them to the metadata batch CLI. This approach is more efficient as it only validates files that have changed.
🏁 Script executed:
#!/bin/bash # Description: Check that metadata-batch-cli:dry exists and works as expected # Verify that the metadata-batch-cli:dry script exists grep "metadata-batch-cli:dry" package.json echo "✅ metadata-batch-cli:dry script exists in package.json" # Verify that metadata-batch-cli.ts can handle the CHANGED_FILES environment variable grep "CHANGED_FILES" utils/metadata-batch-cli.ts || echo "⚠️ metadata-batch-cli.ts might not handle CHANGED_FILES environment variable"Length of output: 557
Metadata Validation Process Verified
- The updated
validate-metadata
script inpackage.json
correctly usesgit diff --name-only HEAD
to generate a list of changed files, passing them via theCHANGED_FILES
environment variable tometadata-batch-cli:dry
.- Verification confirms that the
metadata-batch-cli:dry
script is defined inpackage.json
and thatutils/metadata-batch-cli.ts
properly splits and filters theCHANGED_FILES
environment variable.pages/app-developers/tutorials.mdx (1)
1-16
: Corrected content type classification.The change from
guide
tolanding-page
correctly reflects the actual content type of this file, which features a collection of card links rather than a single tutorial.The removal of the
reference
category is appropriate as this page primarily serves as a landing page for tutorials.pages/app-developers/tutorials/supersim.mdx (2)
3-3
: Simplified description for better clarity.The description has been streamlined by removing redundant details, as these are already visible in the page content.
7-8
:✅ Verification successful
Standardized metadata format for personas and categories.
The metadata has been reformatted to use consistent syntax. The
personas
field now uses a single string instead of a YAML list, and thecategories
field uses an array notation.The categories have been updated to better reflect the content focus, adding "cli" and removing "testing" and "protocol" categories.
🏁 Script executed:
#!/bin/bash # Description: Check metadata schema validation rules for personas and categories # Check if there's a config file defining metadata rules fd -t f "keywords.config.yaml" || fd -t f "metadata.config.yaml" || fd -t f "*config*.yaml" # Look for specific rules about personas and categories formats if [ -f "keywords.config.yaml" ]; then echo "Checking keywords.config.yaml for metadata rules:" grep -A 10 "persona:" keywords.config.yaml grep -A 10 "categories:" keywords.config.yaml fiLength of output: 862
Metadata Standards for MDX File Verified
The metadata in
pages/app-developers/tutorials/supersim.mdx
has been updated to follow our standardized format. The change now uses a single string for the personas field (with the value "app-developer") and expresses the categories as an array. These updates align with the schema rules defined inkeywords.config.yaml
(which confirms "app-developer" is a valid persona and that the category constraints are met). Additionally, the updated categories—adding "cli" while removing "testing" and "protocol"—more accurately reflect the content focus.utils/metadata-batch-cli.ts (7)
10-11
: Good addition of necessary imports.These new imports support the enhanced functionality of the CLI tool. The
generateMetadata
function is used in the updatedmain
function, andglobby
is used for file pattern matching which is more powerful than the nativeglob
.
179-185
: Improved configuration handling with better options management.The previous implementation likely used hardcoded values, while this update properly passes along the CLI options to the
updateMetadataFile
function. The change fromvalidateOnly: true
andprMode: true
tofalse
is significant as it changes behavior from validation-only mode to actual metadata updating.
240-249
: Good implementation of flexible file source handling.The code now properly handles files from multiple sources:
- From the
CHANGED_FILES
environment variable (useful for CI/CD contexts)- From glob patterns passed as command line arguments
This makes the tool more versatile and integration-friendly.
251-259
: Input validation and early exit look good.The code appropriately filters for MDX files and provides a clean exit path when no files need processing. This prevents unnecessary work and provides clear feedback to the user.
263-288
: Robust file processing implementation with proper error handling.The new implementation processes each file individually with:
- Proper metadata generation using the imported
generateMetadata
function- Appropriate update handling with configurable options
- Clear output reporting
- Isolated error handling that prevents a single file failure from stopping the entire process
This is a significant improvement in robustness.
290-296
: Clear summary reporting with visual indicators.The summary output uses color coding and clear statistics to help users quickly understand the results of the operation. The conditional messaging based on
needsReviewCount
provides appropriate feedback for different scenarios.
297-300
: Improved error handling and exit code.The top-level error handler now includes proper console formatting and sets a non-zero exit code on failure, which is important for script integration and CI/CD pipelines.
No description provided.