diff --git a/packages/wp-now/src/config.ts b/packages/wp-now/src/config.ts index 52b8af60..fd356dc9 100644 --- a/packages/wp-now/src/config.ts +++ b/packages/wp-now/src/config.ts @@ -3,14 +3,14 @@ import { SupportedPHPVersionsList, } from '@php-wasm/universal'; import crypto from 'crypto'; +import fs from 'fs-extra'; +import path from 'path'; +import { Blueprint } from '@wp-playground/blueprints'; import { getCodeSpaceURL, isGitHubCodespace } from './github-codespaces'; import { inferMode } from './wp-now'; import { portFinder } from './port-finder'; import { isValidWordPressVersion } from './wp-playground-wordpress'; import getWpNowPath from './get-wp-now-path'; - -import path from 'path'; - import { DEFAULT_PHP_VERSION, DEFAULT_WORDPRESS_VERSION } from './constants'; export interface CliOptions { @@ -18,6 +18,7 @@ export interface CliOptions { path?: string; wp?: string; port?: number; + blueprint?: string; } export const enum WPNowMode { @@ -41,6 +42,7 @@ export interface WPNowOptions { wpContentPath?: string; wordPressVersion?: string; numberOfPhpInstances?: number; + blueprintObject?: Blueprint; } export const DEFAULT_OPTIONS: WPNowOptions = { @@ -135,5 +137,17 @@ export default async function getWpNowConfig( }. Supported versions: ${SupportedPHPVersionsList.join(', ')}` ); } + if (args.blueprint) { + const blueprintPath = path.resolve(args.blueprint); + if (!fs.existsSync(blueprintPath)) { + throw new Error(`Blueprint file not found: ${blueprintPath}`); + } + const blueprintObject = JSON.parse( + fs.readFileSync(blueprintPath, 'utf8') + ); + // TODO: blueprint schema validation + + options.blueprintObject = blueprintObject; + } return options; }