Skip to content
Open
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
7 changes: 7 additions & 0 deletions packages/vscode-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ alt="Screenshot of projects view" width="300px" />

Similar to the projects view, the tags view displays projects grouped by their `tags`.

For each tag, two sections are shown:

- **Tasks** – Lists tasks that exist across projects with that tag. These tasks can be executed for all projects with the tag.
- **Projects** – Lists the projects associated with the tag.

Running a task from the **Tasks** section will execute the task for all projects matching the tag.

<img
src="https://raw.githubusercontent.com/moonrepo/dev/master/packages/vscode-extension/images/tags-view.png"
alt="Screenshot of tags view" width="300px" />
Expand Down
Binary file modified packages/vscode-extension/images/tags-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export function activate(context: vscode.ExtensionContext) {
appendSchemasConfig(context, workspace),
),

vscode.commands.registerCommand('moon.projectTag.runTagTask', (item) => tagsProvider.runTagTask(item)),

// Create a tree view for all moon projects
vscode.window.createTreeView('moonProjects', {
showCollapseAll: true,
Expand Down
80 changes: 79 additions & 1 deletion packages/vscode-extension/src/projectsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,49 @@ class ProjectTagItem extends TreeItem {
}
}

class TagTaskItem extends TreeItem {
tag: string;
taskId: string;

constructor(tag: string, taskId: string) {
super(taskId, TreeItemCollapsibleState.None);

this.tag = tag;
this.taskId = taskId;
this.id = `tag-${tag}-task-${taskId}`;
this.contextValue = 'tagTask';
this.iconPath = new ThemeIcon('play');

this.command = {
command: 'moon.projectTag.runTagTask',
title: 'Run Tag Task',
arguments: [this],
};
}
}

class TagTasksGroup extends TreeItem {
parent: ProjectTagItem;

constructor(parent: ProjectTagItem) {
super('Tasks', TreeItemCollapsibleState.Expanded);
this.parent = parent;
this.contextValue = 'tagTasksGroup';
this.iconPath = new ThemeIcon('list-unordered');
}
}

class TagProjectsGroup extends TreeItem {
parent: ProjectTagItem;

constructor(parent: ProjectTagItem) {
super('Projects', TreeItemCollapsibleState.Expanded);
this.parent = parent;
this.contextValue = 'tagProjectsGroup';
this.iconPath = new ThemeIcon('repo');
}
}

export type ProjectsType = 'category' | 'tag';

export class ProjectsProvider implements vscode.TreeDataProvider<TreeItem> {
Expand Down Expand Up @@ -354,9 +397,36 @@ export class ProjectsProvider implements vscode.TreeDataProvider<TreeItem> {
}

if (element instanceof ProjectTagItem) {
return element.projects;
if (element.id === `tag-${UNTAGGED}`) {
return element.projects;
}
return [
new TagTasksGroup(element),
new TagProjectsGroup(element)
];
}

if (element instanceof TagTasksGroup) {
const projects = element.parent.projects;

const taskIds = new Set<string>();

projects.forEach((projectItem) => {
projectItem.tasks.forEach((taskItem) => {
taskIds.add(taskItem.task.id);
});
});

const tag = element.parent.label!.replace('#', '');

return Array.from(taskIds)
.sort()
.map((taskId) => new TagTaskItem(tag, taskId));
}

if (element instanceof TagProjectsGroup) {
return element.parent.projects;
}
if (!this.projects) {
const version = await this.workspace.getMoonVersion();
const args = ['query', 'projects'];
Expand Down Expand Up @@ -450,6 +520,14 @@ export class ProjectsProvider implements vscode.TreeDataProvider<TreeItem> {
});
}

async runTagTask(item: TagTaskItem) {
const target = `'#${item.tag}:${item.taskId}'`;

await runTask(target, this.workspace, (task) => {
task.group = TaskGroup.Build;
});
}

async checkProject(item: ProjectItem) {
await checkProject(item.project.id, this.workspace);
}
Expand Down