Skip to content
8 changes: 5 additions & 3 deletions cli/commands/site/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs';
import path from 'path';
import { SupportedPHPVersions } from '@php-wasm/universal';
import { __, sprintf } from '@wordpress/i18n';
import { Blueprint } from '@wp-playground/blueprints';
import { BlueprintV1Declaration } from '@wp-playground/blueprints';
import { RecommendedPHPVersion } from '@wp-playground/common';
import {
filterUnsupportedBlueprintFeatures,
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function runCommand(
);
}

let blueprint: Blueprint | undefined;
let blueprint: BlueprintV1Declaration | undefined;
if ( options.blueprintJson ) {
const validation = await validateBlueprintData( options.blueprintJson );
if ( ! validation.valid ) {
Expand All @@ -92,7 +92,9 @@ export async function runCommand(
);
}

blueprint = filterUnsupportedBlueprintFeatures( options.blueprintJson ) as Blueprint;
blueprint = filterUnsupportedBlueprintFeatures(
options.blueprintJson
) as BlueprintV1Declaration;
}

const appdata = await readAppdata();
Expand Down
15 changes: 10 additions & 5 deletions cli/commands/site/tests/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Blueprint } from '@wp-playground/blueprints';
import { BlueprintV1Declaration } from '@wp-playground/blueprints';
import {
filterUnsupportedBlueprintFeatures,
validateBlueprintData,
Expand Down Expand Up @@ -469,8 +469,13 @@ describe( 'CLI: studio site create', () => {
} );

describe( 'Blueprint Handling', () => {
const testBlueprint: Blueprint = {
steps: [ { step: 'installPlugin', pluginData: { slug: 'akismet' } } ],
const testBlueprint: BlueprintV1Declaration = {
steps: [
{
step: 'installPlugin',
pluginData: { resource: 'wordpress.org/plugins', slug: 'akismet' },
},
],
};

it( 'should apply blueprint when provided', async () => {
Expand Down Expand Up @@ -564,7 +569,7 @@ describe( 'CLI: studio site create', () => {
} );

it( 'should apply blueprint without starting server when noStart is true', async () => {
const testBlueprint: Blueprint = { steps: [] };
const testBlueprint: BlueprintV1Declaration = { steps: [] };
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at https://github.com/WordPress/wordpress-playground/blob/trunk/packages/playground/blueprints/src/lib/types.ts, I think we should use BlueprintV1Declaration and not the broader Blueprint type.

However, I'm unsure why it didn't pop up before. I couldn't track what change between 3.0.22 and 3.0.34 caused this.

@adamziel @bcotrim any thoughts?


const { runCommand } = await import( '../create' );

Expand Down Expand Up @@ -602,7 +607,7 @@ describe( 'CLI: studio site create', () => {
} );

it( 'should handle blueprint application failure', async () => {
const testBlueprint: Blueprint = { steps: [] };
const testBlueprint: BlueprintV1Declaration = { steps: [] };
( runBlueprint as jest.Mock ).mockRejectedValue( new Error( 'Blueprint failed' ) );

const { runCommand } = await import( '../create' );
Expand Down
Loading