@@ -70,6 +70,34 @@ await withTempDir("wp-codebox-nested-extra-plugin-source-path-", async (recipeDi
7070 assert . equal ( ( await stat ( join ( plugin . source , "example.php" ) ) ) . isFile ( ) , true )
7171} )
7272
73+ await withTempDir ( "wp-codebox-extra-plugin-root-source-path-" , async ( recipeDirectory ) => {
74+ const pluginRoot = join ( recipeDirectory , "example-plugin" )
75+ await mkdir ( pluginRoot , { recursive : true } )
76+ await writeFile ( join ( pluginRoot , "example-plugin.php" ) , "<?php\n/* Plugin Name: Example Plugin */\n" )
77+
78+ const recipe : WorkspaceRecipe = {
79+ schema : "wp-codebox/workspace-recipe/v1" ,
80+ inputs : {
81+ extra_plugins : [ {
82+ sourcePath : "example-plugin" ,
83+ sourceSubpath : "." ,
84+ mountSlug : "example-plugin" ,
85+ pluginFile : "example-plugin/example-plugin.php" ,
86+ } ] ,
87+ } ,
88+ workflow : { steps : [ { command : "inspect-mounted-inputs" } ] } ,
89+ }
90+
91+ assertWorkspaceRecipeJsonSchema ( recipe )
92+ assert . deepEqual ( await validateWorkspaceRecipeSemantics ( recipe , join ( recipeDirectory , "recipe.json" ) ) , [ ] )
93+
94+ const [ plugin ] = await prepareRecipeExtraPlugins ( recipe , recipeDirectory )
95+ assert . ok ( plugin )
96+ assert . equal ( plugin . slug , "example-plugin" )
97+ assert . equal ( plugin . metadata ?. sourceSubpath , undefined )
98+ assert . equal ( ( await stat ( join ( plugin . source , "example-plugin.php" ) ) ) . isFile ( ) , true )
99+ } )
100+
73101await withTempDir ( "wp-codebox-nested-extra-plugin-invalid-" , async ( recipeDirectory ) => {
74102 const repo = join ( recipeDirectory , "repo" )
75103 await mkdir ( join ( repo , "plugins" , "nested-plugin" ) , { recursive : true } )
@@ -87,6 +115,11 @@ await withTempDir("wp-codebox-nested-extra-plugin-invalid-", async (recipeDirect
87115 plugin : { sourcePath : "repo" , sourceSubdir : "../outside" , mountSlug : "nested-plugin" , pluginFile : "nested-plugin/nested-plugin.php" } ,
88116 issue : "invalid-source-subdir" ,
89117 } ,
118+ {
119+ name : "embedded current-directory sourceSubdir" ,
120+ plugin : { sourcePath : "repo" , sourceSubdir : "./plugins/nested-plugin" , mountSlug : "nested-plugin" , pluginFile : "nested-plugin/nested-plugin.php" } ,
121+ issue : "invalid-source-subdir" ,
122+ } ,
90123 {
91124 name : "missing sourceSubdir" ,
92125 plugin : { sourcePath : "repo" , sourceSubdir : "plugins/missing-plugin" , mountSlug : "nested-plugin" , pluginFile : "nested-plugin/nested-plugin.php" } ,
0 commit comments