@nx/devkit 16.8.0-rc.0 → 16.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/devkit",
3
- "version": "16.8.0-rc.0",
3
+ "version": "16.8.1",
4
4
  "private": false,
5
5
  "description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more.",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://nx.dev",
30
30
  "dependencies": {
31
- "@nrwl/devkit": "16.8.0-rc.0",
31
+ "@nrwl/devkit": "16.8.1",
32
32
  "ejs": "^3.1.7",
33
33
  "enquirer": "~2.3.6",
34
34
  "ignore": "^5.0.4",
@@ -46,5 +46,5 @@
46
46
  "migrations": "./migrations.json"
47
47
  },
48
48
  "type": "commonjs",
49
- "gitHead": "44d0b22f4f6c4a790e2ad4702bf27ffa15073582"
49
+ "gitHead": "29a7b8575e683d3a581b4bf6f82ee4486bfa94dd"
50
50
  }
@@ -27,6 +27,6 @@ function readTargetOptions({ project, target, configuration }, context) {
27
27
  ? calculateDefaultProjectName(context.cwd, context.root, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration)
28
28
  : // TODO(v18): remove calculateDefaultProjectName. This is to be backwards compatible with Nx 16.5 and below.
29
29
  ws.calculateDefaultProjectName(context.cwd, { version: 2, projects: context.projectsConfigurations.projects }, context.nxJsonConfiguration);
30
- return combineOptionsForExecutor({}, configuration ?? targetConfiguration.defaultConfiguration ?? '', targetConfiguration, schema, defaultProject, (0, path_1.relative)(context.cwd, context.root));
30
+ return combineOptionsForExecutor({}, configuration ?? targetConfiguration.defaultConfiguration ?? '', targetConfiguration, schema, defaultProject, (0, path_1.relative)(context.root, context.cwd));
31
31
  }
32
32
  exports.readTargetOptions = readTargetOptions;
@@ -6,13 +6,19 @@ const nx_1 = require("../../nx");
6
6
  const get_workspace_layout_1 = require("../utils/get-workspace-layout");
7
7
  const names_1 = require("../utils/names");
8
8
  const { joinPathFragments, normalizePath, logger, readJson, readNxJson, updateNxJson, stripIndents, } = (0, nx_1.requireNx)();
9
+ const deprecationWarning = stripIndents `
10
+ In Nx 18, generating projects will no longer derive the name and root.
11
+ Please provide the exact project name and root in the future.`;
9
12
  async function determineProjectNameAndRootOptions(tree, options) {
10
13
  validateName(options.name, options.projectNameAndRootFormat);
11
14
  const formats = getProjectNameAndRootFormats(tree, options);
15
+ const configuredDefault = getDefaultProjectNameAndRootFormat(tree);
16
+ if (configuredDefault === 'derived') {
17
+ logger.warn(deprecationWarning + '\n' + getExample(options.callingGenerator, formats));
18
+ }
12
19
  const format = options.projectNameAndRootFormat ??
13
- (getDefaultProjectNameAndRootFormat(tree) === 'as-provided'
14
- ? 'as-provided'
15
- : await determineFormat(tree, formats, options.callingGenerator));
20
+ configuredDefault ??
21
+ (await determineFormat(tree, formats, options.callingGenerator));
16
22
  return {
17
23
  ...formats[format],
18
24
  projectNameAndRootFormat: format,
@@ -39,6 +45,9 @@ function validateName(name, projectNameAndRootFormat) {
39
45
  throw new Error(`The project name should match the pattern "${pattern}". The provided value "${name}" does not match.`);
40
46
  }
41
47
  }
48
+ function getExample(callingGenerator, formats) {
49
+ return `Example: nx g ${callingGenerator} ${formats['as-provided'].projectName} --directory ${formats['as-provided'].projectRoot}`;
50
+ }
42
51
  async function determineFormat(tree, formats, callingGenerator) {
43
52
  if (!formats.derived) {
44
53
  return 'as-provided';
@@ -70,9 +79,6 @@ async function determineFormat(tree, formats, callingGenerator) {
70
79
  ],
71
80
  initial: 'as-provided',
72
81
  }).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived');
73
- const deprecationWarning = stripIndents `
74
- In Nx 18, generating projects will no longer derive the name and root.
75
- Please provide the exact project name and root in the future.`;
76
82
  if (result === 'as-provided' && callingGenerator) {
77
83
  const { saveDefault } = await (0, enquirer_1.prompt)({
78
84
  type: 'confirm',
@@ -88,7 +94,7 @@ async function determineFormat(tree, formats, callingGenerator) {
88
94
  }
89
95
  }
90
96
  else {
91
- const example = `Example: nx g ${callingGenerator} ${formats[result].projectName} --directory ${formats[result].projectRoot}`;
97
+ const example = getExample(callingGenerator, formats);
92
98
  logger.warn(deprecationWarning + '\n' + example);
93
99
  }
94
100
  return result;
@@ -101,7 +107,7 @@ function setProjectNameAndRootFormatDefault(tree) {
101
107
  }
102
108
  function getDefaultProjectNameAndRootFormat(tree) {
103
109
  const nxJson = readNxJson(tree);
104
- return nxJson.workspaceLayout?.projectNameAndRootFormat ?? 'derived';
110
+ return nxJson.workspaceLayout?.projectNameAndRootFormat;
105
111
  }
106
112
  function getProjectNameAndRootFormats(tree, options) {
107
113
  const name = (0, names_1.names)(options.name).fileName;