feat(migrate): resolve VTEX content image refs to absolute URLs + download them - #211
Merged
Conversation
…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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:blocks.json(e.g./arquivos/ids/1→https://store.vtexassets.com/…) — the captured CMS content is now addressable.assets/content/+ writes acontent-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-routeddownloadContentImages. 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 showshttps://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.jsonheld site‑relative pointers and missed catalog images; now props use absolute URLs and the bundle carries local copies for portability.blocks.jsonrefs to absolute URLs, scanwindow.__STATE__forvtexassets/vteximgURLs, download CMS+catalog images toassets/content/, and writecontent-assets.json(url → local file). Cap is 150/run; console logs report totals and skipped.isImageRef,isImageUrl,resolveRef,collectImageRefs,rewriteBlockUrls,countContentImages,contentImageName) and I/O (downloadContentImages);readVtexStateImagesadded. Exporters andprintResultssurface 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.