Skip to content

Commit

Permalink
fix(devkit): show example in deprecation message (#18823)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Aug 24, 2023
1 parent bd76b62 commit 02c5aeb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/devkit/src/generators/project-name-and-root-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const {
readJson,
readNxJson,
updateNxJson,
stripIndents,
} = requireNx();

export type ProjectNameAndRootFormat = 'as-provided' | 'derived';
Expand Down Expand Up @@ -154,8 +155,9 @@ async function determineFormat(
format === asProvidedSelectedValue ? 'as-provided' : 'derived'
);

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.';
const deprecationWarning = stripIndents`
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' && callingGenerator) {
const { saveDefault } = await prompt<{ saveDefault: boolean }>({
Expand All @@ -174,7 +176,8 @@ async function determineFormat(
logger.warn(deprecationWarning);
}
} else {
logger.warn(deprecationWarning);
const example = `Example: nx g ${callingGenerator} ${formats[result].projectName} --directory ${formats[result].projectRoot}`;
logger.warn(deprecationWarning + '\n' + example);
}

return result;
Expand Down

0 comments on commit 02c5aeb

Please sign in to comment.