Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/cli/commands/site/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ export const registerCommand = ( yargs: StudioArgv ) => {
type: 'string',
describe: __( 'Path or URL to Blueprint JSON file' ),
} )
.option( 'original-blueprint-path', {
type: 'string',
hidden: true,
} )
.option( 'admin-username', {
type: 'string',
describe: __( 'Admin username (defaults to "admin")' ),
Expand Down Expand Up @@ -767,6 +771,12 @@ export const registerCommand = ( yargs: StudioArgv ) => {
uri,
contents: readBlueprint( uri ),
};

// When invoked by the desktop app, the blueprint contents come from a temp file
// but resources should be resolved relative to the original file location.
if ( argv.originalBlueprintPath ) {
config.blueprint.uri = path.resolve( argv.originalBlueprintPath );
}
}
}

Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export async function createSite(
enableHttps,
siteId,
blueprint: blueprint?.blueprint,
originalBlueprintPath: blueprint?.filePath,
adminUsername,
adminPassword,
adminEmail,
Expand Down
2 changes: 2 additions & 0 deletions apps/studio/src/modules/add-site/components/blueprints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface Blueprint {
};
[ key: string ]: unknown;
};
filePath?: string;
}

interface DataViewBlueprint extends Blueprint {
Expand Down Expand Up @@ -225,6 +226,7 @@ export function AddSiteBlueprintSelector( {
image: '', // No image for file-based blueprints
playground_url: '', // No playground URL for file-based blueprints
blueprint: blueprintJson, // The actual blueprint JSON
filePath: getIpcApi().getPathForFile( file ),
};

setUploadedFileName( null );
Expand Down
4 changes: 4 additions & 0 deletions apps/studio/src/modules/cli/lib/cli-site-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface CreateSiteOptions {
enableHttps?: boolean;
siteId?: string;
blueprint?: Blueprint;
originalBlueprintPath?: string;
adminUsername?: string;
adminPassword?: string;
adminEmail?: string;
Expand All @@ -50,6 +51,9 @@ export async function createSiteViaCli( options: CreateSiteOptions ): Promise< C
blueprintTempPath = path.join( os.tmpdir(), `studio-blueprint-${ Date.now() }.json` );
fs.writeFileSync( blueprintTempPath, JSON.stringify( options.blueprint ) );
args.push( '--blueprint', blueprintTempPath );
if ( options.originalBlueprintPath ) {
args.push( '--original-blueprint-path', options.originalBlueprintPath );
}
}

return new Promise( ( resolve, reject ) => {
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/stores/wpcom-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const blueprintSchema = z.object( {
image: z.string(),
playground_url: z.string(),
blueprint: z.record( z.string(), z.unknown() ),
filePath: z.string().optional(),
} );

export type Blueprint = z.infer< typeof blueprintSchema >;
Expand Down
Loading