diff --git a/apps/vscode/src/package.json b/apps/vscode/src/package.json index 23cf8d7247..f47a80bdd5 100644 --- a/apps/vscode/src/package.json +++ b/apps/vscode/src/package.json @@ -676,11 +676,6 @@ "default": true, "description": "Help make Nx Console better by sending anonymous usage data to the Nx Console team." }, - "nxConsole.useNVM": { - "type": "boolean", - "default": false, - "description": "Runs tasks using Node Version Manager" - }, "nxConsole.enableGenerateFromContextMenu": { "type": "boolean", "default": true, @@ -695,6 +690,27 @@ "type": "boolean", "default": true, "description": "Configures a TypeScript language server plugin to include configured libraries in root files for TypeScript projects. This allows for importing libraries into other libraries even when the import was not there before." + }, + "nxConsole.enableGeneratorFilters": { + "type": "boolean", + "default": true, + "description": "Enables the filter for listed generators with Nx Console." + }, + "nxConsole.generatorAllowlist": { + "type": "array", + "default": [], + "items": { + "type": "string" + }, + "description": "A list of generator names to show in the picker (can be combined with Generator Block List).\n\nThe name of the generator should be in this format: @package:generator.\n‎ ‎ ‎ ‎ ‎eamples: @nrwl/workspace:library, workspace-generator:my-generator" + }, + "nxConsole.generatorBlocklist": { + "type": "array", + "default": [], + "items": { + "type": "string" + }, + "description": "A list of generator names to hide in the picker (can be combined with Generator Allow List).\n\nThe name of the generator should be in this format: @package:generator.\n‎ ‎ ‎ ‎ ‎ examples: @nrwl/workspace:library, workspace-generator:my-generator" } } }, diff --git a/libs/vscode/configuration/src/lib/configuration-keys.ts b/libs/vscode/configuration/src/lib/configuration-keys.ts index 6186caca40..3f0a80e88b 100644 --- a/libs/vscode/configuration/src/lib/configuration-keys.ts +++ b/libs/vscode/configuration/src/lib/configuration-keys.ts @@ -1,9 +1,11 @@ export const GLOBAL_CONFIG_KEYS = [ 'enableTelemetry', - 'useNVM', 'enableGenerateFromContextMenu', 'enableWorkspaceConfigCodeLens', 'enableLibraryImports', + 'enableGeneratorFilters', + 'generatorAllowlist', + 'generatorBlocklist', ] as const; /** diff --git a/libs/vscode/tasks/src/lib/select-generator.ts b/libs/vscode/tasks/src/lib/select-generator.ts index 6f35b612bf..df18149c65 100644 --- a/libs/vscode/tasks/src/lib/select-generator.ts +++ b/libs/vscode/tasks/src/lib/select-generator.ts @@ -9,6 +9,7 @@ import { normalizeSchema, readAndCacheJsonFile, } from '@nx-console/server'; +import { GlobalConfigurationStore } from '@nx-console/vscode/configuration'; import { nxWorkspace } from '@nx-console/vscode/nx-workspace'; import { QuickPickItem, window } from 'vscode'; @@ -81,6 +82,7 @@ export async function selectGenerator( interface GenerateQuickPickItem extends QuickPickItem { collectionName: string; generator: Generator; + generatorName: string; collectionPath: string; } const { workspace } = await nxWorkspace(); @@ -93,12 +95,32 @@ export async function selectGenerator( return { description: generatorData.description, label: `${generatorData.collection} - ${generatorData.name}`, + generatorName: `${generatorData.collection}:${generatorData.name}`, collectionName: generatorData.collection, collectionPath: collection.path, generator: generatorData, }; }); + if (GlobalConfigurationStore.instance.get('enableGeneratorFilters') ?? true) { + const allowlist: string[] = + GlobalConfigurationStore.instance.get('generatorAllowlist') ?? []; + const blocklist: string[] = + GlobalConfigurationStore.instance.get('generatorBlocklist') ?? []; + + if (allowlist.length > 0) { + generatorsQuickPicks = generatorsQuickPicks.filter((item) => + allowlist.includes(item.generatorName) + ); + } + + if (blocklist.length > 0) { + generatorsQuickPicks = generatorsQuickPicks.filter( + (item) => !blocklist.includes(item.generatorName) + ); + } + } + if (generatorType) { generatorsQuickPicks = generatorsQuickPicks.filter((generator) => { return generator.generator.type === generatorType; @@ -123,7 +145,7 @@ export async function selectGenerator( selection.collectionPath, workspaceType )); - const positional = `${selection.collectionName}:${selection.generator.name}`; + const positional = selection.generatorName; return { ...selection.generator, options,