Takazudo Modular Docs

Type to search...

to open search from anywhere

l-metadata-update

Process new product images and update metadata-db.json on main. Use when: (1) User says '/l-metadata-update' or 'update metadata', (2) New product images need processing and uploading to R2, (3) metad...

Metadata Update Workflow

Process new images, upload to R2, rebuild metadata-db.json, and merge to main via a skip-CI branch.

Prerequisites

  • .env must contain R2_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY
  • New source images must exist in /imgs/ (Dropbox symlink)

Workflow

1. Record current branch

CURRENT_BRANCH=$(git branch --show-current)

2. Clean and download existing images from R2

rm -rf ./static/images/p/*
pnpm r2:download

Ensures convimgs only processes truly new images.

Note: do NOT use node -r dotenv/config scripts/download-images-from-r2.mjs — the dotenv npm package is not installed in this repo, and the script has its own .env loader (no external dependency). Always invoke through the package.json scripts (pnpm r2:download, pnpm convimgs:upload).

3. Process and upload new images

pnpm convimgs:upload

Phase 1: convimgs (skip existing, process new). Phase 2: R2 upload (incremental).

4. Rebuild metadata DB

pnpm build:metadata

Warnings about __ogonly slugs missing metadata.json are expected.

5. Create metadata-update branch and PR

Generate branch name: metadata-update-YYMMDD-HHMM

BRANCH_NAME="metadata-update-$(date +%y%m%d-%H%M)"
git stash
git checkout main && git pull origin main
git checkout -b "$BRANCH_NAME"
git stash pop
git add metadata-db.json
git commit -m "[data] Update metadata-db.json with new product images"
git push -u origin "$BRANCH_NAME"
gh pr create --title "[data] Update metadata-db.json" --base main --body "Auto-generated metadata update"
gh pr merge --merge

CI is skipped for metadata-update-* branches.

6. Return to original branch

git checkout "$CURRENT_BRANCH"

Inform user they can merge main into their branch to pick up the metadata:

git fetch origin main && git merge origin/main --no-edit

Notes

  • metadata-update-* branches skip CI (pr-checks.yml, security.yml)
  • metadata-db.json is one-record-per-line, sorted by slug — do not reformat
  • Steps 2-3 can take several minutes for large image sets