diff --git a/docs/card-field-rename.md b/docs/card-field-rename.md index 68cd7d7042..6d0b6f1122 100644 --- a/docs/card-field-rename.md +++ b/docs/card-field-rename.md @@ -32,6 +32,53 @@ Notes: - It writes a `.bak` file next to each updated JSON file when backups are enabled (`yes`). - Use `no` as the third argument if you do not want backups. +## Rename fields in card definitions (.gts) + +Run the GTS codemod against card definition sources (including templates): + +1) Pick a root directory that contains `.gts` card definitions. + - Common choices: + - `packages/` (host + base + other packages) + - `packages/catalog-realm/` + - `packages/experiments-realm/` + - Repo root to cover all of the above + +2) Dry-run to preview the list of files that would change: + +```sh +node scripts/rename-card-fields-gts.js dry-run yes +``` + +3) If the output looks right, apply the changes: + +```sh +node scripts/rename-card-fields-gts.js apply yes +``` + +Notes: + +- The script scans for `.gts` files recursively. +- It writes a `.bak` file next to each updated file when backups are enabled (`yes`). +- Use `no` as the third argument if you do not want backups. +- It does not touch `data-test-field="cardInfo-*"` attributes. + +### Dependencies + +The GTS codemod relies on dependencies already pinned in the repo: + +- `@glimmer/syntax` (template parsing/printing) +- `@babel/parser` and `@babel/traverse` (script AST edits) + +Install them via the repo's toolchain: + +```sh +pnpm install +``` + +Notes: + +- This project uses Volta for Node + pnpm versions (see `package.json`). + ## AI conversations Existing AI conversations that reference the old card structure will not work after this change. Start new conversations to ensure prompts and payloads use `cardTitle`/`cardDescription`/`cardThumbnailURL` and updated `cardInfo` fields. diff --git a/package.json b/package.json index 06944e670d..fec4381b50 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,10 @@ "@actions/core": "catalog:", "@actions/github": "catalog:", "@babel/core": "catalog:", + "@babel/parser": "catalog:", + "@babel/traverse": "catalog:", "@glimmer/component": "catalog:", + "@glimmer/syntax": "^0.95.0", "@glimmer/tracking": "^1.1.2", "@glint/core": "1.3.0", "@glint/environment-ember-loose": "catalog:", diff --git a/packages/experiments-realm/file-links-example.gts b/packages/experiments-realm/file-links-example.gts index be0b2fd1ac..6a20796ebf 100644 --- a/packages/experiments-realm/file-links-example.gts +++ b/packages/experiments-realm/file-links-example.gts @@ -23,8 +23,8 @@ import { FileDef } from 'https://cardstack.com/base/file-api'; export class FileLinksExample extends CardDef { static displayName = 'File Links Example'; - @field title = contains(StringField); - @field description = contains(StringField); + @field cardTitle = contains(StringField); + @field cardDescription = contains(StringField); // Single file link - e.g., a main document or primary attachment @field primaryDocument = linksTo(FileDef); @@ -36,9 +36,9 @@ export class FileLinksExample extends CardDef {