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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/runtime-core/src/recipe-builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") } : {}),
Expand Down
24 changes: 24 additions & 0 deletions tests/recipe-builder-bench-steps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Loading