Skip to content

feat: write migrated assets to theme during themes:migrate#337

Merged
luis-almeida merged 2 commits into
masterfrom
luis/themes_migrate_assets
May 1, 2026
Merged

feat: write migrated assets to theme during themes:migrate#337
luis-almeida merged 2 commits into
masterfrom
luis/themes_migrate_assets

Conversation

@luis-almeida
Copy link
Copy Markdown
Contributor

@luis-almeida luis-almeida commented Mar 25, 2026

Summary

  • The migrations API now returns an assets hash (filename → base64-encoded content) alongside metadata and templates
  • Added rewriteAssets to decode and write each returned asset to the theme's assets/ folder
  • Existing assets with the same filename are overwritten

Test plan

  • Unit tests for rewriteAssets (base64 decoding, multiple file types, empty hash, error handling)
  • Unit tests for migrate updated to verify rewriteAssets is called with correct args
  • Functional test updated to verify asset file written to disk after migration

@luis-almeida luis-almeida force-pushed the luis/themes_migrate_assets branch from 348b5fc to 7a8cc3d Compare March 26, 2026 09:26
@luis-almeida luis-almeida marked this pull request as ready for review March 26, 2026 10:15
@luis-almeida luis-almeida requested a review from a team as a code owner March 26, 2026 10:15
Copilot AI review requested due to automatic review settings March 26, 2026 10:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for persisting migrated theme assets returned by the theming migrations API by decoding base64 content and writing files into the local theme’s assets/ directory.

Changes:

  • Extend themes:migrate to call a new rewriteAssets helper with API-returned assets.
  • Add rewriteAssets implementation + unit tests for decoding/writing and error cases.
  • Update unit + functional tests to assert assets are written after migration.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/zcli-themes/tests/functional/migrate.test.ts Verifies a migrated asset file is written to disk and cleans it up after test runs.
packages/zcli-themes/src/lib/rewriteTemplates.ts Changes template rewrite behavior to throw on write failures instead of ignoring them.
packages/zcli-themes/src/lib/rewriteTemplates.test.ts Updates tests to assert rewrite failures now throw with the expected message.
packages/zcli-themes/src/lib/rewriteAssets.ts New helper to mkdir assets/ and write base64-decoded assets to disk.
packages/zcli-themes/src/lib/rewriteAssets.test.ts Unit coverage for decoding, multiple file types, empty input, and error handling.
packages/zcli-themes/src/lib/migrate.ts Invokes rewriteAssets with the migrations API response.
packages/zcli-themes/src/lib/migrate.test.ts Asserts rewriteAssets is called with the expected arguments from the API response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/zcli-themes/src/lib/rewriteAssets.ts
Comment thread packages/zcli-themes/src/lib/rewriteTemplates.ts
Comment thread packages/zcli-themes/src/lib/migrate.ts
Copy link
Copy Markdown
Contributor

@BrunoBFerreira BrunoBFerreira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just left two comments. One minor and the other related with the logic we have added here for the construction of the file path. If we want to be more rigid regarding the paths we want to allow, maybe a validation should be added.

Comment thread packages/zcli-themes/src/lib/rewriteAssets.ts
Comment thread packages/zcli-themes/src/lib/rewriteAssets.ts
The migration API now returns an `assets` hash (filename → base64 content).
Decode and write each asset to the theme's assets/ folder after migration.
…plates

Align error handling with rewriteManifest instead of silently swallowing errors.
@luis-almeida luis-almeida force-pushed the luis/themes_migrate_assets branch from 8d1fc8e to 3ac1b31 Compare May 1, 2026 10:55
@luis-almeida luis-almeida merged commit 9caa96c into master May 1, 2026
7 checks passed
@luis-almeida luis-almeida deleted the luis/themes_migrate_assets branch May 1, 2026 12:44
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.

4 participants