# Pack Migrator

Browser tool to convert a v1 unit JSON file to v2 pack format.
**https://contexts.live/org/{slug}/tools/cx-pack-migrate.html**

---

## What it does

Reads a v1 unit JSON (drag-drop or file picker), migrates it to v2 pack
format, shows a migration report, and offers a download.

Already-v2 files are detected and flagged — no changes made.

---

## Usage

1. Open the tool in a browser
2. Drop a `.json` file onto the drop zone, or click to browse
3. Review the migration report — what was mapped, kept, or dropped
4. Check the output preview (first 40 lines of JSON)
5. Click **Download v2 JSON** — saves with the same filename

---

## Migration map

| v1 field | v2 field | Notes |
|----------|----------|-------|
| `title.text.*` | `meta.title.*` | Lang object preserved |
| `id.text.en` | `meta.id` | Scalar string |
| `metadata.language` | `meta.language` | |
| `metadata.*` (other) | dropped | |
| `lines[].text.*` | `lines[].st.text.*` | |
| `lines[].adTextEn` | `lines[].ad.text.en` | |
| `lines[].audio` | `lines[].ad.audio.en` | |
| `lines[].type: "unit"` | `{ "pack": "filename" }` | Text and url dropped |
| `Otype`, `url` | dropped | |

Fields already in v2 form (e.g. `st.text.*`) are preserved as-is.

If no `id` is found, it is guessed from the filename.

---

## Notes

- The tool runs entirely in the browser — nothing is uploaded to the server
- Batch migration (multiple files) is not yet supported — run once per file
- After migration, test the pack with a display page before deploying
