From f834661a2efffca246866d4dc92511a0dfbda87b Mon Sep 17 00:00:00 2001 From: Codefarmer Date: Sun, 30 Mar 2025 12:05:59 +0100 Subject: [PATCH 1/4] fix: show files that matches configured file patterns --- src/provider/treeView.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/provider/treeView.ts b/src/provider/treeView.ts index 4f993a4..f86be09 100644 --- a/src/provider/treeView.ts +++ b/src/provider/treeView.ts @@ -91,13 +91,26 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider ); }); - const filePaths = fileItems + // Filter files based on configured patterns + const filteredItems = fileItems.filter(item => { + if (item.contextValue === FileType.Folder) { + return true; // Always show folders + } + // Check if the file matches any of our patterns + const relativePath = path.relative(vscode.workspace.workspaceFolders![0].uri.fsPath, item.resourceUri.fsPath); + return this.filePatterns.some(pattern => { + const glob = new RegExp('^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$'); + return glob.test(relativePath); + }); + }); + + const filePaths = filteredItems .filter((item) => item.contextValue === FileType.File) .map((item) => item.resourceUri.fsPath); this.analyzeDependencies(filePaths); - fileItems.forEach((item) => { + filteredItems.forEach((item) => { if (item.contextValue === FileType.File) { const dependencies = this.dependencyMap.get(item.resourceUri.fsPath) || []; item.collapsibleState = @@ -107,7 +120,7 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider } }); - return fileItems; + return filteredItems; } private createTreeItemsFromPaths(filePaths: string[], rootPath: string): FileItem[] { From ef47dd0c75473f003cf50d60722d0b3c01d6ebea Mon Sep 17 00:00:00 2001 From: Codefarmer Date: Sun, 30 Mar 2025 13:10:29 +0100 Subject: [PATCH 2/4] chore: correctly compare files against file patterns --- package-lock.json | 60 +++++++++++++++++++++++++++++++++++----- package.json | 1 + src/provider/treeView.ts | 23 +++++++++------ 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index a20f38e..618b690 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.9.3", "license": "MIT", "dependencies": { + "minimatch": "^10.0.1", "yaml": "^2.7.0" }, "devDependencies": { @@ -1022,6 +1023,22 @@ "typescript": ">=4.8.4 <5.8.0" } }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/utils": { "version": "8.18.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.1.tgz", @@ -1130,6 +1147,22 @@ "dev": true, "license": "MIT" }, + "node_modules/@vscode/test-cli/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@vscode/test-cli/node_modules/mocha": { "version": "10.8.2", "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", @@ -1487,7 +1520,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, "license": "MIT" }, "node_modules/base64-js": { @@ -1555,7 +1587,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" @@ -2913,6 +2944,22 @@ "node": ">= 6" } }, + "node_modules/glob/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/globals": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", @@ -3962,16 +4009,15 @@ } }, "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/package.json b/package.json index 7a40701..6029e5d 100644 --- a/package.json +++ b/package.json @@ -190,6 +190,7 @@ "typescript": "^5.7.2" }, "dependencies": { + "minimatch": "^10.0.1", "yaml": "^2.7.0" } } diff --git a/src/provider/treeView.ts b/src/provider/treeView.ts index f86be09..36bc995 100644 --- a/src/provider/treeView.ts +++ b/src/provider/treeView.ts @@ -2,6 +2,7 @@ import * as path from 'path'; import * as fs from 'fs'; import * as vscode from 'vscode'; import YAML from 'yaml'; +import { minimatch } from 'minimatch'; export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider { private filePatterns: string[]; @@ -33,6 +34,7 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider if (element.contextValue === FileType.File) { const dependencies = this.dependencyMap.get(element.resourceUri.fsPath) || []; const uniqueDependencies = new Set(dependencies); + console.log(`uniqueDependencies: ${uniqueDependencies}`) return Array.from(uniqueDependencies).map((dep) => { const isMissing = !fs.existsSync(dep); return new FileItem( @@ -91,17 +93,15 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider ); }); - // Filter files based on configured patterns const filteredItems = fileItems.filter(item => { if (item.contextValue === FileType.Folder) { - return true; // Always show folders + return true; } - // Check if the file matches any of our patterns - const relativePath = path.relative(vscode.workspace.workspaceFolders![0].uri.fsPath, item.resourceUri.fsPath); - return this.filePatterns.some(pattern => { - const glob = new RegExp('^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$'); - return glob.test(relativePath); - }); + + const workspaceRoot = vscode.workspace.workspaceFolders![0].uri.fsPath; + const relativePath = path.relative(workspaceRoot, item.resourceUri.fsPath); + + return this.shouldIncludeFile(relativePath); }); const filePaths = filteredItems @@ -123,6 +123,13 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider return filteredItems; } + private shouldIncludeFile(relativePath: string): boolean { + const normalizedPath = relativePath.replace(/\\/g, '/'); + return this.filePatterns.some(pattern => + minimatch(normalizedPath, pattern, { dot: true }) + ); + } + private createTreeItemsFromPaths(filePaths: string[], rootPath: string): FileItem[] { const tree: { [key: string]: any } = {}; From eb7d72e08a7575ea9ea2cf50e7b258a85626fdf5 Mon Sep 17 00:00:00 2001 From: Codefarmer Date: Sun, 30 Mar 2025 13:38:33 +0100 Subject: [PATCH 3/4] chore: fix dependencies in treeview --- src/provider/treeView.ts | 60 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/provider/treeView.ts b/src/provider/treeView.ts index 36bc995..090d041 100644 --- a/src/provider/treeView.ts +++ b/src/provider/treeView.ts @@ -34,7 +34,6 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider if (element.contextValue === FileType.File) { const dependencies = this.dependencyMap.get(element.resourceUri.fsPath) || []; const uniqueDependencies = new Set(dependencies); - console.log(`uniqueDependencies: ${uniqueDependencies}`) return Array.from(uniqueDependencies).map((dep) => { const isMissing = !fs.existsSync(dep); return new FileItem( @@ -43,7 +42,7 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider vscode.Uri.file(dep), FileType.Dependency, isMissing ? 'Missing dependency' : 'Dependency', - isMissing ? 'error' : 'link' + isMissing ? 'error' : undefined ); }); } @@ -125,7 +124,7 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider private shouldIncludeFile(relativePath: string): boolean { const normalizedPath = relativePath.replace(/\\/g, '/'); - return this.filePatterns.some(pattern => + return this.filePatterns.some(pattern => minimatch(normalizedPath, pattern, { dot: true }) ); } @@ -174,33 +173,36 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider const dependencies = new Set(); parsedDocuments.forEach((doc) => { - if (Array.isArray(doc)) { - doc.forEach((flow) => { - if (flow.runFlow && flow.runFlow.file) { - const dependencyPath = path.resolve(path.dirname(filePath), flow.runFlow.file); - dependencies.add(dependencyPath); + const parsed = doc.toJS(); + const flows = Array.isArray(parsed) ? parsed : [parsed]; + + flows.forEach((flow) => { + if (!flow) return; + + if (flow.runFlow && flow.runFlow.file) { + const dependencyPath = path.resolve(path.dirname(filePath), flow.runFlow.file); + dependencies.add(dependencyPath); + } + + if (flow.runScript && flow.runScript.file) { + const dependencyPath = path.resolve(path.dirname(filePath), flow.runScript.file); + dependencies.add(dependencyPath); + } + + if (flow.addMedia) { + if (Array.isArray(flow.addMedia)) { + flow.addMedia.forEach((mediaFile: string) => { + const dependencyPath = path.resolve(path.dirname(filePath), mediaFile); + dependencies.add(dependencyPath); + }); + } else if (flow.addMedia.files && Array.isArray(flow.addMedia.files)) { + flow.addMedia.files.forEach((mediaFile: string) => { + const dependencyPath = path.resolve(path.dirname(filePath), mediaFile); + dependencies.add(dependencyPath); + }); } - - if (flow.runScript && flow.runScript.file) { - const dependencyPath = path.resolve(path.dirname(filePath), flow.runScript.file); - dependencies.add(dependencyPath); - } - - if (flow.addMedia) { - if (Array.isArray(flow.addMedia)) { - flow.addMedia.forEach((mediaFile: string) => { - const dependencyPath = path.resolve(path.dirname(filePath), mediaFile); - dependencies.add(dependencyPath); - }); - } else if (flow.addMedia.files && Array.isArray(flow.addMedia.files)) { - flow.addMedia.files.forEach((mediaFile: string) => { - const dependencyPath = path.resolve(path.dirname(filePath), mediaFile); - dependencies.add(dependencyPath); - }); - } - } - }); - } + } + }); }); this.dependencyMap.set(filePath, Array.from(dependencies)); From fffe1ff273255631d0c2628c5c1776f849be9cbc Mon Sep 17 00:00:00 2001 From: Dan Caseley Date: Tue, 1 Apr 2025 19:22:58 +0100 Subject: [PATCH 4/4] chore: update VS Code settings to include test flows in workbench Apologies for the whitespace, darned formatters. --- .vscode/settings.json | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2898676..18ebd24 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,21 +1,18 @@ // Place your settings in this file to overwrite default and user settings. { - "files.exclude": { - "out": false, // set this to true to hide the "out" folder with the compiled JS files - "dist": false // set this to true to hide the "dist" folder with the compiled JS files - }, - "search.exclude": { - "out": true, // set this to false to include "out" folder in search results - "dist": true // set this to false to include "dist" folder in search results - }, - // Turn off tsc task auto detection since we have the necessary tasks as npm scripts - "typescript.tsc.autoDetect": "off", - "yaml.schemas": { - "./schema/schema.v0.json": [ - "tests/examples/*.yaml" - ] - }, - "cSpell.words": [ - "airplane" - ], -} \ No newline at end of file + "files.exclude": { + "out": false, // set this to true to hide the "out" folder with the compiled JS files + "dist": false // set this to true to hide the "dist" folder with the compiled JS files + }, + "search.exclude": { + "out": true, // set this to false to include "out" folder in search results + "dist": true // set this to false to include "dist" folder in search results + }, + // Turn off tsc task auto detection since we have the necessary tasks as npm scripts + "typescript.tsc.autoDetect": "off", + "yaml.schemas": { + "./schema/schema.v0.json": ["tests/examples/*.yaml"] + }, + "maestroWorkbench.filePatterns": ["tests/examples/*.yaml"], + "cSpell.words": ["airplane"] +}