Skip to main content
Glama
nrwl

Nx MCP Server

Official
by nrwl
project-name-and-root-plugin.ts2.44 kB
import { GeneratorSchema } from '@nx-console/shared-generate-ui-types'; import { SchemaProcessor, StartupMessageFactory, } from '../nx-console-plugin-types'; import { NxWorkspace } from '@nx-console/shared-types'; import { Logger } from '@nx-console/shared-utils'; import { gte } from '@nx-console/nx-version'; export const projectNameAndRootProcessor: SchemaProcessor = ( schema: GeneratorSchema, workspace: NxWorkspace, lspLogger: Logger, ) => { if ( !schema?.options?.find( (option) => option.name === 'projectNameAndRootFormat', ) ) { return schema; } if (workspace.workspaceLayout?.projectNameAndRootFormat === 'derived') { return { ...schema, context: { ...schema.context, prefillValues: { ...(schema.context?.prefillValues ?? {}), projectNameAndRootFormat: 'derived', }, }, }; } const pnarfDefault = schema.options.find( (opt) => opt.name === 'projectNameAndRootFormat', )?.default; return { ...schema, options: schema.options.map((option) => { if (option.name === 'name') { return { ...option, 'x-priority': 'important', 'x-hint': 'You can provide a nested name instead of setting the directory option, e.g. my-dir/my-app', }; } if (option.name === 'directory') { return { ...option, 'x-priority': 'important', }; } return option; }), context: { ...schema.context, prefillValues: { ...(schema.context?.prefillValues ?? {}), projectNameAndRootFormat: pnarfDefault ? `${pnarfDefault}` : 'as-provided', }, }, }; }; export const projectNameAndRootStartupMessage: StartupMessageFactory = ( schema: GeneratorSchema, workspace: NxWorkspace, lspLogger: Logger, ) => { if (gte(workspace.nxVersion, '18.0.0')) { return undefined; } if ( !schema?.options?.find( (option) => option.name === 'projectNameAndRootFormat', ) ) { return undefined; } if ((workspace.workspaceLayout as any)?.projectNameAndRootFormat) { return undefined; } return { message: 'Starting with Nx 16.7, Nx Console will generate projects with the exact name and directory provided. Check the output files to make sure that they were created in the correct location.', type: 'warning', }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nrwl/nx-console'

If you have feedback or need assistance with the MCP directory API, please join our Discord server