@@ -71,6 +71,24 @@ function readJsonSafe(filePath) {
7171 }
7272}
7373
74+ function resolveManifestPath ( exampleDirectory ) {
75+ const srcManifest = path . join ( exampleDirectory , 'src' , 'manifest.json' )
76+ if ( exists ( srcManifest ) ) return srcManifest
77+ const monorepoManifest = path . join (
78+ exampleDirectory ,
79+ 'packages' ,
80+ 'extension' ,
81+ 'src' ,
82+ 'manifest.json'
83+ )
84+
85+ if ( exists ( monorepoManifest ) ) return monorepoManifest
86+ const rootManifest = path . join ( exampleDirectory , 'manifest.json' )
87+
88+ if ( exists ( rootManifest ) ) return rootManifest
89+ return null
90+ }
91+
7492function listDirs ( directory ) {
7593 return fs
7694 . readdirSync ( directory , { withFileTypes : true } )
@@ -577,10 +595,12 @@ function buildTemplateEntry(exampleDirectory) {
577595 const slug = path . basename ( exampleDirectory )
578596 const packageJson =
579597 readJsonSafe ( path . join ( exampleDirectory , 'package.json' ) ) || { }
580- const manifest =
581- readJsonSafe ( path . join ( exampleDirectory , 'src' , 'manifest.json' ) ) ||
582- readJsonSafe ( path . join ( exampleDirectory , 'manifest.json' ) ) ||
583- { }
598+ const manifestPath = resolveManifestPath ( exampleDirectory )
599+ if ( ! manifestPath ) {
600+ console . warn ( `[templates-meta] Missing manifest.json for ${ slug } , skipping` )
601+ return null
602+ }
603+ const manifest = readJsonSafe ( manifestPath ) || { }
584604
585605 const curated = readCuratedTemplateMeta ( exampleDirectory )
586606 const { permissions, host_permissions, optional_permissions} =
@@ -653,7 +673,9 @@ function main() {
653673 const exampleDirectories = listDirs ( examplesDir ) . filter ( ( directory ) =>
654674 exists ( path . join ( directory , 'package.json' ) )
655675 )
656- const templates = exampleDirectories . map ( buildTemplateEntry )
676+ const templates = exampleDirectories
677+ . map ( buildTemplateEntry )
678+ . filter ( Boolean )
657679
658680 const templatesMetadata = {
659681 version : '2' ,
0 commit comments