@@ -2,6 +2,7 @@ import * as path from 'path';
22import * as fs from 'fs' ;
33import * as vscode from 'vscode' ;
44import YAML from 'yaml' ;
5+ import { minimatch } from 'minimatch' ;
56
67export class MaestroWorkBenchTreeViewProvider implements vscode . TreeDataProvider < vscode . TreeItem > {
78 private filePatterns : string [ ] ;
@@ -41,7 +42,7 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider
4142 vscode . Uri . file ( dep ) ,
4243 FileType . Dependency ,
4344 isMissing ? 'Missing dependency' : 'Dependency' ,
44- isMissing ? 'error' : 'link'
45+ isMissing ? 'error' : undefined
4546 ) ;
4647 } ) ;
4748 }
@@ -91,13 +92,24 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider
9192 ) ;
9293 } ) ;
9394
94- const filePaths = fileItems
95+ const filteredItems = fileItems . filter ( item => {
96+ if ( item . contextValue === FileType . Folder ) {
97+ return true ;
98+ }
99+
100+ const workspaceRoot = vscode . workspace . workspaceFolders ! [ 0 ] . uri . fsPath ;
101+ const relativePath = path . relative ( workspaceRoot , item . resourceUri . fsPath ) ;
102+
103+ return this . shouldIncludeFile ( relativePath ) ;
104+ } ) ;
105+
106+ const filePaths = filteredItems
95107 . filter ( ( item ) => item . contextValue === FileType . File )
96108 . map ( ( item ) => item . resourceUri . fsPath ) ;
97109
98110 this . analyzeDependencies ( filePaths ) ;
99111
100- fileItems . forEach ( ( item ) => {
112+ filteredItems . forEach ( ( item ) => {
101113 if ( item . contextValue === FileType . File ) {
102114 const dependencies = this . dependencyMap . get ( item . resourceUri . fsPath ) || [ ] ;
103115 item . collapsibleState =
@@ -107,7 +119,14 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider
107119 }
108120 } ) ;
109121
110- return fileItems ;
122+ return filteredItems ;
123+ }
124+
125+ private shouldIncludeFile ( relativePath : string ) : boolean {
126+ const normalizedPath = relativePath . replace ( / \\ / g, '/' ) ;
127+ return this . filePatterns . some ( pattern =>
128+ minimatch ( normalizedPath , pattern , { dot : true } )
129+ ) ;
111130 }
112131
113132 private createTreeItemsFromPaths ( filePaths : string [ ] , rootPath : string ) : FileItem [ ] {
@@ -154,33 +173,36 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider
154173 const dependencies = new Set < string > ( ) ;
155174
156175 parsedDocuments . forEach ( ( doc ) => {
157- if ( Array . isArray ( doc ) ) {
158- doc . forEach ( ( flow ) => {
159- if ( flow . runFlow && flow . runFlow . file ) {
160- const dependencyPath = path . resolve ( path . dirname ( filePath ) , flow . runFlow . file ) ;
161- dependencies . add ( dependencyPath ) ;
162- }
163-
164- if ( flow . runScript && flow . runScript . file ) {
165- const dependencyPath = path . resolve ( path . dirname ( filePath ) , flow . runScript . file ) ;
166- dependencies . add ( dependencyPath ) ;
167- }
168-
169- if ( flow . addMedia ) {
170- if ( Array . isArray ( flow . addMedia ) ) {
171- flow . addMedia . forEach ( ( mediaFile : string ) => {
172- const dependencyPath = path . resolve ( path . dirname ( filePath ) , mediaFile ) ;
173- dependencies . add ( dependencyPath ) ;
174- } ) ;
175- } else if ( flow . addMedia . files && Array . isArray ( flow . addMedia . files ) ) {
176- flow . addMedia . files . forEach ( ( mediaFile : string ) => {
177- const dependencyPath = path . resolve ( path . dirname ( filePath ) , mediaFile ) ;
178- dependencies . add ( dependencyPath ) ;
179- } ) ;
180- }
176+ const parsed = doc . toJS ( ) ;
177+ const flows = Array . isArray ( parsed ) ? parsed : [ parsed ] ;
178+
179+ flows . forEach ( ( flow ) => {
180+ if ( ! flow ) return ;
181+
182+ if ( flow . runFlow && flow . runFlow . file ) {
183+ const dependencyPath = path . resolve ( path . dirname ( filePath ) , flow . runFlow . file ) ;
184+ dependencies . add ( dependencyPath ) ;
185+ }
186+
187+ if ( flow . runScript && flow . runScript . file ) {
188+ const dependencyPath = path . resolve ( path . dirname ( filePath ) , flow . runScript . file ) ;
189+ dependencies . add ( dependencyPath ) ;
190+ }
191+
192+ if ( flow . addMedia ) {
193+ if ( Array . isArray ( flow . addMedia ) ) {
194+ flow . addMedia . forEach ( ( mediaFile : string ) => {
195+ const dependencyPath = path . resolve ( path . dirname ( filePath ) , mediaFile ) ;
196+ dependencies . add ( dependencyPath ) ;
197+ } ) ;
198+ } else if ( flow . addMedia . files && Array . isArray ( flow . addMedia . files ) ) {
199+ flow . addMedia . files . forEach ( ( mediaFile : string ) => {
200+ const dependencyPath = path . resolve ( path . dirname ( filePath ) , mediaFile ) ;
201+ dependencies . add ( dependencyPath ) ;
202+ } ) ;
181203 }
182- } ) ;
183- }
204+ }
205+ } ) ;
184206 } ) ;
185207
186208 this . dependencyMap . set ( filePath , Array . from ( dependencies ) ) ;
0 commit comments