[Blueprints] Type Blueprint v2 plugin collision handling - #3865
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 a typed ifAlreadyInstalled collision policy to Blueprint v2 plugin declarations so TypeScript authors can express plugin install collision behavior without casts.
Changes:
- Extends the v2 schema plugin declaration with
ifAlreadyInstalled?: 'overwrite' | 'skip' | 'error'. - Adds declaration-type tests to accept known policies and reject unknown values via
@ts-expect-error.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/playground/blueprints/src/lib/v2/wep-1-blueprint-v2-schema/appendix-A-blueprint-v2-schema.ts | Adds the ifAlreadyInstalled union type + docs to the plugin schema. |
| packages/playground/blueprints/src/tests/v2/blueprint-v2-declaration.spec.ts | Adds type-level tests for accepted/rejected ifAlreadyInstalled values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+656
to
+661
| /** | ||
| * How to handle a plugin that is already installed. | ||
| * | ||
| * @default "overwrite" | ||
| */ | ||
| ifAlreadyInstalled?: 'overwrite' | 'skip' | 'error'; |
Comment on lines
+125
to
+138
| it('accepts plugin install collision handling', () => { | ||
| const blueprint = { | ||
| version: 2, | ||
| plugins: [ | ||
| { | ||
| source: 'akismet', | ||
| ifAlreadyInstalled: 'skip', | ||
| }, | ||
| { | ||
| source: 'jetpack', | ||
| ifAlreadyInstalled: 'error', | ||
| }, | ||
| ], | ||
| } satisfies BlueprintV2Declaration; |
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 changed?
This types
ifAlreadyInstalledon Blueprint v2 plugin object declarations:plugins[].ifAlreadyInstalledoverwrite,skip,errorIt adds declaration tests for accepted values and rejects an unknown value with
@ts-expect-error.Why?
The plugin install step already has this collision policy. Blueprint v2 plugin objects need to expose the same option at the declaration layer so TypeScript authors can express install collision behavior without casts.
This PR only updates v2 declaration types. It does not wire the option into the v2 runner; that should remain a separate, focused PR if needed.
Consumers
ifAlreadyInstalled: "skip"or"error"on plugin objects directly.Testing
npm run format:uncommittednpm exec nx run playground-blueprints:typechecknpm exec nx run playground-blueprints:lintnpm exec nx run playground-blueprints:test:vite -- --testFiles=packages/playground/blueprints/src/tests/v2/blueprint-v2-declaration.spec.tsgit diff --checkPart of #2592.