Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions docs/card-field-rename.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path-to-gts-root> dry-run yes
```

3) If the output looks right, apply the changes:

```sh
node scripts/rename-card-fields-gts.js <path-to-gts-root> 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.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
10 changes: 5 additions & 5 deletions packages/experiments-realm/file-links-example.gts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -36,9 +36,9 @@ export class FileLinksExample extends CardDef {
<template>
<article class='file-links-example'>
<header>
<h1>Title: {{@model.title}}</h1>
{{#if @model.description}}
<p class='description'>{{@model.description}}</p>
<h1>Title: {{@model.cardTitle}}</h1>
{{#if @model.cardDescription}}
<p class='description'>{{@model.cardDescription}}</p>
{{/if}}
</header>

Expand Down
Loading
Loading