There are two scripts available for automatically updating the data structures across the data/groups
JSON files: npm run make-migration
and npm run apply-migration
.
This is an AI enabled script; you'll need to set an Anthropic API key in your .env
file to use this feature. Use with caution!
New migrations will be applied according to the TypeScript type definitions in the src/types
folder, as well as user-provided instructions.
Make sure you update your type definitions before running the migration script!
# Interactive mode
npm run make-migration
# Command line mode
npm run make-migration -- --prompt "your migration instructions" --groups "group1,group2"
# Migrate a single group
npm run make-migration -- -p "Update booking field structure" -g "bristol-tennis"
# Migrate multiple specific groups
npm run make-migration -- --prompt "Add price range field" --groups "group1,group2,group3"
# Migration with complex changes
npm run make-migration -- --prompt "Convert all event times to 24-hour format and add capacity limits based on venue size"
Flag | Alias | Description | Required | Example |
---|---|---|---|---|
--prompt |
-p |
Instructions for how to modify the group data | No | --prompt "Add a new field called capacity" |
--groups |
-g |
Comma-separated list of group slugs to migrate | No | --groups "group1,group2,group3" |
If you run the script without any flags, it will enter interactive mode and prompt you for:
- Migration instructions
- Whether to migrate all groups
- If not migrating all groups, which specific groups to migrate
The script will:
- Create a
details.new
file alongside each group's originaldetails.json
- Display progress for each group being processed
- Show a summary of token usage and costs at the end
- Prompt you to run the apply-migration script when ready
# Migrate specific groups
npm run make-migration -- --prompt "Add a capacity field of 20 to all indoor events" --groups "bristol-badminton,bristol-tennis"
# Migrate all groups interactively
npm run make-migration
The apply migration script takes the generated details.new
files and applies them to the original files after creating backups.
npm run apply-migration
This script does not accept any command line arguments as it automatically detects and processes all pending migrations.
- Scans for any
details.new
files in the groups directory - Lists all found pending migrations
- Asks for confirmation before proceeding
- For each confirmed group:
- Copies the new version over the original
- Deletes the
.new
file
- Provides feedback about each successful migration
-
Update your type definitions, making note of any changes you'd like to prompt the AI with later.
-
Run the migration script:
npm run make-migration
-
Review the generated
details.new
files manually -
When satisfied with the changes, apply the migration:
npm run apply-migration
-
Verify the changes in the original
details.json
files, use the git commit diff to verify every change made is as expected.
Log all the folders in the groups directory.
ls -d data/groups/*/ | cut -d'/' -f3 | tr '\n' ',' | sed 's/,$//'