From 3216ffd4c723a56a0d8b882e2b2108ea3ca1acc4 Mon Sep 17 00:00:00 2001 From: Dzhavat Ushev Date: Fri, 16 Dec 2022 16:26:24 +0100 Subject: [PATCH] feat: add context menu to execute task without Nx cache --- apps/vscode/src/package.json | 13 +++++++++++++ .../src/lib/nx-project-tree-provider.ts | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/apps/vscode/src/package.json b/apps/vscode/src/package.json index d74b60f808..41121237f0 100644 --- a/apps/vscode/src/package.json +++ b/apps/vscode/src/package.json @@ -145,6 +145,11 @@ "when": "view == nxProjects && viewItem == target", "group": "inline" }, + { + "command": "nxConsole.runTaskSkipNxCache", + "when": "view == nxProjects && viewItem == target", + "group": "navigation" + }, { "command": "nx.graph.focus.button", "when": "view == nxProjects && viewItem == project && isNxWorkspace", @@ -182,6 +187,10 @@ "command": "nxConsole.runTask", "when": "false" }, + { + "command": "nxConsole.runTaskSkipNxCache", + "when": "false" + }, { "command": "nxConsole.revealInExplorer", "when": "false" @@ -415,6 +424,10 @@ "title": "Execute task", "icon": "$(play)" }, + { + "command": "nxConsole.runTaskSkipNxCache", + "title": "Execute task without Nx cache" + }, { "category": "ng", "title": "Run Target", diff --git a/libs/vscode/nx-project-view/src/lib/nx-project-tree-provider.ts b/libs/vscode/nx-project-view/src/lib/nx-project-tree-provider.ts index e4d6d0b03b..2d62980e57 100644 --- a/libs/vscode/nx-project-view/src/lib/nx-project-tree-provider.ts +++ b/libs/vscode/nx-project-view/src/lib/nx-project-tree-provider.ts @@ -22,6 +22,10 @@ import { export type ViewItem = ListViewItem | TreeViewItem | AutomaticViewItem; +interface NxOptionalFlags { + skipNxCache: boolean; +} + /** * Provides data for the "Projects" tree view */ @@ -42,6 +46,7 @@ export class NxProjectTreeProvider extends AbstractTreeProvider { ['revealInExplorer', this.revealInExplorer], ['runTask', this.runTask], ['refreshNxProjectsTree', this.refreshNxProjectsTree], + ['runTaskSkipNxCache', this.runTaskSkipNxCache], ] as const ).forEach(([commandSuffix, callback]) => { context.subscriptions.push( @@ -90,7 +95,10 @@ export class NxProjectTreeProvider extends AbstractTreeProvider { return config === 'tree'; } - private async runTask(selection: NxTreeItem) { + private async runTask( + selection: NxTreeItem, + optionalFlags?: NxOptionalFlags + ) { const viewItem = selection.item; if ( viewItem.contextValue === 'project' || @@ -107,6 +115,10 @@ export class NxProjectTreeProvider extends AbstractTreeProvider { flags.push(`--configuration=${target.configuration}`); } + if (optionalFlags?.skipNxCache) { + flags.push('--skip-nx-cache'); + } + this.cliTaskProvider.executeTask({ command: target.name, positional: project, @@ -114,6 +126,10 @@ export class NxProjectTreeProvider extends AbstractTreeProvider { }); } + private async runTaskSkipNxCache(selection: NxTreeItem) { + this.runTask(selection, { skipNxCache: true }); + } + private async revealInExplorer(selection: NxTreeItem) { if (selection.resourceUri) { commands.executeCommand('revealInExplorer', selection.resourceUri);