diff --git a/packages/devkit/src/generators/project-name-and-root-utils.ts b/packages/devkit/src/generators/project-name-and-root-utils.ts index 9f4d7379a80bb7..084edce62e4169 100644 --- a/packages/devkit/src/generators/project-name-and-root-utils.ts +++ b/packages/devkit/src/generators/project-name-and-root-utils.ts @@ -8,8 +8,14 @@ import { } from '../utils/get-workspace-layout'; import { names } from '../utils/names'; -const { joinPathFragments, normalizePath, readJson, readNxJson, updateNxJson } = - requireNx(); +const { + joinPathFragments, + normalizePath, + logger, + readJson, + readNxJson, + updateNxJson, +} = requireNx(); export type ProjectNameAndRootFormat = 'as-provided' | 'derived'; export type ProjectGenerationOptions = { @@ -147,11 +153,16 @@ async function determineFormat( }).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived' ); - if (result === 'as-provided' && callingGenerator) { + + const deprecationWarning = + 'In Nx 18, generating projects will no longer derive the name and root. Please provide the exact project name and root in the future.'; + + if (result === 'as-provided') { const { saveDefault } = await prompt<{ saveDefault: boolean }>({ type: 'confirm', - message: 'Would you like to save this layout as a default?', + message: `Would you like to configure Nx to always take project name and root as provided for ${callingGenerator}?`, name: 'saveDefault', + initial: true, }); if (saveDefault) { const nxJson = readNxJson(tree); @@ -159,7 +170,11 @@ async function determineFormat( nxJson.generators[callingGenerator] ??= {}; nxJson.generators[callingGenerator].projectNameAndRootFormat = result; updateNxJson(tree, nxJson); + } else { + logger.warn(deprecationWarning); } + } else { + logger.warn(deprecationWarning); } return result;