@@ -46,6 +46,7 @@ pub struct TestBuilder {
4646 dependency_groups : Vec < Value > ,
4747 package_manager : Option < PackageManager > ,
4848 packages : Vec < Value > ,
49+ manifests_at : Vec < ( String , Value ) > ,
4950 pnpm_yaml : Option < String > ,
5051 bun_root : Option < Value > ,
5152 registry_updates : Option < Value > ,
@@ -67,6 +68,7 @@ impl TestBuilder {
6768 dependency_groups : vec ! [ ] ,
6869 package_manager : None ,
6970 packages : vec ! [ ] ,
71+ manifests_at : vec ! [ ] ,
7072 pnpm_yaml : None ,
7173 bun_root : None ,
7274 registry_updates : None ,
@@ -163,6 +165,14 @@ impl TestBuilder {
163165 self
164166 }
165167
168+ /// Add a manifest file at an arbitrary path (e.g. `packages/foo/package.public.json`).
169+ /// Goes through MockDisk like `with_package` but the caller controls the filename
170+ /// so non-standard manifests (per issue #333) can be exercised.
171+ pub fn with_manifest_at ( mut self , path : & str , json : Value ) -> Self {
172+ self . manifests_at . push ( ( path. to_string ( ) , json) ) ;
173+ self
174+ }
175+
166176 pub fn with_version_group ( mut self , group : Value ) -> Self {
167177 self . version_groups . push ( group) ;
168178 self
@@ -275,6 +285,11 @@ impl TestBuilder {
275285 disk. add_json ( & path, pkg) ;
276286 }
277287
288+ // Add manifests at caller-specified paths (e.g. package.public.json).
289+ for ( path, json) in & self . manifests_at {
290+ disk. add_json ( path, json) ;
291+ }
292+
278293 // Synthetic Bun root + bun.lock to trigger PM=Bun + catalog discovery.
279294 if let Some ( ref root) = self . bun_root {
280295 disk. add_json ( "package.json" , root) ;
@@ -425,6 +440,15 @@ impl TestBuilder {
425440 dirty : false ,
426441 } ) ;
427442 }
443+ for ( path, json) in & self . manifests_at {
444+ let raw = serde_json:: to_string_pretty ( json) . unwrap_or_default ( ) ;
445+ package_json_files. push ( File {
446+ filepath : PathBuf :: from ( format ! ( "/{path}" ) ) ,
447+ formatting : detect_formatting ( & raw ) ,
448+ contents : json. clone ( ) ,
449+ dirty : false ,
450+ } ) ;
451+ }
428452 let pnpm_workspace = self
429453 . pnpm_yaml
430454 . as_ref ( )
0 commit comments