Skip to content

feat(migrate): resolve VTEX content image refs to absolute URLs + download them - #211

Merged
JonasJesus42 merged 2 commits into
mainfrom
migrate-vtex-content-images
Aug 17, 2026
Merged

feat(migrate): resolve VTEX content image refs to absolute URLs + download them#211
JonasJesus42 merged 2 commits into
mainfrom
migrate-vtex-content-images

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Follow-up on the VTEX content capture, from reviewing blocks.json.

VTEX block props reference content images as site-relative pointers (/arquivos/ids/…, /img/…), not full URLs. Now migrate:

  • Resolves those refs to the real absolute content URL in blocks.json (e.g. /arquivos/ids/1https://store.vtexassets.com/…) — the captured CMS content is now addressable.
  • Downloads the content images to assets/content/ + writes a content-assets.json (url → local file) map, so the migration ships the store's actual content imagery. Capped at 80/run.

New pure helpers (isImageRef, resolveRef, collectImageRefs, rewriteBlockUrls, countContentImages) + browser-routed downloadContentImages. Exporters/printResults surface how many URLs were resolved/downloaded.

Verification

7 unit tests. Full suite green (1100), tsc + biome clean, build OK. Live electrolux.com.ec: 26 image URLs resolved (relative→absolute), 20 downloaded; blocks.json now shows https://electrolux.vtexassets.com/... URLs.

Off main.

🤖 Generated with Claude Code


Summary by cubic

Resolves VTEX content image refs to absolute URLs and downloads them into the migration bundle, now including product/catalog imagery from the VTEX Apollo state. Previously blocks.json held site‑relative pointers and missed catalog images; now props use absolute URLs and the bundle carries local copies for portability.

  • Migrate flow: collect image refs from block props, rewrite blocks.json refs to absolute URLs, scan window.__STATE__ for vtexassets/vteximg URLs, download CMS+catalog images to assets/content/, and write content-assets.json (url → local file). Cap is 150/run; console logs report totals and skipped.
  • Notables: new helpers (isImageRef, isImageUrl, resolveRef, collectImageRefs, rewriteBlockUrls, countContentImages, contentImageName) and I/O (downloadContentImages); readVtexStateImages added. Exporters and printResults surface image counts; docs updated. Tests cover detection, resolution, deep immutable rewrite, counting, and filename derivation.

Written for commit 895639f. Summary will update on new commits.

Review in cubic

JonasJesus42 and others added 2 commits August 17, 2026 19:05
…nload them

VTEX block props reference content images as site-relative pointers
(`/arquivos/ids/…`, `/img/…`), not full URLs. Now migrate:

- **Resolves those refs to the real absolute content URL** in blocks.json
  (e.g. `/arquivos/ids/1` → `https://store.vtexassets.com/…`), so the captured
  CMS content is addressable.
- **Downloads** the content images to `assets/content/` and writes a
  `content-assets.json` url→local-file map — the migration ships the store's
  actual content imagery. Capped at 80 images/run.

New `src/migrate/vtex/content-assets.ts` (pure: isImageRef/resolveRef/
collectImageRefs/rewriteBlockUrls/countContentImages; I/O: downloadContentImages).
Exporters + printResults surface how many image URLs were resolved/downloaded.

Test: 7 cases (relative+absolute detection, resolve, deep immutable rewrite,
count). Full suite green (1100), tsc + biome clean, build OK. Live
electrolux.com.ec: 26 URLs resolved (relative→absolute), 20 downloaded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lo state

Only CMS-props images were captured (~26 on Electrolux) — the product/catalog
imagery lives in `window.__STATE__` (Apollo cache), not in block props, so the
migration was missing most of the store's images. `readVtexStateImages` now
scans the serialized state for vtexassets/vteximg image URLs and adds them to
the content-image download. Cap raised to 150/run.

Live electrolux.com.ec: 20 → 108 image URLs (26 CMS + 82 catalog), 102 downloaded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JonasJesus42
JonasJesus42 merged commit 3536a7a into main Aug 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant