@@ -182,16 +182,29 @@ export class FileStore {
182182 throw new Error ( `Unknown kind: ${ kind } ` )
183183 }
184184
185- // Generate path prefix from template (e.g., 'env/teams/team1/workloads/')
186- const prefix = fileMap . pathTemplate . replace ( '{teamId}' , teamId || '' ) . replace ( '{name}.yaml' , '' )
187-
188185 const result = new Map < string , AplObject > ( )
189- for ( const filePath of this . store . keys ( ) ) {
190- if ( filePath . startsWith ( prefix ) && filePath . endsWith ( '.yaml' ) ) {
191- const content = this . store . get ( filePath )
192- if ( content ) result . set ( filePath , content )
186+
187+ if ( teamId ) {
188+ // Specific team: use exact prefix match (e.g., 'env/teams/team1/workloads/')
189+ const prefix = fileMap . pathTemplate . replace ( '{teamId}' , teamId ) . replace ( '{name}.yaml' , '' )
190+ for ( const filePath of this . store . keys ( ) ) {
191+ if ( filePath . startsWith ( prefix ) && filePath . endsWith ( '.yaml' ) ) {
192+ const content = this . store . get ( filePath )
193+ if ( content ) result . set ( filePath , content )
194+ }
195+ }
196+ } else {
197+ // All teams: match pattern with any teamId (e.g., 'env/teams/*/workloads/')
198+ const pattern = fileMap . pathTemplate . replace ( '{teamId}' , '' ) . replace ( '{name}.yaml' , '' )
199+ const [ beforeTeam , afterTeam ] = pattern . split ( '//' )
200+ for ( const filePath of this . store . keys ( ) ) {
201+ if ( filePath . startsWith ( beforeTeam ) && filePath . includes ( afterTeam ) && filePath . endsWith ( '.yaml' ) ) {
202+ const content = this . store . get ( filePath )
203+ if ( content ) result . set ( filePath , content )
204+ }
193205 }
194206 }
207+
195208 return result
196209 }
197210
0 commit comments