Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
],
}
"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"]
}
60 changes: 53 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
"typescript": "^5.7.2"
},
"dependencies": {
"minimatch": "^10.0.1",
"yaml": "^2.7.0"
}
}
82 changes: 52 additions & 30 deletions src/provider/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<vscode.TreeItem> {
private filePatterns: string[];
Expand Down Expand Up @@ -41,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
);
});
}
Expand Down Expand Up @@ -91,13 +92,24 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider
);
});

const filePaths = fileItems
const filteredItems = fileItems.filter(item => {
if (item.contextValue === FileType.Folder) {
return true;
}

const workspaceRoot = vscode.workspace.workspaceFolders![0].uri.fsPath;
const relativePath = path.relative(workspaceRoot, item.resourceUri.fsPath);

return this.shouldIncludeFile(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 =
Expand All @@ -107,7 +119,14 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider
}
});

return fileItems;
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[] {
Expand Down Expand Up @@ -154,33 +173,36 @@ export class MaestroWorkBenchTreeViewProvider implements vscode.TreeDataProvider
const dependencies = new Set<string>();

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);
}

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);
});
}
const parsed = doc.toJS();
const flows = Array.isArray(parsed) ? parsed : [parsed];

flows.forEach((flow) => {
Comment thread
Fishbowler marked this conversation as resolved.
if (!flow) return;

if (flow.runFlow && flow.runFlow.file) {
Comment thread
Fishbowler marked this conversation as resolved.
const dependencyPath = path.resolve(path.dirname(filePath), flow.runFlow.file);
dependencies.add(dependencyPath);
}
Comment thread
Fishbowler marked this conversation as resolved.

if (flow.runScript && flow.runScript.file) {
Comment thread
Fishbowler marked this conversation as resolved.
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));
Expand Down