From 50aa39de050db4d8bdbbb074e3c4c05250b1af71 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sat, 29 Aug 2026 13:26:16 -0400 Subject: [PATCH] fix(bench): select custom drop-in database setup --- packages/runtime-core/src/recipe-builders.ts | 7 +++++- tests/recipe-builder-bench-steps.test.ts | 24 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/recipe-builders.ts b/packages/runtime-core/src/recipe-builders.ts index 818181de9..c0cc4378d 100644 --- a/packages/runtime-core/src/recipe-builders.ts +++ b/packages/runtime-core/src/recipe-builders.ts @@ -210,16 +210,21 @@ function normalizeRecipeSteps(steps: readonly WorkspaceRecipeStep[], label: stri export function buildWordPressBenchRecipe(options: WordPressBenchRecipeOptions): WorkspaceRecipe { const pluginSlug = requiredPluginSlug(options.pluginSlug, "buildWordPressBenchRecipe") const componentId = options.componentId?.trim() || pluginSlug + const mounts = normalizeRecipeMounts(options.mounts, { defaultMode: "readonly" }) + const hasCustomDatabaseDropIn = mounts.some((mount) => mount.type === "file" + && mount.phase === "pre-install" + && mount.target === "/wordpress/wp-content/db.php") return { schema: "wp-codebox/workspace-recipe/v1", runtime: { wp: options.wordpressVersion ?? DEFAULT_WORDPRESS_VERSION, + ...(hasCustomDatabaseDropIn ? { databaseSetup: "custom-drop-in" as const } : {}), blueprint: blueprintWithWpConfigDefines(options.blueprint ?? {}, options.wpConfigDefines ?? {}), }, inputs: { extra_plugins: normalizeExtraPlugins(options.extra_plugins), - mounts: normalizeRecipeMounts(options.mounts, { defaultMode: "readonly" }), + mounts, }, workflow: { ...(options.prepareSteps && options.prepareSteps.length > 0 ? { before: normalizeRecipeSteps(options.prepareSteps, "prepareSteps") } : {}), diff --git a/tests/recipe-builder-bench-steps.test.ts b/tests/recipe-builder-bench-steps.test.ts index aa75ae76c..cb6cff10e 100644 --- a/tests/recipe-builder-bench-steps.test.ts +++ b/tests/recipe-builder-bench-steps.test.ts @@ -32,5 +32,29 @@ assert.deepEqual(recipe.inputs.extra_plugins?.[0], { originalSource: "/tmp/monorepo/plugins/fixture-plugin", slug: "fixture-plugin", }) +assert.equal(recipe.runtime.databaseSetup, undefined) + +const customDropInRecipe = buildWordPressBenchRecipe({ + pluginSlug: "fixture-plugin", + mounts: [{ + type: "file", + source: "/tmp/db.php", + target: "//wordpress//wp-content//db.php", + phase: "pre-install", + }], +}) +assert.equal(customDropInRecipe.runtime.databaseSetup, "custom-drop-in") +assert.equal(customDropInRecipe.inputs.mounts?.[0]?.target, "/wordpress/wp-content/db.php") + +const postInstallDropInRecipe = buildWordPressBenchRecipe({ + pluginSlug: "fixture-plugin", + mounts: [{ + type: "file", + source: "/tmp/db.php", + target: "/wordpress/wp-content/db.php", + phase: "post-install", + }], +}) +assert.equal(postInstallDropInRecipe.runtime.databaseSetup, undefined) console.log("recipe builder bench steps ok")