11import { readFile , writeFile } from "node:fs/promises"
2- import { buildGenericAbilityRuntimeRunRecipe , buildRuntimePackageRunRecipe , buildWordPressBenchRecipe , buildWordPressPhpunitRecipe , compileRecipeTemplate , type GenericAbilityRuntimeRunOptions , type RecipeTemplateInput , type RuntimePackageRunRecipeOptions , type RuntimeWordPressInstallMode , type WorkspaceRecipe , type WorkspaceRecipeExtraPlugin , type WorkspaceRecipeMount , type WorkspaceRecipePHPWasmExtensionManifest , type WorkspaceRecipeRuntimeBackendPackage , type WorkspaceRecipeRuntimeService , type WorkspaceRecipeStep } from "@automattic/wp-codebox-core"
2+ import { buildGenericAbilityRuntimeRunRecipe , buildRuntimePackageRunRecipe , buildWordPressBenchRecipe , buildWordPressPhpunitRecipe , compileRecipeTemplate , type GenericAbilityRuntimeRunOptions , type RecipeTemplateInput , type RuntimePackageRunRecipeOptions , type RuntimeWorkerCount , type RuntimeWordPressInstallMode , type WorkspaceRecipe , type WorkspaceRecipeExtraPlugin , type WorkspaceRecipeMount , type WorkspaceRecipePHPWasmExtensionManifest , type WorkspaceRecipeRuntimeBackendPackage , type WorkspaceRecipeRuntimeService , type WorkspaceRecipeStep } from "@automattic/wp-codebox-core"
33
44interface RecipeBuildOptions {
55 recipeType : "phpunit" | "bench" | "template" | "generic-ability-runtime-run" | "runtime-package-run"
@@ -11,6 +11,7 @@ interface WordPressPhpunitBuilderOptions {
1111 blueprint ?: unknown
1212 wordpressVersion ?: string
1313 phpVersion ?: string
14+ workers ?: RuntimeWorkerCount
1415 databaseType ?: "sqlite" | "mysql"
1516 wordpressInstallMode ?: RuntimeWordPressInstallMode
1617 extensions ?: WorkspaceRecipePHPWasmExtensionManifest [ ]
@@ -82,6 +83,7 @@ function buildRecipe(recipeType: RecipeBuildOptions["recipeType"], options: Word
8283 blueprint : phpunitOptions . blueprint ,
8384 wordpressVersion : stringOrUndefined ( phpunitOptions . wordpressVersion ) ,
8485 phpVersion : stringOrUndefined ( phpunitOptions . phpVersion ) ,
86+ workers : workerCountOrUndefined ( phpunitOptions . workers ) ,
8587 databaseType : phpunitOptions . databaseType ,
8688 wordpressInstallMode : phpunitOptions . wordpressInstallMode ,
8789 extensions : Array . isArray ( phpunitOptions . extensions ) ? phpunitOptions . extensions : [ ] ,
@@ -182,6 +184,12 @@ function requiredString(value: unknown, name: string): string {
182184 return value
183185}
184186
187+ function workerCountOrUndefined ( value : unknown ) : RuntimeWorkerCount | undefined {
188+ if ( value === undefined || value === "auto" ) return value
189+ if ( typeof value === "number" && Number . isSafeInteger ( value ) && value >= 1 && value <= 64 ) return value
190+ throw new Error ( "workers must be an integer from 1 to 64 or auto." )
191+ }
192+
185193function stringOrUndefined ( value : unknown ) : string | undefined {
186194 return typeof value === "string" && value !== "" ? value : undefined
187195}
0 commit comments