-
Notifications
You must be signed in to change notification settings - Fork 12
Script to rename CardDef and CardInfo fields in gts files #3882
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
base: main
Are you sure you want to change the base?
Conversation
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90bc6f4644
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
packages/base/markdown-file-def.gts
Outdated
| @field cardTitle = contains(StringField); | ||
| @field excerpt = contains(StringField); | ||
| @field content = contains(StringField); | ||
|
|
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.
Populate MarkdownDef cardTitle
MarkdownDef now defines @field cardTitle, but extractAttributes later in this file still returns a title property (and the preview component reads model.title), so importing a markdown file no longer populates the card’s title from the document heading. In practice the preview will fall back to the filename and cardTitle remains unset for markdown cards. Updating the extracted attribute and preview to use cardTitle would keep the previous behavior.
Useful? React with 👍 / 👎.
Preview deployments |
scripts/rename-card-fields-gts.js
Outdated
| [/@model\.title\b/g, '@model.cardTitle'], | ||
| [/@model\.description\b/g, '@model.cardDescription'], | ||
| [/@model\.thumbnailURL\b/g, '@model.cardThumbnailURL'], | ||
| ]; |
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.
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.
Ah I see, I'll use the codemod tool
Host Test Results 1 files 1 suites 1h 40m 59s ⏱️ Results for commit 66a62f3. ♻️ This comment has been updated with latest results. |
wow yes you’re right, sorry about that 😵 |
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.
Pull request overview
This PR introduces a script to automatically rename CardDef and CardInfo fields in .gts files from the old naming convention (title, description, thumbnailURL) to the new naming convention (cardTitle, cardDescription, cardThumbnailURL for CardDef fields, and name, summary, cardThumbnailURL for CardInfo fields). The PR includes both the script implementation and the results of running it on the codebase.
Changes:
- Added
scripts/rename-card-fields-gts.jsto automate field renaming in.gtsfiles - Updated documentation in
docs/card-field-rename.mdwith instructions for using the new script - Applied automated field renaming across multiple
.gtsfiles in the codebase
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/rename-card-fields-gts.js | New script implementing pattern-based field renaming for .gts files with regex replacements |
| docs/card-field-rename.md | Added documentation section explaining how to use the .gts renaming script |
| packages/host/tests/helpers/interact-submode-setup.gts | Renamed @field title to @field cardTitle in FileLinkCard class |
| packages/host/tests/acceptance/code-submode/file-def-navigation-test.gts | Renamed @field title to @field cardTitle in FileLinkCard test class |
| packages/host/tests/acceptance/code-submode/card-playground-test.gts | Updated cardInfo object keys from title to name in test fixture |
| packages/experiments-realm/file-links-example.gts | Renamed field definitions and template references from title/description to cardTitle/cardDescription |
| packages/catalog-realm/system-card/model-updater.gts | Updated cardInfo object keys from title/description/thumbnailURL to name/summary/cardThumbnailURL |
| packages/base/markdown-file-def.gts | Renamed @field title to @field cardTitle |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/host/tests/acceptance/code-submode/file-def-navigation-test.gts
Outdated
Show resolved
Hide resolved
90bc6f4 to
66a62f3
Compare
|
I updated this to use codemod-tool instead of string replacement. I’ve also run the script in staging against my realms, and it works. Please check it again. |


In this PR, I also included the results of the renaming script.