-
Notifications
You must be signed in to change notification settings - Fork 28
Adding a new themes:migrate command (undocumented as it not yet ready for primetime)
#310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1a60fc3 to
8d28778
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new undocumented themes:migrate command to help migrate themes to the latest templating API version, and addresses a regression in error formatting after migrating axios to use the fetch adapter.
Changes:
- Added new
themes:migratecommand with core migration logic and supporting utilities - Fixed axios fetch adapter error formatting by introducing
parseAxiosErrorutility - Extracted common template error handling into
handleTemplateErrorfunction - Updated test files to properly type-cast error objects as
CLIError
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/zcli-themes/src/commands/themes/migrate.ts | New command entry point for theme migration |
| packages/zcli-themes/src/lib/migrate.ts | Core migration logic that calls internal API and rewrites theme files |
| packages/zcli-themes/src/lib/rewriteManifest.ts | Utility to update manifest.json api_version field |
| packages/zcli-themes/src/lib/rewriteTemplates.ts | Utility to rewrite template files with migrated content |
| packages/zcli-themes/src/lib/parseAxiosError.ts | Utility to normalize axios errors from fetch adapter |
| packages/zcli-themes/src/lib/handleTemplateError.ts | Extracted error handling for template validation errors |
| packages/zcli-themes/src/lib/handleThemeApiError.ts | Updated to use parseAxiosError for proper error formatting |
| packages/zcli-themes/src/lib/preview.ts | Refactored to use extracted handleTemplateError function |
| packages/zcli-themes/tests/functional/migrate.test.ts | Functional tests for migrate command |
| packages/zcli-themes/src/lib/migrate.test.ts | Unit tests for migrate function |
| packages/zcli-themes/src/lib/rewriteManifest.test.ts | Unit tests for manifest rewriting |
| packages/zcli-themes/src/lib/rewriteTemplates.test.ts | Unit tests for template rewriting |
| packages/zcli-themes/tests/functional/update.test.ts | Updated error type casting to CLIError |
| packages/zcli-themes/tests/functional/publish.test.ts | Updated error type casting to CLIError |
| packages/zcli-themes/tests/functional/preview.test.ts | Added type annotation for server variable |
| packages/zcli-themes/tests/functional/list.test.ts | Updated error type casting to CLIError |
| packages/zcli-themes/tests/functional/import.test.ts | Updated error type casting to CLIError |
| packages/zcli-themes/tests/functional/delete.test.ts | Updated error type casting to CLIError |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { ValidationError, ValidationErrors } from '../types' | ||
| import validationErrorsToString from './validationErrorsToString' | ||
| import * as chalk from 'chalk' | ||
| import { error } from '@oclif/core/lib/errors' | ||
|
|
||
| export default function handleTemplateError (themePath: string, templateErrors: ValidationErrors) { | ||
| const validationErrors: ValidationErrors = {} | ||
| for (const [template, errors] of Object.entries(templateErrors)) { | ||
| // the theming endpoints return the template identifier as the 'key' instead of | ||
| // the template path. We must fix this so we can reuse `validationErrorsToString` | ||
| // and align with the job import error handling | ||
| validationErrors[`templates/${template}.hbs`] = errors as ValidationError[] | ||
| } | ||
|
|
||
| const title = `${chalk.bold('InvalidTemplates')} - Template(s) with syntax error(s)` | ||
| const details = validationErrorsToString(themePath, validationErrors) | ||
|
|
||
| error(`${title}\n${details}`) | ||
| } |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handleTemplateError function lacks unit tests. This is an extracted function used by both preview and migrate commands, and verifying its behavior in isolation would improve maintainability. Tests should verify that it correctly transforms template identifiers to file paths and properly formats error messages.
Description
First iteration of a new
themes:migratecommand.We are not adding documentation for it as it is not yet ready for "primetime". Once it becomes stable we will document it and announce it.
Nonetheless, the idea behind this new command is to help migrate a theme to the latest templating api version.
The end goal for this command is to automate all required changes to make a theme compatible with templating api v4.
As part of this work I have also addressed a regression: after migrating axios to use the
fetchadapter, we stopped seeing well formatted errors. That should be fixes now.Checklist