[Blueprints] Allow skipping theme install failures - #3854
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an installTheme.options.onError policy to allow Blueprint authors to continue when theme installation/activation/starter-content import fails, and introduces humanReadableName for clearer progress/warning text.
Changes:
- Add
onError: 'skip-theme' | 'throw'andhumanReadableNameto theinstallThemestep options and implementation. - Wrap install + activate + starter-content import in a single
try/catchand warn/continue when configured to skip. - Regenerate the public Blueprint schema and add tests for the new skip + naming behaviors.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/playground/blueprints/src/lib/steps/install-theme.ts | Adds onError handling + humanReadableName and implements skip-on-failure behavior. |
| packages/playground/blueprints/src/tests/steps/install-theme.spec.ts | Adds tests asserting skip behavior and name selection in warnings. |
| packages/playground/blueprints/public/blueprint-schema.json | Updates schema to accept onError and humanReadableName under installTheme.options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
101
to
+102
| let assetNiceName = ''; | ||
| if (themeData instanceof File) { | ||
| // @TODO: Consider validating whether this is a zip file? | ||
| const zipFileName = themeData.name.split('/').pop() || 'theme.zip'; | ||
| assetNiceName = zipNameToHumanName(zipFileName); | ||
| const progressName = () => options.humanReadableName || assetNiceName; |
Comment on lines
+164
to
175
| } catch (error) { | ||
| if (onError === 'skip-theme') { | ||
| const skippedThemeName = progressName() || 'unknown theme'; | ||
| logger.warn( | ||
| `Skipping theme installation for ${skippedThemeName} after failure: ${ | ||
| error instanceof Error ? error.message : String(error) | ||
| }` | ||
| ); | ||
| return; | ||
| } | ||
| throw error; | ||
| } |
Comment on lines
+105
to
+125
| const loggerWarnSpy = vi | ||
| .spyOn(logger, 'warn') | ||
| .mockImplementation(() => {}); | ||
| try { | ||
| await installTheme(php, { | ||
| themeData: new File(['not a zip'], 'broken-theme.zip'), | ||
| ifAlreadyInstalled: 'overwrite', | ||
| options: { | ||
| onError: 'skip-theme', | ||
| }, | ||
| }); | ||
|
|
||
| expect(loggerWarnSpy).toHaveBeenCalledWith( | ||
| expect.stringContaining( | ||
| 'Skipping theme installation for Broken theme after failure' | ||
| ) | ||
| ); | ||
| expect(php.fileExists(expectedThemeIndexPhpPath)).toBe(false); | ||
| } finally { | ||
| loggerWarnSpy.mockRestore(); | ||
| } |
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.
What it does
Adds
installTheme.options.onErrorwith two modes:throwskip-themeAlso adds
installTheme.options.humanReadableNameso skip warnings and progress captions can use the v2 declaration name instead of deriving one from the archive or directory.Rationale
Blueprint v2 needs theme installation to match the plugin failure policy that just landed. A Blueprint author can now declare that a non-critical theme install should not prevent later steps from running.
This PR keeps the change intentionally narrow: it does not add directory-resource path hardening, directory
ifAlreadyInstalledhandling, or WXR controls. Those stay as separate reviewable changes.Implementation
installTheme()now wraps install, activation, and starter-content import in onetry/catchblock. WheninstallTheme.options.onErroris set toskip-theme, it logs:The theme name comes from
humanReadableName, then the derived archive/directory name, thenunknown themeif the failure happens before a name can be derived.The public Blueprint schema and validator were regenerated so
onErrorandhumanReadableNameare accepted underinstallTheme.options.Testing instructions
Validated locally: